#arma3_scripting
1 messages · Page 776 of 1
params [
["_centre", getPosASL player, [[]]],
["_radius", 250, [0]],
["_dir", random 360, [0]]
];
_pos = _centre getPos [_radius, _dir];
_pos set [2, _center#2];
_bolt = createVehicle ["LightningBolt", _pos, [], 0, "CAN_COLLIDE"];
_bolt setPosASL _pos;
_bolt setDamage 1;
``` gave an error
what error?
you wrote both _center and _centre
well the code isn't strictly correct tho
if the terrain is not flat what I wrote is wrong
better use AGL format
params [
["_centre", getPosASL player, [[]]],
["_radius", 250, [0]],
["_dir", random 360, [0]]
];
_pos = _centre getPos [_radius, _dir];
_bolt = createVehicle ["LightningBolt", _pos, [], 0, "CAN_COLLIDE"];
_bolt setPosASL AGLtoASL _pos;
_bolt setDamage 1;
it will always strike at the "ground" (sea if sea, terrain if terrain)
what I wrote before might've given you a position under the terrain if you tried it on a mountain for example
all players should be able to see this right i dont need to do remoteex since its not createvehiclelocal
?
so vice versa ?
Can someone help me with a script for making a respawn point off a back pack. I have it working for the most part, except the the respawn module does not always deploy at the backpack (pack) position...
So far i have
`if (hasInterface) then
{
// ------------------------------------------------------------------------
_allowDeployRespawn = player getVariable ["allowDeployRespawn",false];
if !(_allowDeployRespawn) exitWith {};
// ------------------------------------------------------------------------
// deploy respawn
player addAction ["Deploy Respawn",{
[west, pack, "Camp"] call BIS_fnc_addRespawnPosition;
},nil,1.5,true,false,"","",3,false,""];
// ------------------------------------------------------------------------
};`
What is pack?
idk what you mean by vice versa
There's nothing two way about this
Doesn anyone have a working zombie script that changes civies into zombies? I searched online for it, and either i got people asking for money, or broken links
zombies need animations
You can't do that with scripts
You need some zombie mod
There's a ton of those on the workshop
I've been in a vanilla official zeus session and this guy had zombies everywhere, it was so cool
You sure they weren't a bunch of wounded civilians?!
Because vanilla doesn't have zombie anims
they were hunched over running, different "styles" like runners, quiet ones, and a boss zombie like a windego
thw boss zombie wore like a giant deer head with antlers, wearing a ghillie suit
it could jumo as high as buildings and shit, was super cool. wasn't sure how to replicate that on vanilla
i'd very much like to learn how this is done so i can get other zeus to do it and have immense amounts of zombie slaying fun
Hey guys, I'm doing a spawn script, but I'm having trouble setting an identity to the spawned jet. Anyone know of a simple line to name the spawned object? ```_airframe1 = [getMarkerPos "marker1", 140, "B_Plane_Fighter_01_F", west] call BIS_fnc_spawnVehicle;
_crew1 = _airframe1 select 2;
_wp1 = _crew1 addWaypoint [getMarkerPos "marker2", 0];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "CARELESS";
_wp2 = _crew1 addWaypoint [getMarkerPos "marker3", 0];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "CARELESS";
_wp2 setWaypointStatements ["true", toString {_veh = vehicle this; deleteVehicleCrew _veh; deleteVehicle _veh}]```
Hello everyone, is it possible to use setVelocity and setVectorUp simultaneously in a loop? When creating a loop like this, the object does not respond to setVelocity, but if you remove setVectorUp, then everything is fine
addMissionEventHandler ["EachFrame", {
_vUp = ...some calculations...;
_velocity = ...some calculations...;
myObject setVectorUp _vUp;
myObject setVelocity _velocity;
}, []];
Put setVelocity last
But you're doing that
So it should already be good 
Since when do vehicles have names?
trying to set a variable name so i can use triggers in game for it
tried lines like _veh setVehicleVarName "jet1"; missionNamespace setVariable ["jet1", _veh, true]; but didnt work
ofc it doesn't work because _veh is not defined
oh, no I defined it with the _airframe1. but still didnt work 😮
_airframe1 is an array
the vehicle is the 1st or 2nd element in the array
Not sure which
Check the wiki
oh wait. so if I define the vehicle, like B_Plane_Fighter_01_F it should work?
No
Just check the wiki
Array format [createdVehicle, crew, group]:
_veh = _airframe1#0
it worked! but still a bit confused. why the #0 ?
Tested it like this, instead of calculations I set standard values. Unfortunately, the object was moving, but not smoothly, it was constantly jerking. In general, it seems that currently in Arma it is impossible to simultaneously change the vector of an object and push it via setVelocity
addMissionEventHandler ["EachFrame", {
_vUp = [0, 0, 1];
_velocity = [20, 0, 0];
myObject setVectorUp _vUp;
myObject setVelocity _velocity;
}, []];
# 0 means select 0 as in "take the first element of the array"
ah got it thanks
Anyone know what is wrong with this line?
{_vehicle unassignVehicle _x} foreach units _group;
(I'd like to use this on a waypoint activation )
I defined it
Ah wait...
haha I didn't name the vehicl.. i named the unit in the vehicle 😛 XD
Thanks
(unassignVehicle only takes a single unit parameter)
Nope- still getting error:
On activation: (Thats it)
Missing ;
{QRF_Veh unassignVehicle _x} foreach units QRF_1
An error tells nothing without the actual code, show us
^this^
Aight. I used this instead.
{ unassignVehicle _x } forEach crew QRF_Veh; crew QRF_Veh allowGetIn false;
https://streamable.com/6ngzm1 this is basegame 0 mods loaded
It looks like wounded civilians with their movement speed and animations sped up, and a janky attack thats probably an entirely unrelated animation. Its cool that someone did it in vanilla, but was probably a lot of work
Is the iskindof a slow command? Like does the engine have to make a loop or something to check it?
its the wounded walk animation sped up
@little raptor in case you are wondering
and when you are in contact with them it damages you a bit and starts a whole series of ppEffects
and its generally a pretty 'laggy' script
early versions of it crashed servers too
I tried
player isKindof "man"
result:
Execution Time: 0.0009 ms | Cycles: 10000/10000 | Total Time: 9 ms
but is that fast/slow ?
I would say really fast
hmm ok
tried
allMissionObjects "Air";
result:
Execution Time: 93.0909 ms | Cycles: 11/10000 | Total Time: 1024 ms
what about doing >> on configs, is that fast or slow?
you should try checking if a method is slow or not by using code performance in debug console
yeah I'm going to try. thx for the help, appreciated!
just how relatively fast everything is I don't know
Result:
0.0008 ms
Cycles:
10000/10000
Code:
configfile >> "CfgVehicles"
I gave you an example of an extremely slow command, allMissionObjects
I will give another example of a relatively 'medium fast' command:
alldead
result:
Execution Time: 0.0260 ms | Cycles: 10000/10000 | Total Time: 260 ms
yeah I see it's definitely slower
another test (getting slower):
Result:
0.0014 ms
Cycles:
10000/10000
Code:
configfile >> "CfgVehicles" >> (typeof player)
sure thing
hmm I think this check helps to see the relative speed:
Result:
0.0003 ms
Cycles:
10000/10000
Code:
_i = 578; _i
yeah that's extremely fast
i know the people who made them (called ZAM if anyone knows them) and they said it is around 1.3k lines of code (about 400 to inject into pub zeus but ignore that part
i assume you know the tho coz your uzing EZM
use configOf player
the amount of time it takes is highly depedant on the arg you give it + amount of objects in the mission, so it being slow is a broad statement
nice, thx! 🙂
I'm aware, but still most people told me not to use until as a last resort
entities is usually a much better alternative to allMissionObjects
there is issue with inputAction command when action has double input like eject which is "x2 V" sometimes the code executes sometimes not i still cant figure how to fix that
It returns a number with double tabs
This number ranges from 0 to 1
Just make the condition > 0
im using 0 ofcourse
waitUntil {inputAction "Eject" >0};
but sometimes it triggers sometimes not
Does anyone know how I could check if an item is a weapon or optic?
(from a gui/dialog shop)
BIS_fnc_itemType
class gang {
name = "Hideout Armament";
side = "civ";
conditions = "";
items[] = {
{ "hgun_Rook40_F", "", 200, 0, "" }, //Rook 9mm
{ "hgun_PDW2000_F", "", 200, 0, "" }, //PDW2000
{ "SMG_02_F", "", 200, 0, "" } //Sting 9mm
};
mags[] = {
{ "16Rnd_9x21_Mag", "", 200, 0, "" }, //16Rnd 9mm Mag
{ "30Rnd_9x21_Mag", "", 200, 0, "" }, //30Rnd 9mm Mag
{ "30Rnd_9x21_Mag_SMG_02", "", 200, 0, "" } //30Rnd 9mm SMG Mag
};
accs[] = {
{ "acc_flashlight", "", 200, 0, "" }, //Weapon Flashlight
{ "optic_ACO_grn", "", 200, 0, "" }, //ACO - Green
{ "optic_Aco", "", 200, 0, "" } //ACO - Red
};
};
Do you know how I could check if an item is inside the accs[] section?
enhanced zeus is mod too
Hey there, i added a $pboprefix$ file to my pbo with the content bla. Afterwards i used the prefix in an include like #include \bla\fileinthesamepbo.hpp but i always get Include file bla\fileinthesamepbo.hpp not found. - did i do anything wrong? Or don't prefixes work in a simple mission pbo? Greetings
0 mods loaded in that clip
Interesting... We had the same issue last days but also found no soultion... Probably someone got an idea?
why not just use a key handler?
or even better - there probably is a user action EH for that
because its for a mod and not everyone uses "x2 V" for eject, the weird thing is that i changed my keybind to a single V for eject and it worked, but still not a feasible option for a mod.
i may just wrap the code in while loop to check when the player is outside vehicle at 200m high, though i hate the sound of it
oh wait i misunderstood addUserActionEH that may come in handy actually
still add keydown EH
Account for both pathways
that's how I done my eject script
KeyDown triggers for all keys
yes? if statment?
Why add a slow EH when there's a fast EH for it?
which one?
User action
what if a person ejects via double V
Doesn't it trigger in user action?
if you see here
i have done _text = "Eject"
as far as that goes it won't trigger when double V
maybe with other condition it does? idk
line 3
googling addUserActionEH sent me to addAction
so I'm confused
And it does trigger for 2xV
well I will count that on google then lol
user action triggers when the action happens, it doesn't have to do anything with keys
cool, that will save my day and my upcoming days lol
the params in your second line do they belong to inGameUISetEventHandler ?
yes but ignore that
since I had a mis understanding of how something works
don't follow my method
im 100% sure, i recorded the clip its not enhanced zeus, its enhanced zeus modules
Hey Y'all Trying to make a scrip that creates a trigger for part of it and I just can;t get it to work.
_trig = createTrigger ["EmptyDetector", _dz, true]; _trig setTriggerArea [15,15,0,false,-1]; _trig setTriggerActivation ["B_T_VTOL_01_vehicle_F", "PRESENT", false]; _trig setTriggerStatements [ "this", "objNull setVehicleCargo _vic;", "'UNLOADING NOW!' remoteExec ['systemChat'];" ];
What am I doing wrong?
_dz is the a pos for where the trig should be. It should be activated by the VTOL flying over but it doesn't seem to see it
_dz is not defined in that script
And _vic is not defined in the trigger activation statement
They are defined earlier in my script. sorry was packed with other lines didn't feel like grabbing them.
just so u know this is how I'm defining them.
`private _spawn = [getMarkerPos _start, 1, 50, 5, 0, 0.25, 0] call BIS_fnc_findSafePos; //find safe place to spawn Heli
private _dz = getMarkerPos [_drop, true]; //finds the 2D spot for where to drop supplies. Returns a PositionAGL
private _kill = getMarkerPos [_end, true]; //finds the 2D spot for where the heli should end its flight.
private _crew1 = creategroup civilian; //sets vic crew to civ faction so nobody will shoot at the VTOL while it makes its delivery.
private _crewLead = leader _crew1;
private _vic1 = [_spawn, 0, "B_T_VTOL_01_vehicle_F", _crew1] call BIS_fnc_spawnVehicle; //spawn the vic on the spawn position.
private _v = _vic1 select 0; //Vic1 is an array containing both the vic and its crew. This line selects the Heli out of the array for later editing.
private _pos = getPosATL _v; //find the VTOL's pos
_v setPosATL [(_pos select 0), (_pos select 1), (_pos select 2) + 150]; //sets Heli's altitude to 50 meters off the ground`
_start, _end, _drop, _vic are all defined in params by the user. _vic is the only object, the rest are markers.
well, _vic still won't be defined in the trigger statement.
Trigger statements run in a separate scope.
oh even if they are in the same script??
Yes.
You can effectively pass vars into trigger statements by setting variables on the trigger and then reading them back.
yeah writing it out now one sec
`_trig = createTrigger ["EmptyDetector", _dz, true];
_trig setTriggerArea [15,15,0,false,-1];
_trig triggerAttachVehicle [_v];
_trig setTriggerStatements
[
"this",
"missionNamespace setVariable ['LX3_cargoDrop', false, true];",
"'UNLOADING NOW!' remoteExec ['systemChat'];"
];
if (LX3_cargoDrop == false) then {
objNull setVehicleCargo _vic;
sleep 5;
missionNamespace setVariable ["LX3_cargoDrop", true, true];
};`
still not kicking crate out the back
"pack" is the name of the object (backpack) that the player carries. I have based it off an addaction that is mostly working but i do not understand how to script
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
if ([missionNamespace getVariable "LX3_cargoDrop"] == false) then {
hint "code goes here!";
};
it's not finding when it goes false
Why is your getVariable enclosed in []? it's not an array
comparing variables to ==false or ==true basically never makes sense.
If its already a boolean it doesn't make sense, if its not it will error
very new if ya can't tell lol
if !(missionNamespace getVariable ["LX3_cargoDrop",true]) then { ...```
[] are used for _arrays_, a data type consisting of multiple values. You need () for order of precedence stuff like this.
I have switched to the other syntax of `getVariable` so you don't get an error if this is checked before the variable gets defined.
Note the use of ! before the if condition. This means "reverse boolean". Without it, if the condition evaluates to true, it does the then. With it, if the condition evaluates to false, it counts as true (reversed) and it does the then.
As Dedmen mentioned, you don't need to do if (_boolean == true) -type checks, because that's just checking if the boolean is true and then...returning another boolean that's true. You only need to return the original boolean; it will already be true or false.
if !(missionNamespace getVariable ["LX3_cargoDrop",true]) then {
'UNLOADING NOW!' remoteExec ['systemChat'];
sleep 5;
missionNamespace setVariable ["LX3_cargoDrop", true, true];
};
This is what I am using. I know the var is being set to false but I'm still not seeing my hint to know this if statement ran
When does this if get checked?
shortly after the trigger that changes it. Adding a wait unil now
Are you checking it shortly after the trigger activates, or shortly after you create the trigger?
where did you define pack?
trigger activates.
Why not just put it in the trigger?
I probably have not defined pack. I dont know how to make this work and am looking for someone to help me that does
Because the code I actually want to use, references local params that the trigger can't see. So I need to seperate the 2
try:
if (hasInterface) then
{
// ------------------------------------------------------------------------
_allowDeployRespawn = player getVariable ["allowDeployRespawn",false];
_pack = backPackContainer player;
if (!_allowDeployRespawn || isNull _pack) exitWith {};
// ------------------------------------------------------------------------
pack = _pack;
// deploy respawn
player addAction ["Deploy Respawn",{
[west, pack, "Camp"] call BIS_fnc_addRespawnPosition;
},nil,1.5,true,false,"","",3,false,""];
// ------------------------------------------------------------------------
};
Wilco ty
as people pointed out here you can pass the local variables into the trigger statements using setVariable
_trig = createTrigger ["EmptyDetector", _dz, true];
_trig setTriggerArea [15,15,0,false,-1];
_trig triggerAttachVehicle [_v];
_trig setVariable ["my_vehicle", _vic];
_trig setTriggerStatements
[
"this",
toString {
_vic = thisTrigger getVariable ["my_vehicle", objNull];
objNull setVehicleCargo _vic;
'UNLOADING NOW!' remoteExec ['systemChat'];
},
""
];
until a few mins ago I had no idea triggers had isolated variable spaces. Taking notes, ty
@little raptor No errors, but the addaction did not appear. I have been using this in the backpack init [this, ["Deploy Respawn",{[west, pack, "Camp"] call BIS_fnc_addRespawnPosition;},nil,1.5,true,false,"","",3,false,""]] remoteExec ["addAction",0,this];
you said that pack is the player's backpack
and pack is not defined in that code either
My appologies, pack is the backpack players can pickup and carry around then place on the ground to use scroll menu to activate the addaction "Deploy Respawn"
you don't need remoteExec in init
in fact it breaks everything
Its working with [this, ["Deploy Respawn",{[west, pack, "Camp"] call BIS_fnc_addRespawnPosition;},nil,1.5,true,false,"","",3,false,""]] remoteExec ["addAction",0,this]; except the respawn position looks like it is not on the backpacks actual position in the respawn menu. Works most of the time but not all. So thought a script mite help
ah
this addAction ["Deploy Respawn",
{[west, _this#0, "Camp"] call BIS_fnc_addRespawnPosition;}
,nil,1.5,true,false,"","isNull objectParent _originalTarget",3,false,""]
try that
no error, yet no addaction
well the problem is you're doing that to editor placed backpack
which are not backpacks at all
they're just weapon holders
it will show if you change isNull objectParent _originalTarget to true
but it will only work once
once you pick up the bag then throw it elsewhere it will no longer work
Would calling a script fix that?
it can be fixed but needs a lot more work
yeah, like getting player position and variables like if player has moved >500m and backpack is on ground etc
I just dont know how to do all that 😦
and respawn module called to pack position etc
should be in the vanilla somehow
wat? no
you just need a put event handler
you can add this in initPlayerLocal.sqf
player addEventHandler ["Put", {
params ["_unit", "_cont", "_item"];
if (getNumber (configFile >> "CfgVehicles" >> _item >> "isBackpack") == 1) then {
if (_cont getVariable ["hasRespawnAction", false]) exitWith {};
_cont addAction ["Deploy Respawn",{[west, _this#0, "Camp"] call BIS_fnc_addRespawnPosition;},nil,1.5,true,false,"","true",3,false,""];
_cont setVariable ["hasRespawnAction", true, true];
};
}];
- this code in 3den init of the backpack
_mycount = (count _items) -1; for "_x" to _mycount do { player addItemToUniform (_items select _x); };
This counts the items inside of a players uniform and makes sure that the original items are transferred to the different uniform when toggled using the ACE Self interact menu. What should be added so that a units insignia is also remembered and transferred over to the player in addition to the items?
first of all you can use forEach for that
{ player addItemToUniform _x; } forEach _items
as for insignia:
private _insignia = [player] call BIS_fnc_getUnitInsignia;
player setVariable ["BIS_fnc_setUnitInsignia_class", nil];
//after adding new uniform
[player, _insignia] call BIS_fnc_setUnitInsignia;
I wasn't wondering because I already guessed that was what was happening:
#arma3_scripting message
you can already tell what's fast/slow by measuring the Code Performance
also fast/slow are relative terms
in general anything less than 1 us (0.001 ms) is fast (for SQF at least)
anything above 1 ms is slow. and typically will affect FPS (if unscheduled)
but as I said fast/slow are relative terms
e.g. if you want to multiply 5 by 10, doing this is slow (and stupid, and inaccurate), because you can just do 5 * 10:
_result = 0;
for "_i" from 1 to 10 do {
_result = _result + 5;
};
```so that's why the real question you should be asking is what's faster than what you have in mind.
also it's important to consider where you're running something
e.g. a script that runs once at init and takes 0.1 ms is fast
but if that script runs every frame it's slow
the engine does have to loop but engine loops are fast
because they're compiled code
not interpreted like SQF
Can I player setPosASL ... in multiplayer or it will cause some bug/desynchronizations? (Is there a better way to teleport player?)
yes
I am calling getUnitLoadout on a unit that has containers (uniform, vest, backpack) inside its backpack, and I'm getting these boolean fields for the containers. I can't find any documentation on what they mean.
https://community.bistudio.com/wiki/Unit_Loadout_Array
[
[],
[],
[],
[],
[],
[
"B_Carryall_khk",
[
["H_HelmetIA", 1],
["200Rnd_65x39_cased_Box", 1, 200],
["B_Carryall_khk", true], // backpack
["V_BandollierB_oli", false], // vest
["U_C_Poor_2", false] // uniform
]
],
"H_Cap_blk",
"",
["Laserdesignator_03", "", "", "", ["Laserbatteries", 1], [], ""],
[
"ItemMap",
"",
"",
"ItemCompass",
"ItemWatch",
""
]
]
true means it's backpack (defined in CfgVehicles)
false means it's not backpack (defined in CfgWeapons)
Backpacks are defined in a different config than vests 😃 . That's very Arma. Anyway it's probably worth mentioning on the wiki page what this boolean field means.
added
IsBackpack() ? true : false;
why not just return IsBackpack()? 
yup. the code _i = 123; _i is good example of what is really fast
Something like: "TestItemType" in (getArray (configfile >> "gang" >> "accs"))
assuming gang is defined in configfile
Thought there is shorthand if else in sqf now and I didn't know 
Anyone seen Tried to AccessTargetList for non-local AI group while non-local targeting was disabled! Engine will now enable non-local targeting which will hurt clientside performance. client-side RPT error before?
My guess would be that it has something to do with disableRemoteSensors?
I have it as disableRemoteSensors true; on both clients and server, though not instantly, after some other loadings.
it's when AI commands are run where the AI is remote
I barely have anything related to AI in my mission 🤔
There are few server-side createAgent's which do nothing but have an addAction on them, and some Logic units.
any knowsAbout or such?
the sensors thing might be as well
as in
"the AI info won't be updated on the client to save CPU"
"I want AI info"
"OK, restarting the system at your own risk!"
Single knowsAbout which totally doesn't happen on join (when this message shows up)
in triggers perhaps?
Nope
The only difference I had recently is that I made static units into createAgent instead of createVehicle so they work with animations better
then idk, the mystery remains =)
Very descriptive errors, thanks Arma very cool
Apparently its on profiling build 🤔
Thanks @still forum
#if _EXPERIMENT_BUILD
whats the most efficient way to get all players and the units in their groups (alive and dead) ?
Maybe this in the worst case:
_players = allPlayers - entities "HeadlessClient_F";
_groups = [];
{ _groups pushBackUnique group _x } forEach _players;
_units = [];
{ _units append units _x } forEach _groups;
had this, but apparently its terrible inefficient:
_revivableUnits = [];
{
_revivableUnits pushBackUnique _x;
}
forEach (switchableUnits + playableUnits + allPlayers - (entities "HeadlessClient_F"));
_revivableUnitsCopy =+ _revivableUnits;
{
_unit = _x;
{
_revivableUnits pushBackUnique _x;
}
forEach ((units (group _unit)));
}
forEach (_revivableUnitsCopy);
_revivableUnits```
tx. let me see how yours compares
Should be slightly worse for low-player-count cases but a lot better if you have groups with multiple players in them.
down to 0.467
still quite expensive
alternative could be a cache with initEH + killed + entityDeleted - fairly complex and if "player in group" state can change, need still to track that by other means
What's your use case?
Anyone know a skip time command that sync with all players on the server?
I have a simple question
in https://community.bistudio.com/wiki/addUserActionEventHandler
what do events "Deactivate" and "Analog" mean?
I read that, still confused lol
like for example when does Deactivate fire?
when does Analog fire too?
if somebody changes their VTOL vectoring, is that analog ?
I would guess that Analog fires if you manage to attach an analog input to a user action.
and that input changes at all.
activate/deactivate would be keyup/keydown triggered
hmm
(well, vice versa)
I thought deactivate related to if a user deactivates an action
such as dismounting a bipod
after mounting it
still confused about analog, is it supposed to be something like thrust or vectoring?
Doesn't match the spec anyway. He said all units in player groups.
Oops, messed up
@velvet merlin ```sqf
diag_codePerformance [{
private _players = switchableUnits + playableUnits + allPlayers;
private _revivableUnits = [];
{
_revivableUnits append units _x;
} forEach (_players arrayIntersect _players - entities "HeadlessClient_F");
_revivableUnits arrayIntersect _revivableUnits;
}]
[0.00332,100000] vs yours [0.00455,100000] on my PC
AI mods ?
arrayIntersect is pretty bad for large arrays.
yeah, needs test on a real server
Still having heavy engine command is sometimes better than lots of simple sqf commands
better as in quicker
disableCollisionWith is simply not working for me. I'm trying to disable collision between a static object and a plane, that should be ok right? Since only one is a physx object. I've also tried disabling simulation on the static object as well to see if that helps but it doesnt. The line of code disabling the collision is placed at the bottom of the code so it runs last
sorry missed your question - to cache the playable units and their AI
@velvet merlin Ran yours vs mine script on live server with 90 players, no AI though
["0.28633",10000] vs ["0.18398",10000]
Maybe using just allPlayers without playableUnits can help it though if you don't need AI on playable units slots
allPlayers returns dead players too, unlike playableUnits
So I did an extreme test to see which code works better to return unique units, spawned 100 groups of 8 AI players and used allUnits instead of allPlayers to simulate a case if there is say 800 players all grouped up in small groups.
private _players = allUnits;
private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
private _revivableUnits = [];
{
{
_revivableUnits pushBackUnique _x;
} forEach units _x;
} forEach (_leaders arrayIntersect _leaders);
_revivableUnits;
```^ `["8.83972",100]`
```sqf
private _players = allUnits;
private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
private _revivableUnits = [];
{
_revivableUnits append units _x;
} forEach (_leaders arrayIntersect _leaders);
_revivableUnits arrayIntersect _revivableUnits;
```^`["8.62000",100]`
So append and then arrayIntersect is a bit better in case where all players are grouped up and there are no AI
for "_i" from 1 to 100 do {
private _pos = player modelToWorld [0,10 * _i, 0];
[_pos, side group player, configFile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfSquad"] call BIS_fnc_spawnGroup;
};```to spawn these 800 test units
Now if we pick 100 random units from allUnits to assume they're players (unknown if leaders or not) with
allPlayersTest = (allUnits call {
private _return = [];
for "_i" from count _this to 1 step -1 do {
_return pushBack (_this deleteAt floor random _i);
};
_return;
} select [0, 100]);
performance results are
{
private _players = allPlayersTest;
private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
private _revivableUnits = [];
{
{
_revivableUnits pushBackUnique _x;
} forEach units _x;
} forEach (_leaders arrayIntersect _leaders);
_revivableUnits arrayIntersect _revivableUnits;
}
```^`["2.38037",100]`
```sqf
{
private _players = allPlayersTest;
private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
private _revivableUnits = [];
{
_revivableUnits append units _x;
} forEach (_leaders arrayIntersect _leaders);
_revivableUnits arrayIntersect _revivableUnits;
}
```^`["1.19019",100]`
once again, append and arrayIntersect are much better in a case with 12.5% of units being "players".
So in the end
private _leaders = (allPlayers - entities "HeadlessClient_F") apply {leader _x};
private _revivableUnits = [];
{
_revivableUnits append units _x;
} forEach (_leaders arrayIntersect _leaders);
_revivableUnits arrayIntersect _revivableUnits;
```for just `allPlayers`
or
```sqf
private _players = allPlayers + switchableUnits;
private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
private _revivableUnits = [];
{
_revivableUnits append units _x;
} forEach (_leaders arrayIntersect _leaders);
_revivableUnits arrayIntersect _revivableUnits;
```for several commands for initial list.
Not sure if you even need switchableUnits, not exactly sure how team switch works
Why leaders instead of groups? Tests show it works a bit quicker on same set of test data for whatever reason.
@velvet merlin ^
I want an AL-6 PELICAN (drone) with the turret of the Darter. Anything is possible with arma but what needs to be done to make it happen?
Like the camera turret?
If that is what you want, afaik that would need to be done on a config and model level and would require a custom modification of it, which being an arma asset would render it against the tos.
a poor man's approach is to attach the darter to the pelican and hide it
I try to make a trigger execute a line of code, but it dosen't work
if ["task3", "SUCCEEDED", "true"]; then execVm "KIA.sqf";
it says i need a boolean type
what's the condition supposed to be?
but I did have add the ``
(in english, given that your code doesn't make sense)
Oh that's the condition
is there any way I can "reignite" burning vehicle wrecks?
They seem to give out the best looking fire/smoke combination
@honest pilot Yes, I mean describe in english what you want it to do.
so once a first clean outpost from OPPFOR is completed, I want this trigger to execute a line of code right after
but for that, it need the task3 to be succeeded
Is this a task created with the BIS task framework? Like BIS_fnc_taskCreate?
Maybe:
if (["task3"] call BIS_fnc_taskState == "SUCCEEDED") then { execVM "KIA.sqf" };
nah that last one doesn't work. It needs a Task type as input.
I have made several functions inside a sqf file in my mission folder. How do I call them? (I’ve seen execVM, but I have multiple functions in one file)
That's kinda bad practice these days, but all you need to do is set global variables to those functions and then execute the file once, like this:
MyTag_funcname = {
// function code here
};
MyTag_funcname2 = {
// other function code
};
What’s good practice?
is there a way to get position of a selection, unfortunately non of the getpos command return a pos hitpoints or selections
Combine selectionPosition with modelToWorld*.
thanks !
Hello everyone, how can I find an extra element in an array?
meaning?
There are 2 arrays [1,2,3] and [1,2,3,4]. I need to remove an extra element from them - 4
oh, array difference!
see arrayIntersect
use _array2 - _array1 to get the difference (if _array2 has more items than _array1!)
see https://community.bistudio.com/wiki/arrayIntersect for common items
ty
playSound3D ["Tire_Blowout_SFX\sound\WheelsPOP.ogg",
_WheelASLPOS, false, getposASL _WheelASLPOS , 5, 1, 100]; ```
is it possible to skip the 3rd argument while using the ones after it ?
what do you mean by 3D argument?
you an "skip" optional arguments by just filling in the defaults
default is [0,0,0] and for some reason i got error and it isnt working, also someone in the forum said by doing so the sound will get attached to [0,0,0] instead of skiping that argument
you mean soundPosition? If you're going to bring up an error you should share what it says. Wiki page says default is [0,0,0] but you can also try nil if [0,0,0] overrides your sound source
question, why don't you just use the sound source again for that parameter?
if _object is your sound source getPosASL _object can be your sound position
im using selectionPosition to modelToWorldWorld to get ASL POS of a selection, the problem for me now is im getting error trying to change GetposASL with _WheelASLPOS
is _WheelASLPOS an object?
i have mistaken the first one should be _Veh and the second should be _WheelASLPOS, but still getting the error
_WheelASLPOS is location an Array
soundSource is _Veh and soundPosition is _WheelASLPOS
you can probably use objNull or something for soundSource since you're specifying a position
Hey, anyone here knows a way to disable a specific zeus module?
remove it from the mission?
They might mean disabling Zeus' ability to use a specific module. If so, it might be possible to target it using removeCuratorAddons - the page for addCuratorAddons has an example of targeting an individual module so it seems like it should be doable. You'd need to find the module in the config somewhere to get the right name though, and I don't know if all mods have their zeus modules listed separately like that.
I'm super new to multiplayer scripting and am reading through the page on the wiki for it. The main process of the script it creating an object and then adjusting its position and angle and such. I need to do much more research but figured id ask if anyone had any suggestions or methods they like to use to ensure things like this sync across clients
if it's just a one time thing, you can use setVectorDirAndUp and setPosWorld
all of which are global
so you don't need anything special for multiplayer
it's the same as single player
I was looking at things like public variable, but those two things look neat
I have a suicide bomber script that creates a shack the bomber comes out of.
The script could happen frequently, it relies on other events taking place. Is the one time thing comment because of sending a lot of info, or is there another reason for it?
_slum = ["Land_Slum_House01_F","Land_Slum_House02_F","Land_Slum_House03_F","Land_cargo_house_slum_F"]; _slumHouse = selectRandom _slum; _building = createVehicle [_slumHouse, _newpos, [], 0, "CAN_COLLIDE"]; _building setVectorUp [0,0,1]; _building setDir random 360;
This works in multiplayer.
hmm, it has the opportunity to happen a ton, but 99% of the time it would happen twice within a second or up to 20 times over 3 or 4 seconds
Its pretty light and I think it would be alright. Ill test it out though
Moving things around isn't that taxing, creating things like that is.
It would be optimal to run the whole script on the server though right Leopard? As apposed to running it one every client
for one object maybe not, but for several objects it can be
No need to run on every client.
^ this one doesn't need to run on every client
as I said in the beginning it's global
Cool, and in terms of it being a mod, because its just running on the server and relies only on vanilla content, could the server be the only thing with the mod loaded? Assuming it was dedicated, if it was client hosted then that client would ofc have it
it can, but I don't recommend making such assumptions when designing a mod
instead make sure everything is right yourself
e.g. if you want something to only run on the server, use the isServer check
Ok, ill try and put this into practice, thanks again
If I want to have the script run even if there is no server, i.e. if someone is in singleplayer. Would I go about that by going through all the clients and checking if any of them is a server, and then if none of them are run it normally?
single player is server already
ah ok
server always exists
is isNil supposed to check if a variable exists? Because it just gives me an error saying the variable isnt defined.. Like I know, thats the whole point of the check
Make sure you're passing the name of the variable as a string ( isNil "_variableName" )
woops, thanks
Depending on your purpose, you can also use the alt syntax of getVariable which allows you to assume a default value if the variable is undefined
The code looks like this :
if (isNil "_craterArray") then{
_craterArray = ["1"];
systemChat "created";
};
Its designed to run once at the start and then never again, however it isnt working and is running every time
You're creating a local variable (indicated by leading _) which may not exist outside of the current instance of the script
facepalm, ofc. Is there a way to go about it?
The script loops and I dont want to be resetting array every loop
If you want the variable to be accessed by other scripts on the same machine, make it a global variable (not the same as a network global variable) by omitting the _
Ill be running the script on a server which will be distributing its content to the clients. The script is called in an event handler and I need the script to belong to only that object from the event handler
Wouldnt a global variable defeat that purpose?
Sorry, it's too late in the day for me to wrap my head around what you're trying to do here
If someone else doesn't get to it I'll try to remember to come back tomorrow
All good haha, thanks for your help already
To better articulate what I said above. I need to loop a function called from an EH and use a local array inside of it. My problem is with creating the array at the start, because if I loop over it every time then it would be reset to empty everytime which I can't have. I need the array to belong only to the object the event handler its attached to.
use setVariable
which will be distributing its content to the clients.
I hope you don't mean the array
no, just the position and existence of the objects in the array
Using the commands you mentioned above
I thought I had to
I was going to create it all on the server and then use setVectorDirAndUp as well as setPosWorld to update it everywhere so that the clients could see it the same way the server did
it doesn't matter where you execute those
What do you mean?
I mean they take global args and have global effect
ok, if im creating the objects on the server though I might as well execute them from there though right? Since the objects only exist on the server at that point... or does simply creating the vehicle create them across all clients as well?
well at init yes, you should do createVehicle and setPosXXX, etc. together
if the object was not local, all clients get a copy as well
and the object is simulated where it's currently local
So if I were to create it on the server during runtime and it was a static object then would I need to push information to the clients? Or would be doing it on the server be enough?
but after init it doesn't matter where you execute setPosXXX, etc.
are you sure you read the multiplayer scripting page thoroughly?
your question makes it seem you didn't
I read it, I may not have understood all of it though
Reading it makes me think remoteExec would work, however it would be calling the entire script on the clients instead of just the final positions
again, what you're doing is all global. you only need remoteExec when either the effect or arg is not global
I think im missing the idea on part of that, despite me using only local variables, the effects are still global across all clients?
and the answer to this is not "all server" or "all client". it really depends on what you're doing
yes. effects are global (for setPos and setVecDirUp)
your "variables" are references to network objects
when you make changes the server picks up the changes and syncs them
your question was like: if I create an object and assign it to a local var, does the object get deleted when the script ends (because the local var is destroyed)?
ofc not
Ill try and put this into practice, I feel ill need a lot more experience with it before I understand it
well for starters, don't confuse local variable with local object
a local variable is a variable that is local to the script (or code), and once it's destroyed the var is destroyed too
but a local object is one that only exists on the current machine
also all global objects are always local to a certain machine (it can change), and that machine is responsible for letting the server know how to update the object
Thankyou for all this info
hey I got a little problem on this script but i don't see it
_APC = createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]]; _crew = createVehicleCrew _APC; _crew addWaypoint [17507.4,13198.6,0];
what kind of problem?
it should work fine
0 elements given
3 elements waited
oh right the waypoint is wrong
?
groupName addWaypoint [center, radius, index, name]
it should be _crew addWaypoint [[17507.4,13198.6,0], 0];
oh yea now it works
thanks
@little raptor also what should be the code to add passengers to the apc and make them disembarck once apc have reatch the Pos ?
like an group
you can use BIS_fnc_spawnGroup
moveInCargo
Ok
for making them get out use this:
_wp = _crew addWaypoint ...;
_wp setWaypointStatements ["true", toString {commandGetOut thisList}]
so it should be
`
_Squad = (configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam") call BIS_fnc_spawnGroup ;
_Squad moveInCargo _APC
`
ik for the move in Cargo but to spawn them
Ok
isNil {
_grp = [[0,0,0], west, configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam"] call BIS_fnc_spawnGroup;
{_x moveInCargo _apc; if (vehicle _x != _apc) then {deleteVehicle _x}} forEach units _grp;
};
@little raptor its says moveinCargo group waited 0 given
post the full code
also I don't know what translation you use for those texts but it's crap and meaningless
sry
_APC = createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]]; _crew = createVehicleCrew _APC; _wp = _crew addWaypoint [[17507.4,13198.6,0], 0]; _wp setWaypointStatements ["true", toString {commandGetOut thisList}]; _wp setWaypointStatements ["true", toString {_APC = vehicle this; commandGetOut units this}]; isNil { _Squad = [[0,0,0], west, configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam"] call BIS_fnc_spawnGroup; {_Squad moveInCargo [_APC, 1]; if (vehicle _APC != _APC) then {deleteVehicle _APC}} forEach units _Squad; };
I corrected the missed variables
but it still says that it need an Object to set on Cargo, but for the script _Squad isn't concider as a groupment
why on earth did you change _x?
it's a magic variable
_APC = createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]];
_crew = createVehicleCrew _APC;
_wp = _crew addWaypoint [[17507.4,13198.6,0], 0];
_wp setWaypointStatements ["true", toString {commandGetOut thisList}];
isNil {
_Squad = [[0,0,0], west, configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam"] call BIS_fnc_spawnGroup;
{_x moveInCargo _APC; if (vehicle _x != _APC) then {deleteVehicle _x}} forEach units _Squad;
};
try that code
don't change anything
OOk
did you try the new code?
yes
it deletes the units that didn't fit into the APC
ok
because form what i see the crew of the APC is getin'out the APC
but there is no group goin' outside the APC
Even more, it seems the Group ins't sit into the APC so it delete it
Maybe because the _x is concider as _crew
@little raptor
no
ah
try this then:
_APC = createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]];
_crew = createVehicleCrew _APC;
_wp = _crew addWaypoint [[17507.4,13198.6,0], 0];
_wp setWaypointStatements ["true", toString {commandGetOut (crew vehicle this - thisList)}];
isNil {
_Squad = [[0,0,0], west, configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam"] call BIS_fnc_spawnGroup;
{_x moveInCargo _APC; if (vehicle _x != _APC) then {deleteVehicle _x}} forEach units _Squad;
};
it should only dismount the units in squad
it does the same
it doesn't
I just tested it
it works perfectly fine
I check it out on the spectator view, no squad of solidier appear on the list
and restart your game
Ik
If I cut the code at _crew = createVehicleCrew _APC;
A squad of 4 appear at 0,0,0
but not in the APC
like I said I just tested the code
and it works fine
I don't know what you're doing wrong, but the script should work
so u got passengers on the seat of APC ?
a team of 4
and only that other squad got out
On witch map
it doesn't matter
cause im on RV map
if you mean VR those coordinates are invalid
the size of the VR terrain is 8192
you have a 18248.6 in your coordinates
it's way off the map
Is there a way to get 3DEN's layer parent ID by layer ID?
Do I have to tap into UI to figure it out?
Expected Tree control on the left to have layer IDs as tvValue or something - nope
Looks like all3DENEntities's layers order is the only thing I have, gonna have to compare it against tree on the left to figure it out
Unless I'm over-complicating it and there is a much easier way
how good is the floating point comparison these days? is something like this reliable: 123.456 == 123.456
Yes. That is reliable.
But I'm 99% sure that code isn't actually what you are trying to do
If you're comparing coordinates, do vectorDistance, if some arbitrary float values have something like abs(float1 - float2) <, depending on what you need
123.456 == 123.456 is 100% reliable.
(122.456+1) == 123.456 is not
humm I'm trying to use pushbackUnique [_cost,_itemName]; wasn't sure if that works, it looks like it does in my tests
That's what I use sometimes
0.3 + 0.4 == 0.7 is false
have fun 🤣
But: _x = 123.345; _y = 123 + 0.345; _x == _y is true
exactly
when is it true and when is it false? 
you can't really predict it unless you do it the way CPU does it 
in a better world isEqualTo would compare exactly, and == would approximate by 0.00000001 😄
as long as pushbackUnique works with floating points i'm happy
Well it "works"
it uses exact equal comparison
dunno ;D
it uses isEqualTo
ok great
_a = [];
_a pushBackUnique 0.7;
_a pushBackUnique (0.3 + 0.4);
My visual studio even warns me about it 😄
now it doesn't work 
I'm getting the same, pushbackunique doesn't work....
Not sure why would you even need such unique floats, but something like
_a = createHashMap;
{
_a set [_x toFixed 3, _x];
} forEach [0.7, 0.3+0.4];
values _a;
```might solve it for you
Tweak _x toFixed 3 to needed precision, round or whatever you need it for
thx, just exploring my options
or you could round them like
(round (_x * 100)) / 100
that might work okeyish
Also hashmaps are amazing, thanks for making them happen, @still forum I use them a ton now.
And @unique sundial too, I guess?
floats comparison is done using epsilon usually
i have nothing to do with hashmap it’s all dedmen
Wish we had <HashMap> = <HashMap> select <Code> though.
Had a usage for <HashMap> apply <Code> that would return resulting new HashMap with same keys buy code-returned values too
Will need a new command name though
you can already do it with apply
- createHashmapFromArray
Yeah, that's what I did instead of it
No event handler for layer getting hidden\shown either? 🤔
Toggleflashlight = addUserActionEventHandler ["headlights", "Activate", {
[[],{
_flashlight = player getVariable ['flashlight', objNull];
if (!(isNull _flashlight)) then {
player setVariable ['flashlight', objNull, true];
player say3D "click";
detach _flashlight;
deleteVehicle _flashlight;
} else {
_flashlight = "#lightreflector" createVehicleLocal position player;
_flashlight setLightConePars [70, 25, 5];
_flashlight setLightAttenuation [2, 6, 6, 0, 2, 15];
_flashlight setLightIntensity 45;
_flashlight setLightAmbient [1,1,1];
_flashlight setLightColor [1,1,1];
_flashlight setLightUseFlare true;
_flashlight setLightFlareSize 0.5;
_flashlight setLightFlareMaxDistance 500;
_flashlight attachTo [player, [-0.05,0.04,0.2], "head",true];
player setVariable ['flashlight', _flashlight, true];
player say3D "click";
};
}]remoteExec ["spawn",0];
}];
Description:
I put this script in onPlayerRespawn.sqf
It works, if I start server solo, but when my friend join. _flashlight will not attach. Should I put that in every unit init?
Expectation:
_flashlight for every player that is on/off with headlights key biding and visible for other players.
why respawn, if you want on every player then put it into initPlayerLocal.sqf
Also if just ONE player switches their headlights, you want the lights of EVERY player to switch? Are you sure about that?
That seems unintuitive to me
I add this to onPlayerRespawn.sqf, because if he dies and respawn I want to give him ability to use flashlight. I want create a custom/
individual flashlight for every player. After your message I guess addUserActionEventHandler will add it globally, hmm I thought everyone would have it locally.
so the code above should work if he puts it in initPlayerLocal.sqf asking because i dont have ability to test it in multiplayer or are there other problems beside that?
~= operator when 😄
Well the remoteExec is weird, but besides that I would expect it to work
~== then?
=== and !== too plz
(isEqualTo vs isNotEqualTo)
Speaking of comparisons, checking if two variables reference same array or hashmap could be useful. I remember having a need for it at some point. I guess there is no way to do that efficiently?
#arma3_scripting_dreams
no
no JS heresy here thaaank you
~= would be comparison already, not assignation 😄
~= feels like assignation\modification, similar to +=, /=, etc. in other languages
fair
but isn't ~ usually some bitwise operator?
yeah, doubt anything bitwise will ever be in SQF
Speaking of shorthand assignment operators, stuff like this get used all the time:
_array set [_index, (_array select _index) + 1];
```would've been great to have something like `_array inc _index` as a single command;
and something for subtraction
(_array # _index)++ 😀
Not possible with SQF at all
yeah I kinda assumed that 🙂
prefix increment rather, but not possible because it would mess up push instructions
not for setting array elements it won't
makearray 0
assignto _ident
endstatement
getvariable _ident
push 0 // say this is x
callbinary pushback
endstatement
getvariable _ident
push 0
callbinary select
callunary ++ // this increments x
when you call this code, the array will be [1], the next time you call it, it's going to be [2]

or just inc _num
Yes, but if you'd make it replace the array element it wouldn't
doesn't have to be array
_num inc 1;
_num dec 2;
SQF cannot get the name of a variable you pass to it (or is not designed to allow it)
And number VALUES cannot be modified
not speaking about arrays, incrementing just isn't a thing, arrays can be modified by reference because they have a makearray instruction, and it's always a new one
every other value is always the same reference, (push inst)
Was talking about incrementing a value at index in array, would be
_array set [_index, _array select _index inc 1];
```while my motivation was replacing lots of commands with a single one
you said it yourself that everything in SQF is by reference
so it is possible to increment by reference
Yes but you can't without breaking stuff
_func = {
_i = 0;
++_i;
};
call _func; // 1
call _func; // 2
call _func; // 3
why doesn't pushBack break stuff? 
Also, where's muh hashMapNull 
Because there are no array constants
createHashMap is basically it
Yep, I do that right now
[]?
not a constant
it's a makearray, it's a new array everytime
creates empty hashmaps though, triggers an OCD
Unless with bytecode with optimizer, then its sometimes a constant
constants are strings, scalars, etc, the ones that are a push in the asm
so does objNull and grpNull and configNull and all the other null commands
very rarely literally, had to do alot of analysis on that, and it's usually just the params def value arrays
by that definition strings are not constant either
Yeah, they return new null objects, but isn't empty hashmap bigger than null hashmap?
Muh bytes
not usually just. Only just.
I wrote that code 😄
well with a proper analyzer you can find some other cases(atleast i did)
no
that sounds like a huge trap that can require some deep debugging once you fall into it 😄
Pretty much what I do right now
I use it for getOrDefault and getVariable <array>
A empty hashmap is just a nullptr (plus some size variables). same as empty array. Its not expensive
So createHashMap doesn't actually create anything until first set\merge\whatever? 
yes

it creates a HashMap typed value, same as the other null commands
same as empty array
you sure empty array is not an array with 0 size?
empty array is a nullptr with two 0 sizes
hashmapNull kinda
Well thats behind SQF, not really SQF itself 😄
so isnull createHashMap is never true?
it never works to begin with
There is no isNull <HashMap>
dedmen said "A empty hashmap is just a nullptr"
C++ land null != SQF land null
a null object is not (always) a nullptr, but its still null
oh you were talking about c++ implementation?
yes. SQF doesn't even have pointers
alright 🙂
im having an error at ```sqf
_wepMagazines = getArray (configFile >> "CfgWeapons" >>_rifle >> "magazines");
expected config entry type string in a file that im executing btw
```sqf
[]spawn{
spawnLoot = true;
while{spawnLoot}do{
_magazineArry = [1, 2, 3, 4];
private _buildings = [];
private _buildingBlacklist = [''];
private _weaponPool = [''];
_weaponPool = "
getText (_X >> 'dlc') isEqualTo 'CUP_Weapons'
" configClasses (configFile >>"CFGweapons");
_buildings append (nearestObjects [player, ["house"], 50]);
{
_buildingPosition = [_x] call BIS_fnc_buildingPositions;
{
_rifle = _weaponPool call BIS_fnc_selectRandom;
_magazineCount = _magazineArry call BIS_fnc_selectRandom;
_holder = "WeaponHolderSimulated" createVehicle [0,0,0];
_holder setPos _x;
_holder addWeaponCargoGlobal [_rifle, 1];
_wepMagazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines");
_magazines = _wepMagazines select 0;
_holder addMagazineCargoGlobal [_magazines, _magazineCount];
_holder addWeaponCargoGlobal [_rifle,1];
} forEach _buildingPosition;
}foreach _buildings;
};
};
Anybody knows how to calculate rotation for 3DEN's rotation attribute? Googling on forums gave no working solutions.
rotation to what? Or What to rotation?
ive missed a lot of sleep today how would i do that again?
just _rifle = string right?
Object as input, rotation for set3DENAttribute
should be: configname _rifle
to make it string
So vectorDir vectorUp to rotation?
Think I've done an opposite already, but not sure this way
Yes, or whatever can be had from the object
Found this, but Armaholic is dead: https://forums.bohemia.net/forums/topic/183115-matrix-orientation-script-pack-mop/
Hey everyone, Ive been working with ARMA for a while but have yet to make a substantial contribution of community content, so I thought this would be a good first step. Ive recently been using ARMA 3 as a research tool (simulator), and that work required some tools that didnt yet exist in ARMA. S...
BIS_fnc_getPitchBank doesn't return anything close to values that 3DEN wants
ive tried this but same error
[]spawn{
spawnLoot = true;
while{spawnLoot}do{
_magazineArry = [1, 2, 3, 4];
private _buildings = [];
private _buildingBlacklist = [''];
private _weaponPool = [''];
_weaponPool = "
getText (_X >> 'dlc') isEqualTo 'CUP_Weapons'
" configClasses (configFile >>"CFGweapons");
_buildings append (nearestObjects [player, ["house"], 50]);
_rifle = configName (configFile >> "CFGweapons");
{
_buildingPosition = [_x] call BIS_fnc_buildingPositions;
{
_rifle = _weaponPool call BIS_fnc_selectRandom;
_magazineCount = _magazineArry call BIS_fnc_selectRandom;
_holder = "WeaponHolderSimulated" createVehicle [0,0,0];
_holder setPos _x;
_holder addWeaponCargoGlobal [_rifle, 1];
_wepMagazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines");
_magazines = _wepMagazines select 0;
_holder addMagazineCargoGlobal [_magazines, _magazineCount];
_holder addWeaponCargoGlobal [_rifle,1];
} forEach _buildingPosition;
}foreach _buildings;
};
};
iirc 3DEN rotations are in radians
also didn't you ask this question before?
pretty sure I answered it 
I did and I failed to figure it out back then
just change this line:
_wepMagazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines");
// To:
_wepMagazines = getArray (configFile >> "CfgWeapons" >> (configname _rifle) >> "magazines");
Nope, degrees everywhere
or simply to: ```
_wepMagazines = getArray(_rifle >> "magazines");
thanks for your help dude
yw
visionMode[] = {"Normal","NVG"};
Does anyone know how to add thermal vision?
I want to add a backpack or vest to an ammo crate with stuff already inside. What is the easiest way?
I can do that by
- adding the backpack/vest to the crate
- calling
everyContainerfor the crate - searching for the newly added backpack/vest in the output
- adding stuff to that
This is quite complicated. Is there an easier way?
Context? Most unlikely you can do it within a mission though
That's the only way via scripting
As far as I know
If that's the only way, (which I do think so also) perhaps we can make a ticket so the commands will return the container
...Or, completely new command?
Can I assume that the newly added container is always the last element of everyContainer
or well, it doesn't seem to apply to vests, only backpacks. It looks like vests come first, then the newly added vest, then all backpacks.
although if we could assume that the newly added vest is always the last non-backpack element, it could still be found that way
Changes to the config.bin. Figured it out. "TI" adds thermal vision.
Is a #arma3_config topic, tho
ok
Thanks for this btw mate, worked fine.
Is there any way to disable or restrict mods on a server that is hosted via upnp (on pc)
yes, don't use mods on startup
(you are in #arma3_scripting)
That doesn't work. I had it without mods before and people could still join in with modded stuff.
try #server_windows
Thank you, that's what I meant. I'll look into it
Hey, would anyone know how I could code it so that after a 7 second sleep command, I'd be able to force unconscious an entire squad? One of my friends suggested this but I'm really unsure, it'd be on a trigger, what I have currently is this:
[4] spawn BIS_fnc_earthquake;
sleep 7;
sleep 7;
{ _x setUnconscious true } forEach units _theGroupYouWant;
Is the x a replacement or just part of the code
_x is a magic variable used in a forEach loop. https://community.bistudio.com/wiki/forEach
triggers also execute code unscheduled, you will need to wrap it in [] spawn {"code here"} to use sleep
Huh. Used leaveVehicle on a pilot group. They got out of the thing and then got back in again and flew off.
I guess there is no reliable way to reverse addVehicle
maybe it's bugged and you need to unassign it as well?
unassignVehicle specifically doesn't remove the group assignment.
leaveVehicle is the only one that's supposed to touch it, although I suspect the TR Unload waypoint also does for cargo groups.
After last nights assistance with understanding multiplayer coding I tried to get things to work with it. I converted my script into an addon as I have in the past without issue and am executing the script from the postInit section of my config. The actual script contains a "isServer" check at the beginning of it.
The script runs correctly in both singleplayer and localhosted sessions, however it does not on dedicated servers. I've tried executing it a number of ways, including initServer and havnt had any luck.
The contents of the script is just some createVehicle and position updates on said vehicles, which i've been told update globally by themselves.
Scatter some diag_logs around, then you'll know what's executing and what isn't.
Ok ill try that. Would it show up in the server rpt since thats where im calling it?
Yes.
Make sure you're not using -nologs
server should call preInit, initServer.sqf, postInit and init.sqf in that order.
Hmm, I can't seem to find its rpt file, is it supposed to be located with the other rpt's?
What other RPTs...
The standard client ones
It'll be in the server's profile folder.
Which shouldn't be the same as the client profile folder.
ah, thanks
A really simple question,
_MagList = magazinesAmmo player;
_SortedMags = [];
{
_MaxCapcity = getNumber(configFile >> "CfgMagazines" >> _x >> "count");
} forEach _MagList;
_SortedMags;
I have a mag array of the player's mags, I want to sort them by their ammo count, I do have access to the ammo count of each mag, I just don't know how to sort them.
what do I need to put in the forEach for it to sort it?
decreasing order
@granite sky Your suggestion was helpful, it looks like the script is being called and is passing the isServer check. However its not getting to the next step which is the EH's. Here is that code section:
_curators = allCurators;
allPlanes = entities [["plane"], [], false, false];
{
_x addEventHandler ["CuratorObjectPlaced", {
params ["_curator", "_entity"];
systemChat "added";
allPlanes pushBack _entity;
_entity addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
[_unit] spawn planeKilled;
diag_log "planeCrash Eh1 Added";
}];
}];
_x addEventHandler ["CuratorObjectDeleted", {
params ["_curator", "_entity"];
allPlanes deleteAt (allPlanes find _entity);
}];
} forEach _curators;
Use BIS_fnc_sortBy
And you can't sort in "forEach"
You have to construct a new array, sort it, then extract your original elements
The sort command can also be used if you need it to be faster, but it's stricter on the input requirements.
extract based on mag capacity correct?
Wat? Just look at how BIS_fnc_sortBy works
@opal zephyr Are you sure the curators have been initialised at the point you're calling that?
Im calling that with postInit, so curators should be created already
allPlanes is empty though since the mission in this case is empty
I'm not even sure whether the curator events are triggered local to the current curator or the curator object.
Would need to do a lot of testing.
Your systemChat there won't do anything on a DS though. You'd need to remoteExec it to the client.
Ya, that was for earlier testing, never removed it
Is there a better way to get vehicles during runtime?
Apart from checking with a timer
I've never had much luck with the allCurators command
I don't know how it works exactly
Half the time it doesn't return anything
Better go through all players and find ones that have synced curator modules
Also if that script is running at server Init it won't work
The command was returning correctly everywhere but dedicated. I guess I can try doing it based on sync with players, thanks for the suggestion!
Well the curator EHs should be added to the curator module iirc
So players are irrelevant. you better get the modules instead
Ik, you recommended to go through players to get the modules
as apposed to using allCurators
I could consistently get them with a timer that checked every 10sec or something, but id rather not
No
You can get the modules directly
What does this mean then?
Nothing 
ok.. lol
how do you get the modules directly? And do you think it would work apposed to my current method
Well idk where those EHs execute. Probably where the zeus player is local
It looks like they do
The timer method is seeming more and more to be the option to go with haha
Hmm actually I think I can simply use missionEventHandler "EntityKilled" and just check if the entity is a plane
That should work even if the entity is added by a zeus during runtime, or the vehicle respawns or whatever else happens
EntityKilled is generally really useful. The stock Killed EH only fires on local objects, so it's a pain for vehicles because they switch locality when players board them. MPKilled runs everywhere, which you usually don't want to do either.
curator EH? yes
I have the script running on the server and everything now, however it acts differently on the dedicated then it does on the other server types. It seems like its slow or something, the objects arent being created in the correct spots, and the rotations arent correct. A couple of the objects are somewhat correct, but overall its a mess 😂
I'm sorry, is it a zeus script?
and if so how did you do it
Its a addon and runs when a jet dies
oh alright I thought it was a zeus script
Does anyone know the execution locality of AllMapMarkers?
Whether it's globally executed or locally or both?
I kind of need it to be able to have a players group receive the markers
So they can be drawn with draw3dicon
But only allow up to 10 at a time
Got a weird question how smart is the ArmA 3 Scheduler?
not
priority is with scripts that have not executed for the longest time. it's not just FIFO. it always (meaning every frame afaik) sorts its scripts by their last execution time
there is
Arma*
@little raptor Ah so LRU policy.
Hi! I'm trying to get into coding for arma and wanted to start with a fairly simple checkpoint missions where npcs will automatically stop at the gate until let through via radio command. I (think) I have the stop and go mechanic set up, but I can only spawn in one vehicle at a time as the variable in use cannot be shared, and I would like to make the vehicles spawn in randomly from a pool of randomized preloads but I'm not sure how.
Does anyone have any resources/Ideas?
createVehicle or BIS_fnc_spawnVehicle, and selectRandom 🙂
On a trigger with a random sleep time?
And is there a way to make those vehicles have a particular variable name when they spawn?
no, in a script
and (global) var names are possible but usually not required
Script as in a text file in the mission file?
in the mission directory yes
Got it, okay, um... I'm really new to that and I wouldn't be sure how to do that but I'll see what I can do
Is there a way to make these vehicles follow a predetermined path?
any idea how I could automate this into a single trigger?
code is basically meant to teleport candidate_1, cand_2, ... to sp1, sp2 ... - I have 4 overlapping triggers now and am unsure how to make it less ghetto 😆
//CONDITION
this && (candidate_2 in thisList)
//ON ACTIVATION
null=[]spawn {
[0, "BLACK", 2, 1] spawn BIS_fnc_fadeEffect;
uiSleep 3.5;
player setPos (getPos sp2);
[1, "BLACK", 5, 1] spawn BIS_fnc_fadeEffect;
};```
well if you want to keep using the trigger, you can set it as repeating and just teleport whoever sets foot in it
also your trigger has locality issues
if you have remoteExecCall ["createMarkers", _targetSide, true]; that is called several times and JIP person joins the server, will he also get createMarkers called several times or just once?
multiple times, see https://community.bistudio.com/wiki/remoteExec#Parameters_1
ok in that case maybe its possible to clear the queue?
if you want to only have it happen once, use the same JIPQueueId
or have it run locally on join
well it's supposed to show town ownership to clients, via marker
and the ownership changes
and does it delete previous markers before?
honestly I wouldn't remoteExec that, have UI stuff locally executed
hence sending marker creation to single side at the time
I'm going to just remoteExecCall ["", _updateJipId]; to clear the queue
or, you know, don't add it to the queue??
you mean dont use remoteExecCall ?
you are piling up JIP stuff you won't need for JIP
so I don't get what you are trying to do 
just updating some local markers for JIP and all players of the same side
well I think I got it from here, thx for the help 🙂
what does that mean?
yeah, sadly I want it to teleport different people to different places as opposed to teleporting everyone to a specific place
Still possible with one trigger
Did you even consider where the trigger execues and what player is?
yes, but I'm also unsure my conception of that is the same as what you're trying to point out
yeah, thinking something something for loop and an array but I couldn't really figure it out
{
_x params ["_player", "_spot"];
if (_player in thisList) then {
_x remoteExec ["my_fnc_teleport", _player];
};
} forEach [[p1, s1], [p2, s2], ...]
I'll leave that up to someone else to explain. I'm out
so you are trying to teleport all the players to different spots, when someone enters the trigger, right?
thank you!
each player gets tp'd to a specific spot as he enters the trigger area
based on the assigned variable name, i.e. candidate_1 through n
tpd to sp1 through n
oh, do you still need help?
just code above i guess is the exact thing that you are looking for ;D
anyway, if done with this, i have question in here.
so i'm making code which is saving bohemian respawn time of player (based on UID) on server. This time should be applied back, if player rejoins from different slot.
But i didn't find function to return player's respawn time on sever (basically i don't think EH (event handler) would help with playerRespawnTime, due player can alt+f4 and remoteExec wont execute if i'm not wrong).
I'm making possible solution with -
EH looking for player entity to be killed.
saving time of kill
creating EH player disconnect
find time difference
save corresponding UID and time to server
sleep for respawn time (taken from description of mission)
delete EH player disconnect
wondering, if other, better, solutions exist?
Assuming that the respawn time is a fixed, known value, I think you can do this purely on the server with EntityKilled and PlayerConnected mission event handlers.
oh, maybe you do need PlayerDisconnected as well in case they disconnect while unconscious.
yea, just a bit changed scheme due in this i suddenly can create hundreds duplicates of EH) pretty sure that this script must be run on server, cuz anything can happen with connected player ;D
Is the community.bistudio website not loading for anyone else?
All good here
Hi, please help!
KE1 addAction ["Try Green keycard",{ removeAllActions KE1; KE1 say3D ["SCPsfxKCdec", 10, 1]; KEK1 setObjectTextureGlobal [0, _unsatisfied]; sleep 5; KEK1 setObjectTextureGlobal [0, _waiting]; execVM "Locker.sqf"; },nil,1.5,true,true,"","("|#|K_Keycard_Green" in Items _this)",5,false,"",""];
Marked the error, "Error: missing ]"
Asked several friends and it seems fine to them too
"(""K_Keycard_Green"" in Items _this)"
quotes insides quotes need to be double quotes
thank you
Are yall sure the website isnt down? I cant access it on any browser on my pc, and I cant access it on my phone, and I cant access it via data instead of through my modem.
could open it just now
(and other pages on it I usually don't open, so it's not the cache)
I've been using it all morning and then suddenly nothing
How can I force individual AI from a group to go to a XYZ position?
"move" I think, but they will return to the group leaders location after reaching their destination
doMove for individuals
ah thankyou, missed part of it
I have setup CBA building positions for they to take, but it's not reliable
thanks, so basically just do doMove and use moveToCompleted to force them to hold there
Lou it just started loading again, wacky lol
I just unblocked you huehuehue
<3
How do I get the[] call BIS_fnc_garage; to actually spawn the vehicle?
I can get it to open, and allow me to select a vehicle, but when I close it again the vehicle disappears
OH
Nevermind, just gotta close it
Im having trouble with scaling objects again... When this script runs it ends up with the objects being set to a scale of 1. I've checked the value of _cratersize with a systemchat there at the bottom and it comes back as 2.25. I don't make any changes to the object after its scale is set... Does anyone know what could be up with it?
{
_pos = getPosATL _x;
_pos set [2,0];
_crater = createVehicle["CraterLong", _pos, [], 0, "CAN_COLLIDE"];
_crater setDir (getDir _x);
_crater setVectorUp surfaceNormal getPosWorld _crater;
_crater setObjectScale _craterSize;
deleteVehicle _x;
systemChat (format["Size3: %1", _craterSize]);
} forEach craterArray;
make a simple object instead
I need it to keep its collision
The collision of a scaled simple object is not present
Let me rephrase, it is not present for anything apart from a human unit. All vehicles pass through as if its non existent
If you're not scaling a simple or attached object then you probably have to scale it on each frame
Its a static object and can be scaled just once. The script I posted above works fine everywhere apart from a dedicated server
define everywhere
Singleplayer, and local hosted servers
are other clients able to see it on local hosted servers?
One moment, I need to confirm something for singleplayer, I forgot I updated part of the code since I tried it last
Ok, ya it works fine in singleplayer, if on a dedicated server all users see the same issue
I think you're trying to use it for something that isn't supported.afaik you need to have it execute on every frame to make it update for non-simple/attached objects in multiplayer
If it'll work in multiplayer
damn, that would be very unfortunate if its the case
I might have to make my own model then with scaled versions of it. Or just bite the bullet on it
I distinctly recall having to replace a static object with a simple object before scaling it in multiplayer
though I'm not sure what you mean by collision not working
I didn't run into that
I had this convo with the other day with Leopard, and we came to the conclusion that if it was static it was fine to do just once. But I might implied it being in singleplayer
I think the rules are different for single player
to what degree were you scaling it? And did you try and collide with it with a vehicle
Do you happen to have that code still? Because im creating simpleobjects and they have 0 collision with vehicles
Maybe its just the object im using that has oddly scaled collision 🤷
I just created a simple object from one of the altis wall gate arch things
and then scaled it
Ok I tested it a little and it appears its the object im using that causes the issue haha
How can I differentiate a logic object from a building?
they are both synced to an unit, I need to iterate the synced objects and get only the building
typeOf just returns the type, isKindOf checks if an object is of a type
It's enough, unless you reckon that isKindOf is faster
I have no idea what their speeds are
neither typeOf nor isKindOf are reliable for that
logic is an object that getNumber (configOf _obj >> "simulation") == "invisible" (or its side = 7)
they are two different things
??? typeOf or isKindOf is a perfectly reliable way of selecting a building and not a logic. The logic will never be selected by a typeOf or isKindOf that specifies a classname the logic doesn't belong to or inherit from.
the logic doesn't belong to or inherit from.
what makes you think you have to inherit from anything for a config to work?
I can write my own base class
without any regard to game's base classes
Sure, and if you write your own base class a typeOf or isKindOf that specifies a different one still won't select your object
that was an example
what if someone else wants to do it?
do they have to check what base class I use?
no
I feel like you are somehow responding to a problem they didn't pose
I'm responding with the general and correct solution
instead of a "sometimes works sometimes doesn't" one
Uhh? Test it?
They want to select the building from an array that contains a logic and a building. TypeOf or isKindOf will do that 100% reliably. If you specify a building classname for typeOf or isKindOf, you will never accidentally select a logic. It's not a universal detector for any kind of logic but it is in fact a simple, correct, and complete solution to the actual problem
Got a question can you make AllMapMarkers run for only a group?
Pulling the data from the entire map is stressful for the game.
And that function itself is costly in terms of runtime.
I just proved to you it's not reliable. now if you want to keep to your nonsense I have nothing else to say
You proved you can make a logic that's hard to target with typeOf or isKindOf but that wasn't the actual problem
typeOf or isKindOf isn't 100% reliable at telling you something is a logic but you can certainly reliably use it to select a known sort of object that is not a logic
And I really hate the way you're constantly rude to everyone. It doesn't cost anything to be nice.
and I really don't care what you or anyone thinks
@tough abyss I don't know of any other method apart from using allMapMarkers. I couldnt find an event handler for them either
I have nothing to test. It's not my problem and both solutions that were provided to it are known to work.
what do you mean by "group"?
Im about at the point Ill need to take a break on this project lol. I'm creating a number of craters when a plane crashes, i've tried running it on just the server and when its in a scheduled environment it spawns about a quarter of the craters its supposed to and their orientations are wrong. When I spawn it in unscheduled it just doesnt spawn anything. When I run the script on the clients instead of the server it spawns the correct number of craters, however their direction is not consistent from client to client. I've tried to remedy this using "_crater setPos getPos _crater" to no luck.... Anyone have any final suggestions before I move on?
code?
_i = vectorNormalized (velocity _plane);
_planeDeg = (90 - (((parseNumber(str(_i select 1))) atan2 (parseNumber(str(_i select 0))))+180)) + 180; //this line converts the vectorDir of the object into degrees out of 360
_planePos = getPosASL _plane;
_planePos set [2,(getTerrainHeightASL _planePos)];
_crater = createSimpleObject ["CraterLong", _planePos];
craterArray pushBack _crater;
_crater setDir _planeDeg;
_crater setVectorUp surfaceNormal getPosWorld _crater;
_crater setPos getPos _crater;
_crater setObjectScale _craterSize;
If you think it would be beneficial I can send you the whole thing via dm or something. But there really isnt much more than whats there apart from the event handler its called from
my first question is why do you do parseNumber(str?
why convert to string only to convert back to number again? 
the second question is why do you use _crater setPos getPos _crater;?
it's a well known fact that it's wrong
I think I used parseNumber originally because I was using a test for _i that required it. You're right it seems to be useless now, never noticed since the script appeared to be working fine.
I used setPos based on a note on the wiki as well as forum posts suggesting it would sync the direction. Wasnt aware that it was wrong
ah, never checked the getPos page
When I spawn it in unscheduled it just doesnt spawn anything
spawn in unscheduled is scheduled...
did you pass the local vars?
Sorry I misspoke, I used isnill{call blahblah}; for when I did it unscheduled
and yes I passed the local vars into it
I don't see anything in that code that might break in unschd
Ill try running it on the server unscheduled with the changes you recommended, one moment
I was getting a negative version of the number I wanted, so I added 180
wait it has a - behind it. it's being canceled out 
you have (90 - (bla + 180)) + 180 
that's just 90 - bla
getting a negative version of the number I wanted, so I added 180
setDir works with negative numbers, if that's why you did it
Ill mess with that after, it looks like its just redundant steps instead of something that could break it though right?
if I used a neg with setDir then the object would be facing the other way wouldnt it?
idk what you mean by other way, but it would be mirrored around its front
ok
send me the full code
I still don't see why you said it doesn't spawn anything at all
in unschd
apart from the event handler its called from
EH codes are always unschd tho