#arma3_scripting
1 messages Β· Page 589 of 1
π¦
I just don't get it- it makes no sense, why is there no way to fetch the value?
currentMuzzle; // this command
private _muzzles = getArray (configFile >> "cfgWeapons" >> _type >> "muzzles");
and Fired, FiredMan, FiredNear, Reloaded Event Handlers
That's all I know @lone zenith
(code from notes on https://community.bistudio.com/wiki/selectWeapon)
Hmmm right... Perhaps you could help in a more general sense- I'm trying to throw a grenade irregardless of current animation- the action UseWeapon does the trick the most reliably. Any other suggestions?
forceWeaponFire doesn't work as far as I remember
https://forums.bohemia.net/forums/topic/163774-for-the-devs-make-ais-throw-grenades-in-arma-3/ says action useMagazine
if you want regardless of the current animation, you can use switchMove "" before doing the throw
@lone zenith
Ah no but I want to mix the throw gesture with the anim
I'll check out the useMagazine, but I think I tried that one
Heya i want to use the Gunbag from ace but it seems i cannot put the sniper i use in there is there any way i can use a script or anything to 'increase' the space in the gunbag
gunbag has no space or weight limit
seems like machine guns cant fit into gunbag though
Oh, by the way
Would it be more efficient to pass in instigator from a hit eventhandler, or just run findneareastenemy on the player?
Because that duplicate code was there for that reason
i guess instigator can be null/nil
how? if they crash into something?
findNearestEnemy doesn't really mean that that enemy also hit the player
if you damage yourself e.g from a height
Hmm
I do see that actually a lot of that code wasn't needed, even if I keep it as it was
But generally, would it hurt to run findNearestEnemy even if I already have instigator?
Q: do you want to know who fired at the unit?
A:
- yes: use the Hit/Killed EHs
- no: yaba-daba-doo
a nearest enemy behind a wall wouldn't hurt you π
But they may also not be aware of your presence
(a marksman 800m away with line of sight, yes)
Mmm
what do you want, the closest enemy or who shot you?
Doesn't matter, I think I've got it now
oookido!
But generally, would it hurt to run findNearestEnemy even if I already have instigator?
Would it hurt to run code that you don't need at all? yes. Thats just a waste of cpu time
Ok, that's more sort of the answer I wanted
Although I wasn't very clear
But thank you
If I want to complete 'fadeMusic' before starting another track, do I need 'sleep'?
yes
That sleep would be the same timeout as the time param in fadeMusic then?
0 fadeMusic 0;
5 fadeMusic 1;
playMusic "mySong";
sleep (_songDuration - 5);
5 fadeMusic 0;
sleep 5;
5 fadeMusic 1;
playMusic "otherSong";
// etc
there is also https://community.bistudio.com/wiki/BIS_fnc_jukebox that can do everything for you⦠iirc
@narrow pollen β
Thanks for your answer, however I am not sure how to use the Jukebox function
Does it fade music automatically or?
I think so yes
Also, I currently have states defined for the vanilla tracks in config.cpp>CfgMusic>class vanillatrackname>statesarray[] = {example, example2}.
How would I go about retrieving all tracks that contain a certain state, and letting Jukebox randomly select a track out of that list/array?
I am not sure how to access the info inside a class (CfgMusic) inside another class(trackname), in config.cpp
Is it possible to use the High Command module in a way to enable a player to assume command mid mission and release it (also mid mission) aswell if they don't feel like commanding anymore making it possible for another player to assume command?
@narrow pollen configFile >> "CfgMusic" >> etc
Would there be any conflicts by me using the vanilla track classnames and defining their state?
In cfgmusic inside a mod's config.cpp
Since that classname would already be defined in Arma itself?
that's mod overriding, I think that would be fine but don't take my word - ask in #arma3_config to be sure
Hi, I was wondering if there was a way to execute code on a schedule that isn't in-game uptime or anything of the sort, more like real-time a week or so in-between? I have made a "election" script of sorts, and we were planning on doing one once a month. Would this be possible with the help of a dll like real time?
uiSleep 7 * 24 * 60 * 60;
```π
but with an extension yes, you can do everything you want
That would be quite a long server uptime haha. Alright ill look into KK's blog with real_date
like real-time a week or so in-between
Arma server won't be up for a week π
in editor, I set this DBG = []; in Attributes > General > Init.
and add this code to B_Heli_Transport_03_F Init:
this addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"];
systemChat (format["HD: %1", str _this]);
DBG pushBack (format["HD: %1", str _this]);
}];
when I try to lift off my heli explodes π why/how is it happens?
it seems that it has something to do with str command
I don't think that's the issue
if you remove this DBG code, your helicopter would explode anyway
why?
your issue is either that pushBack doesn't return anything where "HandleDamage" might need a value, or is something completely unrelated
wrong-ish.
pushBack returns index of inserted element..
if handledamage returns 1 or more, helicopter boom
aaah, I mixed it with append
more than one element in the array, insta boom
yep π
oh, but I thought EH should only respond to events not create new ones (unless I explicitly tell it to)
just add _damage; as the last line of the EH
and EH trigger on events, they don't create one - indeed

ah I think I am starting to understand... so when heli get any hit it will call this event before it gets any damage and this event will set the damage it should receive according to the parameters?
selection damage and yes π
and when I dont register it, it has default event?
player addEventHandler ["HandleDamage", { 0 }]; // invincible
player addEventHandler ["HandleDamage", { 1 }]; // Mr Glass
if nothing set, the game has the default damage system yes
this EH happens before the normal damage is applied
What do I need to know to make my own framework?
SQF
And anything
How long does this usually take for beginners?
I understand, Thank you!
from start to finish
beginner should use existing framework not build one
How long does this usually take for beginners?
a framework that does nothing, 00h00m00s
a framework that does everything, +infinity
a framework that does ?, ? time
Okay maybe I should be more specific
maybe yes π
lol, not really sure to specify what im asking
but any tips where I can go to learn sqf?
sure thing
I usually just learn langauages with trial and error
kk thanks
Does owner work on a client machine?
@modern adder wiki π
clientOwner
So that's a no
Okay, is there any other way of executing a function on everyone in the group without executing it on the local machine?
Already have, just wanted to check
Already have, just wanted to check
the green sE means Server Exec, that's it ^^"
is there any other way of executing a function on everyone in the group without executing it on the local machine?
remoteExec?
yeah�
I need to exclude the local machine
is the local machine in the group?
Yes
remoteExec with (units _group - [player]) then
sometimesβ¦ your worst enemy is your own brain yes π
Well, I wouldn't have come up with that tbh, still learning sqf π
Is there any way to find the size of a gameLogic? For example I placed a "ModuleSector_F" with a size of [30,30,0] and need the size in script.
aaand Google brought me the answer:
sectorModuleVar getVariable ["objectArea", [50, 50]];
``` @mortal crypt π
setVariable instead? π
Thank you!
@celest plume edit your message to either use sqf tags, or post in sqfbin and link here, thanks
Apologies. Thank you! I will figure out how to do that.
np - a pinned message explains how to (the sqf tags)
OK, I have a simple problem, but it has been wrecking my head for days. I am using SQF and I am trying to make a multiplayer sandbox-type thing and I need a faction-system.
What I am trying to do is grab some sort of identification from the object controlled by the player that I can add to a serverside array. I am have tried this:
//This is in the InitServer
[Swagger,["Join Swagger","FactionJoiners\SwaggerJoin.sqf",[],5,true,true,"","true",3,false,"",""]] remoteExec ["addAction", 0, true];
// And that calls this script
params ["_target", "_caller", "_actionId", "_arguments"];
_objNetId = _caller call BIS_fnc_netId; // "0:2"
_obj = _objNetID call BIS_fnc_objectFromNetId;
_Owner = str (owner _Caller);
if ((side _caller == WEST) && !(_Owner in InFaction)) then {
swaggerfolk pushback _Owner; //Adds the player to the Swaggerfolk variable
InFaction = InFaction pushBack _Owner; //Adds the player to the InFaction Variable
publicVariableServer "SwaggerFolk"; //Sends the information to the server
publicVariableServer "InFaction"; // Ditto
private _message = "";
_message = format ["Welcome to Swaggers folk!"];
_recipient = allPlayers select {(alive _x) && !(_x getvariable ["FW_DEAD",false]) && ((_x distance _target) <= 10)};
{
_message remoteExec ["systemChat", _x];
} foreach _recipient;
};
I have tried calling BIS_fnc_netId on _caller, and call BIS_fnc_objectFromNetId on the NetID, but neither of them will get pushed into the Swaggerfolk Array or the InFaction (defined in the Taskmanager). Is there any way I can modify this script to get me the information I need? The Arrays (Swaggerfolk and InFaction) will need to be called upon and checked in other remotely executed addAction/remoteexec scripts.
I can put it this way, none of the information gets transferred the serverside array. It works perfectly fine in singleplayer (of course), but that is an entirely different story of course.
Quick explanation: I need to grab some information from the _caller that remains persistent and can be checked again, in a later script.
I've been scrolling through snippets of the nopixel framework trying to understand it.
Can anyone help me understand what this means in detail?
_item = _this select 1;
I don't understand"_this select 1"
Im assuming _item is a variable
@patent estuary _obj allowDamage false;//Damage disabled ---------- So, whereabouts is this meant to belong and how do i get to affect objects on my map. Not a fan of scripting so knowledge is limited
put it in their initialisation field this allowDamage false;
if you plan on editing missions then you will need to learn how to script, there is no easy way around that π
@simple notch Using https://community.bistudio.com/wiki/call
to call a function with arguments (params) would pass them into the _this magic variable for said function. Then you can retrieve the passed arguments by using _variable = _this select 0 for the first argument passed, 1 for the second, ..
My issue is that certain objects on my terrain builder map - My own terrain with objects on - Has objects that do a 90 degree flip that are part of the map, not placed via 3DEN when a player or something hits it/collides with it.
Is there any way to prevent that happening
[1, 2, 3] call {
_this; // equals [1, 2, 3]
_this select 0; // 1
_this select 1; // 2
_this select 2; // 3
};
``` @simple notch
see also: https://community.bistudio.com/wiki/select
if they are vanilla BI objects then no you cant, if they are your own objects put damage = no in the named properties of the geometry lod. - this is for baking into a terrain.
They are indeed vanilla objects
Not the smartest idea to make objects flip themselves 90 degrees in the air when damaged by default
But whatever
Thanks Uro
np
When passing arguments with 'call' to call a function, do I need to define the params with params [] inside my function?
Or can I just select them from the _this variable either way
ideally
_this select x is so Arma 2β¦
also, params privates your variables @narrow pollen
private _ximgroup = _this select 0;
private _ximcombat = _this select 1;```
remove the last two lines
That's what I wanted to ask
Thats confusing lol
So simply if (_ximcombat) {}; is correct, yeah that should be good
It's basically a quick tool to get rid of the old _this select stuff?
- you have type checking and default values
yep,
and to check variables as Heyoxe said (advanced syntax),
and to auto-private vars
don't forget then
if (x) then { y };
this channel is sensitive to SQF errors :p
then is the worst, I forget it all the time π
yeah isn't it a bit redundant, or is there a reason it exists?
the worst thing is I tend to write it while coding at work π
π
gotcha
if (something) = IF TYPE
then = operator, IF TYPE then CODE
alright
&& = operator condition && CODE
something && {}
π
every other language works without it somehow...
I love how there is close to nothing about SQF learning online lol
becides bistudio
Because the wiki has everything that you need π
Maybe im missing something then
do you know programming? any other langauge?
Very minor c++ and I did like 2 years of java in high school
I love how there is close to nothing about SQF learning online lol
SQF was made by Bohemia Interactive for Bohemia Interactive, so there is that yeah π
SQF was made by Bohemia Interactive for Bohemia Interactive
That sounds like an ad π
I come from mainly php and it's okay for me, just learning how the engine works but the basic 'code workflow' is there
Shoot feels like a whole new world to me lol
xd
Yeah it's just understanding what does what is difficult for me
I've been scrolling through the wiki reading everything about it and i feel like ive made 0 progress lol
learn from source code
gain through pain! β
Well, I found the nopixel framework on github and ive just been analyzing the code from it
Do not start with that kind of thing. Look at more basic things, try to do a simple mission that includes some sqf, etc.
configProperties [configFile >> "CfgMusic" >> "intense"]; Does this return an array with the classnames that have "intense" in the musictype array inside a music-track class?
No
How would I go about doing that then?
configProperties [configFile >> "CfgMusic", "YOUR_CONDITION"];
see https://community.bistudio.com/wiki/configProperties
Right, sorry I messed up the syntax
configProperties [configFile >> "CfgMusic","intense"];
Nop
Would I need to loop through it?
it needs to be code. The code will have a magic variable _x that refers to the current config being tested. So you'd have to do getText (something) and isEqualTo something
If I create a dialog, and on one of the controls, I add a UI event handler with ctrlAddEventHandler do I still have to manually delete that event handler later on when I close the dialog again with closeDialog or will it be automatically cleaned up once the control it's attached to no longer exists?
configProperties [configFile >> "CfgMusic",getText(_Musictypes) is EqualTo "intense"]; Eh this doesn't seem right
indeed, it doesn't
The condition needs to be a string that has code inside for example "(configName _x) isEqualTo 'something'"
If a vehicle model has multiple points in the pos cargo selection, is it possible to get the positions of all of them instead of just one?
_someArray= configProperties [configFile >> "CfgMusic","'intense' in _MusicTypes"]; Would this return all config entries that have 'intense' in the '_MusicTypes' array inside a config entry (e.g. class MusicTrack01) ?
Is there an efficient way to detect the state of the landing gear of a helicopter without checking each individual animation phase?
check the animation source?
I searched the AnimationSources of the Mohawk but couldn't find any reference to the landing gear :/
have you tried using animationNames on it?
yes but then then you get different animationNames for every helicopter, e.g. on the mohawk i could check for frontgear but on the huron its gear_up π
spawn a landed one, a flying one, compare what's what and you're done! I don't see what's so difficult about it π
but afaik, there is no "isGearOut" command
there is an Event Handler, though
the https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Gear "Gear" EH
@viral basin β
but its only for planes
π okay then i guess i have to lookup every helicopter π
its 3rd* version of the game but there still stuff like this...
they dont do team meetings at BI?
maybe they hire freelancers and dont bother setting coding "standards" (forgot the name)
Another question, will sqf player findNearestEnemy player knowsAbout player;work on a client? As it says on the biki that the 'who' unit (player findNearestEnemy player) must be local
I don't know if the enemy will be local or not
private _enemy = player findNearestEnemy player;
if (local _enemy) then {
private _var = _enemy knowsAbout player;
};
In what situation would they be local?
@modern adder in the case of a player-hosted mission, for example
So, enemy units are local to the server yes?
And only the server (or client in non-dedicated)
AI units are local to the server or to the headless client, if any
Thank you
an enemy can be a player in PvP π
https://community.bistudio.com/wiki/Multiplayer_Scripting can help you maybe π
Yep, thanks
@winter rose You are correct,
createVehicledoes result in the object being local to the machine that executed that code as far as I can determine.
@wet shadow aaand it was written here
https://community.bistudio.com/wiki/Multiplayer_Scripting#General_information_about_locality β¦ by no less than I, quite some time ago π
musicVolume == 0;
};
``` This will return true when musicVolume will be 0 right?
yeah�
mhm strange
How would I execute code when that waitUntil is true?
ah wait it needs to be in a scheduled environment only
that's probably why it's not working currently
still learning syntaxes... for a test I want to test to see if my variable object _helitest is set to damageAllowed true or false so I can see if a trigger is working.
this is what I have in my debug console
if (isDamageAllowed _helitest) then (hint "true")
logically should this statement basically say: if true then hint "true"? - saying damageAllowed was true
so if I did
If (not isDamageAllowed _helitest) then (hint "false")
this would work in a similar manner if damageAllowed was true?
@fair drum no, do this instead
If !(isDamageAllowed _helitest) then (hint "false")
yes that too. Also @fair drum
https://community.bistudio.com/wiki/Operators
so if I wanted to combine these I would do:
If (isDamageAllowed _helitest) then {hint "true"} else {hint "false"}?
simplified:
hint str(isDamageAllowed _helitest)```
hint str isDamageAllowed _helitest;```
ayee
stahp ninja'ing me!!1! π π
but theory wise, which is what I need to be grasping here, my line would function? just yours is less characters?
yours would work, yes
okay I see. still learning to be efficient. I'm trying to learn python too which would be my first programming language and I do the same thing.
So im pulling my hair out trying to figure out a clean way to detect input actions so i can replace their results. Im using displayAddEventHandler on KeyDown and MouseButtonDown to detect the action for opening the map so i can show my gui instead. Problems are MouseButtonDown doesn't have a return true option to prevent the map from opening so both map and gui open. Also once my gui is open if the player hits the same key bound to opening the map my displayAddEventHandler for display 46 doesn't fire so i cant close my gui. I really want to understand how all this key binding/inputs stuff works. If you know of a good tutorial/guide or are willing to do one on one to help me set this up so it runs clean, please let me know. I dont want to use the popular method of using whiles or loops.
hmmm it appears that my end goal trigger is not working. for reference, my heli is now set to _heliTest
I have _heliTest deselected on the "Enable Damage" under special states to prevent it from exploding at mission start. I then have a trigger set to:
Condition: true
On Activation: _heliTest allowDamage true;
Trigger: Timer Countdown [10,10,10]
My trigger is not reenabling damage on the heli however if I go into Zeus, I can click on the heli and type _this allowDamage true and it works... is this just due to a problem of running it in a multiplayer server?
@fair drum triggers can't use private variables
@fair drum you need more knowledge about variables and where and how you can use them. https://community.bistudio.com/wiki/Variables
hmmm I guess I got confused cause I'm currently working through Focker's Arma Scripting guide and he uses almost all private variables. guess I'll retry with global
should i use initplayerlocal or initplayerserver to handle teleporting players?
currently i have it as remotexec in initplayerserver to make sure JIPs get teleported
initplayerlocal fires when player connects
@molten roost https://community.bistudio.com/wiki/Initialization_Order
are you still working Lou?
π΄
?
So I've scripted an object to randomly spawn on PKL which has the rice paddies. I want this object to be able spawn anywhere except in a rice paddy. What command could I use to say 'never spawn on any water surface no matter how shallow. The problem I have is that I think the Editor get confused because the I say...
_fe = _pos isFlatEmpty [10,200,0.3,15,0,false,objNull];
so [0] in the array says "not on water" but the terrian gets tricky with the berms around the rice paddies
would -1 work?,.....oops, I see -1 = ignore, Ok
hello all, im trying to get fog % to be detected in a part of a script. I thought i had it but apparently not. I have it set so when 30% volume of fog is present, it should kick into the fog tracks but it looks like it refuses to switch. it will only stay in the safeTracks section
{
if(fog >= 0.3) then
{
//playing fog music
_selecter = floor(random count _fogTracks);
playMusic (_fogTracks select _selecter);
duration = (_fogDurations select _selecter);
currentTrack = (_fogTracks select _selecter);
if(debugging == 1) then
{
hint format ["Changed music to Fog Music Trackname: %1", (_fogtracks select _selecter)];
};
}
else
{
//turn off fog music
_selecter = floor(random count _safeTracks);
playMusic (_safeTracks select _selecter);
duration = (_safeDurations select _selecter);
currentTrack = (_safeTracks select _selecter);
if(debugging == 1) then
{
hint format ["Changed music to NormalMusic Trackname: %1", (_safeTracks select _selecter)];
};
};
};```
any suggestions?
in addMissionEventHandler there is: PlayerDisconnected and HandleDisconnect, HandleDisconnect will fire before PlayerDisconnected? and it will happen before the player character gets "killed" and disappear?
@sage flume it was about 2am when you sent this message, so no π
also, I am not the only one able to help here - many talented scripters are here too π
Its me again (hopefully something that is not googled in 5 seconds(I tried)).
When I try to run follwing code sqf ["TSC_addACEActionUnflip", { params["_vehicle"]; private _action = ["TSC_unflip","Flip Tank", "Modules\TankFlip.paa",{ private _vehicle = _target; _vehicle setVectorUp surfaceNormal position _vehicle; _vehicle setPos (getPos _vehicle vectorAdd [0,0,5]); },{alive _target && (vectorUp _target select 2) < 0.5}] call ace_interact_menu_fnc_createAction; [_vehicle, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToObject; }] call CBA_fnc_addEventHandler;
I get an reserved variable in expression error. Problem is, I dont know which it is. And the error only appears on a dedicated server when the vehicle respawnes.
["Tank_F","init",{
params["_vehicle"];
["TSC_addACEActionUnflip",_vehicle] call CBA_fnc_globalEventJip;
},true,[],true] call CBA_fnc_addClassEventHandler;```
maybe you need () in surfaceNormal line
also, you are defining _vehicle twice, and _target doesn't exist
it's an action.
you still need to use ```sqf
params ["_target", "_caller", "_actionId", "_arguments"];
so instead of sqf private _vehicle = _target;
params ["_target", "_caller", "_actionId", "_arguments"];```
and just use ```_target```?
and that also in the condition
he can use ace_interact_menu_fnc_addActionToClass instead of all this no?
There is a bit more code then shown. Just shortend the init code for readability. (only the init eh)
Problem is still the same, but it seems that the error accurs somewhere else.
Seems to be that the init eventhandler is called mulible times or something will do more testing and report back.
as far as I know, you dont need CBA events etc to use ACE interactions. if you run ace_interact_menu_fnc_addActionToObject on client it should work for JIP too
That I have to try. Added a locality check in the init eH which fixed that bug.
@spiral fractal will test the jip and report back.
try to take the code you have in CBA_fnc_addEventHandler and move it to player init it should work, or you can switch to ace_interact_menu_fnc_addActionToClass that way you can add this menu to every tank and maybe it is possible to add it to all vehicles
Will do that, Thanks for the input!
atm the changes I made bugged out the action but thats something I can fix alone :D
If I use a function with [] call, does waituntil work inside that function (inline function)? Or is it non-scheduled?
call has the same scheduler setting as its parent
https://community.bistudio.com/wiki/Scheduler#Where_code_starts_scheduled
code executed with call from a scheduled environment
https://community.bistudio.com/wiki/Scheduler#Where_code_starts_unscheduled
Code execution with call from an unscheduled environment
The call is inside an eventhandlers, so I assume that's unscheduled then
basically: won't change the schedule yep
I need a delay in my function that is called from the eventhandler, but I am unsure how to do it without it being an scheduled environment
spawn
I guess I will use that yeah
waiting = scheduled
spawn from the very beginning, you will remain in the same scope
Does https://community.bistudio.com/wiki/BIS_fnc_jukebox have the possibility to play on a group basis? Or does it play music for all players?
Would it be possible to execute that function, with different parameters, for different groups?
CfgDisabledCommands is "disable what has to be restricted". Is there some way to "disable all and allow only what needed" ?
in remoteExec on server I do: _player setVariable ["my_role", _roleId, true]; _player is player that passed from client side, but when I check with allVariables player dont have this variable, why (I tired with and without public param)?
it seems to work if I pass owner _player as public (3rd) 
why run _player setVariable ["my_role", _roleId, true]; through remoteExec? The 3rd arg true means the command will pass-through network.
I have array with available role spots, and it should probably exists on server, when player select role, server has to set player owner to the role spots array and notify other players etc
mb you go with publishing the updated array from server to clients?
if a client wants to take a role, it remoteExec's the server some takeRole func, the func on the server does its job, updates the roles array and publicVariableClient's it to clients?
and clients are notified through their addPublicVariableEventHandler EH?
"initialize": [stealthMusics, combatMusics, safeMusics, volume, transition, radius, executionRate, noRepeat]
stealthMusics: Array of Strings
combatMusics: Array of Strings
safeMusics: Array of Strings
volume: Number```
https://community.bistudio.com/wiki/BIS_fnc_jukebox
Does anyone know what the other parameters in that array do? They are not documented.
array of string = music names
Yeah, that I know
I am asking what 'transition','radius', 'executionRate','noRepeat' mean
I mean I can guess what they do for some of them
But I am unsure what values they take
I suppose transition is fadein/out in seconds?
it works as you said but because I use setUnitTrait it should already notify all players, and the variable that I set on player is mostly for use in ACE menu
Do CfgDisabledCommands affect singleplayer?
I would say⦠Perhaps
try and report, so I can update the wiki
Tried. It definitely does.
ok! Thanks, will update
The trick was.. I added
class CfgDisabledCommands
{
class PUBLICVARIABLE
{
targets[] = {1, 0, 1};
};
class PUBLICVARIABLECLIENT
{
targets[] = {1, 0, 1};
};
class PUBLICVARIABLESERVER
{
targets[] = {1, 0, 1};
};
};
(In short: it disables publicVariable stuff on clients.)
I ensured all works as intended on a dedicated server. But when I got back to singleplayer, I figured out everything blows up.π
why? in SP, client is serverβ¦
isServer returns true in SP
but it is also a client, and on client the things were disabled -> logicπ
instead of doing client-check first
if isClient exitWith { /* only client stuff */ };
if isServer exitWith { /* only server stuff */ };
```the logical way would have been to check server first:```sqf
if isServer exitWith { /* only server stuff */ };
if isClient exitWith { /* only client stuff */ };
Who knows which way arma applies the CfgDisabledCommands settings.
devs, hopefully!
Interesting, can I disable all commands and then allow only those I use?
and from it,
It is a powerful tool and can make or break your game, since some of the default in-game mechanics also uses scripting. The use of CfgDisabledCommands feature requires advanced knowledge of scripting and should not be attempted unless the mission maker is confident in his abilities and is aware of potential dangers.
default in-game mechanics also uses scripting
Good point. I guess not so many people can definitely answer which mechanics uses which scripting
mostly, BIS_fnc
Ok. Another question. If I disable publicVariable stuff. Would it affect network missionNamespace setVariable ?
no
different commands are different commands
block one, you kinda obviously don't automatically block the other
It disables commands, not functionality
So, even with publicVariable disabled a malicious person may try to poison a server variable through missionNamespace setVariable ?
yes
And can it be blocked somehow?
if you talk about in-memory functions, use CfgFunctions
if you talk about in-memory functions, use CfgFunctions
But except functions there are also variables.
yep, my sentence is conditional
in-memory functions
Can it be a "non-in-memory" function?
it could be an execVM
but basically preloaded function
preloaded function
Is that a function loaded throughCfgFunctions?
not especially, it can be a compile(final) preprocessFileLineNumbers
so as far as I understand, the technical difference between compile and compileFinal is - compileFinal somehow internally marks its output as "final"; and if that output is assigned somewhere, then the assignment will last forever and won't be updated anyhow.
the wiki is here to help
The wiki gives no details - it describes just the effect of compileFinal
what you said is what is written on the wiki basically
The wiki says: "Compile expression and makes it final, preventing it from..."
My initial understanding was:
<variable> = compileFinal <expression>; And I couldn't understand what is the purpose of making "expression" final;
And my current understanding says, than "final" becomes not the "expression" but the "variable"; Kind`a difference.
Yes
a flag is set on the variable once you store the compileFinal result into it, with that flag set the variable cannot be overwritten anymore
And does the flag travel with that variable?
var2 = finalVar1;
var2 = 'some-new-value`;
systemChat str var2; //what's the output here?
try and see to be sure, but I think var2 can be overridden
configClasses (configFile >> "CfgMusic") apply {configName _x} call BIS_fnc_arrayShuffle Can I use the array shuffle like this or should I create a new variable?
("true" configClasses (configFile >> "CfgMusic") apply {configName _x}) call BIS_fnc_arrayShuffle```You missed the condition
It worked though
I have a condition, I just thought it wasn't relevant to my question π
always post at least the full line!
aCalmMusicClassnames = "'calm' in getArray (_x >> 'moods') " configClasses (configFile >> "CfgMusic") apply {configName _x} call BIS_fnc_arrayShuffle; this is what I have
Oo can't read that. and neither will you when you come back to it in a month
Maybe brackets are missed, and might not so readable but works I guess
Basically adds all config classnames to an array that have 'calm' in the moods array inside a config-entry
Also, where do I need brackets you say?
Never mind, it worked without them
alright, great
For manipulating camera, you have functions like camSetTarget camSetRelPos camCommit
But these fucntions also have variants called camPrepareTarget camPrepareRelPos camPrepareComit
What exactly is the difference? From what I can see, they both have the same effect.
Is there a way to get the currently playing music?
none afaik, but you can use https://community.bistudio.com/wiki/addMusicEventHandler
@autumn swift if needed, see https://community.bistudio.com/wiki/Camera_Tutorial
can someone drop a link that would help me get started with putting gps map on vehicle screens.
Ctrl+M?
I believe he meant "on vehicle screens" π
He probably wants to see it physicalized
yes sorry
I just checked on Chinook and Gear EH works it returns false when gear is up, who asked about gear state yesterday? I think Wiki page need edit after additional testing
@viral basin
I just checked on Chinook and Gear EH works it returns false when gear is up, who asked about gear state yesterday? I think Wiki page need edit after additional testing
@spiral fractal i managed to find every animation name, luckily i just had to lookup 3 helicopters π but thank you anyways
RAH-66 Comanche only return when gear is down... also works, gear takes more time
do all vanilla helicopters trigger it properly?
I checked: UH-80, RAH-66, CH-471 for now, with this code in Init:
this addEventHandler ["Gear", {
params ["_vehicle", "_gearState"];
systemChat str _this;
}];
it works, littlebird dont
if you can test all vanilla A3 helicopters that would be great, so I can update the wiki
its seems that every heli with gear up option fire this event, even the MQ-12 UAV
another thing that I was testing is when heli "land" on water and drowns, it dont fire HandleDamage EH, but Dammaged and Engine EH work, then when it touch the ocean floor it becomes wreck
w00t!! Thanks for testing
I suppose it was correct in OFP/ArmA, and maybe Arma 2
and the respawn system not work for it
btw CH-47 Chinook floats on water π
and can land and take off on water, but I guess A3 wont allow it π
There's no CH-47 in vanilla Arma 3 so...
what is there then?
CH-67 or?
I forgot to mention that I have ACE and CBA installed π @winter rose
maybe that is why the Gear EH works?
I don't think so
but that is a made up name for CH-47
Ah well...
you can even see by its shape that it can float
Yeah, ACE renames some vanilla things so that's why
yes
You know, stealthy and maybe bit sci-fi-ish CH-47 is CH-67 Huron in vanilla
and Comanche was a prototype that was cancelled so I dont think it cant exist in 2035 π unless the program was relaunched later in Arma world
Latter in Armaverse, as mentioned in somewhere... but it's offtopic so I'm not going to discuss about this here anymore! π
Hi, I'm a wee bit confused about how to do this waitUntil
So, I'm trying to make it wait until the returned value from sqf scriptDone XIM_hEvaluateCombat is true
waitUntil {scriptDone XIM_hEvaluateCombat} then```
XIM_hEvaluateCombat is a handler for a spawn
I know that it takes a condition
I'll get rid of the then
Is that the only issue?
well yeah
Okay, thanks
unless you are in an unscheduled environment ofc
Don't worry, I already found that out the hard way π
query on https://community.bistudio.com/wiki/radioChannelAdd
There is no mention of network or locality requirements.
So do I add locally and effect is global or what ?
you would have to test, and eventually report so we can update the page
if I had to guess, I would say "effect local" as channel id varies (and radioChannelCreate is local iirc?)
@slim verge
Ah no, glob/glob
channelcreate is servereside, so... thus far have sent created channel id's to clients via pv setvariable
am now in the stage of If condition add player in a client environment, just wondering if every other player needs to be told this or it just happens
atm testing mp is difficult as no plaqyers about in community to test
ok thx Lou
What command or function prints out to the (dedicated) server console?
Maybe debug_log?
No joy.
do you know it is doable?
https://forums.bohemia.net/forums/topic/194065-can-a-script-write-to-the-server-console/
not without an extension, apparently
Seeing another mod (CUP Terrains I believe) print out. Could just be something during initialization I guess. Oh well.
Wonder if anyone can help me please, im calling spectator through a button, it works fine until i exit spectator and it doesn't return control to the player and is frozen, not sure how to fix it
waitUntil {!isNull (findDisplay 60492)};
private _display = findDisplay 60492;
_text = _display ctrlCreate ["RscText",-1];
_text ctrlSetPosition [ 0.850625 * safezoneW + safezoneX , 0.016 * safezoneH + safezoneY, 0.144375 * safezoneW, 0.033 * safezoneH ];
_text ctrlCommit 0;
_text ctrlSetText "Spectator Menu";
_list = _display ctrlCreate ["RscListBox",-1];
_list ctrlSetPosition [0.845469 * safezoneW + safezoneX, 0.126 * safezoneH + safezoneY, 0.134062 * safezoneW, 0.858 * safezoneH];
_list ctrlSetBackgroundColor [0.28,0.28,0.28,1];
_list ctrlCommit 0;
_list ctrlAddEventHandler ["LBDblClick",{["Terminate"] call BIS_fnc_EGSpectator}];
_list lbadd "Exit Spectator";
_list lbSetData [(lbSize _list)-1,"Exit"];
_list lbadd "";
there will be a disableinput true line somewhere
you need to set it to false
on exit
or you may need to set dialog 0
found it player enableSimulation false;, totally missed it π cheers @slim verge
what modules replace ALICE and SILVIE in A3? lol
@spiral fractal can you be more specific? Whats the problem? Eden or Zeus?
I want to add civs and civ vehicles, I know there is "Civilian Presence" module, but its not like ALICE (as far as I understand) because ALICE added civs everywhere the play go and current module has radius and I have to set waypoints, also how can I add vehicle traffic with that module?
about Gear EH idk if this line is correct: "Also triggered for helicopters in landing mode, regardless if they have retractable gear or not.",
in my tests, EH worked only on helis with retractable gear, all CSAT helis dont fire this EH
Hey guys, am I being stupid? I am not able to get this to work...
addMissionEventHandler ["Draw3D", {
drawIcon3D ["", [1,1,1,1], ASLToAGL getPosASL _Captive, 1, 1, 1, "Target", 1, 0.05, "PuristaMedium","","",true];
}];
about Gear EH idk if this line is correct: "Also triggered for helicopters in landing mode, regardless if they have retractable gear or not.",
in my tests, EH worked only on helis with retractable gear, all CSAT helis dont fire this EH
@spiral fractal
I may remove that line if you confirm it doesn't trigger for AI
@waxen cosmos an event handler is a new (unscheduled) script and doesn't know about your _captive variable - otherwise, the rest seems fine
I think it would be better if someone more "trust worthy" would test Gear EH... but I think I saw couple messages when playable AI took off on its own
@waxen cosmos an event handler is a new (unscheduled) script and doesn't know about your
_captivevariable - otherwise, the rest seems fine
@winter rose - I've just tested various ways to try and run this script. What would be your suggestion in running this from start-up as I'm running out of ideas.
make this captive a public variable, like L1D_captive
@waxen cosmos
struggling with an antistasi variant on our server. Issue being when players respawn, they end up back in slotting up screen having to reselect their unit. Never seen this in any of our missions before.
There are no respawn templates in use, nothing set in the editor gui, and the only entries i can see for respawn are all in the description.ext, that being respawn delay and respawn type being "BASE".... havent a clue what string to mass search for,
any ideas ?
Maybe their getting a missionEnd on the client side?
looked at the Killed EH nothing there
nothing dead player related to endmission, any other ideas
maybe it has something to do with Petros AI? he is the lose condition there, I think
has anyone made some good/bad experiences with how addForce / addTorque commands behave in MP if executing per Frame ? Are there glitches of sorts (more than usuel) or anything like that?
How do you properly spawn a tripwire mine with SQF? When I spawn my custom tripwire mines in the editor and load the senario they work perfectly fine by going off as soon as something touches them. But, when I spawn them in game with either createVehicle of createMine, I have to passthrough the wire a few times for it to actually go off and sometimes they just never activate.
createMine, and wait
the mine is not immediately active to give you time to get away
@steel fox β
Them red triangles that popup indicate the mine is active right?
Using recruit diffuculty for testing
@winter rose
It indicates that your side spotted a mine
Is there anyway to use BIS_fnc_countdown without having the mission end? Or even easier the Countdown module in eden.
bis_fnc_countdown only does an actual countdown and doesn't trigger anything.
The Countdown module only uses bis_fnc_countdown and does trigger a mission end.
arma doesn't report wrong local variable names in unscheduled code. Why and can I enable it somehow?
it expects you to be perfect is why
And spawned code is for kids and it doesn't expect kids to be perfect or what?
sounds right to me
Anybody know why this line throws generic error in expression? I'm running it in an execVM btw
waitUntil {sleep 0.5; scriptDone XIM_hEvaluateCombat};```
XIM_hEvaluateCombat does in fact exist
is it a script handle?
Yes
I have this at the start of my code to make it true the first time the engine reaches the waitUntilsqf XIM_hEvaluateCombat = [] spawn {}; //sets the waituntil for XIM_fncEvaluateCombat to be true the first time it is run
paste the error from ur rpt
sure
Oh, it says suspending not allowed in this context?
that doesn't make any sense...
It's within execVM
Does it have to be within spawn?
no, execvm should do it.
though, it evidently is in an unscheduled environment so...
Doesn't make much sense really.
The script containing it is called within XEH_PreInit.sqf like this:sqf if (hasInterface) then // runs on all player clients, including host (if there is one) { execVM "\XIM_Core\scripts\multiplayer\client.sqf"; // executes client.sqf }
sure it isnt also being called from somewhere else?
π€·ββοΈ
I have my answer
Event handlers are unscheduled
Oh no, actually that code is before my event handler π€¨
it also wouldnt matter if you were doing an execvm from an event handler... it should still be scheduled.
unless that waituntil is inside an eventhandler directly?
some context around it might be helpful. the line itself is fine.
no, waituntil is outside all eventhandlers
It is however within a while do loop
But I don't see how that could create a problem
can u post the file? or at least surrounding lines
share a link to it
What I'm trying to do is prevent an eventhandler calling XIM_fncEvaluateCombat until the function itself has finished running
Same with XIM_fncToggleCombat too
you have it in two event handlers...
No
L70 and 85
Forgot about those ones haha
the error tells u the line..
Are you sure?
they usually do
I don't see the line no in the rpt
Ingame maybe?
Hmm, no not there either
Anyway, thank you very much for your help
ehh, probably not actually, because the event code doesnt know what file it came from
Ohh, different thread right?
yea. new scope stack.
got it
cheers
Does defining loadingTexts[] within CfgWorlds add to other text that can appear there, or does it replace all other loadingTexts[]?
As in, if I define a loadingTexts[] within my config.cpp, and it only has one entry, will only that one show up?
Even if there are other mods loaded with their own loadingTexts[]
replaces. you should be able to add to it with
loadingTexts[]+={};
ill double check that + position
yea that should be correct.
kk
Can someone help me understand what the definition of the ! And || operations happening in this? @ me if you know the answer
if(currentMusicState != "nonCombat" || isMusicCurrentlyPlaying == 0) then
@ashen warren β
|| is or
&& is and
! is not
!= is "not equal"
I thought so but I wasnβt completely sure. Thanks
see https://community.bistudio.com/wiki/Operators for all the possible operators
Ok interesting, Iβm working on something and it doesnβt like to detect a section called isfog on my script that is using that if then statement. But it skips over it.
My line number and notes of what is going on on the top of the document if someone could explain to me if something I did is incorrect
What is isFog?
It is a detection for fog in a different sqf that runs fog >= 0.3 in a do loop I believe. It also has the day detection in the same loop
For more information on what I mean
But it skips over it.
For sure?
I know itβs weird but it does.
It will not switch to it. When fog is over 0.3
I have gotten it to switch if I removed the noncombat part of the if statement
Doubt _fogTracks exists?
check your variable(s) before the if
...If doesn't exist, should return error tho
Yes itβs at the way way top of the sqf.
I didnβt paste it into the thing which I should have
If I remove the battlestate = noncombat related stuff. It will use fogtracks and just change every second
It still doesnβt make any sense how it wouldnβt detect that isfog section when I add in the noncombat items it will ignore it?
Does anyone know how to alter Ace variables from the server on selected clients? remoteExec in combination with setVariable doesn't seem to do the trick. I want to change ace_hearing_disableVolumeUpdate
is it a global variable?
I am not entirely sure, I can set it locally just fine by doing ace_hearing_disableVolumeUpdate = true;
Did you try the alt syntax for setVariable?
https://community.bistudio.com/wiki/setVariable
I have, to no avail
I am not sure what I should use for the namespace param
player, right?
Since I would be executing it on every client selected with remoteExec
Assuming it's a missionNamespace variable:
missionNameSpace setVariable ["ace_hearing_disableVolumeUpdate",true,true];
Though this makes it a publicVariable. You can use owner IDs (such as with remoteExec) to set it on specific machines.
So, how would I approach setting it on a group?
If you don't expect duplicates (having AI in the group) something like:
private _groupOwnerIDs = [];
(units myGroup) apply {_groupOwnerIDs pushBackUnique (owner _x)};
missionNameSpace setVariable ["ace_hearing_disableVolumeUpdate",true,_groupOwnerIDs];
That would need to be executed on the server.
Actually my mistake, select doesn't have that syntax. Fixed it.
what command should I use to play sound and make it attached to the object it is playing "from" so if the object moves sound will move too?
I use playSound3d but it stays in the position it was added to
@crude needle Thank you very much, I will try that
@spiral fractal I do believe say3d has that functionality. Though it is not global.
it maybe ok if its not global, but I think its impossible to pass file path, I have to declare it in description.ext and I dont want that
why not
The other solution would be to create a sound source I think
[{missionNameSpace setVariable ["ace_hearing_disableVolumeUpdate",false,_groupOwnerIDs];},[], 5] call CBA_fnc_waitAndExecute; Is this this correct? Or do I need to put the setVariable params inside the optional arguments parameter? https://cbateam.github.io/CBA_A3/docs/files/common/fnc_waitAndExecute-sqf.html
I figured it out π
It works just like that
hey. if i make a teleport script. can i use one pole to teleport to different places? would i just put a second teleport script under the first?
i wanna be able to make a hub of sorts on my training map
haha
nope, #server_admins I guess
Was inspecting https://community.bistudio.com/wiki/BIS_fnc_setTask
That`s weird, but internally it does not respect the isGlobal param when dealing with child tasks.
What do you mean?
I call
[
_taskId,
group player,
taskDescription _realTask,
taskDestination _realTask,
_state,
0,
true,
false,// DON'T run globally!!!
taskType _realTask,
false
] call BIS_fnc_setTask;
but inside BIS_fnc_setTask there is:
...
//line 267; isGlobal not respected
[_x,nil,nil,nil,_state,nil,false] call bis_fnc_setTask;
...
//line 298; isGlobal again not respected
[[_parent,"",_parentChildren],_owners] call bis_fnc_setTask;
//
And that breaks the mission scripts
ah well. I don't have access to my computer right now but if you think this is an issue, please create a ticket (if it doesn't exist already)
Hi, I was wondering if there's a way to return a variable within an if statement without making it a global variable?
For example:```sqf
if (true) then
{
private _number = 5
};
if (_number == 5) then
{
...
}```
I'd like to be able to access the _number variable outside of the scope of the if
Is that all I can do?
It's a logic issue here
What if you don't go through your if? What should the last part do?
try instead I suppose
Poor example, I know
But thanks, I'll try defining it outside the scope :)
define it in the scope you want to use it, and change its value wherever you like (in same-or-lower scopes ofc)
Yep, cheers
For reference and explanation (https://community.bistudio.com/wiki/Variables#Local_Variables_Scope)
Thanks
Me and a friend are trying to combine 2 SQM lines from different maps, so far we've gotten both maps too work individually and certain aspects too work but the rest wont, we're closeish too what we want currently but we keep getting a random error.
"mpmissions\main%20combination%20.altis\mission.sqm line 18219: .Mission: Member already defined"
The code at the line 18219 is
class Item31
{
linkID=31;
item0=88;
item1=87;
class CustomData
{
type="Sync";
};
};
};
};
};```
No clue what language ARMA works in personally so we're both stumped here, any advice would be appreciated.
why dont u just copy the editor items from one sqm into the other... in the editor?
or merge one sqm into the other if you want everything (again, in the editor)
Because we're tryna take some stuff from a map we like too use and put it onto our own map (Not for publishing, just private use) and it all runs on weird scripts, if what you just said would work still in this case how would we go about doing this?
Psure they're both missions but i am not entirely sure on the inner workings of ARMA stuff so
Most of it's all the same for me
yes but helping you might be easier if you talk about right things
and connor said it might be simples to copy the stuff in editor
since you might quite easily miss stuff by copying them in the sqm file
the editor is literally there so you dont have to mess up the sqm directly.
Yeah, MB they're both missions , one of them has the usual stuff we want too just mess about and we're tryna pull in god mode and such from another mission, but that error keeps re-occuring, when we go about doing what the error comes up with it differing stuff
Yeah, we'll try that now
imagine writing mission sqms by hand π©
if there are some complicated features build in they might not even be copyable that easily.
Alright, how would we go about doing the whole thing through the editor like Connor suggested
click on the objects you want. ctrl c. open the sqm u want to paste then in. right click, paste on original position (if that matters), otherwise ctrl v will do
or there is a button (under file i think) to merge one sqm into the other
Alright thanks very much for the help β€οΈ
is it possible to detect variable change somehow? I have CBA, player setVariable["var1", 100]; I want to get "notification" when var1 is lower than 50 for example
@modern adder
Hi, I was wondering if there's a way to return a variable within an if statement without making it a global variable?
Uh. you mean like
if (true) then {
5
}
? π
The last value left over in a scope, will be returned from it
That's exactly what I was looking for, thanks mate
Is there a Discord server for Intercept?
I have a quick question and not sure where to direct it
This topic should fit if is script-related
Oh ok, cool π
I'm building an Intercept-based mod which has been working well so far. However, I'm having trouble with mission event handlers not firing. Here's my code;
void on_entity_respawn(types::object new_entity, types::object old_entity) {
logger("Respawn EH called");
}
void intercept::post_init() {
client::addMissionEventHandler<client::eventhandlers_mission::EntityRespawned>(on_entity_respawn);
}
However, the log message doesn't appear when an entity (eg player) respawns. Recreating the above in SQF works. What am I doing wrong?
Uh, sorry I've no experience with extensions π
No worries! I'm hoping Dedmen might see this π
(not sure what the etiquette is here on @ing people)
No intercept discord, I have my intercept projects discord, and main intercept uses-ish slack.
Quite sure you need to store the return value from addMissionEventHandler.
The return is a reference counted handle, when you let it go away it will automatically remove the eventhandler
@scenic pollen
Yep, it returns EHIdentifierHandle when that handle destructs, it calls removeMissionEventHandler
Ahh I see, that makes sense. Thanks! Would your intercept projects discord be the right place for me to ask any more questions in the future?
@scenic pollen what is your mod about? I'm interested in Intercept usage applications
π
Well its mainly me there, and as I'm basically the only intercept support, I guess that would work π
https://discord.gg/sMmYXB
You can ofc also use #arma3_tools or just ping me here
@astral dawn Will DM you π
Speaking of extension, what's the best tutorial/reference to code Arma Extension?
there is a wiki page with the bare minimum required in some languages
Killzone Kid has some tutorials
http://killzonekid.com/arma-scripting-tutorials-how-to-make-arma-extension-part-1/
π If I'd start to make an extension from scratch without any experience, what's the best language you'd recommend?
The language that you already know π
depends what language you know. i do C#
...sqf π
its pretty hard to mess up
I've kinda bruh at any of coding, I only have sqf and bit of Lua experience
C# is so strict it has a dedicated 50 shades book you can't really make language mistakes
tis k. i only knew sqf when i started doing extensions
use SQF-VM and write a wrapper so you can write extensions in SQF
wouldnt that mean you can only use sqf commands though? the only benefit being it executes faster?
yeah :D
Not really faster I think
π .... then whats the benefit of using it?
its crazy and thus funny
Aight boys, I think I'll go with C# (maybe later). Cheers!
...oh wait one more question, is that Discord server Dedmen posted better place to discuss extensions?
no
thats just my discord for my few projects.
Extension talk here is usually #arma3_tools just because all the real programmers are down there
Understood, thanks!
Which command do I use to change view distance for the missile picture in picture view?
PiP quality in video settings, that's it @quartz pebble
so no explicit way to tell it "show 12km"?
I know. The players who have it enabled were asking how to make it show further.
"higher quality option" is the only way.
tx
hey guys!
Currently making a mission where players need to travel around with some assaultboats, where there will be alot of embarking and disembarking.
During my first testrun I realised that the players took damage from the boat during the disembark, this could easely be solved by drivers do better training on handling the boat itself.
But lets just assume the problem goes on. xD
So I wanted to make use of the eventhandler for "getout" to simply disable the damage the first 3 seconds and then turn it back on again.
Clearly it didnΒ΄t work out as I hoped and now im asking you what may be wrong.
SecureEject.sqf (runned from initplayerlocal.sqf)
player addEventHandler ["GetOut", {
params ["_vehicle", "_role", "_unit", "_turret"];
if ((typeOf _vehicle == "sfp_strb90_rws")) then {
player allowDamage false;
hint "damage off";
Sleep 3;
hint "damage on";
player allowDamage true;
};
}];
a quick guess could be, eventhandlers are unscheduled and cannot handle sleep?
you cant sleep directly in an event handler. iit isnt scheduled
try this, but it may not be fast enough on all occasions.
player addEventHandler ["GetOut", {
params ["_vehicle", "_role", "_unit", "_turret"];
if (typeOf _vehicle == "sfp_strb90_rws") then {
[] spawn {
player allowDamage false;
hint "damage off";
sleep 3;
hint "damage on";
player allowDamage true;
};
};
}];
_this* allowDamage
_this is the vehicle?
player addEventHandler ["GetOut", {
params ["_vehicle", "_role", "_unit", "_turret"];
if (typeOf _vehicle == "sfp_strb90_rws") then {
player allowDamage false;
hint "damage off";
[] spawn {
sleep 3;
hint "damage on";
player allowDamage true;
};
};
}];
``` use this instead
always try to stay in unscheduled for as long as you can
i was just about to get to something like that^, though that specifically would leave them in godmode if they didnt get out of that boat...
nope. params outside the if
*fixed
_vehicle isnt defined for the condition like that
gah ... common
ma brain today
π
sorry for late reply, had some visitors coming over, thanks guys, I give this a try π
hmm, something is definetly weird.
I didnΒ΄t get the one @queen cargo suggested.
So I started from scratch:
player addEventHandler ["GetOut", {
params ["_vehicle", "_role", "_unit", "_turret"];
hint "Test";
}];
And the hint doesnΒ΄t show at all...
If I leave this as it is it should trigger everytime eject or getout action is done?
From wiki
"
Triggers when a unit gets out from a vehicle. It can be assigned to a remote vehicle but will only fire on the PC where the actual addEventHandler command was executed. This EH is triggered by moveOut, "GetOut" & "Eject" actions, if an alive crew member disconnects or is deleted, but not upon a seat change within the same vehicle.
this addEventHandler ["GetOut", {
params ["_vehicle", "_role", "_unit", "_turret"];
}];
vehicle: Object - Vehicle the event handler is assigned to
role: String - Can be either "driver", "gunner" or "cargo"
unit: Object - Unit that left the vehicle
"
oh π€¦ββοΈ GetOut is supposed to be added to the vehicle im pretty sure. try getoutman
Vehicle the event handler is assigned to yea
I trying to randomly spawn camp sites on PKL but they sometimes wind up in a rice paddy. I want to avoid that. I have this...
_fe = _pos isFlatEmpty [15,-1,0.2,15,0,false,objNull];
but also added this to try to accomplish the restriction..
if not (((count (_pos nearRoads 60)) > 0) or ((count _fe) < 1) or {(((ATLtoASL _pos) select 2) < 0)}) then
they still spawn on rice paddy
how can I script a more strick command?
I need something to say avoid any and all water
been reading but .....
_pos = _fe;
_pos set [2,0];
_camps pushBack _pos;
you could try surfaceIsWater, although I'm not 100% sure if Arma knows it is water.
so I guess your best bet is using surfaceType and figure out which surface has been used on the rice paddies
Not sure but I think they are just sculpted by the terrain maker
Alrighty, I am a noob at scripting stuff, but here goes. I am trying to create Zeus modules to change the view distance of a player. I have the setViewDistance down and I can make a custom module, but I cannot figure out how to target a player and change their view distance only
I wonder if the rice plant has a classname??
thanks @exotic flax
you gave me an idea
well, the surface also defines the clutter, which should be the rice plants (because I don't think Blud manually placed each plant)
very true,
Question: is there a required light level for detecting mines, and is there a way to manipulate it?
Maybe, and mods
that's, uh, limiting
Β―\_(γ)_/Β―
Is there a way to set a publicVariable to nil?
Because from my understanding, if I were to create a variable in the same name, set it to nil and try to broadcast it, I would cause an undefined error
@modern adder in Arma 2, yes
in Arma 3, no
It is explained on the wiki
Yeah thanks, I figured it out
I can do it with sqf player setVariable ["varname", nil];
how triggers work? I mean the code for triggers
it runs the condition unscheduled every 0.5s (by default, changeable)
do the probing mechanics on ED-1E only work with Contact loaded? https://community.bistudio.com/wiki/Arma_3_Probing_Mechanics#Probing_Event_Handlers
How can I deactivate the slow walk of ais when they are damaged
ForceWalk etc. not working when they are 0.7 damaged
@naive needle set their leg damage to < 0.5 I believe
@slate fulcrum have you tried it?
@winter rose I have, but without the optional Contact dlc loaded.
and�
there a link to a page that can help me with the usage and syntax of
_x```
@fair drum see the wiki with "Magic Variables", but mostly the forEach page
kk thx
_x only means "current element of the array"
@winter rose and it didn't work, that's why I asked if it's a Contact only thing
Well, unless you did something wrong I believe you figured it out ^^
But strangely enough, it is not mentioned on the page π€
I would need to test (tomorrow) ; I don't know
The page does mention something about "material", and the example code uses the string "alien" for it, but it's weird that they would make the code work only with the organic alien network stuff.
Would you want to see "soldier's meat"? π
I will test tomorrow and update the page if needed. Want me to ping you then?
@slate fulcrum?
Ah, yes, that'd be great
okido
thanks mate
Anyone know if there's some kind of FOB generating script where you define a marker area and it procedurally builds a fob, that would be pretty cool sort of like a furniture script
so when the command says:
{ _x setDamage 1 } forEach units group player;
am I only to select one of the units/group/player?
for example:
{ _x setDamage 1 } forEach deadGroup1;
all units in the group
the first one is just the wiki example im trying to learn off
"do this action" "forEach units of this group"
_x is the item of the current "loop" - the code will be applied on each list item
I don't know what you want to know or ask
yes so I want "set to dead" forEach "units in the group deadGroup1"
so would i have to do:
{ _x setDamage 1 } forEach units deadGroup1;
yes that works. i guess i just got confused since the wiki has 3 parameters in the example so i was wondering which ones to include
forEach gets array, in this example to get the array that will be passed to the foreach you call units on group of the player.
everything that happen inside the { } will be applied to every element in the array, so in this example , every soldier in the group.
_x will be available inside the { } as a way to access the current element that foreach selected from the array.
when I use BIS_fnc_spawnEnemy is there way to customize gear, outfit etc of the spawning units?
you could either create configs for units with custom gear and spawn those, or you could spawn units with BIS_fnc_spawnEnemy, get the return array (containing the units), loop over them and give them modified loadouts
if I choose the first option its means that I will have to use different function?
no, simply set the 4th parameter with the classes you want
and you can even use the 7th parameter to run code on each spawned unit π
in Wiki example 4th param is ["O_Soldier_F"] will it be possible spawn O_Soldier_F but with M200 sniper rifle for example, using only 4th param?
code in 7th param executed when? before/after unit appears? I dont want to spawn unit, its gear then replace gear
like I said; either make a custom config with the unit you want to spawn (including custom gear), or use a script which is executed after the unit has been spawned
configs requires to make a mod though, since it can't be down in missions
ok, Thank you!
too bad this info not appear in wiki page... also no info on performance, MP support etc.
the wiki explains which parameters are used, what they should contain and what they do... enough to connect the dots IMHO π
if every possible combination of usage has to be written down than every function/method would need its own wiki
I am new to scripting and after reading this page I have left with unanswered questions π¦
need a syntax check to see if I'm putting this together right.
({alive _x} count units [d1,d2,d3,d4,d5]) == 0
this should check if d1 through d5 groups have anyone alive, and if none are alive, it should give a true value correct?
thats not how units works
private _index = [d1,d2,d3,d4,d5] findIf {
(units _x findIf {alive _x}) > -1
};
private _allAreDead = _index == -1;
_allAreDead
i think this might do it
well
count units [d1,d2,d3,d4,d5]
should give me the number of units in that array of groups right?
no, thats not how units works
https://community.bistudio.com/wiki/units
Syntax:
units groupOrUnit
Parameters:
groupOrUnit: Group or Object
and the example from that page is:
_myUnitCount = count units group player;
it only has an added variable to store that number.
so it can really only handle one group at a time the way I'm writing it such as
count units d1
yes
so for an array of groups you would need to loop through it to check each group individually
but using count to do that would keep checking the units and groups, even if it already found someone alive.
it would work so isnt technically wrong, but findIf exists on the first alive unit it finds so its a little faster
so reversing your script you are doing...
creating a local variable named _index which checks if Y is > -1.
and then Y checks to find any alive unit and return how many there are?
using Y as a placeholder
not exactly
the first findIf loops through the groups array.
the nested findif loops through each unit of the current group.
if the nested findif finds an alive player, it exits and returns the index it was on for units _x.
> -1 is to say if findIf returned any valid index at all. so if it did, someone was alive.
same goes for _index == -1. It checks if the first findIf returned an index for a group with a unit alive. If it didnt, everyone is dead.
You dont need to assign the first findIf to a variable like _index, i did for readability, same as _allAreDead.
alright I'm going to stew over this for a little bit and see if it sinks in. I hope you guys don't mind me asking probably basic questions for you. I've been reading all the wikis and watching as many videos as I can to learn this stuff and I don't like taking other people's scripts cause then I actually never learn anything
i wouldnt trust videos. Things should start to make sense easier if you understand the format of how sqf is written. I suggest you read this page
https://community.bistudio.com/wiki/SQF_syntax
and then read individual command pages as you need them.
Is it posible to place a mission script in fx "Arma3\Scripts" and then load it from a mission?
The edit terrain module's door locking var does not set globally, and is only executed on the server? Are there workaround for this in the editor or what do people do for workarounds for this functionality from the module settings?
I am trying to workaround it by searching for the existing vars in a format loop and then resetting them as public, there must be a better way... ```sqf
[
hanger1,
hanger2,
hanger3,
hanger4,
hanger5,
hanger6
] apply {
private _building = _x;
for "_id" from 1 to 20 step 1 do {
private name = format ["bis_disabled_door%1", _id];
private _doorVar = _building getVariable [_name, nil];
if (_doorVar isEqualType 0) then {
_building setVariable [_name, _doorVar, true];
};
};
};
Hi. Does anyone know how to display Old Man style mission title?
What title? Intro screen?
@warm hedge - i'll send you on PM a picture since it's not allowed here as far as I can remember.
No
Hi guys, i want to call a script from outside the mission folder, but it cannot find it. is this even possible? ive set the path like this: "C:\Arma3_server\Scripts\Rang\Rang.sqf";
No what?
So you don't want the answer?
_title = "Thing you want to show";
[parseText format ["<t font='PuristaBold' size='1.0' color='#f2a832'>%3</t><br /><t font='PuristaMedium' size='1.25'>%1</t><br /><t font='PuristaMedium' size='0.85'>%2</t>",_title, Localize "STR_A3_OM_System_Intel_DiaryUpdateNotification", Localize "STR_A3_OM_System_Intel_DiaryUpdateTitle"], true, nil, 7, 0.7, 0] spawn BIS_fnc_textTiles;
playSound "Beep_Target";``` in `a3\missions_f_oldman\systems\scripts\intel.sqf` @fossil yew
Thank you. Sorry for tagging you several times, I don't know a better way here.
Just use external services. This is just for anti-spam
You know what things to change the words New Intel and Diary was updated, change things in format
Yeah, I do.
Hi, is it possible to detect all bullets which land within a 50m radius of the player and find the unit who shot them?
I don't think so. There's no EH to detect a bullet has landed nor landed near
They are indeed, but it's not possible to detect to land in performance-friendly way IMO
Since if a bullet has landed somewhere, it's objNull anymore and you can't detect with nearestObject or such commands
Maybe
Would probably kill performance to run it so often though haha
Indeed
I suppose you're trying to make (be) suppress (ed) function, maybe LAxemann's way is one of the good example
https://www.youtube.com/watch?v=E8Q_KF-u1UI
No
Oh
But that could help?
I'm trying to make a dynamic music mod actually
Based on combat
Maybe? I don't think I've ever tried the thing
Has laxemann got a github?
IDK. Maybe?
would I be violating anything if I debinarised his source and took a look?
I do believe looking itself won't, but if you're in doubt, confirm before take a shot
Ok, cheers
Hey there, is it possible to delete the "customMark"-Marker with a command? We're currently working on a custom map and unfortunately it's not possible to delete it by using "DEL"...
You⦠can?
i tried, i can't π or do you mean the command?
@viral basin what exactly do you mean;
Delete a hand-drawn marker with deleteMarker, delete a marker with the del key, something else?
Yeah but the custom marker, the one you set with (LShift + LMB), is not deletable with deleteMarker
It's impossible AFAIK
you mean the personal waypoint? if you don't want that you can turn it of in the settings
your own you can delete with delete on the map not remotely afaik
hmm okay, i guess i have to do a workaround then π
Hey, I have a really noob question. I'm trying to use the countSide function to count units in a trigger area. Following the exact example on the wiki yields an error. Just for reference I used _numunits = west countSide list _trigger1;
Where trigger1 is the variable name of the trigger
Am I doing something wrong?
I put a 3 second sleep beforehand to make sure the trigger has enough time to initialise
trigger1, not _trigger1 @sinful axle
it doesn't need to be global, but if you named your trigger trigger1, that is the name you should use
What's the best way to execute another sqf within a sqf (let's say to start a sound loop sqf while the main sqf script continues to run). Is it just: ** exec "example.sqf"** ? (just making sure I do the right one).
if you use it once, yes
if multiple times, the ideal way is to make it a Function (see CfgFunctions)
I'll only be calling it once but because this is going to be a sand alone mod I don't want it to kill peoples servers when it just plays a sound on loop, haha.
Thanks for the answer. π
Thank you Lou, that explains it.
@spice vigil the call is dependant on whether you want to function/script you are calling to run parallel to the function/script it is been called from
For example it is being called
Myscript
Line 1
Line 2
[] call MyTag_myscript;
[] execVM "myscript";
[] spawn{some code eg [] execVM...}:
Line 3
In the call and execVM which runs in line, eg in the same thread, Line 3 will only run after the called function or ExecVM script has finished,
whereas the spawned code will run seperately (In parallel)on a different thread
in your example, i would say spawned is the best way forward
Hold on, I'm very rusty so I need to process this. So in your example that would execute another sqf script and they would run alongside each other? (with the spawn command)
well it depoends if you call, execvm or spawn
spawn runs parallel yes
spawn = start another thread and run code in that thread
whereas execVM and call = wait until i have finished these scripts, functions before you continue with the script I am running at the moment....
Okay, cool. Once thing I am a little confused on (more wanting to double check) is the fnc you are calling. Do you ExecVM the FnC you make in the CfgFunctions* or do you just call the file name (wherever it may be)?
wait I copy pasted wrong cfg I mean CfgFunctions (edited above)
so cfgfunctions is a way of defining a script as a function, there are other ways
Example
TXU_MyFunction = compileFinal preprocessfilelinenumbers "fn_MyFunction.sqf";
compared to [] execvm "fn_MyFunction.sqf";
The difference is
You define (compile) a functionion normally before you need to use it (E.g call it). This function is then stored in memory and when you call it you are calling it direct from memory meaning it runs faster, so if you intend calling a any code more than once, its better practice to compile it as a function.
ExecVM on the other hand is compiled and run at the same time EVERYy time you call it
Hello, gentlemen! Does anyone know if the addPublicVariableEventHandler is JIP syncronized or not? Should i add it for client every init?
To be more specific, should i place it in initplayerlocal.sqf or may be i can use it in init.sqf and rejoined client would still track PublicVariable EventHandler
effect local says the wiki, so you need to execute it on every client
putting it in either file would work.
thanks, ill give it a try. Frankly, i forgot to google it beforehand
To be honest Terox, my head hurts, haha. I think I understand the spawn command now though. You mind if I PM you with some questions if this doesn't work? (clog up the chat less).
@spice vigil everyone in here is learning any questions / answers benefit all m8
@spice vigil maybe this page can help
https://community.bistudio.com/wiki/Variables#Local_Variables_Scope
No worries, I'm always scared I'm asking too many questions, haha.
I've decided I want to spawn a fnc from my CfgFunctions in my config.
I would say there are 4 main areas you need to learn really well in order to improve your scripting.
- Understand the syntax and information in the comref which details the parameters used in each command and their scope, as in where they need to be run and what effect that has on other connected machines
- Understand Variables, _local, Global and Public Global which Lou just linked you to
- Know how to debug your code so that you can return the variables you are using to either the rpt file or system, side global chat or hint.
This may help you with that https://forums.bohemia.net/forums/topic/166233-zeu-debugging-tutorial-foundation-template/
and
4) How to ask a question in here thaty is likely to get an answer
To expand on 4
How do I write a script tto do ABCDEFGHI
will likely get you nothing
whereas asking a more specific question like you did earlier and in some cases displaying your efforts to debug
will likely get you a decent answer.
Taking that into consideration there are some answers I have seen in here that display a lack of understanding from the person answering the question as to how little understanding the person asking the question has.... Typical arrogance of someone who assumes everyone is a professional coder . (I am a gas fitter, i have just learnt what I have over many years of working with BIS scripts)
if you take a look at the thread I linked you to, it shows a debug of linear code being called within linear code
eg
"------ PARAMS ------ fprocess_params ------> START : @ 4439.84"
"------ PARAMS ------ fset_params ------> START : @ 4439.84"
"------ PARAMS ------ fset_params ------> END : @ 4439.84"
"------ PARAMS ------ fprocess_params ------> END : @ 4439.84"
so frocess_params was called
While it was running, it called fset_params internally
fset_params runs then ends
fprocess_params then continues to run to its end
this was like
fprocess_params...
line 1..
[] call fset_params
//// fset_params finishes
line 2
///fprocess_params finishes
Thanks for all the help and info (I'll get into when I have time). I'm a historian in real life, I don't even like scripting. I've only learnt what I have for this one sqf in my mod pack, haha.
its just another skill to add, all skills are worth that
I really do appreciate the help.
Yeah, I'm a complete idiot. My script was fine, I just didn't put [] in front of the spawn command. I apologise.
yeah, call doesn't need them, spawn does
(but that does not make you an idiot)
Again big thanks. My mod is almost ready after all this time, haha.
mod pack
?
Again with the beginner questions. If I have a while loop contained within []spawn will I need to make all variables outside of it global if I intend to use them in the while loop, even if they're in the same script?
what @oblique arrow means is that it is forbidden to pack multiple mods (you don't own/make) into one, @spice vigil
@sinful axle yes, see above link (variable scope)
(or pass them as reference)
Sorry, I mean "Mod" as in my mod. all contents 100% made and owned by me.
Note that you arent allowed to upload anything you dont own to the steam workshop although having your own repository is usually considered as fine
ah oki
Thank you!
Reading through the wiki on global variables I've noticed the publicVariableServer and publicVariable. I might be reading it wrong but do I need to add publicVariableServer to my sqf script if my mod is going to be used in multiplayer? Or are they only used if you want the server to have a different variable to everyone else?
do I need to add publicVariableServer to my sqf script if my mod is going to be used in multiplayer
no
Or are they only used if you want the server to have a different variable to everyone else?
no
its used for when you want to distribute the value of a variable to other players/machines
Okay, I totally just misunderstood it then. Thanks.
is there a way to find the nearest player to an object/position in multiplayer
find the nearest units and then check if they are players
the other way around, take allPlayers and check the distance?
more "performance-friendly" I would say π
Is near_____ just checking distances of all objects?
yep
ouch.
you cannot filter by player/playable status - you would "get all" then filter with select
@winter rose Ah yea, I didn't think of that, thanks. I'll just check the 2d distance to each player and return the one with the lowest value.
Is near_____ just checking distances of all objects?
no
Hello fellows. I am using the vanilla vehicle respawn module in my mp mission, and I often find the vehicle does not actually respawn on destruction. I am running a script from the expression field (that sets the vehicleName and a few other things linked to that particular vehicle). Are there things to avoid when using this module? I donβt even know if using an expression has any impact, but thatβs all I can think of. Itβs an intermittent issue :/
Anecdotally I have heard people say they prefer homemade solutions .. but Iβve never been clear why. Cheers
which modules are you running? just vehicle respawn or vehicle respawn sync'd respawn tied to that vehicle respawn?
Nothing complicated .. the main offender is non vanilla mh6.. and is the only vehicle linked to the module.
I guess I could do my own check (if the heli does not exist, then spawn it in, and check that every 30 seconds or something).. but I would have thought the vanilla modules are more robust π
Which is why I am wondering if itβs somehow a problem if my own making
without the expression field I find they work fine for the basic level I'm using them for (maybe try them stock?). maybe someone else more experienced can help you further.
Yeah I think I had better results when they just respawned something ... I think I only started seeing issues after using the expression field. But maybe itβs nothing to do with that π€
BIS_fnc_spawnEnemy returns array? how to add it to addToRemainsCollector?
addToRemainsCollector takes⦠an array @spiral fractal
Is near_ just checking distances of all objects?
no
Is there a point where eg with 80 players allPlayers would be worse than a radius 5 near__?
probably
when I do: addToRemainsCollector [player, player, opfor, ["O_Soldier_F"], 16, 1, {}] spawn BIS_fnc_spawnEnemy; enemies dont spawn

Is there a command to check if someone has Zeus access?
Doesn't seem to have anything here ^
how to make it work then?
where is the array? when I check the value of the result I get BIS_fnc_spawnEnemy inside
you need to call the function
also, you should use ( ) around it
or use a temp variable
I have global var DBG in init, I store the result there
if I call spawnEnemy my game crash
actually, this function does not return anything
from the sqf:
Returns:
ARRAY - list of all spawned crows
I guess it's a bad copy-paste
there is a while-true in it, and there is absolutely no spawn or return value anywhere
you have sqf of this function?
@spiral fractal https://community.bistudio.com/wiki/BIS_fnc_spawnEnemy fixed
So it's possible to remove turrets from vehicles through the use of function scripts, but is it possible to add a different turret to a vehicle? Say I wanted to add the bardelas turret to the Rhino MGS and make a wheeled SPAA, would that be possible?
physically, no
weapons fired, yes
Ah okay
can devs fix functions when they release patch?
yes, but which function?
most of them probably... spawnEnemy has undefined variable for example, also no end condition
no end condition is not an "error" per se
the undefined variable has been reported and is already fixed in the next patch
I think there should be end condition...
I agree, but that's not an error in itself
also, if they fix this⦠everyone that used this function should edit their mission
retrocompatibility is the main priority. poor design sure, but not broken function
you can still make your own with spawnUnit and stalk!
well... π
i have a custom ui with a map control in it, but we cant click on tasks to see description. how can i fix that?
Theory crafting away from pc- I think this should work: if ({player distance _spawnpoint>5} count all players <1) then (_spawnpoint deleteAt floor random {count _spawnpoint})
_spawnpoint is an array of random locations a player can spawn in but only if there are no other players spawning there, it's selected by select random
```sqf please
also, player distance _spawnpoint will always use the same unit, player - use _x
_spawnpoint = [respawn_0, respawn_1, respawn_8, respawn_9] call BIS_fnc_selectRandom;
if ({ _x distance _spawnpoint >5} count allPlayers <1 ) then (_spawnpoint deleteAt floor random {count _spawnpoint});
player setPos (getPos _spawnpoint);
On further thought count _spawnpoint may fail as it isn't returning a number is it..
```sqf, and break your code in smaller pieces
also, then {}, not ()
@waxen cosmos basically, what do you want to do?
linkItem is 100% AG EG?
β¦79% actually
I run function on server, and pass player to it, inside the function I do _player linkItem "B_UAVTerminal"; and its not working
this line works _player setVariable ["nc_role", _roleId, _playerID] in that function
ah wait I think I have other error that cause it π³
always script with the -showScriptErrors flag!
I forgot to change switch cases when I refactored my code π
seems to work now (SP)
@winter rose I'm testing again today and it seems like you can probe units (soldier meat) and the script does seem to work on them, but I haven't been able to make it work on objects
