#arma3_scripting
1 messages ยท Page 675 of 1
did you try adding the channel to player on server?
[_channel, [player]] remoteExec ["radioChannelAdd", 2];
so it worked for about 4 seconds, then was removed once I spawned. yet I still show added under radiochannelinfo. the channel works fine in SP editor where I can force a customChat with script. but when in multiplayer, I can't even force a customChat either through the server or player.
perhaps it's a sync issue
add the channel with some delay after it's created
like a few seconds
hmmm let me try that
so now I've narrowed it down to the respawn menu. while in the respawn menu, I can access the channel, but the moment I spawn, it gets removed. all i have is the menuPosition respawn template and nothing in my onplayerrespawn.sqf even touches chat channels
when you respawn you get a new "body" 
in fact you should touch onplayerrespawn!
yes, but I'm still showing in the array of added units while in my new body
with the transferred vehiclevar
remove and add again
in onplayerrespawn
that looks to have fixed it. what was confusing me is I didn't even know to think of that because everything was still showing that I was added to channel at all times. even when I was the new unit and had my editor reference.
so do I need to call a end mission on the server? or will it automatically end if every client has ended? for example...
load.sqf:
_test1 buttonSetAction "profileNamespace setVariable ['myTest', 1]; saveProfileNamespace; closeDialog 0;";
_test1 ctrlShow true;```
output.sqf:
_test2 = profileNamespace getVariable ["myTest", 0];
diag_log format["Test: %1", _test2];
when its loaded i dont get a 1... only if i reconnect or die.
anyone know why and how to solve?
I thought I said ENTIRE, not a part of them. Those two don't make sense
put it on sqf bin
nvm ill keep testing myself, thanks anyway
its freeeeeeeeeeeeeeeeeee and no signups needed
Hello everyone, so, a quick question, it might make you want to slap me and i understand you.
What i'm trying to do is to get the game to respawn players inside a vehicle, checking if it's empty or not, if it is, then respawn the player inside that vehicle, if it's not, then select another vehicle (there're 12 vehicles, each with a single unit capacity), what i have is this but even i know it is SOOOOOOO wrong:
_respawnVeh = {respawn_west1, respawn_west2};
if (hasInterface) then {
player addEventHandler ["Respawn", {
{{alive _x} count crew _respawnVeh == 0} forEach _respawnVeh;
if crew == 0 do
{player moveInCargo _respawnVeh};
}];
};
if crew == 0 do 
Are you using anything like the menu position system?
@warm hedge Is it THAT bad? Sorry i'm used to scripting simpler things (i'm not adept at programming or anything, but i'm trying to learn)
@fair drum I'm trying to set the respawn trough the init.sqf
More like it's simply illegal.
crew is a reserved variable because it is a command, and that is not a way to use this command.
do is also not a suitable command to use if, then instead
Is there a way to check if a player is muted via the player list ?
I want to mute a player in sidechat/direct if he got muted by another player (via HandleChatMessage) ๐ค
Hello, I'm sorta confused on defining variables with just unit names. Exactly why doesn't the game like this set up? ๐
Unit1 = "I_soldier_UAV_06_F";
RemoveBackpackGlobal Unit1;```
It seemed to work for vehicles themselves, but units seem to need a extra step
Unit1 is not an object, but just a string
Uh, how would I unstring that? I want it to keep it generic for that specific class.
Because I tried just
RemoveBackpackGlobal "I_soldier_UAV_06_F"; and generic error as well.
you'd probably need something like this
{
if (typeOf _x == "I_soldier_UAV_06_F") then {removeBackpackGlobal _x};
} forEach allUnits;
or alternatively remove it before/when spawning them, depending on when this is used
It's used on inti it seems on liberation framework. But typeOf _x == shoudl work for both ways yea?
[[KP_Liberation_infantry_laa], {removeBackpack _this;}]``` This is part of the array I wrote out as part of their file that fires off on any unit spawn.
Isn't allUnits select {typeOf _x == "I_soldier_UAV_06_F"} better?
idk, wouldnt think so. why loop through all units just to loop through some of them again?
/* - Specific object init codes depending on classnames.
Format = [Array of classnames as strings, Code to apply]
_this is the reference to the object with the classname */
KPLIB_objectInits = [
[["Flag_White_F"], {_this setFlagTexture "res\NFG\Prototype200x200.paa";}],
[["Land_HelipadSquare_F", "Land_HelipadCircle_F", "Land_HelipadRescue_F"], {{[_x, [_this, true]] remoteExecCall ["addCuratorEditableObjects", 2]} forEach allCurators;}],
[[FOB_box_typename], {_this call F_setFobMass; [_this] remoteExecCall ["F_setLoadableViV", 0, _this];}],
[[KP_liberation_recycle_building], {_this setVariable ["ace_isRepairFacility", 1, true];}],
[[KP_liberation_small_storage_building, KP_liberation_large_storage_building], {_this setVariable ["KP_liberation_storage_type", 0, true];}],
[KP_liberation_medical_facilities, {_this setVariable ["ace_medical_isMedicalFacility", true, true];}],
[KP_liberation_medical_vehicles, {_this setVariable ["ace_medical_medicClass", 1, true];}],
// Hide Cover on big GM trucks
[["gm_ge_army_kat1_454_cargo", "gm_ge_army_kat1_454_cargo_win"], {_this animateSource ["cover_unhide", 0, true];}],
[[KP_Liberation_infantry_lat], {removeBackpack _this;}],
[[KP_Liberation_infantry_laa], {removeBackpack _this;}]
[["Flag_White_F"], {_this setFlagTexture "res\NFG\Prototype200x200.paa";}],
];```
Is the full file
{
} forEach (allUnits select {typeOf _x == "I_soldier_UAV_06_F"})```, I mean
in case you're still having trouble with this, try using the ButtonClick event handler instead. buttonSetAction uses SQS code, not SQF, so what you have there may not be valid.
yea to me that is worse than just foreach because you loop through allUnits with select and then loop through the selected units again with foreach, instead of just looping them all once with forEach
mmm, just weird that they have vehicles and other objects work fine but not infantry. Could just be set up that with with KPLIB_objectInits
thank you for your help btw.
Ah, true
0.0272 ms
Cycles:
10000/10000
Code:
{
} forEach (allUnits select {typeOf _x == "O_Soldier_F"})```
```Result:
0.0259 ms
Cycles:
10000/10000
Code:
{
if (typeOf _x == "O_Soldier_F") then {};
} forEach (allUnits)```
with more units select will be faster
Why isn't this code I got from the forums doing anything: _center = createCenter sideLogic; _group = createGroup _center; _pos = getpos player; _cas = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""]; _cas setVariable ["vehicle","O_Plane_CAS_02_dynamicLoadout_F"]; _cas setVariable ["type", 1];
where do you execute it?
console
is "ModuleCAS_F" a virtual cas?
not sure I think the virtual cas class name is something like : "SupportProvider_Virtual_CAS_Bombing"
Result:
0.0415 ms
Cycles:
10000/10000
Code:
{ } forEach (entities [["B_support_AMG_F"], [], false, true])
Result:
0.117938 ms
Cycles:
8479/10000
Code:
{
if (typeOf _x == "B_Support_AMG_F") then {};
} forEach (allUnits)
This is way faster. Tested with 50 units.
You should use the alternative version of createUnit:
private _moduleGroup = createGroup sideLogic;
"ModuleCas_F" createUnit [
getPosATL player,
_moduleGroup,
"
this setVariable ['vehicle','O_Plane_CAS_02_dynamicLoadout_F'];
this setVariable ['type', 1];
this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];"
];
@little raptor thx man that works ๐
hmm what's weird is that with unsung planes the planes seem to blow them self up when firing
are you sure they blow up when they fire??
or do they explode when they spawn?
they fire then blow up
yep they shoot them self in air
vanilla planes seems to be ok
could be the counter measure stuff
do they have counter measure?
idk
well they fire their counter measure after shooting
maybe it's "bound" to something else in unsung
I'm testing all the unsung planes, bit hard to know which plane is good for CAS though with all the loadout abbreviations
Here's the list: ``` blows up:
- AF
uns_F4E_GBU
uns_F4E_AGM
uns_A7_AGM - Navy
uns_A7N_AGM
uns_F4J_AGM
ok:
- AF
UNS_F111_AGM
uns_f105D_AGM
uns_f100b_AGM - Navy
uns_A4B_skyhawk_AGM
uns_A6_Intruder_AGM
so its with some planes only
There's a short lag between an unit in a group's dead and the leader recognizes that he's dead now and kick him out from the group. Is there any command/function to remove this lag?
reveal mayhaps but I wouldn't hold my breath
Unfortunately reveal is not the thing, so you don't need to worry about to die
killed event handler + set group to grpNull 
can you change the mouse cursor like zeus does?
afaik no
oh no :/
I'm not absolutely sure.
you can check the Zeus files, see if there's any "reference" to those mouse icons.
if you find anything let me know! I also needed this a while ago but gave up.
yea I already did check the curator files..
IIRC there's no possibility than a map GUI control?
yes map should be possible
The cursors are defined in configFile >> "CfgWrapperUI" >> "Cursors" . that's all I know
Hello everyone, does anyone have a problem that the BIS_fnc_kbTell dialogs go too fast and don't play sound? Although subtitles appear.
yes, you need to assign a speaker to the person saying the line
if you use a simple module/Logic, it will speak MickeyMouse-y
Thank you, but I have it marked in the config (actor= "DB_HQ"). Or do you mean the 6 parameter BIS_fnc_kbTell?
I mean, what is DB_HQ?
This is a unit on the base.
oh, that's weird then. I only encountered this issue if it was a Logic speaking
Thanks for the help, I'm just working with BIS_fnc_kbTell for the first time. And my task is to make radio conversations between the HQ and the player.
only true if most units are of that type.
If you just filter out 10% with the select, the select will be better
_test1 ctrlSetEventHandler["ButtonClick","profileNamespace setVariable ['myTest', 1]; saveProfileNamespace; closeDialog 0;"];
doesnt work, same issue
they use CBA
CBA uses a feature called function caching. it won't recompile the function on every mission start and thus it's faster:
https://cbateam.github.io/CBA_A3/docs/files/main/script_macros_common-hpp.html#PREP
functions are defined in XEH_PREP.hpp
what about addEventHandler?
is stacking switch dos a bad idea on performance vs just stacking if thens or using a fsm?
all of them are nearly the same
do you know if the FSM carries the handle return with them to access inside or do I need to pull that in with setFSMVariable?
๐คท I've never worked with FSMs. they're just fancy way of doing if thens
If you really care about performance use "precompiled" conditions
(if the conditions are fixed/predictable)
well if they are all the same, with these amount of conditions, I'd rather be visual with a FSM editor
wait what? CfgFunctions in the base configFile (not missionConfig) recompiles every time you start a mission?
since when did that happen?
and why is that a thing?
if it doesn't then what CBA says makes no sense
there's no way to make loading times faster besides that
I don't know
it sure as heck doesnt load the changes i make to files, so why does it need to recompile if nothing changes?
You can disable cba function cacheing if you want to live-load changes to function code https://ace3mod.com/wiki/development/setting-up-the-development-environment.html#71-disabling-cba-function-caching
im talking about cfgFunctions
@still forum is what I said true?!
#arma3_scripting message
(do cfgFunctions recompile in every mission)
as a dev you should know
There is a cache in uiNamespace
If you don't set allowRecompile or filePatching or whatever it should copy from there
Not sure, that initFunctions script is huge :u
I'm not sure why CBA would claim that it speeds up the loading times if otherwise 
before I go any farther, can I clean this up?
hashmaps
guess I gotta read up on those lol
and this is exactly what I meant by "precompiled" conditions
conA -> condB -> load codeAB
kind of thing
very fast
but tedious to set up
got a quick small example?
either at one point it was recompiled every time (I seem to remember a patch where it happened, then got removed the one after)
but maybe they are simply talking about CBA functions idk?
call {
if (A) exitWith {
if (A1) exitWith {
//code A1
};
if (A2) exitWith {
//code A2
};
};
if (B) exitWith {
...
};
if (C) exitWith {
...
};
};
Transforms into:
hm = createHashMapFromArray [
[
A, createHashMapFromArray [
[
A1,
{
//code A1
}
],
[
A2,
{
//code A2
}
]
]
],
[B, ...]
[C,...]
]
call (hm get A get A1)
of course the best way to set those is with a code that generates it automatically
I have an example of that too but it won't fit here 
ah so I was messing around with the first example then a hour ago
but I didn't continue with it enough
less than 2000 chars? ๐
Or maybe they're just referring to compile /compileFinal
(you won't be doing that if you "cache" the name of the function and load it from uiNamespace)
Hey guys. I'm trying to find a way to set a specific type of ammo on a crew served weapon. From what I've found, I think I should be using the setMagazineTurretAmmo into the turret's init, but I'm not to sure as I keep getting an error whenever I try
what's the error?
and post your code
did a bit more. Ended up stopping the error, but nothing happens
ye 1 sec
vehicle setMagazineTurretAmmo [UK3CB_BAF_23Rnd_40mm_G_Box, 6, UK3CB_BAF_Static_L134A1_Deployed_Low]
&
vehicle addMagazine ["UK3CB_BAF_23Rnd_40mm_G_Box", 15];
pasted into the turret's init
wat?
vehicle setMagazineTurretAmmo [magazineClass, ammoCount, turretPath]
magazineClass is a string
turretPath is an array
Gotcha. I really don't know much of this, so I didn't realize when reading the wiki
could also do [side,string] array keys. Not sure if thats faster in the end, but might be.
Letting all the work be done in a single hashmap lookup, rather than having to recurse down in script
I'll take another shot at this. Thanks for helping!
actually there's one thing better about this. you can have "unequal" lengths:
call (hm get [a,a1])
call (hm get [a,a1,a11])
etc.
I like it! ๐
yeah, you can have only the side.
But not really easy to have a automatic fallback ala (if side+class not found, try only side)
well easy yes but performant
Any ideas on why my paradrop script seems to work locally but not on a server?
(vehicle _player) setPosATL [_position select 0, _position select 1, 2000];
this seems like its the problem
what value did you give _player
when I click somewhere it teleports me for a split second and then tps me back
also post the whole script on sqfbin.com and paste it here
sure, sec
it's remoteexec'd like this: [clientOwner, (getPlayerUID player), _pos] remoteExec ['SG_fnc_paradrop', 2, false];
uhh ok so on the client end
the activation trigger looks like this: sqf _actionid = player addAction [ "Paradrop Vehicle", { openmap [true,false]; titleText ["Select Map Position", "PLAIN"]; onMapSingleClick " [clientOwner, (getPlayerUID player), _pos] remoteExec ['SG_fnc_paradrop', 2, false]; false " }, nil, 5, false, true, "", "" ];
so this is trying to clear the onMapSingleClick on the client after the drop happens
true
I mean if you needed the id the non-public variant was ok. I was asking why you're making it public
set last to false
does setVariable broadcast over the network?
if its true it does
when you set the public flag yes
oh yeah. I think i set that to true at some point but it isnt necessary anymore
yeah I'll remove that
so your script is executing, you are just being teleported and then back again instantly?
@fair drum ok but I want onMapSingleClick to stay that function
like, I want that to be called every time there's a click event until it succeeds
I recommend the stackable version instead
use the actual event handler
what does that mean
Since Arma 3 v1.58 a stackable MissionEventHandler is available and should be used instead: MapSingleClick.
ah ok. and then probably call remoteExec to delete the event handler when the drop is successful
why remoteExec
because the actual drop is run on the server
your addmissioneventhandler is local
right, but how would the local machine know when to remove it otherwise?
I guess I could have a waitUntil position change or something
ok, but I don't want the event to keep firing every time a player clicks on the map
well i do but only until it actually succeeds
then I want it to stop happening
but yeah I'll modify it to use eventhandlers and see if that fixes it. Not sure why that would be the reason I get teleported back though. it seems like I get 1 frame of being in the right spot and then I get sent back
I don't think it does
let me read your script
ok
I have faffed around with Event Handlers and all that (bear in mind I'm not very 'script' minded) and cannot manage to lock the co - pilot seats of my helis? I have the pilot locking working. Any help would be appreciated
this addEventHandler ["GetIn", { if (driver (_this select 0) == (_this select 2) ) then { if (!(vehicleVarName (_this select 2) in allowedPlayers)) then { moveOut (_this select 2); Hint "You are not Allowed!"; }; }; }];
start using params rather than select
this addEventHandler ["Getin", {
params ["_vehicle", "_role", "_unit", "_turret"];
if (driver _vehicle isEqualTo _unit) then {
if (!(_unit in allowedplayers)) then {
moveOut _unit;
hint "You are not Allowed!";
};
};
}];
you might want to add some additional conditions like the type of vehicle though
@brazen lagoon first of all, don't use getPos
second of all, I think the problem is here:
_chute = createVehicle ['i_parachute_02_f', getPos vehicle _player, [], 0, 'can_collide'];
_chute setVelocity _velocity;
vehicle _player attachto [_chute, [0, 0, 2]];
do this instead:
[false,false] remoteExec ["openmap", _caller_id, false];
[_player] spawn {
params ["_player"];
_pos = [_position select 0, _position select 1, 2000];
vehicle _player setPosATL _pos;
waitUntil {getPos _player select 2 < 250};
_velocity = velocity vehicle _player;
_chute = createVehicle ['i_parachute_02_f', _pos, [], 0, 'can_collide'];
_chute setVelocity _velocity;
vehicle _player attachto [_chute, [0, 0, 2]];
waitUntil {(getPosATL _player select 2) < 5};
deleteVehicle _chute;
};
(also I swapped one of your getPosATLs with getPos
(I know I said don't use it but you should here)
what's the reasoning behind not using getPos
it's in AGLS format
but do you want the copilot seat locked at all times no matter what? why not use lockTurret?
https://community.bistudio.com/wiki/position
for parachuting tho you actually need getPos (AGLS)
i 'think' the copilot is considered a gunner
basically its mixing position types?
yes
gotcha
No so what I have is two pilots with their own variable names obviously, and only those two should be able to get into a Pilot, Co-Pilot or Gunner seat.
e.g. a unit in a building that is 10000m tall is at 0 agls height
hmm ok lemme try it out in sp again and then ill test on the server if it works
btw I messed up one part
fix it yourself 
_pos = [_position select 0, _position select 1, 2000];
_position is not defined
oh right
just define pos in the outer scope and pass it as param
well I just changed the spawned script to take in position
@little raptor the problem is this creates the chute at 2000m
which then tps you back up
so I think you do actually need to get the position of the vehicle
oh
I didn't notice the waitUntil
which position did you use?
I hope it's not getPos again
getPosATL
use ASLtoAGL getPosASL
which I think is the one that createVehicle wants?
that's the definition of AGL
on land: AGL = ATL
on sea: AGL = ASLW
makes sense
is your allowedplayers on every client? or did you define it on the server but forget to make it public?
On server, I think ๐, I have an .sqf with allowedplayers and my two pilots with variable names matching. That bit works with locking pilots
@fair drum @little raptor nope, it's still doing it. it's teleporting me for a split second then sending me back
but where is that sqf with the allowplayers variable being fired? only server? or is it in something like init.sqf which all clents run
Oh! init.sqf sorry
are you getting an error at all or is it just not doing anything
So what I sent originally works to lock the pilot. No errors but that is all it does.
I don't know what to add to lock the co pilot/gunner seats
are your allowed players using the same unit class?
like say, a pilot from the editor?
My entire ORBAT is using the same class, team_lead, but I can change that easily
๐ Get ready:
- Apache (Apache Project)
- Wildcat (3CB)
- Griffin (RHS Retexture)
- Chinook (CH-47 Mod)
- Puma (RKSL)
- Merlin (3CB)
If it is simple to get the positions I can do that if you tell me how?
do you want the turrets locked for everyone or just allow the allowed players
copilot is a turret
Only allow the allowed players
may I see the updated version?
figured it out
so load up the vehicle and do a fullCrew vehicle on it and post it
seems to be a race condition of some sort. the first setPos isn't running fast enough so the rest of the code is basically a no-op because the vehicle is never actually set to that altitude
yeah that was my first guess too
I thought passing the position directly to createVehicle would fix it 
yeah it's odd
but nothing a waitUntil won't fix
or shit even just a sleep but that's hacky
Put into the init?
just name the vehicle something and start the game and do it from the command line
[[heliD,"driver",-1,[],false]]
[[heliD,"gunner",-1,[0],false]]
i mean one of the transport helis. and when i say load it up, i mean load it up with full units
this addEventHandler [
"GetIn",
{
params ["_vehicle", "_role", "_unit", "_turret"];
private _turretCrew = fullCrew [_vehicle, "turret", true];
if (driver _vehicle isEqualTo _unit || _turretCrew findIf {_unit isEqualTo _x#0} != -1 || gunner _vehicle isEqualTo _unit) then {
if !(_unit in allowedPlayers) then {
moveOut _unit;
hint "You are not allowed!";
};
};
}
];
just trying to verify that the modded vehicles don't have something that won't work with this
cause I want to see if those modded heli's have their crew members as "turret" like the taru bench does
[[heliD,"driver",-1,[],false],[B Alpha 1-1:7,"cargo",2,[],false],[B Alpha 1-1:8,"cargo",3,[],false],[B Alpha 1-1:9,"cargo",4,[],false],[B Alpha 1-1:10,"cargo",5,[],false],[B Alpha 1-2:1,"cargo",6,[],false],[B Alpha 1-2:2,"cargo",7,[],false],[B Alpha 1-2:3,"cargo",8,[],false],[B Alpha 1-3:1,"cargo",9,[],false],[B Alpha 1-3:2,"cargo",10,[],false],[B Alpha 1-3:3,"cargo",11,[],false],[B Alpha 1-3:4,"cargo",12,[],false],[B Alpha 1-3:5,"cargo",13,[],false],[B Alpha 1-3:6,"cargo",14,[],false],[B Alpha 1-4:1,"cargo",15,[],false],[B Alpha 1-5:1,"cargo",16,[],false],[B Alpha 1-5:2,"cargo",17,[],false],[B Alpha 1-5:3,"cargo",18,[],false],[B Alpha 2-1:1,"cargo",19,[],false],[B Alpha 1-6:1,"cargo",20,[],false],[B Alpha 2-2:1,"cargo",21,[],false],[B Alpha 2-4:1,"cargo",22,[],false],[B Alpha 2-3:1,"cargo",23,[],false],[B Alpha 2-6:1,"Turret",-1,[0],false],[heliG,"gunner",-1,[1],false],[B Alpha 1-1:4,"Turret",-1,[2],false],[B Alpha 1-1:5,"Turret",0,[3],true],[B Alpha 1-1:6,"Turret",1,[4],true]]
Co-Pilot is Alpha 2-6
So it's the chinook, so there are the side gunners on the Miniguns however it classes the end seats of the benches as turrets
I see, well if you don't care about those end bench seats then that will do fine. didn't add the gunner _vehicle isEqualTo _unit though
Right now I don't, we rarely fill up a full chinook. If I did does it become a pain?
Yeah that's fine, I'm just going to check my others hold on
[[grifD,"driver",-1,[],false],[B Alpha 4-5:1,"cargo",4,[],false],[grifG,"gunner",-1,[0],false],[B Alpha 3-3:1,"Turret",0,[1],true],[B Alpha 3-4:1,"Turret",2,[2],true],[B Alpha 3-5:1,"Turret",5,[3],true],[B Alpha 3-6:1,"Turret",7,[4],true],[B Alpha 4-1:1,"Turret",1,[5],true],[B Alpha 4-2:1,"Turret",3,[6],true],[B Alpha 4-3:1,"Turret",6,[7],true],[B Alpha 4-4:1,"Turret",8,[8],true]]
Long and short of it yeah
do you care if non heli crew get into the side turrets on other vehicles like the chinook?
No not particularly, my main effort is to stop those that aren't pilots flying
oh well let me change that then
Understood
this addEventHandler [
"GetIn",
{
params ["_vehicle", "_role", "_unit", "_turret"];
private _turretCrew = fullCrew [_vehicle, "turret", true];
private _copilotName = (_turretCrew select 0) select 0;
if (driver _vehicle isEqualTo _unit || _unit isEqualTo _copilotName || gunner _vehicle isEqualTo _unit) then {
if !(_unit in allowedPlayers) then {
moveOut _unit;
hint "You are not allowed!";
};
};
}
];
try that
fixed
Can this go on any helicopter yeah?
'probably'
Roger ๐
hello, i downloaded arma 3 just today and i was looking at the scrpting page, i was wondering where should i add an event handler, for example, should i use addEventHandler in a file such "initPlayerLocal.sqf"? so when it gets triggered it gets called for the player? and what parameters can i use for "this" before the addEventHandler? i know i can use player but can i use any other entity? if yes, how do i add an event handler for all the entities (both players and bots)?
All of these things depend on the exact type of event handler and what you want it to do
can u be a bit more specific?
Okay so I'm back at work tomorrow and need to sleep so I will test the others tomorrow but it has worked on one of the Helicopters.
https://gyazo.com/961d5e7a63e3cbb7d304d4fe68a4d55e
Cheers for the help, I'll let you know what happens for the rest
do you know any scripting?
not at all
i know some c++
it doesn't look to hard
just need to figure out few things
good
well what you ask doesn't have an easy answer
in multiplayer scripting "locality" is an important concept
downloaded arma 3 and instantly goes to scripting. mah man
there's no straight answer to "where should I put this?"
it depends what commands you're using
I can think of one thing ๐
for example what if i want to hint to everyone played joined the mission?
and what if i want to print player killed this entity?
still for everyone?
in a multiplayer mission?
lots of different concepts in those. read the multiplayer scripting page, locality, and variables pages
the answer to that would be:
- a hint in
initPlayerLocal.sqf - for kiiled: a
killedor (MPKilled) event handler, whichremoteExec(broadcast over network) asystemChatfor everyone
I can show you some docs/tutorials to get started
since you know C++ it won't be hard for you
https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
and the table at the top is really helpful for quickly navigating thru stuff.
you can also find some other learning docs at the bottom
thank you
and this is for multiplayer scripting:
https://community.bistudio.com/wiki/Multiplayer_Scripting
something like this would work?
player addMPEventHandler ["MPKilled", {
params ["_unit", "_killer"];
if (isPlayer _unit && isPlayer _killer) then {
{ hint format "%1 killed %2", name _killer, name _unit} forEach allPlayers - _headlessClients;
}
}];```
?
inside initPlayerLocal.sqf?
not bad for a beginner ๐
but no! ๐
what's the issue there?
first of all your syntax for format is wrong
https://community.bistudio.com/wiki/format
it takes an array on the left
it should be:
format ["%1 killed %2", name _killer, name _unit]
second of all:
EH code will trigger globally on every connected client and server
so you should've only added one hint, notforEach
but I gotta hand it to you, I'm still really impressed that you just installed Arma and got so far! ๐
its basically c++ lol
u just read the wiki
is this better?
player addMPEventHandler ["MPKilled", {
params ["_unit", "_killer"];
if (isPlayer _unit && isPlayer _killer) then {
format ["%1 killed %2", name _killer, name _unit] remoteExec ["hint", -2];
}
}];```
you learned how to use remoteExec already?!
I had to explain it a million times to some people! ๐
anyway, no need for it tho
the EH triggers globally for everyone
okok thx
thx for all the docs and stuff ๐
really appreciate it
๐
np
you might find this useful too:
https://community.bistudio.com/wiki/Operators#Order_of_Precedence
as a programmer you could use it!
it saves you some headaches down the road!
is it the same of c++?
sort of
not entirely
for example >>, or ^ , etc. do not have the same precedence/meaning
@little raptor when you do your switch evaluations using
private _variable = call {
if (blah) exitWith {};
if (blah) exitWith {};
};
i have to add arguments like a traditional call right? or in this instance will it pull in local variables from earlier in the script?
any idea why this addAction doesn't work? It shows up in the listing of actions but doesn't actually seem to trigger.
this addAction [
"HALO Jump",
{
openmap [true,false];
titleText ["Select Map Position", "PLAIN"];
_mh_id = addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
[clientOwner, (getPlayerUID player), _pos, false] remoteExec ['SG_fnc_paradrop', 2, false];
}];
[player, _mh_id] spawn {
params ["_player", "_mh_id"];
diag_log format ["player: %1, id: %2", _player, _mh_id];
waitUntil {!visibleMap || ((getPosATL _player select 2) > 1500)};
removeMissionEventHandler ["MapSingleClick", _mh_id];
};
},
nil, 5, false, true, "", ""
];```
nope. a called code can see the local variables from its caller (parent) scope(s)
like a code in if () {} or while or etc.
this pleases me
how do i repeat an action infinitely?
i crashed with this
while {true} do {
_unit playActionNow "agonyStart";
sleep 1;
}```
also note that in the unary version of call, _this is what would be in the parent scope:
in other words:
[1] call
{
call {
params ["_1"]; //<-works and _1 is now 1
}
}
crashed?!
yes
initPlayerLocal
player addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage"];
_firstTime = true;
if (_firstTime && isPlayer _unit && _damage > 0.9) then
{
_firstTime = false;
_unit setDamage 0.9;
while {true} do
{
_unit playActionNow "agonyStart";
sleep 1;
}
}
}];```
[] spawn {
{ deletevehicle _x;
} forEach (getMissionLayerEntities "hangar" select 0);
shouldn't this delete everything inside of the hangar layer?
its not doing that
ah I see
you need to learn about the scheduled environment too
yeah i guess
what's the problem?
sleep is not allowed in there
gotta have a spawn in there before you can use sleep commands
@polar anchor spawn is sort of like thread detach in C++
but it's not actually multithreaded
oh okk

do you execute that in eden?
the command needs server exec
ughhh... i just started realizing the my VSC formatter for sqf keeps lowercasing random things which screws up my case sensitive things!!!!!
(if you're not doing that in SP)
I tried it in SP first but its not working
oh..
did you check to see if there's anything in the layer?
(getMissionLayerEntities "hangar" select 0)
run this alone in debug console
also if you want to loop an animation it's better to use event handlers (for animations)
such as animDone
its reporting the stuff inside the layer
did you try a couple of systemChats to see where it's not working?
I couldn't see anything
is that the actual code you ran?
it's missing a }
no it doesn't report error for unclosed brackets
I guess they didn't expect my levels of noobness
pepehands.gif
ok thx
how do i spawn code inside an event ?
here's an example that someone posted a few comments ago:
#arma3_scripting message
got it thx
you should also be careful! you may inadvertently overwrite a variable.
that's where private comes into play (it's not necessary otherwise)
two more questions:
i'm trying to do a system where if you die, you don't directly die but u get wounded and u can get healed (haven't finished yet), at the current state i would like to know how can i do something like i did below but working? xd. the two variables outside the event are errors, how would i do something like i meant correctly? second question: i'm adding an event handler inside another event handler, is that corrent? if so what can i do if both of them have one parameter with the same name? how can i distinguish them?
sqfwaitUntil { !isNull player };
private _isFirstTime = true;
private _isKillable = true;
player addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage"];
if (!_isKillable && _damage > 0.9) then
{
_unit setDamage 0.9;
exitWith {}
}
[_unit, _damage] spawn
{
params["_unit", "_damage", "_isFirstTime"];
if (isPlayer _unit && _damage > 0.9) then
{
if (_isFirstTime) then
{
_isFirstTime = false;
_unit setDamage 0.9;
// First time it would be killed, he gets invulnerability for one second
_isKillable = false;
_unit switchAction "agonyStart";
sleep 1;
_isKillable = true;
_unit addEventHandler ["AnimDone", {
params ["_unit", "_anim"];
if (_anim == "agonyStart") then
{
_unit switchAction "agonyStart";
}
}];
}
}
};
}];```
- if there is anything else you would suggest me to improve on i would appreciate it
so say I have a variable peanuts how can I rename that peanuts_1 etc for indexes. if it was a string I would have just done "peanuts_" + str _i to get my "peanuts_index"
like bad syntax or stuff like that
use setVariable with that string option?
yeah that was my backup plan. didn't know if there was a way with global variables
missionNamespace setVariable is global variables (if executing in the missionNamespace)
will _forEachIndex work inside of an apply?
the two variables outside the event are errors
ok, so first of all, you're using local variables. local variables are preceded with an underscore_
a local variable is only visible to the current scope and scopes created directly from the current scope (called, if, while, etc.)
an event handler is not a "direct scope" (it is executed somewhere else)so it doesn't see your variable
second of all, you can use the unit's "namespace". check setVariable
i'm adding an event handler inside another event handler, is that corrent?
not really. at least not the way you did it
another issue with your code is that you should return something with your handleDamage EH. it's not overriding the damage right now
in sqf, to return something, you end the code with a statement that returns a value:
call {
1; //returns 1
};
call {
alive player; //return a bool
};
note that this is wrong:
call {
_alive = alive player; //return nothing
};
no
@polar anchor another issue with your code is the exitWith
it takes an "IF" on the left
if (cond) exitWith {};
๐ซ๐ณ
and you might wanna take a look at lazy eval for conditional statements:
if (a && {b && {c}}) exitWith {};
```it's a bit more advanced
2am donโt blame me ๐
What about those 2 private variables?
How can I use them outside the EH?
I explained them
I tried removing the _ but getting the same result
So is the _ implicitly setting a variable privateโs
you shouldn't put private then
?
private is a different concept
I obv removed the private keyword too
a local variable is not necessarily private
private is like declaring a new variable in a new scope:
_a = 1;
if (true) then {
private _a = 2; //this _a is private to this scope
};
_a; //_a is 1
Is _ just a convention?
anyway, you should've used "namespaces" instead
would this get me the intended result of skipping a vehicle spawn if the vehicle that was created last loop is still alive? (loop and other stuff not shown) launcher is basically the silo or capture point
https://sqfbin.com/iyuxuyudawewojiyuhay
no
it actually makes the variable local
the variable is destroyed when the scope ends
if (_type == "attackheli") exitwith {};
if (_type == "mrap") exitwith {};
if (_type == "quad") exitwith {};
if (_type == "tank") exitwith {};
if (_type == "truck") exitwith {};
if (_type == "antiair") exitwith {};
if (_type == "apc") exitwith {};
``` 
But isnโt it already local to the scope of where u declare it?
haven't put anything there yet
This is an example of the array being pulled in earlier
L2_arudy_vehicle_positions = [
["tank", [5667.15, 6990.76, 0], 234],
["apc", [5653.15, 7003.32, 0], 167],
["antiair", [5666.75, 7013.35, 0], 199],
["truck", [5621.29, 7019.85, 0], 176]
];
are you facepalming that I didn't put anything there yet for the exits, or that its a garbage way of doing a huge switch do lol?
So without _ itโs global and with it itโs local, indipendently of where u declare it (scope)?
I think the page R3vo linked explains it well enough:
https://community.bistudio.com/wiki/Variables#Local_Variables_Scope
Btw gotta go now thanks for you help, tomorrow Iโll try to understand better
Thanks ๐
np
Flesh out the script, then ask again. Half of the stuff is missing
I ommited stuff since I thought it wasn't nessisary for you to read through it all... here's full so far.
and call {...exitWith} will not exit your script if that is what you wanted
I haven't put anything in the exitWiths yet for that section. but in the first section with the positionsarray is what I'm going for in the end
ill fill them in real quick
I still don#t get your ealier question
If you wanna check if the vehicle is still alive then just save it in a global var and do alive Myvehicle
its gonna be potentially an array of 10s of units. let me flesh it out and give you a full view of it
@cosmic lichen
https://sqfbin.com/azijimuzigusuhibutux
nvm I figured something out with using set and the array
your code is the perfect fit for a hashmap 
ooone day i'll get to learning them lol
what would be the best way to learn how to make a large 3d plasma shield dome (or even something simple like what a trigger looks like in the editor or ingame with visible triggers turned on)? would it require some sort of 3d model import? maybe I could do it with a particle effect? not sure where to start
like the draw trigger areas in preferences ( i think its 3den enhanced tho)
idk how editor does it, but there is a 3d sphere virtual object. maybe scale that to the size you need ๐คท
i think that has collision though. let me try to fly a plane through it. i need something with no collision
it actually doesn't. thats nice
that actually looks perfect with some tweaks!
https://ibb.co/9WC9V5g
could probably add an electric type texture
They're just like array of [key, value] pairs. Except they provide "constant time lookup" for keys. (unlike arrays, you don't have to go thru the elements one by one to find them; a hash function will calculate what it "maps" to and takes you there, which can be significantly faster if you have lots of elements)
Basically they're similar to this array:
[
[key1, val1],
[key2, val2],
...
]
If you have key1, you get val1 without having to loop through the elements, etc.
Good day. Is there a way to get all the subfolders of the certain folder inside mission? And get all the filenames inside subfolder
I don't think there's a command to get every files in a mission folder
Pity. Thanks.
One thing you can do is to make a ticket and spam @dedmen (jk) ๐ค
ั ะ nah, I think I'll find something to do by myself about it
The thing I did to achieve similar is list every files in a file ๐
I thought about writing some console app which will output "createHashMapFromArray" argument for me. It's not the same as "add some files and they'll be handled" but shitty instrument is better than nothing at all.
Im looking to make a tool that measures distance that the bullet has travelled once fired, yet simply dont know how id start, id appreciate any help.
no
no, probably not. Accessing files on disk directly rather not
So slightly different thing is required than addonFiles?
Got it, thanks
Mmm... is it me you asking?
Nop, for Ded
ยฏ_(ใ)_/ยฏ
Anyone know a good way to check if a player is walking up a steep hill (which would force them to walk as apposed to run when holding shift)
Can I compile .fsms the same way as .sqfs?
BIS_fnc_function = compileFinal preprocessFileLineNumbers "filepath/file.fsm";
No
you exec fsms via execFSM
Also, use compileScript instead of compileFinal and preproc.
But there has to be a way to compile them into a variable like e.g. BIS_fnc_WLAICore, BIS_fnc_WLAIPurchases, BIS_fnc_WLGarrisonRetreat etc.
https://community.bistudio.com/wiki/Category:Function_Group:_Warlords
There's no way. If you're using CfgFunctions you can define a function that points to FSM but it's just a wrapper function that does execFSM under the hood.
no need to use compilescript ...
The question is can I have the scripts outside of the mission folder?
In an addon, yes. I don't see how it's related to "compiling" an fsm into variable.
Because you can store .sqf-scripts outside of the mission folder and then compile them into a variable thus preventing the script itself from being downloaded...
its recommended
so you want a serverside only fsm that clients cannot see?
you can execFSM on server.
But you cannot execFSM on client and get a file that only the server has and transfer it to client
So all FSM-files that a client has to execute have to be part of the mission-folder?
yeah
they can be in an addon too
atleast I don't know a way not to
Ok, thanks.
hey, i'm learning how to make GUIs but i am always getting an error "Resource not found" when i try to show it.
This is my Description.ext:
#include "BaseComponents.hpp"
#include "MyComponents.hpp"
this is MyComponents.hpp: https://pastebin.com/g5vVAjRr
and this is BaseComponents.hpp: https://pastebin.com/FD9BUqTv
what's the issue?
openDialog?
well cutRsc won't work because you need to define the resource in RscTitles, but createDialog should work ๐ค
with what he has right now it should show up
0
false
i know it doesn't find that class but why
i've done everything correctly (?)
๐ค
maybe because of the missing ; at the end?! 
description.ext.txt perhaps? ๐คฃ (no idea)
why not use import ?
o.o
still not working
but thx
nope
wdym?
https://community.bistudio.com/wiki/import it's some new stuff for importing classes into mission config
Works for me ยฏ_(ใ)_/ยฏ
wtf
ye
ok cool thx
import RscPicture;
import RscCombo;
import RscText;
import RscButton;
class Test
{
idd = 5000;
class ControlsBackground
{
class PictureBackground: RscPicture
{
idc = 1200;
text = "#(argb,8,8,3)color(0,0,0,0.5)";
x = 0.391719 * safezoneW + safezoneX;
y = 0.368 * safezoneH + safezoneY;
w = 0.221719 * safezoneW;
h = 0.275 * safezoneH;
};
};
class Controls
{
class ComboWeapons: RscCombo
{
idc = 2100;
x = 0.490719 * safezoneW + safezoneX;
y = 0.4285 * safezoneH + safezoneY;
w = 0.0876563 * safezoneW;
h = 0.022 * safezoneH;
};
class TextWeapon: RscText
{
idc = 1000;
text = "Weapon:"; //--- ToDo: Localize;
x = 0.438125 * safezoneW + safezoneX;
y = 0.423 * safezoneH + safezoneY;
w = 0.0360937 * safezoneW;
h = 0.033 * safezoneH;
};
class ButtonGive: RscButton
{
idc = 1600;
text = "Give"; //--- ToDo: Localize;
x = 0.475766 * safezoneW + safezoneX;
y = 0.58624 * safezoneH + safezoneY;
w = 0.0515625 * safezoneW;
h = 0.022 * safezoneH;
};
};
};```
restart
you must close it
ooooooooooooooof
go back to eden and come back
just hit save
in eden editor
then do findDisplay 313 createDisplay "test"
no need to ever preview the mission
works
Every time you do a change, hit save
yw
one more question: why 313 as idd?
.
313 is the Eden Editor display IDD
eden display
common displays:
313 eden
46 mission
12 map (and displayCtrl 51 is the map ctrl)
49 pause display
49 is escape, 12 is map
right! ๐
Nice party knowledge there
is there a way to get the config ref from a class name?
I know i can do this on an object "configOf player;" but i have class names in an array id like to look the display name for but they are not all in cfgVehicles.
if your going to go that way I think this would be better.
private _config = [
"CfgVehicles",
"CfgWeapons",
"CfgMagazines",
"CfgAmmo",
"CfgGlasses"
] select {isClass (configFile >> _x >> _x_object_type)} select 0;
private _x_object_name = getText (configFile >> _config >> _x_object_type >> "displayName");
no
yes
ok so how does yours solve my problem? yours returned a number.
it wasn't the full answer genius
you were supposed to adapt it
hey, cool down
ok genius, then you didnt help
both of you ๐
thats what i did. you post something partial, someone adapts it and gets a solution. so ive done everything you wanted me to do.
ok yeah im walking a way now.
Hello. I want to make interactive pop-up dialog sequences, and add some dialog critical choices that change side relations in-game. But I have zero experience with scripting.
- Can someone point me in the right direction and/or give me tips to get started?
- Should I make something simpler first?
- (Willing to spend hours tweaking code)
@tough abyss google arma create ui tutorial. You will find all links and vids that will help you get started.
@still forum @little raptor
It may not be the best but I went with this, hope its useful to someone else.
private _x_object_type = _x select 0;
private _config = ("true" configClasses (configFile)) select {isClass (_x >> _x_object_type)} select 0;
if !(isNil "_config") then
{
private _x_object_name = getText (_config >> _x_object_type >> "displayName");
_ctrl_object_id = _ctrl lbAdd _x_object_name;
_ctrl lbSetData [_ctrl_object_id, _x_object_type];
};


thats pretty terrible actually
configFile >> configname _x
thats nonsense.
_x == configFile >> configname _x
already. You're walking backwards just to be able to walk forwards again
Also your ("true" configClasses (configFile)) is nonsense for classnames.
classnames can only be in CfgVehicles, CfgWeapons, CfgMagazines, CfgAmmo, CfgGlasses or UI classes which your code wouldn't find
hi, how can i manipulate a path using variables example:
if ((uniform player) in ["uniform_1", "uniform_2", "uniform_3"])
then {_myVar = "blk"} else {_myVar = "wht"};
player setObjectTextureGlobal [3, "path\to\imgae\custom_"_myVar"\file_"_myVar".paa"];
This for example won't work and i wasn't find a clue to solve this by myself. Hope some one can give me a tip.
do you really need to lookup entire config like that?
no you don't
This was alot better already
yeah
and with findif it would be even better, like Leopard posted
not sure why some people insist on making backwards steps 
also missing )
Yes i see was free typing ๐ ^^
yes so origannly i wanted a solution just for display names. Then i thought id make something that would work allow you to look up any thing by class name or what ever if i want it for terrain objects so i wrote what i posted.
This is what im using for my UI though. hope it makes you all happy.
private _config = [
"CfgVehicles",
"CfgWeapons",
"CfgMagazines",
"CfgAmmo",
"CfgGlasses"
] select {isClass (configFile >> _x >> _x_object_type)} select 0;
if !(isNil "_config") then
{
private _x_object_name = getText (configFile >> _config >> _x_object_type >> "displayName");
_ctrl_object_id = _ctrl lbAdd _x_object_name;
_ctrl lbSetData [_ctrl_object_id, _x_object_type];
};
also if x then {_myVar = "blk"} else {_myVar = "wht"};
can be written as
_myVar = if x then {"blk"} else {"wht"};
or
_myVar = ["wht","blk"] select x
select is the most optimal here
findIf might be slightly better
yes, due to all the config lookups findIf will probably be better
oh yeah, i meant what you wrote
ah :u
Can publicVariable event handlers contain e.g. waitUntil?
no, it's unscheduled.
if I am making an array, can I put [] as one of the items in the array to make it empty?
for example, I want it to randomly select a weapon, but I want there to be a chance that it will not select any weapon
Weapons as in weapon class names?
""
not like that:
["weapon1", "weapon2", ""]
if you want to have a certain chance better use random
if it is a weapon with a magazine, would it be ["",""]
this will have a 1/nth chance of being selected
yea
my array looks like this:
_weaponArray = [["weapon1", "mag1"], ["weapon2", "mag2"], ["", ""]];
would that work the way I want it to?
Is it possible to change a config property for ammo through a script? Trying to make flare rockets with changeable fuse distances and want to know if it's worth attempting.
like I said, depends what you want.
this will give it a fixed chance, regardless of number of weapons:
_weapons = [
["wpn1", "mag1"],
["wpn2", "mag2"],
...];
_wpn_mag = if (random 1 > 0.05) then {
selectRandom _weapons
} else {
["", ""]
}
its alright, i dont need a specific chance
if you have, say, 1000 weapons, the chance of getting ["",""] will be pretty slim
No, you can't change config via script.
using what I said would be easier
and saves you typing
Any suggestion on how to go about making an interaction that changes the fuse on a rocket? Make different rockets with different fuses and have it just change the ammo in the vehicle?
Best ask that in #arma3_config, they know how to perform that kind of sorcery.
what would 2 + (round random 2) be?
2,3,4

would this code repeat 5 times?
r = 0;
while {r < 5} do {
//code
r = r + 1;
};
for
yes
https://pastebin.com/3mGXkyqu ok the code is working so far, when used in the Debug Console, but as function it won't work, the path that i want to generate using the suggested format Command returns in the function any instead of blk or wht.
aby means undefined variable
private _ranksColorSwitch = "blk";
_ranksColorSwitch =
thats nonsense, why set it twice right next to eachother.
Just
private _ranksColorSwitch = if
Is there any way to make music play in a 3D environment ?
"suggested format Command returns in the function any instead of blk or wht." which one exactly?
say3D
if defined in cfgSounds say3D
otherwise playSound3D
I've tried that but for some reason it doesn't play
Do you have it in CfgSounds?
It's from a mod called Rome Music
You mean this one with the typoed v at the end?
format ["\gm\gm_characters\gm_ge_characters\data\uniform\ranks\army_%1\gm_ge_or4_osg_%1.rvmat", _ranksColorSwitchv]
you need to put the music piece into CfgSounds. if its a music mod it will only have it in CfgMusic
How would i do that?
@wicked roost !wiki Description.ext#CfgSounds when?
@wicked roost ๐
Even the first format returns any but i think it's maybe an issue in my way of thinking. Can it be the case that the Path in this ACE Command would be still saved as format ["\gm\gm_characters\gm_ge_characters\data\uniform\ranks\army_%1\gm_ge_or1_s_%1.rvmat", _ranksColorSwitch] instead of "\gm\gm_characters\gm_ge_characters\data\uniform\ranks\army_blk\gm_ge_or1_s_blk.rvmat"?
no....
yes?
I don't understand that question. doesn't make sense to me
add diag_log and check
sounds like your _ranksColorSwitch is nil, did you really send the full script or did you copy-paste snippets together?
if the entire format returns any that's not why
Ah derp
Your variable is undefined
You're not passing it to the script inside the action
And as far as I can see ace_interact_menu_fnc_createAction doesn't give you the ability to specify arguments
_handleSidePlayer = [_requestID, _side] spawn WFBE_CO_FNC_MonitorHandleSkills;
if (_side == west) then {
_opposingSide = east;
} else {
_opposingSide = west;
};
_handleOpposingSidePlayer = [_requestID, _side] spawn WFBE_CO_FNC_MonitorHandleSkills;
publicVariable "WFBE_SRV_VAR_RequestPlayerSkill";
["INFORMATION", format ["RequestSkill.sqf: Waiting for the team score calculation threads to finish... _requestID: %1", _requestID]] Call WFBE_CO_FNC_LogContent;
waitUntil {(scriptDone _handleSidePlayer) && (scriptDone _handleOpposingSidePlayer)};
(NOTE! Arma 2) Any idea why the last line throws a "Generic error in expression"?
Possible fixes are , make it a global variable, or setVariable it onto the player, or compile your action statement from string, or check the players uniform everytime inside the action statement
if you don't expect the player to change uniform (which you already aren't checking), I'd say just make it global variable
can I use addItemCargoGlobal to add both magazines and vests to a container?
waitUntil {(scriptDone _handleSidePlayer) && (scriptDone _handleOpposingSidePlayer)};
wat?
just call them
you can try, probably not
ok
magazines aren't
so addItemCargoGlobal works for a vest, right?
i dont have arma open rn
backpacks and weapons are also CfgWeapons but they also have seperate commands
backpacks are vehicles

ok so what is the command for a vest?
addItemToVest
bro why does no one know
because we haven't tried
I mean yes
is it:
Yes, No, or I don't know?
yes
Half the fun is trying to solve problems yourself without any help ๐ (imho)
try and write on wiki ๐
this is basically my question:
Which of the following works on both Vests and Magazines?:
addItemCargoGlobal addWeaponCargoGlobal addMagazineCargoGlobal
im guessing its not the third
addItemCargoGlobal
as I told you
it also works on weapons
perhaps the addItemCargoGlobal command was later updated to support weapons and mags
it works on everything you carry besides the backpack
addItemCargoGlobal should still work in singleplayer, right?
ye
okie
_weaponArrayOne = [
["srifle_EBR_F", "20Rnd_762x51_Mag"],
["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2,
["arifle_MXM_F", "30Rnd_65x39_caseless_mag"],
["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2,
["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"],
["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2,
["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2,
["", ""], 3];
r = 0;
while {r < 4} do {
_weaponAndMag = selectRandomWeighted _weaponArrayOne;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addWeaponCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
r = r + 1;
};
_weaponArrayTwo = [
["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2,
["LMG_03_F", "200Rnd_556x45_Box_F"], 2,
["launch_RPG7_F", "RPG7_F"],
["V_HarnessOGL_brn", ""],
["",""], 4];
r = 0;
while {r < 2} do {
_weaponAndMag = selectRandomWeighted _weaponArrayTwo;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addItemCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
r = r + 1;
};
_itemArray = [
"HandGrenade",
"optic_Arco_blk_F", 2
"optic_Hamr", 2];
r = 0;
while {r < 2} do {
_item = selectRandomWeighted _itemArray;
if (_item == "HandGrenade") then {
AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
}
else {
AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
};
r = r + 1;
};
any idea why this isnt working in the init.sqf file?
nothing happens. i dont even get an error message
and AirdropCrate is the name of the container that I want this stuff added to
what
why not just use a for loop
what is this mess :u
and why global variables for your loop iteration, and why global variables without tag
global variables should always have a tag, and use local variables if you don't need global, like here.
What are these empty weapon classnames?
Why are there duplicates in there?
Do you know that selectRandomWeighted exists?
you are missing private's on your variables
Why are you using addWeaponCargo for the weapons at the top, but then use addItemCargo for the weapons in the middle?
select 0;
select 1;
just use _weaponAndMag params ["_weapon", "_mag"]
uhhhhh
dont worry about it
the reason im using addItemCargoGlobal for the second weapon array is because there is a vest included
it doesnt matter tho
@still forum what is the reason that im not getting anything added to the crate? is it because of the variables?
I just see a huge mess ยฏ_(ใ)_/ยฏ
but i dont know why its not working
is there anything about it that would make it not work?
_item == "HandGrenade" that will never work and only trigger error, an array can never equal a string
but _item = selectRandom _itemArray
no but
which is an array of array of strings
oh
does the _itemArray look better now?
all of them do
got it
i dont know how to use weighted
then we can explain?
sure
Learning new things trains the brain, can recommend
https://community.bistudio.com/wiki/selectRandomWeighted
selectRandomWeighted ["a", 1, "b", 2]``` is the same as ```sqf
selectRandom ["a", "b", "b"];
yes
ok
just put the weight next to each element
_itemArray = [
"HandGrenade",
"optic_Arco_blk_F",
"optic_Arco_blk_F",
"optic_Hamr",
"optic_Hamr"
];
selectRandom _itemArray
->
_itemArray = [
"HandGrenade", 1,
"optic_Arco_blk_F", 2, // 2x chance
"optic_Hamr", 2
];
selectRandomWeighted _itemArray
The commata have been added

Q: re: HASHMAP is there a way to get the values in the same way we get the keys?
Or must we do this: _hashmap apply { _x#1; }?
no, no
apply doesn't support hashmap as wiki says
cool, good to know, ty
you must use forEach
or rather have to take a long way round it then, introduce a function that does it
does it look better now?
_weaponArrayOne = [
["srifle_EBR_F", "20Rnd_762x51_Mag"], 1,
["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2,
["arifle_MXM_F", "30Rnd_65x39_caseless_mag"], 1,
["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2,
["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], 1,
["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2,
["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2,
["", ""], 3];
r = 0;
while {r < 4} do {
_weaponAndMag = selectRandomWeighted _weaponArrayOne;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addWeaponCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
r = r + 1;
};
_weaponArrayTwo = [
["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2,
["LMG_03_F", "200Rnd_556x45_Box_F"], 2,
["launch_RPG7_F", "RPG7_F"], 1,
["V_HarnessOGL_brn", ""], 1,
["",""], 4];
r = 0;
while {r < 2} do {
_weaponAndMag = selectRandomWeighted _weaponArrayTwo;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addItemCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
r = r + 1;
};
_itemArray = [
"HandGrenade", 1,
"optic_Arco_blk_F", 2
"optic_Hamr", 2];
r = 0;
while {r < 2} do {
_item = selectRandomWeighted _itemArray;
if (_item == "HandGrenade") then {
AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
}
else {
AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
};
r = r + 1;
};
"1"
HASHMAP get values function, i.e.
private _getHashMapValues = {
private _map = _this;
keys _map apply { _map get _x; };
};
forEach is faster
how so? illustrate...
_vals = [];
{
_vals pushBack _y;
} forEach _map;
you are taking the keys and copying them, then iterate through all of them and do a hashmap lookup for EVERY key
forEach just iterates once, no lookups, no keys fetching, no keys copying

No you don't
yes, yes I do
You don't have to ask a question that you already received the answer to
I am trying to shave a pushBack operator out of it... ๐
pushBack is fast
it may not be as fast as apply tho (I think it preallocates too)
assuming apply de-cons to _x, _y, etc
speaking about arrays here
forEach works for HASMAP? that was the question.
yes
!wiki HashMap
lol you wish
I do ๐ฆ
foreach with hashmaps doesn't set the _forEachIndex, but i guess it's intended right? doesn't make a lot of sense to provide it
it does
๐ค
_hm = createHashMap;
_hm set ["1",1];
{
_forEachIndex
} forEach _hm
5.12395e+008
๐ค
I can't see how it'd be useful either way 
the order never stays the same
it might be intuitive, who knows.
but then again SQF expects a semi-colon after curly brace close, so...
and it doesn't cost me anything to give you a counter
apply and select and findIf then?!
exactly. or any other array operator support for it.
I also created a system that lets me add a _forEachIndex to every loop
together with the continue/break
just been too lazy to make a command for it
verified apply does not support hashmap, assuming select neither
@little raptor I can understand the thing you got muted for now
wat? 
At some point you just gotta get out the block button, its healthier
What do you mean verified, HashMaps are new and their documentation is complete, it went straight through #community_wiki...
I also don't understand why someone needs to verify something thats written on wiki and that the guy who friggin made hashmaps already literally told you directly just minutes ago.
But some people...
I'm sure it is accurate; pardon me if I don't take your word for it @still forum , or anyone's.
Sorry guys, i had to go for a little. so this is what i have. does the code look like it should work? or are there still problems with the variables? this is being tested in singleplayer but its intended to be multiplayer. its in the init.sqf file
_weaponArrayOne = [
["srifle_EBR_F", "20Rnd_762x51_Mag"], 1,
["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2,
["arifle_MXM_F", "30Rnd_65x39_caseless_mag"], 1,
["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2,
["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], 1,
["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2,
["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2,
["", ""], 3];
r = 0;
for "_i" from 1 to 4 do {
_weaponAndMag = selectRandomWeighted _weaponArrayOne;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addWeaponCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
};
_weaponArrayTwo = [
["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2,
["LMG_03_F", "200Rnd_556x45_Box_F"], 2,
["launch_RPG7_F", "RPG7_F"], 1,
["V_HarnessOGL_brn", ""], 1,
["",""], 4];
r = 0;
for "_i" from 1 to 2 do {
_weaponAndMag = selectRandomWeighted _weaponArrayTwo;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addItemCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
};
_itemArray = [
"HandGrenade", 1,
"optic_Arco_blk_F", 2
"optic_Hamr", 2];
r = 0;
for "_i" from 1 to 2 do {
_item = selectRandomWeighted _itemArray;
if (_item == "HandGrenade") then {
AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
}
else {
AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
};
};
is 3 the number of times the code repeats?
no, it's "from 0 to 3" so 4 times
but you can also do "from 1 to 3"
could I do from 69 to 420
yup
cool
would be 420 - 69 + 1
so #352 he he
repeats twice
yes
ok
thanks
i also have one that repeats 4 times
you know whats even better than using for or a while loop with a variable?
just copying and pasting the code as many times as you want it
works every time ๐
what if you want to change the code?
or, a bit slower but maybe a bit simpler to read:
{ } forEach [1, 2, 3, 4];
resize 4
there is still nothing in the crate
and im not getting any error message or anything
any ideas why its not working?
where do u exec?
what is airdropcrate?
AirdropCrate is the variable name of a container in-game
logging
If you see your log message, you know that line of code executed
log some variables too, and you know that line of code executed and what the variables were
_weaponArrayOne = [
["srifle_EBR_F", "20Rnd_762x51_Mag"], 1,
["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2,
["arifle_MXM_F", "30Rnd_65x39_caseless_mag"], 1,
["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2,
["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], 1,
["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2,
["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2,
["", ""], 3];
for "_i" from 1 to 4 do {
_weaponAndMag = selectRandomWeighted _weaponArrayOne;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addWeaponCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
};
systemChat "Test";
_weaponArrayTwo = [
["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2,
["LMG_03_F", "200Rnd_556x45_Box_F"], 2,
["launch_RPG7_F", "RPG7_F"], 1,
["V_HarnessOGL_brn", ""], 1,
["",""], 4];
for "_i" from 1 to 2 do {
_weaponAndMag = selectRandomWeighted _weaponArrayTwo;
_weapon = _weaponAndMag select 0;
_mag = _weaponAndMag select 1;
AirdropCrate addItemCargoGlobal [_weapon, 1];
AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
};
systemChat "Test";
_itemArray = [
"HandGrenade", 1,
"optic_Arco_blk_F", 2
"optic_Hamr", 2];
for "_i" from 1 to 2 do {
_item = selectRandomWeighted _itemArray;
if (_item == "HandGrenade") then {
AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
}
else {
AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
};
};
systemChat "Test";
So instead of asking "where in these dozens of lines of code could something be broken" you know
"Ah, this works, but this doesn't, so the problem is somewhere inbetween"
when I say everything I literally mean everything
put a log message everywhere where you want to know whether something happened
ok
@still forum I put in 3 test messages in system chat and I am not getting any messages in system chat
there is no chat in singleplayer, do you have a chat at all?
you can either use local MP preview, or use diag_log.
But diag_log is annoying if you don't have a second monitor and some tool that live-updates your log
give use diag_systemChat please which eats anything ๐
some people use hint for that, but hint only shows a single message
and i really have no clue what anything youre talking about is
no
if you have a syntax error, it won't compile, and nothing will run
Dunno if compile errors are displayed ingame
ive always gotten error messages when there is an error in my script
what is compile?
in general ingame error messages are basically always sub-par.
Should always check RPT for errors
scripts get compiled
what is RPT?
Arma has a wiki
its almost 1 AM I can't explain you the basics of scripting.
See Arma wiki for diag_log, RPT, compile
ok
are mission event handlers not working on multiplayer and vice versa?
ok ty
Quick question, in order to actualise variables/flags/etc. for a new player joining in an MP scenario, is there any other way to do it besides doing getVariable a whole bunch of times?
Hello everyone, just a quick question, i'm trying to call a code from an SQF in my mission, it is aimed at setting the same animation for certain units, at the current time it is not working but i don't know why:
animation.sqf:
_unit = _this select 0;
[] spawn {
waitUntil {time > 0};
while {true} do {
_unit switchMove "AmovPercMstpSnonWnonDnon_exercisePushup";
sleep 16;
};
};
On unit's init:
test1 = [this] execVM "scripts\animation.sqf";
But it says: _unit is not defined
_this select X
is only used when dealing with params of a function. If that's all the code you have in animation.sqf, there's no need to declare _unit. You can replace _unit with _this and it should work.
oh, ok thanks, but ai'nt "switchMove" a function?
_this spawn {
params ["_unit"];
waitUntil {time > 0};
while {true} do {
_unit switchMove "AmovPercMstpSnonWnonDnon_exercisePushup";
sleep 16;
};
};
you can just send it right into the sleep scope is what he means
if you use setVariable and use its 3rd param, set global, to true, it will become global and persistent
so it will auto pull from the server when a new player joins
or did i just misread your question
_this select X is used after calling the function, kinda. To give an example, addAction has a number of params for the script part:
unit addAction ["Test", {
params ["_target", "_caller", "_actionId", "_arguments"];
}];
If want to declare a variable as _target or _caller you do
unit addAction ["Test", {
variable1 = _this select 0;
variable2 = _this select 1;
so now variable1 is _target and variable2 is _caller. In this case, _this refers to the "params" array, "_this select 0" simply means you're choosing the first item of the array.
It's a bit difficult to explain in words exactly, but some of the functions will have a "params" array that you can then select from, it's best to check the wiki
Oh ok, so for it to work it needs multiple parameters