#arma3_scripting
1 messages · Page 133 of 1
Is anybody aware of a way that somebody's scope sway could end up being zero? Without mission-side scripts or hacks?
To be clear getCustomAimCoef player equals zero
Unless you have a script somewhere, sounds like a hack to me
Repeated use of setunitloadout in a short time on the same player can also cause the sound to go quiet.
I had an idea concerning vehicle AI and being stuck... first off...is there any type of EH that is sort of like "istouchingobject"? i know theres condition IsTouching ground. But i had the idea,that if i vehicle is touching an object A) destructable, then check with a timeout of 60 seconds if its still touching it(stuck on destructable road barricade as in this example) or B) Is touching non dextructable object like rock or low wall(common map objects that they stuck on alot) if so: for A, setdamage1 to object or if B: hide object.
is this something that could work,without perfomance impact checking regularly?
it could cut in half how often vehicles get stuck indefinetly. the check could ignore buildings,just focus on certain object classes
you could just check if vehicle has not moved by using timer and position
wouldnt suffice in a dynamic envoirnment though. many times a vehicle SHOULD be stationary. that cant simply tell you that its stuck
check if its have move WP
what about sentry wp?
your saying ONLY if it had move?
then thats same as not moving
gotchya
still wouldnt work though. as vehicles WILL stop to engage and continue wp after known threats are dead
it would end up deleting alot of walls and rocks around the area perhaps
imagine your bipoded on a wall,and a AAPC drives next to you,stops to engage,then a minute later your wall dissapears
check that there is no enemies near before trying to unstuck, but I wouldnt go about deleting stuff but rather use script to move the vehicle to nearest road or something
I actually do that in my mission
yes setpos is a common usage
i do it too
but in my mind i was considering vehicles i dont have current eyes on
more dynamic
do you use it in a dynamic way or on your group?
I move the vehicles
automatically/autonomously or a function you need to call?
not sure what you mean, there is script running on each group that moves the stuck vehicles
can you share it? i meant was it used on demand,or constantly checking
so constantly checking right?
yes constantly checking, I can share the script but its not standalone but depends on other functions
thanks man id appreciate it
ill dm it to you
Hey! I'm working on the AI Sector Searchlight script by ALIAScartoons but I didn't get it to work on a MP scenario, but not sure why. I keep getting a "Undefined Variable in expression: _v_chek" error on line 36 when loading it but from what I can tell , _v_chek is defined on line 10? The script is working in terms of its making the unit move the searchlight. But obviously this error is quite annoying. WHat am I doing wrong?
// nul = [this,100,3,"scan_1",true] execvm "AL_AI_scan\al_scan.sqf";
private ["_vik","_ai_scan","_alt","_ini_dir","_ini_poz","_alt","_rnd_fct","_delay","_v_chek","_fire_y","_v_chk"];
sleep 10;
if (!isServer) exitwith {};
_vik = _this select 0;
_alt = _this select 1;
_delay = _this select 2;
_v_chk = _this select 3;
_fire_y = _this select 4;
_ai_scan = gunner _vik;
_v_chek = missionNamespace getVariable _v_chk;
if (!isNil{_vik getVariable "activ"}) exitWith {};
_vik setVariable ["activ",true,true];
if (_delay < 1) exitWith {"I recommend using a higher delay than 1 sec"};
_ini_dir = getdir _ai_scan;
_ini_poz = getposASL _ai_scan;
if (_alt>0) then {_rnd_fct = 50} else {_rnd_fct=0};
if (_fire_y) then {_tur_lans = (_vik weaponsTurret [0] select 0);[_vik,_tur_lans,_v_chk] execvm "AL_AI_scan\start_fire.sqf"};
_obiect_comp = createSimpleObject ["A3\data_f\VolumeLight_searchLight.p3d",[0,0,0]];
_obiect_comp hideObjectGlobal true;
[[_vik,_obiect_comp],"AL_searchlight\al_search_light_effect.sqf"] remoteExec ["execvm",0,true];
_obiect_comp hideObjectGlobal false;
while {alive _ai_scan} do
{
_v_chek = missionNamespace getVariable _v_chk;
if (!_v_chek) then {
_ai_scan enableAI "move";
_ai_scan enableAI "target";
_ai_scan enableAI "autotarget";
waitUntil {_v_chek = missionNamespace getVariable _v_chk}; // Wait until _v_chek becomes true
_ai_scan disableAI "move";
_ai_scan disableAI "target";
_ai_scan disableAI "autotarget";
};
_angle = [(random 30),(random 30)*(-1)] call BIS_fnc_selectRandom;
_watchpos = _ini_poz getPos [20+(random 100),_ini_dir+_angle];
_watchpos set [2, (_watchpos select 2) + _alt + (random _rnd_fct)];
_ai_scan doWatch _watchpos;
sleep _delay + (random 3);
};
deleteVehicle _obiect_comp;
_ai_scan enableAI "move";
_ai_scan enableAI "target";
_ai_scan enableAI "autotarget";
link to demo scenario: https://steamcommunity.com/sharedfiles/filedetails/?id=1481699891
_v_chek is defined by reference to another variable. If that variable doesn't exist, then _v_chek will also not exist. Trace the logic backwards.
_v_chek = missionNamespace getVariable _v_chk; // looks for a global variable with the name defined in _v_chk
_v_chk = _this select 3; // looks for the fourth (zero-indexed) parameter passed to the function
[this, 100, 3, "scan_1", true] execVM "..."; // that parameter is "scan_1"```
So it's looking for a global variable named `scan_1`, which must be defined as a Boolean (true/false) before the script runs.
This is a bit of a clumsy implementation on the script's part. Firstly...use params, man :U
Secondly, a syntax exists for getVariable that can assume a default value for the variable if it doesn't exist. Using that syntax would save the missionmaker having to define the variable ahead of time.
I have this one in the init.sqf, I wondered if that's enough.
scan_1 = true; publicVariable "scan_1";
And then on the entity in the Editor it's called like this
nul = [this,5,3,"scan_1",true] execvm "AL_AI_scan\al_scan.sqf";
But would that mean that it's looking for the scan_1 parameters in the script sqf and not the init.sqf?
No, it means the script is being run before the variable is defined: https://community.bistudio.com/wiki/Initialisation_Order
Although the script has a 10-second sleep which should avoid that 🤔 but hey ho
However, the init.sqf thing is wrong in a different way. init.sqf runs on all machines, so the variable is defined on all machines, so publicVariable is not needed. And...init.sqf is run on all machines including JIP clients when they JIP. So if someone joins after the variable is set false to stop the script, their init.sqf will set it true again. Won't start the script again but it's dangerous.
I would suggest removing the pre-definition of scan_1 and just changing the script to use the other syntax of getVariable. Then you won't have to think about these problems at all.
_v_chek = missionNamespace getVariable [_v_chk, true];```
You can remove the null = from the start of your execVM calls btw. That's a workaround for an old problem with the Editor which no longer exists.
I've been alt-tabbing like mayhem to understand it all ... But it's slowly getting there.
The getVariable pre-definition is mentioned twice, but I guess it's only needed in the while {alive _ai_scan} do part of the script? Because the first one is just defining it, and then the second one is to actually set the parameters of the syntax?
And regarding the null = It would then just become
execvm "AL_AI_scan\al_scan.sqf";
null = execVM "something.sqf" syntax was a workaround to long-term issue we had like 15 or so years. The null = part is not necessary right now, AFAIK
It's actually used 3 times. Once at the start and twice in the continuous loop.
The one at the start appears to be completely pointless as it's never referenced. I think you can remove it, but if you don't, fix it to avoid script errors.
The last two are actually important as they check the variable's true/false state to control the loop's behaviour. Those need to be kept and fixed.
Oh yea, you're right.. I missed the 3rd. I'll comment out the first one for now.. Then the other two should look like something like this? (added a comment on the first one, to understand if I was correct)
while {alive _ai_scan} do // Script will change something defined below
{
_v_chek = missionNamespace getVariable [_v_chk, true]; // Changes _v_chk to true
if (!_v_chek) then { // Script will then proceed with the following
_ai_scan enableAI "move";
_ai_scan enableAI "target";
_ai_scan enableAI "autotarget";
waitUntil {_v_chek = missionNamespace getVariable [_v_chk, true]}; // Wait until _v_chek becomes true then does the following below.
_ai_scan disableAI "move";
_ai_scan disableAI "target";
_ai_scan disableAI "autotarget";
};
_angle = [(random 30),(random 30)*(-1)] call BIS_fnc_selectRandom;
_watchpos = _ini_poz getPos [20+(random 100),_ini_dir+_angle];
_watchpos set [2, (_watchpos select 2) + _alt + (random _rnd_fct)];
_ai_scan doWatch _watchpos;
sleep _delay + (random 3);
};```
Then in the units init I would put this line to make it run
execvm "AL_AI_scan\al_scan.sqf";
No, you still need the array of parameters you're passing to the script, you just don't need null =
Is it as simple as just removing null = ?
[this,5,3,"scan_1",true] execvm "AL_AI_scan\al_scan.sqf";
I sometimes think WAY to hard about these :p
What about the scan_1 though? Because you mentioned that it won't be needed because we have defined it in the script itself now right?
This implementation is generally correct. Could be streamlined a bit more but eehhh
Your comment on what the getVariable does isn't right. It doesn't change _v_chk to true. It checks for a global variable with the name contained in _v_chk (which is scan_1). It returns either the value contained in scan_1, or true if the variable isn't defined.
You should no longer need to pre-define it in init.sqf. You do still need to include its name in the array of parameters. The script still monitors it, but it now assumes a default value if the variable doesn't exist yet. It still needs to know what name to look for in case you do define and change it later.
I'm not totally sure what the expected behaviour of the script is, so you might need to change the default value to false rather than true.
I think it's true to stop the scanner where it is, and false to let it move. So the default value you need depends on whether you want it to move by default, or be stopped by default.
The way the script is set up is that you can set up a trigger and if, for example in my mission, BLUFOR steps into that trigger, it'll stop the script. I assume it's for that purpose. The onActivation is set for
scan_1 = false; publicVariable "scan_1";
It has these parameters lined out in another .sqf
nul = [vehicle_name,watch_altitude,delay_scan,"control_variable",enable_random_fire] execvm "AL_AI_scan\al_scan.sqf";
vehicle_name - string, name of the vehicle you want to simulate sweep scan and or fire
watch_altitude - number, altitude in meters, useful if you want the AI to look upwards and simulate AAA scan or shooting,
set it to zero if you want to keep AI watch direction more or less horizontal
delay_scan - number, delay in seconds before AI selects another position/direction to watch at
"control_variable" - string, is the name of a boolean variable you link the object to, it has to be between quotes "" to work,
is a variable that allows you to control de script,
it needs to be defined when mission starts as true and before running the "AI Sector Scan script"
As long the variable is true the script will keep running, make it false via trigger or another script to stop the script
See the DEMO mission to see how you can use it
enable_random_fire - boolean, if is true AI will shoot while scanning the area, if is false AI will only scan the sector
Right, so I think its description of how the control variable operates is slightly wrong, because it doesn't match the actual code
It says setting the variable to false stops the script, but that's not the case; the loop's only exit condition is the scanner AI being dead
And that's defined with this right? It kinda literally says whats it's supposed to do.. if the gunner of the vic (searchlight in this case) is alive... just loop
while {alive _ai_scan} do
Yep. There's no other way of fully stopping the script.
I've figured out the way the toggle variable works. While it's true, the AI scans randomly. When it's false, the AI stops scanning and is allowed to turn and track targets.
So the comment is almost correct, setting it to false stops the AI from scanning. But it doesn't stop the script; if you set it to true again later, the loop is still running and will detect that and make the AI go back to scanning.
That's a reasonable design in itself, but it's not what the documentation says, and it's another reason not to define the variable in init.sqf (if someone JIPs while the AI is in shoot mode, their init.sqf will put it back into scan mode!)
Can i use onEachFrame on server side ?
I mean doesn't it require a graphical interface ?
Yes, use the event handler version though or CBAs version
Nice, thank you 🙂
I think for my purpose now it's fine (for now), the group is doing a base raid so once BLUFOR steps into the zone they'll kill every entity in it anyway. I think I understand now how it should work too 🙂
It all works now flawlessy, also on dedicated 😄 So thanks so much for the help.. I understand it more now 🙂
having trouble with playSound3D command on a hosted server if i execute this example via debug consol it is hearable for everyone but if i use a custom sound the sound only plays for the executing player
wiki example:
playSound3D ["A3\Sounds_F\sfx\blip1.wss", player, false, getPosASL player, 1, 1, 100];
my sound:
playSound3D [getMissionPath "sounds\test1.ogg", player, false, getPosASL player, 1, 1, 100];
That should work fine (source: I've done it)
i played the same sound with say3D and it worked without issues but playSound3D not
the problem with say3D is that the sound can hardly be heard as soon as you turn away from the sound source even though you are standing right next to it, idk if it is intended or a bug
The only reason (that I can think of) why playSound3D might not be audible for everyone with that example is if the clients somehow had different versions of the mission file, one with the sound and one without. But I don't know how that would happen and that would break say3D as well.
It should work perfectly with your code, and I've done exactly that myself many times without problems.
do you know why this issue with say3D happens? if i execute this code
[player, ["test1", 1000, 1, 0, 0]] remoteExec ["say3d", 0];
you can hear it from 100 meters away but as soon as you face away from the sound source its not hearable anymore and this also happens if you stand right next the source
I've never noticed that myself
please test it xD
playSound3D does have an optional parameter to operate in local-only mode, which would cause the behaviour you described. However, this parameter is off by default, and the code you posted doesn't turn it on. If the code you posted isn't the actual code, now's the time to mention it.
no it is the actual code and the sound is defined in description.ext and plays for the host but not for the client but im executing it via debug consol idk if this could be the issue but the same sound plays for everyone if played with say3D
Description.ext definition doesn't matter for playSound3D. It doesn't use config classes, it goes off the actual file path.
Debug console or not doesn't matter. playSound3D has global effect.
Any scripted that could help me create a game mode? I am not much on arma 3 scripting so I figured I would try to find someone that can actually script lol
Second scripting question of the day, after trying to figure it out for an hour .. I managed to find a script that downloads data from someone else, changed it to a HUD element and managed to change code so that it only adds the addAction if that player has a certain item in it's items.. But, it only checks on script load and nothing after that.. I tried while {true} do but obviously.. that just checks it every milisecond and overwhelms the server.. And I could not find any proper solutions online. This is the code:
T8L_fnc_addActionLaptop =
{
{
_items = items player;
if !( _x getVariable [ "T8L_pvar_dataDownloaded", false ] && ("ItemcTab" in _items)) then
{
_x addAction [ T8L_var_TLine05, { call T8L_fnc_ActionLaptop; }, [], 10, false, false ];
};
} forEach allUnits;
}
};```
Im guessing there is a better way then just doing while {true} do and then sleep for a minute.. ?
Not sure if another/better way is to do is the findIf paramater..
waitUntil { { alive _x } count [unit1, unit2, unit3] == 0 } // slow, always goes through all array elements
Depends what the methods are by which a player might acquire that item.
I don't think there's a general EH that fires whenever an item is changed in a unit's inventory.
https://community.bistudio.com/wiki/addAction
addAction and BIS_fnc_holdActionAdd support conditions - code that must return true for the action to display. You can add the action freely and let the condition decide when it's displayed.
They'll have it once they set up their inventory, they won't have it on server load/join. And maybe somebody else will pick it off their bodies in case they are downed to start the data transfer again. But in best case, they'll carry it with them the whole mission
In this case I think the addAction condition is best, because it'll only be evaluated if the unit is in front of you.
Ah, so if I set the radius to 2m or something, the item (the laptop) that gets the addAction will check within 2m if there is someone with that item?
I mean addActions are only considered for the cursorObject.
So you add the action to everyone, and then it's only doing at most one "classname" in items _target per frame.
I'll dive deeper into this at some point. I tried to convert this into something useful for me, but didn't have any luck. So maybe a break is needed..
player addAction ["Test Action","test_action.sqf",[],-1,false,true,"","((unitBackpack _this isKindof 'tfw_ilbe_a_gr') && ('tfw_rf3080Item' in (items _this + assignedItems _this)))"];
Obviously, this one check if the player has a backpack + an item in that.. and I'd only need 1.. but I kept getting errors :/
What kind of errors?
yea.. breaks help.
This is what I used. It calls this line for the action text: T8L_var_TLine05 = "Start Data Transfer"; THis is what I just used. and it just works flawlessy..
_x addAction [ T8L_var_TLine05, { call T8L_fnc_ActionLaptop; }, [], 10, false, false,"","('ItemcTab' in (items _this + assignedItems _this))"];
I think what I did was use && in between the call action and checking if the items is in the inventory... which obviously doesn't work.
can someone clarify the trigger interval for me?
quote BIKI: However, when trigger is attached to some object, the trigger will inherit the simulation frequency of the object it is attached to.
Does this mean interval setting is useless when attached to say a module from editor?
such as a show/hide module?
essentially i do not need my triggers checking every 0.5 seconds,and want to use many. so i want to put them on 5 seconds or so interval to play it safe performance wise
Not sure exactly but it means trigger wont do a check more frequently than your module does its simulation (probably rarely)
Btw attached means attachTo command
oh i totally misinterpereted that
some reason i thought of synced to
nice one
hello,
how do i make a custom song play for the player on the mission end screen, and instead of "Mission Completed" to show a custom text instead
song is in .ogg format in mission folder under "music"
https://community.bistudio.com/wiki/Arma_3:_Debriefing
https://community.bistudio.com/wiki/BIS_fnc_endMission
Define a custom debriefing in description.ext, and use BIS_fnc_endMission to activate it. Note the music parameter in BIS_fnc_endMission - you can turn off the default music and use playMusic to play your own.
Note the locality (Local Effect). You'll need to remoteExec the function to end the mission properly for all players.
so i set playmusic part to false to stop the default arma music?
how will put the custom song instead then?
so in the end trigger it will be:
[End1, true, true, false, false] call BIS_fnc_endMission;
playMusic "end1";
in description.txt:
class CfgMusic
{
tracks[] = {};
class end1
{
// display name
name = "ending";
// filename, volume, pitch
sound[] = { "\music\ending", db + 0, 1.0 };
};
is this correct?
[End1, true, true, false, false] call BIS_fnc_endMission; // no
["End1", true, true, false, false] call BIS_fnc_endMission; // yes
in description.txt:
description.ext
just making sure, avoids hair pulling situations 😄
oh yeah tell me about it
He's a lizzard, lizzards have no hair
a Dragon - I don't want him to steal muh gold
params ['_pos','_radius'];
private _array_roadListFiltered = [];
{
if ((typeName _x) isEqualTo 'OBJECT') then {
_bbox = boundingboxReal _x;
_bbox params ["_a","_b"];
_size = _a distance _b;
if (_size < 25) then {_array_roadListFiltered pushBack _x};
};
} forEach (_pos nearRoads _radius);
_array_roadListFiltered;
};
// usage
_array_roadSegments = [(position player),500] call TAG_fnc_filterJungleRoads;``` Where I should put this code, in init.sqf or? I don't understand what is usage
if you don't need it, don't use it
I don't want AI vehicles to use footpaths because they will get stuck in jungles, I need it, so where to put?
Might be best to post where you got it from 😄
to provide an explanation of the code
I took this code from forums.bohemia.net, hope it's not problem
you're most likely free to use the code, it'd just be good to post the link you got it from so that we can look at the explanation in the forum post
Title says it all. I want to reduce my Array of roads to only the bigger ones, not one of the tiny paths introduced in Tanoa. Anyone with ideas how to do this?
Third post
Ah, that code is just to get all the big/small roads, its not actually to limit AI or anything
is there a way to block AI vehicles from using footpaths?
im making a drone view to screen script and ive got it working but how do i make it so that the place its viewing is loaded as its not close to any player at the start of the mission so all that loads is terrain how do i force load any objects and buildings there without having a player in the area?
also including the buildings included in the map
im also using a invisible target as the target if that helps so the drone view is always going to be stationary
so im making a vehicle spawn script and want to add a cool down on it so people cant spam spawn and create chaos with it this is what ive got so far but i get an error in game when i do it so what am i doing wrong here?
this addAction ["Create Vehicle", {
private _veh = createVehicle ["55th_Aslung_pattern_fuel_olive", getMarkerPos "pad1",[],0,"None"];
},nil,1.5,true,true,"","true",10,false,"",""];
sleep 90;
Put code inside spawn, something like this
this spawn {params['_object']; _object addAction ["Create Vehicle", { private _veh = createVehicle ["55th_Aslung_pattern_fuel_olive", getMarkerPos "pad1",[],0,"None"]; },nil,1.5,true,true,"","true",10,false,"",""]; sleep 90;};
Hi @winter rose the other day you gave a script to hide editor placed markers for an specific side. I have a problem when i host the map on a dedicated server. I have mobile markers attached to vehicles using a script and those markers doesn't hide when players join the server. Is there anything i can do to hide them?
Interesting observation about REing a data structure to same client twice:
arr = []; f = {arr pushBack _this}; [1,2,3] remoteExecCall ["f", [player, player]];
```, then
```sqf
[arr, (arr select 0) isEqualRef (arr select 1)]
```=>`[[[1,2,3],[1,2,3]],true]`
engine doesn't copy it twice and properly passes same object into RE function twice
same with hash maps
same with remote client
initPlayerLocal.sqf may do
Yup, the hiding script is being executed on initPlayerLocal.sqf
I'll try with initPlayerServer
It doesn't work
@frosty barn #creators_recruiting
Perfect thank you
howdy i have started making a optre mission where each player is supposed to spawn in their own cryopod before dropping in a drop pod, i have done some digging and found that the best way to do this is through an event handler. i have made an attempt at it and since this is my first time actually scripting i am likely making errors and not knowing what i am doing wrong so im hoping that somebody here can help me in the right direction. My current code is this sqf scrub1 addMPEventHandler ["MPRespawn", { scrub1 moveInCargo pod1 }]; however its not working and im not sure what it is im doing wrong plan is that when a player respawns it moves them to their own cryopod, this is to eliminate people attempting to spawn in the same pod. Any help would be much appreciated
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
thank you i had no idea how to do that i have since edited my message
Where do you have this code?
i had it on the player itself, i tried it first with respawn instead of mprespawn but that didnt change it. do i need to put it in a SQF file
What is pod1? Same object that is always present on the map for players to spawn in?
If you want to have it as Init field in editor, try something like:
this addMPEventHandler ["Respawn", { params ["_unit", "_body"]; _unit moveInCargo pod1; }];
yes my apologies i should have specified. pod1 is the variable name for the cryopod which is always present, scrub1 is the variable name of the unit for that pod
Add my line to each player, change pod1 to other pods as needed
Can pods be occupied later? What if player respawns and there is already somebody in the pod?
this is why i was running it as an event handler so that each player has their own pod and they are the only ones capable of spawning in said pod
i could have used a module but i dont trust the people i play with to spawn one at a time
unfortunately that had no effect
What happened and what did you expect?
what i expected was to be teleported into the pod upon spawning, what happened was that i still spawned on the respawn marker
spawning the first time or respawning?
both
Respawn only handles next spawns
Where did you add this line to? Your playable unit init line?
In 3DEN or Zeus?
added it to the playable unit in the 3DEN editor
Try respawning and see if it works
i did same outcome
Change moveInCargo to moveInAny
Add logging inside Respawn code to see that it runs
diag_log str ["Respawn just ran!", _unit, pod1];
check RPT what it logs
I'm using DSA and the enemies appear in the form of a civilian, but a hostile one (Friendly units also fire at them), and I want to have an objective to survive, with the win condition being all the spooks are gone, but I can't use a simple civilian presence otherwise dead bodies would be counted, so I'm wondering if it's possible to check if a specific infantry role is present in a given area?
everytime i spawn it sends this in the ARMA.rpt "[""Respawn just ran!"",scrub1,pod1]"
Try more basic setup, change pod1 to some random car
and what adds these markers?
I am wondering, is there a way to spawn IR laser. Like the one on your gun, but spawn it and point it into the sky?
One way I can think is maybe spawning a civ unit with a laser and forcing it to look up and hiding it. But I am prettu sure, hiding the model will hide the laser
drawLaser
Thanks!
Altho I am having some isses, any ideas why this doesnt seem to work?
addMissionEventHandler ["Draw3D", {
drawLaser [
getpos mfbeacon1,
[0,0,1],
[1000, 0, 0], [],
5,
20,
-1,
false
];
}];
Doesn't work how
as in nothing happens
Are you sure? drawLaser takes a positionASL
I mean the vector should be going up and it should be a thick ass laser coming from the mfbeacon1 object, I would see it
Is that actually REMOTE exec? or local exec?
Target is player... so its not remote.. So all it is is a fancy overcomplicated call
Yeah it doesn't serialize/deserialize the variable to execute it locally
super sure?
I can't see how it would know
I tried both, local player and remote player
remote player also got it twice and it was same array and hashmap
So it is reliable
What if you locally set into the first array, so modify it.
Then the second remoteExec being received creates a new copy?
remoteExec doesn't have any history about what it created in the past, that doesn't make sense
It is new copy on each RE receiving, but engine unserializes it only once, then feeds into REd function however many times that target was specified
Nvm, figured it out, kinda it was asl indeed
Nothing wrong or broken here, it was just interesting to know that unserialized data is built just once
a = [1,2,3]; arr = []; f = {arr pushBack _this}; a remoteExecCall ["f", [player, player]];
```=>
```sqf
[arr, (arr select 0) isEqualRef (arr select 1), arr select 0 isEqualRef a, arr select 1 isEqualRef a]
```=>
`[[[1,2,3],[1,2,3]],true,false,false]`
All good, I was just checking if deserealized data was built once more if you RE it to same client by listing their entity twice. It doesn't and its good.
Oh so you are doing ONE remoteExec. And one remoteExec passes only one variable. yeah
You said "REing a data structure to same client twice" But you only do it once
Yeah I worded it wrongly. Recently found out that providing two entities of same client would also execute RE function twice.
Was looking for a way to prevent second execution and thankfully data is the same and isEqualRef check solves it
Was using crew _vehicle as RE targets and there is no way to only select unique RE targets from client side
I have ran into a wall I can not overcome. I am trying to make a script to attach one object to another object's selection and follow the selection's movement. Basically the attachto function but for a selection. Is there a way to do it? I could not figure out a way to track pitch, roll, and yaw.
doesnt the memPoint in attachto do that?
I wish. If it was for only attaching to one specific object, sure, but not for attaching it to any object. I could not find a way to find the mempoint for a random object I want to attach to short of getselectionbones and that is still in dev build. I also question how useful it will be since the attachto biwiki says:
That's specific to triggers. If you're using anything other than a trigger, that note doesn't apply
im not expert in attachTo but the example 5 shows drill on the hand
ok so it will work with getselectionbones then.
correct, but it does so by explicitly attaching drill to hand. What if it ends up as drill on chest, or drill on leg? How do I do it when the mempoint is initially an unknown variable?
That's not an attachTo problem, it's a problem with the design that has led to the selection being completely unknown
Attaching objects to an arbitrary selection with rotation following is completely possible: _object attachTo [_otherObject, [0,0,0], _selectionName, true];
The problem you seem to have is with finding the name of the selection you want to use. The solution to that depends hugely on what exactly the script is meant to do.
How do I find out if player is currently aiming down weapon sights?
cameraView
cameraView == "GUNNER"
theres still not a getter for if the gun is able to be fired on the next fire command
Thnak you. You made me realize I was being a massive idiot and missed the obvious answer staring me in the face since day 1.
The new arma update sees double damage to the one unit. Is there a way to disable this?
"HandleDamage" can trigger "twice" per damage event. Once for direct damage, once for indirect damage (explosive damage). This can happen even in the same frame, but is unlikely.
^^ here is the wiki on the new eventhandler: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage
I run escape servers that see players unconscious but not dead. The double deaths bug out the player & they get revived into a locked camera view. I tried entering this code when they are revived, but it didnt work:
// Start Arma3 player bugged fix
private _display = findDisplay 46;
if (!isNull _display) then {
(_display) displayRemoveAllEventHandlers ["KeyDown", "MouseMoving", "mouseZChanged"];
}
_unit switchCamera "Internal";
[] _unit call ATHSC_fnc_exit;
// End Arma3 player bugged fix
handleDamage is not a new event handler and it firing multiple times per damage event isn't new
Hey! I'm working on a custom background scene, but I can't get the camera to work! It spawns its own player unit in the sky instead of mine in a hidden place, and the view doesn't switch to the camera. Any common mistakes I might be making?
here's my init.sqf
player enableSimulation false;
player hideObject true;
enableEnvironment false;
showCinemaBorder true;
_camera = "camera" camCreate getPosATL campos;
_camera cameraEffect ["internal", "back"];
_tar=selectRandom [phen,airfield,sovi];
_fov=0.7;
if (_tar==phen) then {_fov=selectRandom [0.25];};
_camera camPrepareTarget (_tar);
_camera camPrepareFOV _fov;
_camera camCommitPrepared 5;
_camera spawn {_camera=_this;
while {sleep 20; true;} do {
_tar=selectRandom [phen,airfield,sovi];
_fov=0.7;
if (_tar==phen) then {_fov=selectRandom [0.25,0.25,0.25,0.7];};
_camera camPrepareTarget (_tar);
_camera camPrepareFOV _fov;
_camera camCommitPrepared 5;
};
};
Not sure if this is more an editor or scripting Q: But what im trying to do is something a little dynamic. drawing a blank on a dynamic way to achieve it. I want to have a small regroup or rally point area, so a trigger. and in it,there will be a group(could be any) and i need the next group to enter it,all of them to join group of the first group.
is this possible? without waypoints or variable names?
This is not a new behaviour, been like that since very first alpha
variable names can work,its just theres gona be 10 or more groups
Engine does two fake-y HandleDamage fires, one for bleeding, another for some head damage that it doesn't apply unless its a fatal hit
You can skip these out of your calculations with _context > 2 check
new parameter in 2.16
This line about direct and indirect damage is also false and needs to be removed from the wiki
🤓
"HandleDamage" is persistent. If you add it to the player object, it will continue to exist after player respawned.
```This is true for all entity event handlers
does "break;" kill all loops everywhere or just any loop it's inside of
of course its just only the loop it is inside of
The mission sqm doesn't get loaded 😭
got it!
Those markers are added by a script executed in the init of the vehicle/helicopter
Sorry, i add the markers in the editor and the script executed in the init of the vehicle/heli relocate and attach them to the vehicle
then you need to use these markers's names as well
that or use allMarkers
allMapMarkers
if its in a nested loop, will it break just the lowest one, or every one its nested inside of?
It'll break the inside one.
_posFound = false;
_randomPos = [];
for "_i" from 1 to 6 do{
while {!_posFound} do
{
_randomPos = [_first_objective,100,300,0,2] call BIS_fnc_findSafePos;
if (_randomPos = [0,0,0]) then
{
break
} else {
_posFound = true;
};
};
_waypoint = _grp addWaypoint [_randomPos, 1];
_waypoint setWayPointType "SAD";
};
trying to get this to find random waypoints near a position for boats to attack and if it can't find one just break out of it
but i'm getting "error missing '('" on the if statement line
Yup i used those names and the hiding script works perfectly in the game-hosted multiplayer an singleplayer, but not in dedicated server
thank you, i forget that I have to use that
which makes me feel even dumber because in other languages it wouldve been "==" so i was wrong twice lol
nods
repeatable or just once?
Also you're probably doing it wrong with findSafePos. That thing does something like 1000 attempts itself, so wrapping it like that is... odd.
Actually the while just doesn't do anything?
repeatable. the idea: 10 squads start the scenario. over time they will dwindle down from 8 strong to X strong. i want to essentially,at any point ,merge two or three squads together. i would like to do this in a particular area such as a custom retreat point to
It will do only once because _posFound is true after 1st and you don't change that back to false before next
standby
if you can can create a solution youll have saved me tonnes of time, was about to give up on this. each group also has a variable name and same callsign,id need to keep at least one of the groups variable names as all groups in OP have wp's and events based on name happen
// --------------------
// Type: None
// Activation: Anybody
// Activation Type: Present
// Repeatable: True
// Server Only: True
// --------------------
// Condition
private _units = thisList select {_x isKindOf "CAManBase"};
private _groups = [];
_units apply {_groups pushBackUnique (group _x)};
count _groups >= 2;
// Activation
private _units = thisList select {_x isKindOf "CAManBase"};
private _groups = [];
_units apply {_groups pushBackUnique (group _x)};
if (count _groups < 2) exitWith {false};
diag_log format ["Trigger %1:: More than 2 groups detected... merging...", thisTrigger];
while {count _groups > 1} do {
private _parent = _groups select 0;
private _toMerge = _groups select (count _groups - 1);
diag_log format ["Trigger %3:: Group %1 merged to %2", _toMerge, _parent, thisTrigger];
units _toMerge join _parent;
_groups = _groups - [_toMerge];
};
have fun
it does it more than once because of the for loop, I tested it and it gave me 4/6 waypoints
much appreciated mate
gona fire it up
server only? false is ok? its SP
doesn't matter then. i wrote it for MP
you were kinda correct though, it does loop through more than once, but because i dont swap it back to false it doesnt check for new positions, so they're all in the exact same spot, good call out ty
@bleak mural there actually might be an error with this due to how I did my index selections and removal (if multiple groups enter at the same time during the interval phase). gonna work that out real quick and update it
@bleak mural updated
simply flawless
it works perfectly.
my idea for a use for it in a SP mission was related to giving player pilots more tasks...if groups out in the field get dwindled down,theyll pick up weakened squads,exfil back to a FOB,then go get another diminished squad,do same,and get em to full strength with your code here, then fly em back to the front. Thanks so much
try to delay it a bit before with e.g
waitUntil { sleep 0.1; not isNull player };
Thank you lou! ill try it just now
does anyone know?
vehicles drive where they can
It worked fine, thank you again lou!
how can they? AI vehicles use the footpaths in the jungle, vehicles often end up there deep in the jungle and get stuck. their suffering should be alleviated
{
_x setDamage 1
} forEach (vehicles inAreaArray jungle)
no more suffering
but to answer seriously, which terrain are you using? footpaths should use the "trail" (iirc) road type. if they don't the vehicles will use them too
if you're using a vanilla map you can report it in #arma3_feedback_tracker and it might get fixed
It is normal behaviour on Tanoa, I guess because the jungle tracks are marked as TRACK rather than TRAIL.
is there a script that can remove all Nades from the AI?
even ones from mods?
nvm found it lol
Is there a known workaround for GetIn/GetOut event handlers not firing for seat changes? I have script that gives the driver of a vehicle a couple actions, but I can't figure out how to add them from a seat change vs. getting in the vehicle normally
you could always add the actions to every player and then make the show condition about being in the driver's seat of a vehicle
Ty for breaking my overthinking cycle lol
i used the moveinany part of it and it worked its just not working as an event handler ```sqf
scrub1 moveInAny pod1;
Is there any way to make a vehicle invisible but still move?
Yeah click on it in editor or in game and uncheck visible
post your final EH code
thx mate.
I feel stupid because it was so simple :/
here it is sqf scrub1 addEventHandler ["Respawn", { scrub1 moveInAny pod1;}]; I also want to not that i also ran the event handler seperately and it worked ```sqf
scrub1 addEventHandler ["Respawn", { scrub1 sideChat "respawned";}];
maybe im just thick and im missing something
You can't use scrub1 inside event handler, I posted you a version with params and _unit
Because it still points to old dead unit at this point during respawn
so this ```sqf
_unit addEventHandler ["Respawn", { _unit moveInAny pod1;}];
No, use the code I gave you
_unit is undefined on yours
you need to get it from EH with params first
this addMPEventHandler ["Respawn", { params ["_unit", "_body"]; _unit moveInAny pod1; }];
unfortunately same as before and im starting to think that while it should work in theory that it just wont work ive been at this for three days now to no avail, i thank you for trying to help me i will continue to research and make attempts at it but it may be frivilous.
Try having it in most simple setup
New mission, one respawning player, some vehicle as pod1
see if it works there
will do
Vanilla assets too
ok that worked so perhaps its the mods?
or the mission maybe?
well its not the mods
Other scripts messing something up maybe
Try your mission but haave some vanilla vehicle for pod1
didnt work in that mission, fortunately it was a mission made for the purpose of testing the spawn thing
it was just a vr with a spawn point and somecryobays
Well... createVehicle works... http://i.imgur.com/U9N1jTA.png
maybe it was my previous event handler messing it up
found the issue
it was the humble respawn timer, appearently it only works when there is no delay
anyways thank you for helping me, just so you know you are a wonderful human being
Hello, can anyone help me disable curator features for a specific curator through sqf? I'm trying to enable Zeus for a platoon leader so they can order units inside vehicles and I need them to not be able to change unit skill or health.
This is my code so far:
[alpha_1_actual_curator, "object", ["UnitPos", "Exec"]] call BIS_fnc_setCuratorAttributes; //set attributes
alpha_1_actual_curator addCuratorEditingArea [1, [0,0,0], 0];
removeAllCuratorAddons alpha_1_actual_curator;
while {true} do {
_cameraLimit = ((getPos curatorDrone)#2)+5;
alpha_1_actual_curator addCuratorCameraArea [1, getPos curatorDrone, 10];
alpha_1_actual_curator setCuratorCameraAreaCeiling _cameraLimit;
sleep 1;
};
I plan to add handling for designating a drone and change the while to while the unit is alive, but first I want to check if using Zeus for this is possible.
@meager granite Thanks for the info. I think you are right, the new _context parameter has broken co10 Escape game mode, causing multiple deaths.
Just wondering how to turn _context off so it defaults to handling damage like it was before update 2.16?
Changelog states: Tweaked: "HandleDamage" event was extended with additional context.
I tried adding this into initplayerlocal.sqf but it didnt work:
player addEventHandler ["HandleDamage", {
private _context = 0;
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
if (_context > 0) exitWith {};
}];
This is what each value in _context relates to:
context:
0 : TotalDamage - total damage adjusted before iteration through hitpoints
1 : HitPoint - some hit point processed during iteration
2 : LastHitPoint - the last hitpoint from iteration is processed
3 : FakeHeadHit - head hit that is added/adjusted
4 : TotalDamageBeforeBleeding - total damage is adjusted before calculating bleeding
Love your work on KOH & wasteland. I have had hours of fun playing those.
It shouldn't have broken anything, nothing changed regarding the damage itself, there is just new context parameter in the EH
As for fixing it, you'll need to find HandleDamage in mission itself and make it ignore EH calls with _context > 2
@meager granite ok thanks. In the escape game mode you go unconscious after being hit and the player goes into a 3rd person camera mode. After the update you get two kill messages and get stuck in the camera view after a revive 😞
Update shouldn't have changed anything about HandleDamage 🤔
object create_vehicle(std::string type_, vector3 pos_, std::vector<marker> markers_ = {}, float placement_ = 0.0f, std::string special_ = "NONE")
{
game_value_array<5> args({
game_value_string(type_),
game_value_vector3(pos_),
game_value_array_dynamic<marker, game_value_string>(markers_),
game_value_number(placement_),
game_value_string(special_)
});
return std::make_shared<object_ptr>(host::functions.invoke_raw_unary(__sqf::unary__createvehicle__array__ret__object, args));
}
C++11/14 ftw
What do I need to enter into my server's difficulty settings to disable the shift+click marker on the map. Trying to teach my guys legit land nav and be sure they arent cheating lol
How can i show a german Ü in the strings of a script?
okey thanks
Wishing for something like setNoNil to skip setting the value if its nil:
hs = createHashMap;
private _value = player getVariable "var";
if(!isNil"_value") then {
hs set ["var", _value];
};
```=>
```sqf
hs = createHashMap;
hs setNoNil ["var", player getVariable "var"];
@meager granite thanks so much for your help. I added an ignore above _context 2 in the HandleDamage event handler & everything seems to be back to normal.
if (_context > 2) exitWith {};
🍺
Hello, I am wondering if there's any way to fetch the "eyePos" of an elevated commander turret (Strider/Fennek) for use in scripts.
why not?
does eyePos commander _theTank work?
Unfortunately it does not.
That seems to just register the eyepos of the actual commander unit inside the vehicle as opposed to the actual turret "eye"
oh, then config browsing will tell you
Alright, thank you.
// This worked for my purposes
(vehicle player) modelToWorld (vehicle player selectionPosition "commander_turret_hit")
I'm trying to make a static detonator for some explosives, and am having issues.
/*Code for creation of "TNTarray". Done with "Game Logic" module in 3DEN. This, as far as I can tell works.*/
private _TNTarray = ["tnt1", "tnt2", "tnt3", "tnt4", "tnt5", "tnt6", "tnt7", "tnt8", "tnt9", "tnt10", "tnt11", "tnt12"];
/*Code for the detonator. Placed in the items init. This throws the error "Missing ;" for some reason I can't seem to spot.*/
this addAction ["Detonate TNT", {setDamage 1} forEach _TNTarray];
Thanks for any help!
setDamage requires an object to apply the damage to.
this addAction ["Detonate TNT", {{_x setDamage 1} forEach _TNTarray}];
Edit: added code for forEach
yes, this addAction code is an entirely different script, so it doesn't know about _TNTarray
wait is the "_x" serving as a sort of proxy object here? then the "forEach" command defines the x?
_x is a magic variable that corresponds to the object that is currently being handled by the forEach.
https://community.bistudio.com/wiki/forEach This explains it a million times better than I ever could.
for some reason the "addAction" doesn't seem to work, it isn't adding any action I can perform on the object
Make sure the entire forEach is enclosed by { }
Then I haven't a clue, unfortunately.
Make sure you read what Lou said as well, he's probably forgotten more about SQF than I know.
I have a suspicion it's the object itself being weird, trying with one I know has worked with "addAction" before
yeah it is lol, guess I'll have to find another detonator prop
it's now throwing an error saying _TNTarray is an undefined variable, I suppose that indicates that the array hasn't been made successfully?
Read this.
sadly I don't understand what that means lol, I'm not very good at this stuff 😅
Understandable, basically because you made the _TNTarray in a separate location and prefixed it with private, that array does not exist outside of that file/module/whatever.
I suppose I could just define every single explosive like this?
forEach "TNT1, TNT2, TNT3, etc.";
You'd have to format it as an array.
forEach ["tnt1", "tnt2", "tnt3", "tnt4", "tnt5", "tnt6", "tnt7", "tnt8", "tnt9", "tnt10", "tnt11", "tnt12"];
ooh yess thank you, I forgot how to 😅
No worries! I wish you good luck on your journey.
Although the action code is a separate scope to the script that created the action, addAction supports arguments - information passed from the creating scope into the code scope
https://community.bistudio.com/wiki/addAction
private _tntArray = [...];
this addAction [
"Detonate TNT",
{
params ["_target", "_caller", "_actionId", "_arguments"];
{ _x setDamage 1 } forEach _arguments;
},
_tntArray
];```
You could also make your array a global variable (no _ prefix), which can be accessed by any script on the machine where it was created
0 setOvercast selectRandom [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
isnt this syntax correct?
entering it via mission init
no error,just isnt picking a random overcast setting
oh i got it nvmind
[selectRandom [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]] call BIS_fnc_setOvercast;
Is there a Way on How i can get my Ai to go to the waypoint exact location without like stoping a little bit away or something like that. Like when there is a car i front of him he keeps distance even when he is in careless mode Can i script it somehow to make hem go realy close op to it?
vehicles consider their wp complete when within a set distance. up to 50 meters though they usually get close. helo is 250 meters
if you want,you can give a wp to where u want vehicle to go,then another final wp right next to it
that way it "should" go to exactly where the 2nd last wp was
Hello! Question to sqf experts. Why does this code return false? Aren't _a and _b referencing the same object? Or is something different understood in sqf by "reference"? (I'm coming from C# background where similar code would return true)
_a = zeus_indfor;
_b = missionNamespace getVariable "zeus_indfor";
hint(str(_a isEqualRef _b));
What are all the possible damage types for ace_medical_fnc_addDamageToUnit?
Why not just random 1?
or (round random 10) * 0.1 😄
I'm not certain exactly how isEqualRef is meant to work, it's a bit more enginetechnical than I understand, but your usecase is something that would usually be handled with isEqualTo. That might be something to consider instead.
0 and 1 are less likely.
(floor random 11) * 0.1 nearly works except it can roll 11 occasionally (until 2.18 hopefully)
Even simpler version: _a = player; _b = _a; _a isEqualRef _b; also returns false
yeah isEqualTo works, I just find it a bit peculiar
Most things in SQF are peculiar :P
haha true
is there an equivalent to bis_fnc_exporteditorpreviews for weapons?
isEqualRef is only relevant for arrays and hashmaps, I guess.
Ok I'm about to go insane, what the hell is happening? This code works fine in SP/Local MP:
fn_GetTellArrayLocal = {
params ["_receiver", "_fileName", "_subtitle"];
_array = [_receiver, "Say", "radio", ["1", {}, _subtitle, [_fileName]], "DIRECT"];
_array
};
zeus_indfor kbAddTopic ["Say", "radio.bikb"];
_tellSub = "Cut the bullshit, Petrovich. You know exactly why we're here.";
_tellArr = [Petrovich, "\rs\petro_j2_real.ogg", _tellSub] call fn_GetTellArrayLocal;
zeus_indfor kbTell _tellArr;
However, on Dedicated Server it only works if zeus_indfor is an AI. It does **not **work if zeus_indfor is a player 😭
This code returns true so the player has the topic:
hint(str(zeus_indfor kbHasTopic "Say"));
Do I need some special magic to call kbTell on players on DS? Players do speak in local MP.
Hi, i have a question ? how can i know the damage that will be applied in the event "HandleDamage" ? Because i tried to put
this addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
if ((damage _unit) >= 0.9) then
{
hint "Avoided !";
0
};
}];
but it's not working, the unit can still die, i'm not sure if the (damage _unit) is the damage before or after but i think it's before since it's not working. now the "_damage" parameter of this event seems to give a value according to all hitpoints so i'm not sure what i should do with that one.
Something like this myb:
this addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
hintSilent format ["DMG: %1 \n Source: %2 \n Instigator: %3", _damage,_source,_instigator];
if(_damage > 0.1) then {
systemChat format ["disableing damage on unit."];
_damage = 0;
};
}];
Yeah i made something really similar to you so thank you because it's working
this addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
private _damage_to_deal = _damage;
if (_damage >= 0.95) then {
_can_pass = false;
_damage_to_deal = 0.99;
};
_damage_to_deal;
}];
but it's just that except the "hitHead" and "hitBody" on 1, the rest won't kill the unit but strangely, when there is a hit on "hitAbdomen" it seems to change the "hitBody" too so i don't really know. Btw atm i'm using the damage parameter no matter of what has been hit, it seems to work perfectly.
So what is your goal here to disable the damage or what ?
the goal at the beginning was to disable the damage except for big one like if it is lethal on one shot for example
but since i'm not sure what could lead to that, i will keep disabling damage
Then this will work:
this addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
if(_damage < 0.9) then {
_damage = 0;
};
_damage
}];
i will try to play around with that event and see what i cando
ah yeah i will do something like that then but i will bypass the "arm" and the "legs" since that will disable all damage under 0.9, btw thank you for your help 😄
Are you Using ace mod?
What are all the possible damage types for ace_medical_fnc_addDamageToUnit?
no why ?
https://github.com/acemod/ACE3/blob/master/addons/medical_damage/ACE_Medical_Injuries.hpp
Scroll down you will see DMG types
Just for if legion example doesn't work. Because ace uses its own damage Handling and you need to do that differently
And usually ppl doesn't tell are they using ace or not
are you not able to assign variables in switch cases?
_damageLevel = "light";
switch _damageLevel do {
case "light": { //0.3
_spot = "medical_spot_1";
_min = 0.0;
_mid = 0.3;
_max = 0.6;
};
case "medium": {//0.5
_spot = "medical_spot_2";
_min = 0.1;
_mid = 0.5;
_max = 0.7;
};
case "heavy": {//0.7
_spot = "medical_spot_3";
_min = 0.3;
_mid = 0.7;
_max = 0.9;
};
case "random": {//0.5
_spot = "medical_spot_4";
_min = 0.0;
_mid = 0.5;
_max = 0.9;
};
};
in this case, _min, _mid, and _max never changes.
I have to assign the switch to a variable and add a return to get any information out.
_damageLevel = "light";
_info = switch _damageLevel do {
case "light": { //0.3
_spot = "medical_spot_1";
_min = 0.0;
_mid = 0.3;
_max = 0.6;
[_spot, _min, _mid, _max];
};
case "medium": {//0.5
_spot = "medical_spot_2";
_min = 0.1;
_mid = 0.5;
_max = 0.7;
};
case "heavy": {//0.7
_spot = "medical_spot_3";
_min = 0.3;
_mid = 0.7;
_max = 0.9;
};
case "random": {//0.5
_spot = "medical_spot_4";
_min = 0.0;
_mid = 0.5;
_max = 0.9;
};
};
_info
like so
(only tested for light)
Hi guys, im using the incontinentia's undercover script. I dont know if anyone is familiar with it. Im tryng to figure out if there is a function to make AI spawned by, zeus or using a recruit module like SpyderAddons one go undercover too
You can change variables, but any variable that was created in the switch case will be destroyed when the case ends. If you create the variables first, then modify them in the switch case, they'll persist.
It's how scopes and sub-scopes work in SQF: https://community.bistudio.com/wiki/Variables#Scopes
You CAN create variables in If statements, though, right?
You can create them but they'll be destroyed when the scope ends
(note: all this only applies to local variables, global variables persist regardless)
this would probably be better as a hashmap anyways
idek what a hashmap is
The only thing I might know is linear look up times from a meme I saw years ago
eh don't worry about it then. its just a key value pair and does really well with stuff like this, especially when you start getting lots of elements
Hashmaps are really good for saving performance with big data sets, but when you have four (4) cases in your switch, it really doesn't matter
private _myvar = 123;
if (true) then {
// new scope
private _yeahyeahyeah = 4567;
_myvar = 343434343434;
};
systemChat str _myvar; // prints 343434343434
systemChat str _yeahyeahyeah; // doesn't print as inner scope killed _yeahyeahyeah when it finished
Hi, i have a problem. I want to loop an alarm sound on a trigger when a player is detected by ai. But it ends before it plays (it starts up like a air raid siren) does any one know how to set it up so it plays the full thing and repeats it?
Yeah, this makes sense now that I think about it. My brain decided it wasn't gonna work.
what do you have so far so I know what commands you want to use
Well, a trigger and the base alarm sound under the effect tab. It's set to if blufor detected by opfor. Nothing more
In super basic functionality as you haven't given much more info:
/*
Type: None
Activation: Blufor
Activation Type: Present
Repeatable: True
Server Only: False
*/
// Condition
private _alarmSound = missionNamespace getVariable ["LucoAlarmSound", objNull];
this && isNull _alarmSound
// Activation
LucoAlarmSound = playSound "alarm";
G, thanks
For the animated briefing, which file should the timeline code be ran?
https://community.bistudio.com/wiki/Arma_3:_Animated_Briefing
private _timeline = [
[
0, {
[markerSize "start", markerPos "start", 0] spawn BIS_fnc_zoomOnArea;
}
],
[
5, {
[markerSize "adv_1", markerPos "adv_1", 5] spawn BIS_fnc_zoomOnArea;
}
]
];
[_timeline, 0, nil, allMapMarkers, "start"] spawn BIS_fnc_animatedBriefing;
// timeline, index, hide, show, end, code
waitUntil {
!(missionNamespace getVariable ["BIS_fnc_eventTimeline_playing", true]);
};
Is this okay? I keep getting a params error in the file
Is there a way to check if a unit is a "drone" or "drone unit"?
I am working on a script that triggers on the initialization of any unit and it seems to even affect units inside drones which it shouldn't.
I have no clue about drones, but maybe check if the unit is "inside" of a vehicle that is a drone
but tbh I don't know how drones work
whats the error?
I would have to get the classname of every possible drone for that, no? :(
you could possibly check for the existance of a config property "uavCameraDriverDir" or "uavCameraDriverPos"
I need the script to work regardless of what mod the drone is from, hence why that'd be problematic.
Ah, will try that, thanks.
getNumber (configOf _uav >> "isUAV") == 1 to detect if it is an UAV
getText (configOf _unit >> "simulation") == "UAVPilot" to detect if it is an UAV Pilot
even better
probably best solution
SQF wizards reside in this chat.
uhh
Not sure I'd call em that.
Just googled it, Jesus, apologies.
LMAOOO
It errors on the BIS_fnc_animatedBriefing file, gives me param Errors
[
[ "_timeline", [], [ [] ] ],
[ >
0:31:23 Error position: <params
[
[ "_timeline", [], [ [] ] ],
[ >
0:31:23 Error Params: Type String, expected Array
0:31:23 File A3\Functions_F_Tacops\Systems\fn_animatedBriefing.sqf, line 22
lol i missed it
Moment you said "Not sure I'd call em that" my brain went "I feel like I am missing something"
2nd one specifically! Seems to work, will start experimenting more, once again thank you 
so, there is actually an error in the documentation of that function which I have just found. Its missing the music parameter which expects a string
I thought so as well!!! But i wasnt too sure
you actually need:
[<2DArray>, <number>, <string>, <array>, <array>, <string>, <bool>, <code>] spawn BIS_fnc_animatedBriefing
yeeeea
I'll change the wiki page
👍 ty man, just wasnt too sure if it was a me issue or a general issue lolz
For anyone who wants to know, executing
_this execVM "INC_undercover\Scripts\initUCR.sqf";
in any unit will start the undercover system for that unit, and if its part of the player group it will start to the whole group
Anyone knows how to use the garage feature of jeroen arsenal?
Anyone know how to change the background image on the main menu?
I've read this guide:
https://community.bistudio.com/wiki/Arma_3:_Main_Menu#Guidelines
However it only shows how to set up the spotlight and a scene in the backGround
hi all, im using some coding to spawn ai on a trigger set to Any player - present / call{this}
ive set the trigger zone, named the game logic "spwn1" where the ai is supposed to spawn, and used empty markers named "wypt1" and "wypt2" where they should travel after spawning but when i enter the trigger zone i get this warning: any clue?
call{_ambush1 = [getPos spwn1, east, (configfile >> "CfgGroups" >> "East" >> "VN_PAVN" >> "vn_o_group_men_nva_field")] call BIS_fnc_spawnGroup;
_wp1 = _ambush1 addWaypoint [position wypt1 , 0];
_wp2 = _ambush1 addWaypoint [position wypt2 , 0];
_wp2 setWayPointType "SAD";}
thank you! how do you define them?
You don't. See what I wrote
ill give it a try 🙂
call{_ambush1 = [getPos spwn1, east, (configfile >> "CfgGroups" >> "East" >> "VN_PAVN" >> "vn_o_group_men_nva_field")] call BIS_fnc_spawnGroup;
_wp1 = _ambush1 addWaypoint [markerPos "wypt1" , 0];
_wp2 = _ambush1 addWaypoint [markerPos "wypt2 ", 0];
_wp2 setWayPointType "SAD";}
you have extra space in second marker name
call{_ambush1 = [getPos spwn1, east, (configfile >> "CfgGroups" >> "East" >> "VN_PAVN" >> "vn_o_group_men_nva_field")] call BIS_fnc_spawnGroup;
_wp1 = _ambush1 addWaypoint [markerPos "wypt1" , 0];
_wp2 = _ambush1 addWaypoint [markerPos "wypt2", 0];
_wp2 setWayPointType "SAD";}
thanks!!
@cosmic lichen @meager granite now im getting a different error and they arent spawning...
hmmm
what is _pos ?
no clue... im using gePos for a game logic as the spawn location
Can I post the pastebin of a script of mine. I want to make sure if that script if run from a composition by the zeus all players get its effect
You're passing wrong stuff into what should be a position
anyway i can fix it? very new to scripting...
Post code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Will this script if run from the zeus locally as a composition take data about all players and try to run?
yeah i think youre right now its throwing a different error
did not think spawning AI on a trigger would be so challenging 😅
What do you want to do with this code ?
this script when placed by the game master locally as part of a composition it will check the player plane altitude and spawn several missiles at the altitude of players + 1000m and those missiles will track the player planes. My question is will this version of the script where the whole code block is encapsulated with the "forEach playableUnits" will run the commands for all players. without it last time it only took data locally from the game master about himself and not about the other players. the deletevehicle p1 line is to delete the object that makes the is part of the composition and has the code in it in order to save power on the server and to avoid junk
Is there a proper way to calculate the elevation of an artillery turret for a given target ?
try this your code in that pastebin was all over.
0 spawn {
private _players = allPlayers - entities "HeadlessClient_F";
{
if(isnull objectParent _x) then {continue;};
private _veh = vehicle _x;
if(_veh isKindOf "Air" && (side _x == west)) then {
for "_i" from 0 to 4 do {
private _zAxis = (getposATL _veh) select 2;
if(_zAxis > 200) then {
private _pos = _veh getRelPos [900,180];
private _newPos =_pos vectorAdd [0,0,_zAxis+1000];
private _missileDir = _newPos vectorFromTo getposATL _veh;
private _missile = createVehicle ["ammo_Missile_rim162", _newpos, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [_missileDir, [0,0,-1]];
_missile setMissileTarget _veh;
sleep 4;
};
};
};
}foreach _players;
};
deletevehicle p1;
Myb you could take a look here
https://github.com/Mankore/A3_Artillery_Calculator_RHS
I'll give it a look
Thank you 🙂
https://github.com/acemod/ACE3/blob/master/addons/artillerytables/functions/fnc_turretPFEH.sqf
Also here myb.
niiice
I have another question: if i use player setVariable ["test", [], true] the variable will be broadcasted on every computer. But if i use (player getVariable "test") pushBack 1; the variable will not be broadcasted. How do i share the variable ?
Broadcast it again after doing changes to it
(player getVariable "test") pushBack 1;
player setVariable ["test", player getVariable "test", true];
Or a cleaner version:
private _array = player getVariable "test";
_array pushBack 1;
_array pushBack 2;
_array pushBack 3;
player setVariable ["test", _array, true];
Keep in mind that two clients broadcasting same thing could overwrite each other, sort of a race condition
I was hoping there was a solution that would consume less resources on the network but i see i have no choice
Its a barebones tool, you can make your own solution
instead of broadcasting the whole thing, make a RE function that will have each client do the pushBack themselves to their own local array
It gets complicated with JIPs though
Still unless you're sending megabytes, its all a drop in the ocean
what is 0 spawn?
Will try the code
I also have one more code similar to this but instead of missiles spawning it's a bomb at player level can you help me make it optimal as well
to simulate the ace combat burst missiles
spawn needs a preceding parameter, even if you don't use it. 0 is just a cheap parameter.
ok
Could you please assist me to make this code here compact as well
https://pastebin.com/aCkTL12T
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
the way it works is that it checks for the players altitude. Under a certain altitude spawns a bomb in the plane killing the player and over a certain altitude it spawns it at a fixed altitude below the player
I will try myself first to see what I can do
What's the most correct way of detecting whether a particular object is a unit? Definition of unit for this purpose is "capable of crewing a vehicle".
_unit isKindOf "CAManBase"
Seriously?
if I put this in my code will it also aim at blufor AI?
iskindof has nothing to do with side so id say yes
I already check the side
animals derive from the "Man" class so you cant use that for iskindof hence "CAManBase" works better
Yeah, the engine surely isn't using config parentage for this stuff though.
Soon there will be a better way https://community.bistudio.com/wiki/getEntityInfo
maybe faster to get it from config though
Multiple SQF commands is usually slower than a single SQF command that does all its operations engineside
(And in this case, it's been tested #dev_rc_branch message )
Been trying to find a way to disable pre placed fuel pumps on the map, but haven't found any solutions I've managed to get to work.
Any suggestions on how to do it?
Hide them, replace with simple object?
ah nice didnt notice the alt syntax first
setFuelCargo 0 on the pumps seems to work fine though. I'm not sure what you tried that didn't work.
I know FuelCargo 0 works, but since I can't edit the pre placed ones,I can't do that to them.
Though hiding and replacing them with editable pumps could be a solution.
you can set fuel 0 on terrain fuel pumps
private _nearFuel = nearestTerrainObjects [_somePosition, ["FUELSTATION"],500,false];
{
_x setFuelCargo 0;
} forEach _nearFuel;```
If I understand correctly, that sets fuel of each fuel station within 500 meters to 0?
Each fuel station that is a terrain object. It doesn't do mission-placed objects.
I see. Well those aren't what I was going for, so this is perfect. Thanks.
what does this error mean? This is the code im trying to use
_randomElement = selectRandom [
"AidlPercMstpSnonWnonDnon_G01",
"AidlPercMstpSnonWnonDnon_G02",
"AidlPercMstpSnonWnonDnon_G03",
"AidlPercMstpSnonWnonDnon_G04",
"AidlPercMstpSnonWnonDnon_G05",
"AidlPercMstpSnonWnonDnon_G06",
"AidlPercMstpSnonWnonDnon_G0S",
"Acts_CivilIdle_1",
"Acts_CivilIdle_2",
"Acts_CivilListening_1",
"Acts_CivilListening_2",
"Acts_CivilStand_Default"
];
_randomTest = selectRandom [
"work1",
"work2",
"work3",
"work4",
"work5",
"work6",
];
hint _randomTest;
//_unit playMove _randomElement;
Invalid comma at last element there
Thanks Verox that does give me an approach to finding the offending scripts, not a profiler but I can try it and if the scripts are amenable I cut the problem down. Will put something together and see what the data says.
@grizzled cliff Would using lineIntersects be faster and have a smaller performance hit with this?
by the way how do I implement it in something like this
0 spawn {
private _players = allPlayers - entities "HeadlessClient_F" ;
{
if(isnull objectParent _x) then {continue;};
private _veh = vehicle _x;
if(_veh isKindOf "Air" && (side _x == west)) then {
for "_i" from 0 to 4 do {
private _zAxis = (getposATL _veh) select 2;
if(_zAxis > 200) then {
private _pos = _veh getRelPos [900,180];
private _newPos =_pos vectorAdd [0,0,_zAxis+1000];
private _missileDir = _newPos vectorFromTo getposATL _veh;
private _missile = createVehicle ["ammo_Missile_rim162", _newpos, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [_missileDir, [0,0,-1]];
_missile setMissileTarget _veh;
sleep 4;
};
};
};
}foreach _players;
};
deletevehicle p1;
cause I thought if I can make it work then the code will also kill blufor AI which will make it look cool
I thought at one point to use allunits
would it work?
cameras made by camcreate automatically replace the camera of all players correct? or is there a command like camswitch? cant find anything on biki and havent touched cameras in a long while
No, the camera view does not automatically switch to newly-created cameras. That would be terrible. Certainly not for all players, since camCreate is Local Effect.
Use cameraEffect or switchCamera to select cameras or objects to follow.

an external image? or an image from like a place in game?
are addaction commands of compositions global or local
add actions are always local. the bigger question, is when are you using the composition. compositions placed in editor will have their inits fired on every client (global), compositions placed in zeus are local to the zeus computer.
I encapsulated the commands in foreach _players
_players is allplayers - the headless clients
thats's not how locality works
It's to visually spawn a missile
that fires from the rear of a submarine so the players see it
and its started by an add action?
yes the zeus goes in said submarine and there's an action to fire the missile
the missile spawns off a prop in the back of the sub
anything that happens inside of the add action's script is local to the machine that pressed the action. so when you write your script that is called from it, you need to write it so that you take that into account.
this addAction ["<t color='#FF0000'>Launch Missile</t>", {
private _players = allPlayers - entities "HeadlessClient_F" ;
{
private _pos = launch modelToWorld [0, 2, 1.6];
private _missile = createVehicle ["ammo_Missile_Cruise_01", [0, 0, 0], [], 0, "none"];
if ((getPosASL launch) select 2 > 0) then
{
_missile setPosASL _pos;
};
if ((getPosASL launch) select 2 < 0) then{
_pos = getposASL launch;
_dist = abs (((getPosASL launch) select 2) - 0 );
_missile setPosASLW AGLtoASL (_pos vectorAdd [0, 0, _dist+ 4]);
};
_missile enableSimulation true;
_missile setVectorDirAndUp [[0, 0, 1], [1, 0, 0]];
}forEach _players;
}
]; ```
here's the action
this will create n number of missles where n = playercount. createVehicle is a global effect command so every client will see every one of them. You do this, stuff goes boom and your players are dead probably.
you don't have to iterate through players at all. just make one missile.
I tried without the foreach and none saw it
this action is in a composition zeus will spawn later in battle
sorry dont know what your trying to do
no one saw the missile? or no one saw the action?
no one saw the missile
what is launch?
the prop the missiles come from
so give me the whole story. you got a prop attached to the sub or something in the composition?
I'm trying to replicate so I can work it out for you
I have a submarine from hafm. I attached on it a prop. With the add action the missile comes from the prop if prop above water or from the surface of the water if prop is underwater
I didn't use the sub itself as refernce cause it's z position is broken
so i'm assuming in the init of the prop you are just assigning a global variable as itself? launch = this?
so the only thing in the prop is the variable name launch
in the submarine there's the add action I posted
so I don't have that mod, but I just used a invisible helipad instead above the sub. and it works fine for me.
// sub init
// variable name: sub
this addAction [
"<t color='#FF0000'>Launch Missile</t>",
{
private _pos = launch modelToWorld [0, 2, 1.6];
private _missile = createVehicle ["ammo_Missile_Cruise_01", [0, 0, 0], [], 0, "none"];
if ((getPosASL launch) select 2 > 0) then {
_missile setPosASL _pos;
};
if ((getPosASL launch) select 2 < 0) then {
_pos = getposASL launch;
_dist = abs (((getPosASL launch) select 2) - 0 );
_missile setPosASLW AGLtoASL (_pos vectorAdd [0, 0, _dist+ 4]);
};
_missile setVectorDirAndUp [[0, 0, 1], [1, 0, 0]];
}
];
// pad init
// variable name: launch
[this, sub] call BIS_fnc_attachtorelative;
keep in mind, the way you have it right now, only the zeus that placed down this sub will see the launch action
you also need zeusCompositionScriptLevel = 2; in your description.ext file btw
Is it possible to dynamically change the duration of a BIS_fnc_holdActionAdd and increase or decrease the duration while its being used?
Hi, i have a question ? Is it possible to ragdoll an AI ?
conditionProgress: String - (Optional, default "true") condition for the action to progress; if false is returned action progress is paused.
Special arguments passed to the code: _target, _caller, _actionId, _arguments
You can pause it
wait you mean by the launch action the missile flying or the action named "Launch Missile"
Can i pause/continue it from another sqf file which was executed from codeStart?
Through the power of variables, yes
// other script:
myHoldActionPause = false;
sleep 5;
myHoldActionPause = true;
// progress condition
{ myHoldActionPause }```
Thank you
the action named "launch missile" will only appear to the zeus who put it down in your current state. everything else works fine.
addForce
Oh ok i didn't know that, it's working perfectly but the unit is always set unconscious, is there a way to avoid that ?
no
oh ok thank you 😄
_unit setUnconscious true;
sleep 1;
_unit setUnconscious false;
Hi got a database running but still getting:
extDB3: Error with Database Connection
hi, see their doc
I play in Tanoa. There are footpaths there that are often deep in the jungles, although they are probably intended to be used only by foot soldiers, unfortunately the AI recognizes the footpaths as a road and therefore uses them. Is there a possibility that these paths can be deleted using scripts?
we don't do mod / dll support
eventually try in #arma3_troubleshooting, but that's about it
I have a question will playsound sound the same throughout the map?
I want to use it for an explosion sound and want it to be heard far away
Do you have an example case?
With the help of one script, I saw that the AI recognizes a footpath as a road.
Hey all, a quick maybe simple issue here.
A few years back my vehicle clean up script would kick dead players from their vehicles once the vehicle was deleted nothing special was run to do this, it just used deleteVehicle _vehicle
Since last year when my server reopened, however, when the vehicles clean up the corpse no longer pops out and is also deleted, did something change within Arma, or is it more likely that I goofed somewhere?
if i use publicVariable "blah", does it update the JIP queue of variable blah, or does it add to the queue?
So if i ran the function 3 times does it run 3 times for JIP players?
AFAIK update/overwrite
Update IIRC, but anyone currently connected will get sent the thing three times.
How would one remove dead bodies from a vehicle
use moveOut, alive, and crew
_crew = fullCrew _vehicle;
{
if !(alive _x) then {
deleteVehicle _x;
}
} forEach _crew;
I tried this, but it doesn't seem to work.
Try this:
private _vehicle = vehicle player;
{
if(!alive _x) then {
deleteVehicle _x;
};
}foreach crew _vehicle;
What about ejecting their dead bodies?
private _vehicle = vehicle player;
{
if(!alive _x) then {
_x action ["Eject", _vehicle];
};
}foreach crew _vehicle;
Anybody else would find HASHMAP select ARRAY useful?
createHashMapFromArray [
["a", 123]
,["b", 321]
,["c", 111]
,["d", 222]
,["e", 333]
] select ["a","c","e"]
```=>`[123,111,333]`
actually ARRAY select ARRAY can be useful too, so you can for example select needed values out of large EH arrays
Like I can see it could be useful but a loop could accomplish the same thing
and it’s niche so not sure if you’d get Bohemia to add it
Of course its possible through loop, but having it as single command could save a bit of ms
Ehh we can’t test it but I doubt the improvement would be as much as you think
Have you tested the performance of a looped approach?
No but I can estimate it will be several times slower than having it in-engine
Get from a hashmap is consistent regardless of map size so it should be easily mathematically calculable
I think the main cost will be creating of the new array
The issue is number of commands, the less you have the better
I'm doing inside Fired event handler, added to every single unit in the game so I'm trying to squeeze it as much as possible.
Mind explaining your use case a bit more
Tracking every single projectile for detailed damage tracking
So you are adding to the map per Fired
Building hashmaps and brief arrays of useful data out of event data
then sending summaries to server so its tracked there
In some cases I need to compact larger hashmaps into smaller arrays, thus HASHMAP select ARRAY idea
did you read what the return of fullCrew is before you did this?
no its an array of arrays where the first index of the inside arrays are the crew members
[
[R Alpha 1-1:1, "driver", -1, [], false, R Alpha 1-1:1, "$STR_POSITION_DRIVER"],
[R Alpha 1-1:2, "turret", -1, [0], false, R Alpha 1-1:2, "$STR_A3_COPILOT"]
]
ahh, got it
@grizzled cliff "probably because of Eastern Europe and their crappy computers" :D
Equivalent to _array apply { _hashmap get _x } ?
Hmm, good point, maybe it will be optimized by SimpleVM?
I lost track of where and how to test simpleVM
it would
Is it usable anywhere atm? Curious how much faster it is on these tiny loops.
its enabled on profiling branch and dev branch
is the hasmap limited to 10k params?
i used a loop to create dict with 20k params and it worked then i used arr = dict apply {_x} an now arr is 20k parameters
wait, arrays are no longer limited to 10k ?
i guess not, i almost crashed arma but i created a 1M params array, this is a bug or a feature? 
https://community.bistudio.com/wiki/Array
The limit is 10 million, not 10 thousand (good luck with performance though)
The 10k limit is for iterations of a while loop in an unscheduled context

Any of them, but step 0 is probably learning to read channel names
well hasmaps are not limited to 10M :p
😠
if (
_hitPoint isEqualTo "#structural" &&
{!isNull _vehicle} &&
{_ammo isNotEqualTo ""} &&
{
private _ammoCfg = configFile >> "CfgAmmo" >> _ammo;
GET_NUMBER(_ammoCfg >> "explosive",0) > 0 ||
{GET_NUMBER(_ammoCfg >> "indirectHit",0) > 0}
}
) exitwith {
};
☝️ Ace 3 uses this in their handleDamageEH to detect explosion damage... how can I get a vanilla GET_NUMBER alternative?
private _mitigate = true;
private _vehicle = objectParent _unit;
if (
_point isEqualTo "#structural" &&
{!isNull _vehicle} &&
{_projectile isNotEqualTo ""} &&
{
private _ammoCfg = configFile >> "CfgAmmo" >> _projectile;
getNumber ((_ammoCfg >> "explosive",0) > 0) ||
{getNumber ((_ammoCfg >> "indirectHit",0) > 0)}
}
) then {
// Explosion damage is not mitigated, do nothing.
_mitigate = false;
};
☝️ getNumber doesn't work for me, gives me a missing "(" error
remove the ,0
👌 thanks! It will work as intended still?
getNumber (_ammoCfg >> "explosive") > 0 ||
{getNumber (_ammoCfg >> "indirectHit") > 0}
yes
I wish I had a gaming company to hire you as the main dev!
GET_NUMBER is a macro. Whatever's in the macro will still be vanilla script commands, they're just using it like a function (why not an actual function? 🤷). The ,0 is a second parameter being passed to the macro, like a function, and it's probably the default value to use if the config property isn't defined, like with getVariable.
why not an actual function?
function call is a bit slow
there's the call command, plus passing the parameters, plus maybe doing a params or select to extract stuff
macros are expanded inline by the preprocessor, so there's no call overhead
If on a script executing on server I run something like: "remoteExec ["fnc_long_cinematic", -2]", what is a sensible way to wait for all clients to have executed "fnc_long_cinematic" ?
so the server side script can continue to do something after that
I guess have server wait for the fastest client to set some public variable and hope shit wont get too out of sync
it's a bit tricky
you have to use a callback by the clients to tell the server that the script is done
if instead of -2 you specify the clientIDs as an array, you can count how many of them have called the callback
you also have to take into account that a client may never finish the cinematic (e.g. they get disconnected)
imo you can do something like this:
playedCinematics = [];
remoteExec ["fnc_long_cinematic", -2];
sleep CinematicDuration;
waitUntil {playedCinematics findIf {time < _x#1} < 0};
// continue with the rest
fnc_long_cinematic
// report to the server that the client has started the cinematic
remoteExecCall ["fnc_cinematicStarted", 2];
// cinematic stuff
...
// report to the server that the client has finished the cinematic
remoteExecCall ["fnc_cinematicFinished", 2];
fnc_cinematicStarted
private _clientID = remoteExecutedOwner;
private _playID = playedCinematics findIf {_x#0 == _clientID};
if (_playID < 0) then {_playID = playedCinematics pushBack [_clientID, 0]};
playedCinematics#_playID set [1, time + CinematicDuration + _someDelay]; // add a few seconds of delay, in case the client has performance issues
fnc_cinematicFinished
private _clientID = remoteExecutedOwner;
private _playID = playedCinematics findIf {_x#0 == _clientID};
if (_playID < 0) exitWith {};
playedCinematics#_playID set [1, 0]; // complete the cinematic
you can also use a hashmap instead of playedCinematics = []; but it's not really important
I see nice answer! can you explain the '#' syntax youre doing there '_x#1' and 'playedCinematics#_playID' I've never seen that?
nvm found it "_myArray # 2; // returns "third item" - Arma 3 only"
hey guys! does the setDamage command work in decimals like: setDamage 0.05;
yes, since it goes from 0 (not damaged) to 1 (fully damaged)
Same as select but higher precedence
thank you! i need to figure out how much i need to reduce the damage of APERS tripwire as i dont want it to kill a player outright but have them badly wounded
I'd have to broadcast changes to playedCinematics after every 'pushBack' and 'set' right? Any chance for race conditions to happen here?
wait is the setDamage setting the current HP of the unit or how much damage it does?
now im confused haha
ohhh no wonder why the tripwire mine was constantly killing me haha
no matter how much i lowered it xD
is there a script that lowers how much damage it does?
Helloh I need help again 😄
I'm currently working on a script for a mission, the mission has 3 transformer switches and the players have to use ace interactions to set the 3 switches to the correct settings so that the generator is overloaded and blows up
I dont want to write the script 3 times, so I was hoping to use one file with parameters
I've got the ace interactions working thus far, except that I need to somehow publicise the current state of the transformer switches so that I can use a trigger to make the generator go boom when all 3 are correct
I tried using
params ["_switch_object"] //pp_switch_1
_action_name_switch_generator = format ["Pie_%1_generator", _switch_object_text];
// set switch to generator
_action = [_action_name_switch_generator, "Set switch to 'Generator'", "",
{
_target animateSource ["switchposition",-1];
hint "Switch set to generator";
_temp_pp_switchPos = "Generator";
_variableNameSwitchPos = format ["%1_switchPos_",_switch_object];
missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
},
{true}] call ace_interact_menu_fnc_createAction;
[_switch_object, 0, ["ACE_MainActions", _action_name_base], _action] call ace_interact_menu_fnc_addActionToObject;
However that always gives me an error that the setvariable got an Any instead of a string
Anybody got any smart thoughts
?
(note I left some formatting stuff that works out of the script so its a bit shorter)
So I have this made from a while ago, actually been meaning to move it all to unscheduled space.. Maybe the code can help you on your quest.
https://steamcommunity.com/sharedfiles/filedetails/?id=2961943348
no
the code is correct as it is
ok much thanks
I don't know what the point of the _temp_pp_switchPos and _variableNameSwitchPos variables is but anyway to fix the error just use _target instead of _switch_object
params ["_switch_object"] //pp_switch_1
_action_name_switch_generator = format ["Pie_%1_generator", _switch_object_text];
// set switch to generator
_action = [_action_name_switch_generator, "Set switch to 'Generator'", "",
{
_target animateSource ["switchposition",-1];
hint "Switch set to generator";
_temp_pp_switchPos = "Generator";
_variableNameSwitchPos = format ["%1_switchPos_", _target];
missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
},
{true}] call ace_interact_menu_fnc_createAction;
[_switch_object, 0, ["ACE_MainActions", _action_name_base], _action] call ace_interact_menu_fnc_addActionToObject;
Thank you
The _variableNameSwitchPos is so that I can use the script for multiple transformers and set a missionNamespace variable for each one respectively, or does that not make sense
?
I know but I don't understand the word "pos" there (it's a string, "Generator")
Ah, Pos is meant for switch 'Position'
as in selection pos? (which is a string)
the switch on these can be animated, so thats where 'position' came into my head from
but yeah from a purely code perspective it doesnt make sense you're right 😅
You can also animate the meter and even change the colour of the indicator lights ^^
Ye I've got the meter set up already 
For the lights
_switch setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"];
Yee I'm thinking about doing the lights when they have the right setting, but I gotta look at how much performance impacts triggers have since I'd need the light to only switch to a certain color when its on the right settings
and then go back to normal if the settings are changed again
which would put me at 2 triggers each so 6 triggers just for the lights, at my current knowledge level at least
Why do you need triggers at all cant you just asign a variable to a object that changes everytime you change the lever and based on that variable you run the lights.
There shouldn't be need for trigger, you can just call a script function after your "action" script that checks if all switches are set right?
Though then multiplayer shenanigans
that sounds smarter than my current knowledge level 😄
Do you use init.sqf, or do you have all code in init scripts in editor?
Like something like this
Pie_fnc_CheckSwitches = {
if (switch1_switchPos_ == "Generator")
{
switch1 setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch 1
};
// Test other things, set other things for other switches
};
and then in all your actions
_action = [_action_name_switch_generator, "Set switch to 'Generator'", "",
{
_target animateSource ["switchposition",-1];
hint "Switch set to generator";
_temp_pp_switchPos = "Generator";
_variableNameSwitchPos = format ["%1_switchPos_", _target];
missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
call Pie_fnc_CheckSwitches;
},
When any switch changes, you update all switches lights and stuff
currently using a file with the script in it and then execVMing it fron the objects init
then you can easily add a global function like that
I shall try it, thank you peeps 
Question not on my pc right now cant test. What would happen if i make a fnc in object init will that fnc be global or local ?
obj init runs on every player that has the object. Which is usually every player.
thus global, everyone will have it
And if i save that object as a composition and spawn it later when game allready started then would be local?
The init field for compositions placed in Zeus is only executed on the machine of the Zeus that placed it
(and only if the server/mission has the config setting to allow init field execution for compositions)
I see now thanks.
Mh that's unexpected. I would think it should behave the same as in Eden and be global. But guess that makes sense
I don't know why it be like that, only that it do be like that
Does anyone know why the following doesn't work with these switches? I want to lower the lever position::
_value = 0;
_value = _value - 0.1;
switch1 animateSource ["switchposition", _value];
i want to use it in a holdaction and lower the lever from 0 to -1 by every progress tick
The lever only goes down one step
It's not a problem with the switches. The issue is that your code is basically saying:
switch1 animateSource ["switchposition", -0.1];``` every time you do it. So every time the code runs, it sets the animation position to `-0.1`, which is...the same position every time.
am getting there slowly
how would i do it correct?
private _currentState = switch1 animationSourcePhase "switchposition";
switch1 animateSource ["switchposition", _currentState - 0.1];```
Myb something like this not tested :
[
switch1,
"Raise switch",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"_this distance _target < 3", "_caller distance _target < 3",
{systemChat format ["Starting"];},
{
params ["_target", "_caller", "_actionId", "_arguments", "_frame", "_maxFrame"];
private _relProgress = _frame / _maxFrame;
_target animateSource ["switchposition", ((2*_relProgress)-1)];
},
{
systemChat format ["Finished"];
},
{
params ["_target"];
systemChat format ["Interupted"];
_target animateSource ["switchposition", 0];
},
[], 10, nil, true, false
] call BIS_fnc_holdActionAdd;
thank you both
Hm ok trying out the function thing at the moment, however I'm encountering the same problem with my params not being transmitted correctly 🤔
//Switch ace action
_action = [_action_name_switch_generator, "Set switch to 'Generator'", "",
{
_target animateSource ["switchposition",-1];
hint "Switch set to generator";
_temp_pp_switchPos = "Generator";
_variableNameSwitchPos = format ["Pie_%1_switchPos",_target];
missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
[_switch_object, _target]call Pie_fnc_setSwitchLights;
},
{true}] call ace_interact_menu_fnc_createAction;
[_switch_object, 0, ["ACE_MainActions", _action_name_base], _action] call ace_interact_menu_fnc_addActionToObject;
//Pie_fnc_setSwitchLights
Pie_fnc_setSwitchLights =
{
params ["_switch_object_text","_target"];
_switch_object_test = param [0];
hint _switch_object_test;
//hint "pie fnc executed";
hint format ["pie fnc executed %1 %1",_switch_object_test, _target];
_variableNameSwitchPos = format ["Pie_%1_switchPos",_target];
_variableNamePowerLvl = format ["Pie_%1_powerLvl",_target];
_switch_switchpos = missionNamespace getVariable _variableNamePowerLvl;
_switch_powerLvl = missionNamespace getVariable _variableNamePowerLvl;
switch (_switch_object) do
{
case pp_switch_1:
{
if( _switch_switchpos == "Generator" || _switch_powerLvl == "80") then
{
_switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch
hint " red light";
} else {
_switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,1,1,1,ca)"]; // not red light on switch
hint " not red light";
};
};
case pp_switch_2:
{
if( _switch_switchpos == "Generator" || _switch_powerLvl == "80") then
{
_switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch
hint " red light";
} else {
_switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,1,1,1,ca)"]; // not red light on switch
hint " not red light";
};
};
case pp_switch_3:
{
if( _switch_switchpos == "Generator" || _switch_powerLvl == "80") then
{
_switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch
hint " red light";
} else {
_switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,1,1,1,ca)"]; // not red light on switch
hint " not red light";
};
};
default { hint "zero, three or four" };
};
//hint "Function was executed!"; // Function will show a hint when executed
};
That code then just generates the same old any for both params
what am I doing wrong with my parameters 😄
too much code
I wish I was smart enough to put it in less code
you never params'ed _target
https://community.bistudio.com/wiki/addAction
Parameters array passed to the script upon activation in _this variable is:
params ["_target", "_caller", "_actionId", "_arguments"];
(unless ACE does it itself, idk)
_target comes from the ace action, I input it in the original fnc call
[_switch_object, _target]call Pie_fnc_setSwitchLights;
I dont use it in the fnc yet other than it being in the format since I'm trying to just get the first param to be transmitted correctly
yeah but ```sqf
_target animateSource ["switchposition",-1]; // where is _target defined?
🤔 good question, it definetly works at the moment so I guess its ace already doing it somehow?
ACE doesn't use addAction for its actions
https://github.com/acemod/ACE3/blob/master/addons/interact_menu/functions/fnc_keyUp.sqf
_target and _player are provided automatically by ACE
It does look like _switch_object is not defined in the action code, yet you pass it to the function:
[_switch_object, _target] call Pie_fnc_setSwitchLights;```
Ah ye wrong locality, wouldnt the target still work then though?
Maybe™
That's not a locality problem btw. Locality is when you're on the wrong machine. This is a scope problem.
Your switch (code structure) has switch (_switch_object), which is not defined
You could probably save some effort by saving the missionNamespace variables in the switch object's namespace instead. Don't need to worry about format-generating unique names then.
Still wish there was publicVariableJIP STRING or something like that, so you can make a variable to be broadcasted to JIP
Could be useful for large data structures, you update small bit of the structure on all clients through a function while make the whole structure to be sent whole to JIP
Sure it can also be scripted, but having engine handle it would make it more convenient
Now contemplating whether I should script such system myself or say fuck it and just publicVariable the whole thing on each small change
/* rhsusf_m1240a1_m240_usmc_d addWeaponTurret ["rhs_weap_TOW_Launcher_Static", [0,0]]; */
hint "good!";
hmm....
I'm currently try to attach objects to an arbitrary selection that will follow rotation. This is what I currently have: _object attachTo [_otherObject, [0,0,0], _memorybone, true]; This works well when the _memorybone for the object is the same between lods (i.e. spine, head, hand, etc). I find component from fire geo and use that, no issue.
Any idea how to find the controlling _memorybone when it is a different name from the selection? Say door_5 & door_5_axis? wheel & wheel axis? Obviously for more broadly than _memorybone = selection + _axis/_X.
If you got an alternative to using attachto that works, that works as well.
just had a quick question: "While true" in the past dropped my system to its knees, couldnt tell why. i avoided since. It is generally safe and performance friendly to use correct?
as an example, this checks for player in vehicle every minute. should be lightweight right? since its just player?
while {true} do
{
if (player != vehicle player) then
{
playmusic format ["RadioAmbient%1",floor (random 31)];
};
sleep random 60;
};
before you probably accidentally forgot to sleep, which will attempt to loop as fast as the scheduler allows it to, which if written without that in mind, can toast your system.
Its generally frowned upon to use true as the condition though as, without a handle, you can't ever stop it.
this checks for a player in a vehicle anywhere from~~(0, 60]~~ [0, 60)seconds. could be 10, could be 3 sleeps of 0.3 (if the dice roll is spicy)
i see. so having a way to stop a "true" statement is the way to go. in my case,it wouldnt need to be stopped, at least i cant see any potential reason for it so its a clean enough syntax agreed?
and yeah maybe i had the sleep wrong or not atall, i see what you mean
challenge: once your music starts, make the loop wait for the music to end, then do its random wait time. I'll give hints if you get stuck.
I think you mixed up the brackets
You're right, been a while since I used included/excluded math notation
looksl ike it actually but the script works
nonono, that wasn't for you to use
( means exclusive, [ means inclusive in math notation
oh i just checked yeah i see, i thought that was odd lol
i mean to say, its 0 to <60
so how to get around that?
i actually had that issue a while ago with music
it involves using the "MusicStop" music event handler
thats a new EH to me.
_isEmpty = true;
if (!isNull _vehicle) then {
{
if(!alive _x) then {
deleteVehicle _x;
};
}foreach crew _vehicle;
_crew = crew _vehicle;
if (count _crew == 0) then {
deleteVehicle _vehicle;
missionNameSpace setVariable [_variable,objNull];
}else {
"Vehicle is not empty!" remoteExec ["hint",_caller];
_isEmpty = false;
};
};
Is there ANY reason this isn't deleting dead players from the crew of the vehicle?
Works fine for dead NPCs, but player bodies won't get deleted and _isEmpty is always false.
EH's are game changing
wait till you figure out scripted event handlers to make your own
Just realized that having getSoundInfo command similar to getTextureInfo and getModelInfo could be very useful
Worth a ticket
Yeah, I went through some of the upcoming dev stuff and didn't see anything still
So you can get the duration out of the file's header
One problem can be that you can't delete player's body until player switched control to a new unit.
@bleak mural well, if hes using a custom music file (which I think he is), he could fudge it by adding a config value for the duration of the file that he adds, then grab that value for his sleep
By the time this script is run, the player has respawned
Its a stock music, config has no info about duration there
On other notes, I think the IDC syntax of lbSetPictureRightColorSelected is broken. It gives the missing ; error that happens when the command syntax isn't recognized. The alternative control object syntax works fine.
Deleting crew was always very buggy, where are you deleting it at? Server? Client?
There is probably no main syntax, was likely copied from other articles
I'll put a discussion on if we should delete that syntax, or just mark it as not functioning in #community_wiki
supportInfo "" select {_x find toLower "lbSetPictureRightColorSelected" >= 0}
=>
["b:CONTROL lbsetpicturerightcolorselected ARRAY"]
only alt syntax in the engine
considering that 1.20 was like 10 years ago I doubt anyone cares about main syntax anymore, just remove it from there
kk
Try having action presser query the server to execute this script
There is also https://community.bistudio.com/wiki/deleteVehicleCrew
lotta words, I'm not understanding them
Instead of fixing deleteVehicle to properly work on dead bodies they added a new command which has 2 syntaxes that work differently
And I think also still bugged, I had an issue with it recently
You reckon that'll work better in this usecase?
So just play around with stuff until its sort of working
I'll give it a shot
I think dead bodies also break if they're controlled by player for too long
Then they are never properly deleted and that seat is no longer script usable (normal gameplay get in works)
well what'ya know
all in all, its all fucked with dead bodies in vehicles, try stuff until something works
It happened to work, thanks for the quick fix!
Been trying to debug this for the past day
I thought it was working, as I was testing with dead AI, and then I tried as a player, then it stopped working.
Why do they act differently?
Do issues like this occur in reforger, with the new engine?
Not that I know of, but its completely new from A3 engine
Probably has its own troubles, nothing is perfect
I used Exile and it ejected players inside vehicles on death via Killed EH, always worked.
Not perfect for immersion but #Arma
if !((vehicle player) isEqualTo player) then
{
unassignVehicle player;
moveOut player;
};
That's the code i used before stopping, and never saw it not working.
A bit annoying when you get killed in a air vehicle because sometimes the body went underground, but again #Arma 
Yeah, could be a way to fix this
I like dead players inside vehicles because it opens gameplay opportunities in KotH
For example you can revive dead units while also inside the vehicle, including mid-flight
This is better way to check if player is in vehicle:
if!(isNull objectParent player) then {
unassignVehicle player;
moveOut player;
};
//or
if(isnull objectParent player) exitWith {};
unassignVehicle player;
moveOut player;
How much crap is stored for a single hit on a vehicle
it stores your DNA
Same exact issue on my escape missions after the recent update.
Anyone able to help me out with a hiddenselection problem I've been having? I'm trying to change the texture of a shirt, and this is how I thought you'd write the code into the init box, but nothing works. Example: this setobjecttexture [0,texture_name]
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Also texture_name is not a string but a variable/identifier
tldr: it's not a valid texture
I love that.
Now I want to do that with a nuclear meltdown. To force the troops to be ready to very quickly evacuate after flipping the switches.
Guess I'm gonna build a mission soon :x
using the guide from an author of a uniform mod, that was the example that he used. In my instance, I want to change the texture to what he's listed as being named DPCU, when I do this setobjecttexture [0,DPCU] nothing changes, and I get a string error pop up.
[_switch_object, _target]call Pie_fnc_setSwitchLights;
_switch_object is undefined up there.
Also add logging before you call the func.
You can just log _this too to see if you can pull it from there
So, this would then be the correct way to write it then? in theory? ***this setobjecttexture [0, "\modname\texturename.paa"] ***
In theory yes
cheers mate, I'll give it a try
Also this please
I'll try that sqf thing, I just didn't quite understand the format of it.
I get an error when trying this setobjecttexture [0, "\modname\texturename.paa"] stating that the picture is not found
well, it's one of this lad's uniforms, and this is his own classname guide for hidden selections: https://steamcommunity.com/workshop/filedetails/discussion/2581537651/3035976310921236154/
The texture that I'm trying to load onto the shirt is named DPCU in his classname list.
Well read the guide carefully then. You've pretty skipped into the conclusion
well, this is how he explains the process of changing the texture of the shirt In the unit's init: this setobjecttexture [0,texture_name] to change the shirt textures And at the top of his guide, he has the classnames of the textures simply listed as such Replace * with one of: ABSTRACT, ADPM, AMCU, AMCUF, ARID, ARMATA, ATACS, BCD, BCG_AM, BCG_AN, BCG_BR, BCG_BRSA, BCG_DG, BCG_R, BCG_T, BCG_U, BCG_WD, BCG_WL, BCG_WW, BCM, BCP, BDC, BLC, BME, BROWN, CADPAT, CDW, CHIP, DARK, DCCU, DPCU, DPDU, DPM, EMR, ESE, FLECK, GLC, GRANITE, GZONE, ICAM, IDPM, IDT, ITMP, JEITAI, JIGSAW, KA2, KDC, KILO, M05, M09, M09D, M14, M2011, M2015, M81, M90, M98, MAD21, MANDRAKE, MARPAT, MARPATD, MCAM, MCAMF, MCAMD, MCAMT, MLAND, MTARN, MTP, MWC, NFP, NZMCU, NZMTP, OBH, OCP, OCPF, OD, PAP, PSDC, RCAM, SLOCAM, SURPAT, T07D, TAC, TAN, TAT, TAZ90, TCAM, TCAMF, TE3, TIGER, TIGERAT, TUNPAT, UNIPAT, US4CES, VEG, VSR, VZ2007, WLP, XINGKONG, Z93
You're reading it entirely wrong
More like you don't really seem to have a need of setObjectTexture but just have tpw_g3_g3_rs_ng_uniform_* uniform class
would you be able to nudge me into the general area as to what I need to be doing?
Replace * with one of: [...]
This explains well. Which means,*in these guides have to be renamed into one of them
and insert that into the aforementioned this setobjecttexture [0, *here* ]; line for the init?
Sorry man, coding is far from something that I'm knowledgeable on.
I tried this setObjectTexture [0, "tpw_pcu_g3_fs_fm_uniform_DPCU"]; but it gave me the same string error
"tpw_*_uniforms\data\g3_shirt_co.paa" this is the texture name I guess
progress; it changed the texture, but it changed to the wrong uniform's cut of the texture, example: it's showing the texture for a Crye G3 in DPCU, but I'm after the texture for a PCU jacket.
Got it! Thank you greatly! And now I've learnt how to do it on other uniforms for next time
🙂
Can you set up a replication case?
I had it happening over and over fairly reliably recently
Can try making a repro out of it
I have a question ? Is there a command to see what are the dlcs loaded on the server or the mission ? Because the command "getMissionDLCs" only check the dlcs units in the mission, nothing else and i wanted to know if it was possible to know if a CDLC is enabled or not.
I don't think there's a specific command for it, but checking for the DLC addons in CfgPatches should do what you need
oh i didn't think about that, because when you see the latest changelog of the dlc "reaction forces" they said "If the Western Sahara CDLC is enabled, some of its vehicles are added into the randomized vehicle spawn and motor pool" so i think they are checking the config, so i will try that then, thank you 😄
They're probably using the __has_include preprocessor command. (Can't use SQF commands to do config lookups in config) https://community.bistudio.com/wiki/PreProcessor_Commands#has_include
oh ok interesting but i think that "isClass (configFile >> etc)" should be fine for me to check dlcs or even mods 😄
Hi, I'm a beginner, bit stumped with variable scopes here. Can local variables in an .sqf be passed onto event handlers in that same .sqf?
I'm trying to use the task framework to create a few tasks with a local effect (eg, "Mount vehicle"), so each player gets it completed independently before moving on to other tasks. To this end, correct me if I'm wrong, each player needs to have this task with a unique task ID. I did this by adding [this, "av6_taskMount_01"] execVM "scripts\AV6_taskMount.sqf";with a different ID to each playable unit, and then start the .sqf with private _soldier = _this select 0; private _taskID = _this select 1; These variables are undefined in any EH I create. Can I change that?
Event handlers are creating fresh script scope, there are lots of ways to pass stuff into them
For your case it could be something like:
_soldier setVariable ["my_task_id", _taskID];
_soldier addEventHandler ["Killed", {
params ["_unit"];
private _taskID = _unit getVariable "my_task_id";
// Fail the task here
}];
Also tasks are local, they're nothing more than an UI effect, you probably don't need a unique ID for each player because essentially each player only has to care and know about their own task
Task framework is used to ease things when you want tasks to be synced over the network
Its a wrapper for https://community.bistudio.com/wiki/createSimpleTask and associated task commands
I tried using a single ID to create a simple "mount vehicle" task for all players locally, which worked fine until I used BIS_fnc_taskSetState to complete it - then it got completed for everyone, even those who hadn't gone near the vehicle. createSimpleTask and its associated commands worked as needed, but didn't display any task notifications.
Task Framework is for making tasks MP-synced, thus your completion was synced to everyone
To change task state locally
Actually if you want some assicated effects and stuff, call https://community.bistudio.com/wiki/BIS_fnc_setTask directly
There is isGlobal flag to not broadcast task state to others
BIS_fnc_taskSetState is a wrapper for BIS_fnc_setTask pretty much
Of course... thank you! You've been very helpful
private ["_taskID","_state","_hint"];
_taskID = param [0,"",[""]];
_state = param [1,"",[""]];
_hint = param [2,true,[true]];
[_taskID,nil,nil,nil,_state,nil,_hint] call bis_fnc_setTask;
All that it does
You sent nil's to BIS_fnc_setTask to not to do anything with arguments you don't want to change
Oh cool, I can use that.
I meant just for that function
Don't feed nils into other functions, unless you're sure they can deal with it
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Hi, im creating my first mission in arma 3 and want to add a function when looting dead ai, limit the total items in the inventory to only 3, but didnt manage so far, anyone can help?
_unit = _this select 0;
if (isPlayer _unit) then {
if ((player distance _unit) < 3) then {
_fullInventory = getUnitLoadout _unit;
if (isNil "_fullInventory") exitWith {
hint "The inventory is empty!";
};
_totalItems = count magazines _unit + count uniformItems _unit + count backpackItems _unit;
if (_totalItems > 3) then {
while {_totalItems > 3} do {
{
_subInventory = _x;
while {count _subInventory > 3} do {
_unit removeItem (_subInventory select 0);
_subInventory = _subInventory - [_subInventory select 0];
};
} forEach [magazines _unit, uniformItems _unit, backpackItems _unit];
_totalItems = count magazines _unit + count uniformItems _unit + count backpackItems _unit;
};
hint "Excess items removed from inventory!";
} else {
hint "The inventory already has 3 items or less!";
}
} else {
hint "You are too far to loot!";
}
} else {
hint "Only players can loot!";
};```
_fullInventory = getUnitLoadout _unit;
_uniformItems = _fullInventory#3#1;
_vestItems = _fullInventory#4#1;
_backItems = _fullInventory#5#1;
_changed = false;
while {count _uniformItems + count _vestItems + count _backItems > 3} do
{
_changed = true;
if (count _backItems > 0) then {_backItems resize (count _backItems - 1); continue};
if (count _vestItems > 0) then {_vestItems resize (count _vestItems - 1); continue};
if (count _uniformItems > 0) then {_uniformItems resize (count _uniformItems - 1); continue};
};
if (_changed) then
{
_unit setUnitLoadout _fullInventory;
}
tho I don't really recommend doing that
because, e.g. if the player places something in his vest and he already has 3 items, something will be removed from his backpack
Why not use Eh Take ?
because I just corrected his script to make it work
Which would be a better way?
Have 0 sqf knowledge
trying to make something of a random loot using the ai body as loot table
Take EH
actually nvm
also I think when you use getUnitLoadout on a dead unit you won't get his backpack items
I love arma 3 scripting
i believe that i misspelled what i wanted, in this case i want the dead body that im looting the gear from to generate 3 random items on total when i open its inventory(including uniform, vest and backpack inventory)
tried the code, no success
Nvm, figured out a way, just not 100% if it will work rn, but really interesting, although not realistc
[_this] spawn
{
params["_unit"];
addMissionEventHandler ["EntityKilled",
{
params["_unit"];
if (_unit isKindOf "Man") then {
private _box = createVehicle ["Box_NATO_Wps_F", getPosATL _unit, [], 0, "CAN_COLLIDE"];
private _tomb = createVehicle ["Land_Tombstone_04_F", getPosATL _unit, [], 0, "CAN_COLLIDE"];
clearWeaponCargo _box;
clearMagazineCargo _box;
clearItemCargo _box;
clearBackpackCargo _box;
{_box addItemCargo[_x,1];} forEach (assignedItems _unit);
{_box addWeaponCargo[_x,1];} forEach (weapons _unit);
{_box addItemCargo[_x,1];} forEach (vestItems _unit);
{_box addItemCargo[_x,1];} forEach (uniformItems _unit);
_box addItemCargo[(uniform _unit),1];
_box addItemCargo[(vest _unit),1];
_box addItemCargo[(headgear _unit),1];
_box addBackpackCargo[(Backpack _unit),1];
deleteVehicle _unit;
hideObjectGlobal _box;
_tomb addAction ["Loot",{_this select 1 action ["Gear",_this select 3]},_box];
};
}];
};
For future reference if anyone needs to create a custom crate after a unit dies, you can add this to their init, with this setup it creates a tombstone, did by digging on forums(For selecting which object to spawn: https://forums.bohemia.net/forums/topic/177963-make-an-object-appear-as-another/; For creating the crate: https://forums.bohemia.net/forums/topic/211102-put-player-gear-in-ammo-box-on-death/)
Now the question is how performance is going to be when ai start dying left and right
👏 V4, completely rewrote the actual switch/power level code and moved from triggers to functions completely, also added it turning off the lights in the area and generally made it more cool
Thank you for your help everyone <3
This looks amazing!
im quite curious to understand this feature in High command: Create Task Spawns code saved to High Command - Commander module's namespace _logic getVariable "onTaskCreated"
from what i understand, i can, on a waypoint of a unit,run a line of code for them?
a modifier to a waypoint called "create task" is present on high command. it should execute a line of code,but im not sure where "commander modules namespace " is. never heard of it.
or what "_logic getVariable "onTaskCreated" /how its supposed to be run. i never used logics before
essentially i want to run a code on a group on a wp by using "createtask" via the wp modifier
[this,def,25,3,false,true] call CBA_fnc_taskDefend
Thanks 
im also looking at "radios = <array>; - Radio channels reserved for radio triggered waypoints." i think this is more of what im trying to do. im calling it but the hroup isnt carrying out the CBA function once reaching the waypoint
Next points of the to-do list is looking for more fitting sounds to use, preferrably looking for some kind of generator+generator winding down noise, gonna take a bit to check the vanilla sounds 😄
And also possibly custom explosion effects, which someone mentioned would be cool
ok so i must be misinterperating this or it doesnt actually work
BIS_HC_1 setVariable ["onTaskCreated", Code, true];
when this is called on a groups wp via High command,it should run the code on them correct?
to that end i have a syntax as follows:
BIS_HC_1 setVariable ["onTaskCreated", [_this] call CBA_fnc_taskDefend, true];
i get no errors,but the group dont follow the CBA defend script
code would be { code }
ok il try that
ok i did work but im getting an error(i think elated soley to cba)
should be nothing to worry about right? i think its referencing group this
always fix errors
however if i change"_this" to "_group this" the syntax throws error
see what arguments are provided to this onTaskCreated event
anyone here worked with hashMapObjects before?
Im woundering the following: If i create a hashmap Object, for example, on the server, have itself being setup with all the internal stuff and create and whatelse, if I then publicVar it all clients, will it re-run the create method?
ah i think i understand.. i thinks its looking for the values
... " /x/cba/addons/ai/fnc...taskdefend.sqf
|#|params [
["group", grpNull, [grpNull...'
ERROR params: type number,expected array,object,group,location....
so location of defense/module etc
because im doing this on the fly,there is no exact location,other than the groups pos
then get the group's pos?
[this,def,25,3,false,true] call CBA_fnc_taskDefend
"def" is referencing an object pos
how to get group pos?
getPosATL leader myGroup
actually with that syntax i think it wont throw errors and group will carry out script on pos
il tidy it up thank you
You don't need this specific bit of code any more because you've changed approach, but I want to explain why this was wrong, for future reference.
_ is the prefix for a local scope variable. If you put that in front of a word, the game assumes you're trying to refer to a local scope variable with that name, and goes looking for it. Including if the word would otherwise be a command.
The original code _this is a reference to the Magic Variable _this, which contains some information provided by the scope - arguments passed into the function, or something like that. https://community.bistudio.com/wiki/Magic_Variables The exact contents depends on the context, and _this doesn't exist in all contexts, so watch out for that.
When you change it to _group this, you're not changing it to "get the group of whatever _this is". You're changing it to "the local scope variable called _group, and then the global scope variable called this", which is nonsense syntax. Just two variables one stated after the other.
If _this actually contains a unit in a group, then the correct syntax for getting that group would be group _this. group is a command to return the group of a unit; _group is a local variable.
The _ prefix has a specific meaning in SQF and you can't just move it around at random.
Up till reading this my only understanding of it was "_this" or "_group" needed to be run after mission start as "this" wouldnt be recognised.
its alot of info i cant say i understand it all,but thanks,it gives me a new direction to learn towards
If i wanted to reference the current group,how to write this? "leader mygroup" ... myGroup refers to the groups variable but this is run on a random group out of a possible 10
"leader groupthis" ?
However you're choosing that random group, just save whichever one was chosen as a variable, instead of hardcoding a reference to a particular group. e.g.
private _selectedGroup = selectRandom [mygroup1, mygroup2, ...];
private _selectedGroupLeader = leader _selectedGroup;```
apolagies i explained wrong
im not choosing a random group
i have 10 groups, on a wapoint i issue via high command(could be any group) i need the code to run on that particular group
see what arguments are provided to this onTaskCreated event
what are the onTaskCreated event's provided arguments?
so Alpha1 and alpha 2 have wp's. i may choose to modify Alpha2's move wp with this createtask function
You'll be pleased to learn that this is not documented
apolagies i forget what that even means
Lou, the error?
The available documentation is here: https://community.bistudio.com/wiki/Arma_3:_High_Command
It's not a real EH, it's some special thing the HC system does, and information on what arguments it provides - if any - is not given
this is staright from biki, there is hardly any other info out there BIS_HC_1 setVariable ["onTaskCreated", Code, true];
let's find out and fill in the blanks then
If it doesn't provide any useful arguments, then you'd have to use hcSelected to get the currently selected groups, which must be the ones the order is being given to
meaning errors are unavoidable?
Why would you take that from what I said?
because i thought theres no way to get the ones the order is being given to
Please read it again.
In HC, you can only give orders to groups you have selected. Also, when you have groups selected, any order given is given to all those groups. Therefore, at the moment an order is given, the groups currently selected must be the groups that are being given the order.
The onTaskCreated event may turn out to directly provide a reference to the group in question (maybe one day we'll find out!), but if it doesn't, we can use that logic to deduce it ourselves.
