#arma3_scripting
1 messages Β· Page 44 of 1
the reason they die when they touch the ground is cuz of the parachutes
the parachutes are set to drop significantly faster than vanilla and its at lethal speeds, the paradrop script disables damage prior to landing to avoid it
those parachutes shouldnt be available for general use but for whatever reason, are
im giving them vanilla parachutes
hey how do I use this in an sqf file,
what I am trying to achieve is basically I paste an
execVM "testScript.sqf"
and then whatever objects the script is pasted on, it runs the script in the file on that object
this execVM "testScript.sqf";
in file use _this
Expression called upon at start. In multiplayer, it is called on every machine and for each player who joins in the progress. The variable 'this' refers to the affected object.
About init fields in the Editor.
I get an error saying
error undefined variable in expression: _this
Where do you use it?
external file, mentioning an object for BIS_fnc_holdActionAdd
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
[
_this,
"Search Locker",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
"_this distance _target < 3",
"_caller distance _target < 3",
{},
{},
{
hint "Searched"
},
{},
[],
12,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _this];
anyone know why its not working?
how do you execute it?
execVM in an objects init box
I mean show me the exact code
alright
Execution
execVM "loot\lockerLoot.sqf";
lockerLoot.sqf
[
_this,
"Search",
"", "",
"true", "true",
{ hint "Started!" },
{ systemChat str (_this select 3) },
{ hint "searched" },
{ hint "canceled" },
[], 10, nil, true, false
] call BIS_fnc_holdActionAdd;
it should be this execVM ... not just execVM ...
as you were already told
ah apologies, appreciate it both you and @proven charm
Looking for a script that when you look at a sign or a object in a vehicle, either a service menu comes up on scroll (option list) or service option. Anyone know?
https://community.bistudio.com/wiki/addAction for a scroll option, just define in condition that player has to be in vehicle for it to show up
So service is already in, just adding the usage of that is what I need?
I dont understand parameters, assistance?
(I speak for a server I make, so its a public usage is my concern if possible)
example 5 does show the parameters and some values for assistance. did you take a look at it?
your _hostageUnit is a string, not an actual unit
First, most of the time you should use getPosATL/setPosATL or getPosASL/setPosASL - getPos/setPos are older commands that are slower and have some flaws.
Second...you're defining _hostageUnit as a string, not a unit.
Third, you're using getPos on a string. If hSpawn_x is meant to be an actual object or unit, you need to use that, not a string; if that's a marker then using a string is correct, but you need getMarkerPos.
"" denotes the String data type, which is literal text. Command documentation will tell you which commands expect what data types.
Yes
I had a look, what values could I change to adjust to fit what I need for the service.
(servicing of vehicles and etc)
Eh...probably? Maths is hard
nah, it's correct.
howdy,so I created custom missile config for planes but AI does not want to launch them aganist air targets. How can I fix this issue?
#arma3_config is the place to ask about that
ah,thank you for correcting me
Currently looking to issue some extra gear from an exosuit mod to a couple of players in a PvE scenario for my unit, but the weight of these items is a bit high for how my unit has their stamina stuff set up with ACE. What's the most effective way of being able to issue this gear to a select few player units and have them still able to perform without fatigue being as much of an issue without changing anything for the rest of the players?
setUnitTrait changing the loadCoef trait, probably
My main concern is how to set those values in a way that applies across respawns, but only to those units.
My assumption is that those values in the unit init wouldn't persist when they respawn?
you should be able to test that on your dev server
oneachframe {hintsilent str (player getunittrait 'loadcoef')}; and then kys
Yep, all working. Thanks for the tip.
I'm getting an error about type Number expected Bool and I'm confused as to how to fix this, even though it seems to be working in game. ```c
21:32:44 Error in expression <grade];
if ((_x select 0) == _paygrade) then {
_paymentToDo pushBack [_player, (>
21:32:44 Error position: <then {
_paymentToDo pushBack [_player, (>
21:32:44 Error Type Number, expected Bool
Here's a snippet of the script that's causing that error. Any help would be appreciated
```sqf
_totalPayment = 0;
_paymentToDo = [];
_paygrades = (missionConfigFile >> "SOG_AdminSystemClientModule" >> "dummyVariables" >> "payday" >> "paygrades") call BIS_fnc_getCfgData;
{
_player = _x;
_paygrade = _player getVariable ["PayGrade", "E1"];
{
// diag_log format ["%1", (_x select 0)];
// diag_log format ["%1", _paygrade];
if ((_x select 0) == _paygrade) then {
_paymentToDo pushBack [_player, (_x select 1)];
_totalPayment = _totalPayment + (_x select 1);
}
} count _paygrades;
} count (playableUnits);
if (_totalPayment > companyFunds) exitWith { hintSilent "Poor Guys" };
{
(_x select 0) setVariable ["Cash_Bank", ((_x select 0) getVariable["Cash_Bank", 0]) + (_x select 1), true];
} count _paymentToDo;
["deduct", _totalPayment] call SOG_ClientModules_fnc_adminRefresh;
["deduct", _totalPayment] remoteExecCall ["SOG_Server_fnc_handleFunds", 2];
};
This is what the full output looks like: ```c
21:56:37 "[[""E1"",1000,""Enlisted""],[""E2"",1250,""Enlisted""],[""E3"",1500,""Enlisted""],[""E4"",1750,""Enlisted""],[""WO1"",2000,""Warrant""],[""WO2"",2250,""Warrant""],[""WO3"",2500,""Warrant""],[""WO4"",2750,""Warrant""],[""2LT"",3000,""Officer""],[""1LT"",3250,""Officer""],[""CPT"",3500,""Officer""],[""MAJ"",3750,""Officer""]]"
you must return a boolean to count condition
you're currently returning a number, thus the error
stop using this "count perf" cheat thing, just forEach π
count when you actually need to count something, not iterate over an array
can I have a forEach within a count?
all 3 counts you have just replace with forEach and the problem will go away
or if you want to keep it with count, simply leave a true on the stack
also all those selects, use params
fx.,
{
_x params ["_obj", "_thing"];
_obj setVariable ["Cash_Bank", (_obj getVariable["Cash_Bank", 0]) + _thing, true];
} forEach _paymentToDo;
(rename the variables ofc, i got no idea what these things are)
ok thanks for the help
you can probably also use a hashmap here
@cedar kindle And if they aren't?
you can still use a CBA PFH and only process part of the problem on each frame.
Is there any way to set something up in a mission such that player profile facewear is ignored and the loadout facewear is used other than just manually using removeGoggles>addGoggles per unit in their init? Itβs a massive pain in the ass.
great idea
use PFH
and after that why dont we take this shit even further on the script scheduler?
we do not have to stop here
meh ... there where some word missing
can I somehow measure the detection rate/chance of unit depending on stance that unit is in? I'd like to see if unit doing a Ctrl+W/Ctrl+S "semi"-stances is harder or easier to detect than when in normal stand/crouch/prone stance. Placing two units in front of eachother while one of them does different poses seem to be too random
Yes. There's a config value for the animation "stealthiness". IIRC it was called visibleSize or something
tidy: ```sqf
_spawns = [hSpawn_1,hSpawn_2,hSpawn_3,hSpawn_4,hSpawn_5,hSpawn_6,hSpawn_7,hSpawn_8,hSpawn_9];
selectRandom _spawns;
btw there is ,, in the code
if you want to exclude spawn objects from selectRandom you can do this:```sqf
selectRandom (_spawns - [_notThis]);
then the _notThis will not be selected
or something like ```sqf
private _spawns = [hSpawn_1, hSpawn_2, hSpawn_3, hSpawn_4, hSpawn_5, hSpawn_6, hSpawn_7, hSpawn_8, hSpawn_9];
private _weights = [0.1, 0.1, 0.6, 0.6, 0.6, 1.1, 1.1, 1.1, 1.1];
private _hostagePos = _spawns selectRandomWeighted _weights;
_spawns = _spawns - [_hostageSpawn];
private _pos2 = _spawns deleteAt (random count _spawns);
private _pos3 = _spawns deleteAt (random count _spawns);``` π€
"select random index inside the array boundary, save the value at that index into a separate value and delete it from the array"
the positions to use for "hMarker_2"/"hMarker_3"
just like you did in your own code? sqf _hostageUnit setPosATL (getPosATL _hostagePos); "hMarker_1" setMarkerPos (getPosATL _hostagePos); "hMarker_2" setMarkerPos (getPosATL _pos2); "hMarker_3" setMarkerPos (getPosATL _pos3);
Is there a way to hide mouse cursor from display?
make it a title?
Need a display to track mouse movement with MouseMoving event and stop the player from moving the camera
Unless there is another way to do that π€
Don't think title fires MouseMoving, does it?
inputAction can detect mouse movements I think
i don't think it would
i don't think you can disable the cursor
there was a FT thread about it
but was never implemented iirc
It does, thanks for the hint
Thinking about having an invisible map control that does ctrlMapCursor each frame, if there is an empty cursor there π€
Arma moment: MouseMoving and inputAction report no mouse movement if you do disableUserInput, yet mouse moves properly.
Well, having invisible map control that does ctrlMapCursor could be a solution, if there was an invisible map cursor in vanilla config.
Simple question, why is the following not working? It is supposed to attach/detach the suppressor for the entire player group.
if (("muzzle_snds_M" in primaryWeaponItems player)) then {
_x removePrimaryWeaponItem "muzzle_snds_M";
hint "Silencer off";
}
else {
_x addPrimaryWeaponItem "muzzle_snds_M";
hint "Silencer on";
}forEach units group player;
{
if (("muzzle_snds_M" in primaryWeaponItems _x)) then {
_x removePrimaryWeaponItem "muzzle_snds_M";
}
} forEach units group player;
Unless you want to add/remove based of only player having/not having it
yea, it should be based on ether the player has it or not and then attach/detach for the whole group including the player.
private _its_on = "muzzle_snds_M" in primaryWeaponItems player;
{
if(_its_on) then {
_x removePrimaryWeaponItem "muzzle_snds_M";
} else {
_x addPrimaryWeaponItem "muzzle_snds_M";
};
} forEach units group player;
private _its_on = "muzzle_snds_M" in primaryWeaponItems player;
if(_its_on) then {
hint "Silencer off";
} else {
hint "Silencer on";
};
{
if(_its_on) then {
_x removePrimaryWeaponItem "muzzle_snds_M";
} else {
_x addPrimaryWeaponItem "muzzle_snds_M";
};
} forEach units group player;
```with hint
This works perfect. So it's better to work with a variable.
Thank you for your help!
well, you can replicate the whole loop instead. Either works.
Hello, I hope this is the right place to ask this.
I got this repeated trigger to work as intended, but after everything plays out in about two minutes, the trigger can be tripped again.
I wonder, is there a simple way to put sleep 600; somewhere to delay it's reset? I tried it right under terminate _handle; but it works just like before.
The trigger is as follows:
[] spawn { _handle = [player, player, east, ["AM_Ghoul_O_Radhop", "AM_Ghoul_O_Default", "AM_Ghoul_O_Hopper", "AM_Ghoul_O_Default"], 15, 1] spawn BIS_fnc_spawnEnemy; sleep 50; terminate _handle; };
Do you mean you want trigger to not start again for 600 seconds after you triggered it?
Yes
I guess you could disable simulation on the trigger.
or save last activation time in variable on trigger itself and check it inside the condition
disabling saves lives CPU cycles
Not a big trigger guy, but I guess something like:
thisTrigger spawn {
_this enableSimulation false;
sleep 600;
_this enableSimulation true;
}
```inside activation?
Theoretically yeah
Thanks guys, I'll try it out.
_x removePrimaryWeaponItem (primaryWeaponItems _x select 0);
```to be sure to remove any suppressor they might have, making the code even more universal!
This worked exactly as intended and will be universally useful across the board, thanks again!
You're writing good code, keep on! 
Hmm, I have encountered a strange issue where when I use BIS_fnc_spawnEnemy; and set them as east (they are placed as west in the editor by default otherwise) their squad is marked red as east but individuals are still blue and shoot each other after being spawned by the trigger.
This all happens within the single squad.
are you certain your BIS_fnc_spawnEnemy "classes" argument is for right side units?
I think I misunderstood, then. I thought the "side" overrides "class" affiliation
The units are from west roster.
side determines which side they belong
[player, player, EAST, ["Armored_Coat_01_body", "Armored_Coat_02_body", "Armored_Coat_02_body"], 20, 1] spawn BIS_fnc_spawnEnemy;
you could make east soldier (model) to be in west side with that (I think)
the "Armored_Coat_01_body" is WEST by default, but I thought they would become EAST
you are kinda right but at init the config side takes precedence for some reason
you can change their side after 1 frame
but I don't recommend it
instead just set their loadout
I thought that a little delay and then a side change could fix it.
Alright
No, no.. I did not do that yet. I'll look into it now, thanks for the pointers!
I personally spawn ordinary riflemen first then just change their loadout (e.g if I want a bluefor viper I create a B_soldier_f then just do _unit setUnitLoadout "O_Viper_F" (or whatever it was...)
I think I will rewrite the triggers to use this method instead. It sounds much cleaner. Thank you!
It bothers me that BIS_fnc_spawnEnemy has a side parameter if it doesn't work
it only works if the side is the same as the spawned unit's side... 
that's a createUnit limitation, not related to the function itself
Yeah..
Okay, but given that limitation, the function should either not offer the option, or should make it work by some other means (e.g. using a delay as you described). Letting you specify a side when that doesn't actually do anything is certainly related to the function.
, % should be a string
, "%"
you can also use %
since you're using structured text
Can anyone help me make a script to make it seem like a helicopter was hit by lightning when it enters a trigger area, but actually just damage it's tail rotor? this is what I have so far.
https://community.bistudio.com/wiki/setHitPointDamage is all you need
well and ofc finding the correct hitpoint, https://community.bistudio.com/wiki/getAllHitPointsDamage
also locality, so in the end, something like
if !local lightningHeli exitWith {};
lightningHeli setHitPointDamage ["replaceme", 1];
Hey! Is there a way of using Sleep in an unscheduled environment? I'm looking online and can't find anything sadly.
If I remember correctly, it's to do with Spawn, but I can't remember the exact code.
No sleeps in unscheduled. You can create a new scheduled thread with spawn or execVM from unscheduled, though
I'll look a little further into it. Thanks π
this helped, thanks!
[] spawn {
sleep 10;
call MUH_fnc_something;
};``` is the basic idea
"sleep" in unschd env would mean "freeze the game during that period and do absolutely nothing"
obviously no one would want that
does anyone know what this means help
you have a macro issue somewhere. Check to see if your macro "LOG" accepts arguments cause I think you fed it one and its not set up to take one currently
im using cba right so where would i go to check that
like where all my keybinds are or?
CBA shouldn't throw an error unless you may have included things wrong/file path wrong elsewhere I think.
but
if it is CBA, turn off "warnings are errors" in pboProject to ignore it
Heyo, does anyone know if the player variable BIS_revive_incapacitated is set as global in the default arma revive system?
yeah so the cba isnt triggering it anymore. now you have file pathing issues atm
yes its global
// from a3/functions_f_mp_mark/revive/defines.inc
#define STATE_RESPAWNED 0
#define STATE_REVIVED 1
#define STATE_INCAPACITATED 2
#define STATE_DEAD 3
#define GET_STATE_STR(state) format["%1(%2)",["RESPAWNED","REVIVED","INCAPACITATED","DEAD"] select state,state]
#define SET_STATE(unit,state) ["",state,unit] call bis_fnc_reviveOnState;unit setVariable [VAR_TRANSFER_STATE, state, true]
#define SET_STATE_XTRA(unit,state,source) ["",[state,source],unit] call bis_fnc_reviveOnState;unit setVariable [VAR_TRANSFER_STATE, [state,source], true]
#define SET_STATE_XTRA2(unit,state,source,reason) ["",[state,source,reason],unit] call bis_fnc_reviveOnState;unit setVariable [VAR_TRANSFER_STATE, [state,source,reason], true]
#define GET_STATE(unit) (unit getVariable [VAR_STATE, STATE_RESPAWNED])
#define IS_DISABLED(unit) (GET_STATE(unit) == STATE_INCAPACITATED)
#define IS_ACTIVE(unit) (GET_STATE(unit) < STATE_INCAPACITATED)
ππ€
pboproject is an absolute pain to use because it wants perfection... which sucks for the user, but its best for the user as well. tough love.
Well I have another question π€ Maybe someone has an idea, I have unfortunately found nothing helpful. Is there any way to check if a hold action becomes visible on screen?
So that you know:
I have put a jump action on spacebar and want to prevent that you jump by mistake when you want to press the hold action π
you mean unmount it? or delete the files in it. if the latter, its a physical location on your drive
yea sorry i had a dumb moment but i got it figured out now
//check if another hold action is running, if so terminate the new hold action execution
if (!isNil "bis_fnc_holdAction_scriptHandle" && {!scriptDone bis_fnc_holdAction_scriptHandle}) exitWith {};
taken from the function itself
I have looked at that too. However I dont want to check if the hold action is running, but if it is displayed on screen π
is it good that my pboproject is taking a bit now instead of instantly giving me errors
For your sanity's sake just change the jump key lol
Would probably be better haha. But spacebar is just THE jump key π€£
Is it possible to change the key for a hold action? I guess not?
findEmptyPosition works fine on terrain, but what about on something like a ship deck
Probably gonna have to cast rays or something
like testing bounding box at a position the object isnt at? @meager granite
Yeah, depending on your needs
i am currently working on a set of scripts that "teleports" an object to the player in order for them to use it and then teleports it away when they are done. I am doing this with an addAction and setPos for each movement. The issue is it only works once for each, so it will teleport to the player and teleport away but then it wont work again. Any ideas? I dont want to use an SQF since it is supposed to all be a composition instead i am using something like testTest = true
Could someone help me with combining two arrays defined from a config.hpp if a player's UID matches a specified UID. ```hpp
storeCategories[] = {
"storeBackpacks",
"storeGoggles",
"storeHeadgear",
"storeItems",
"storeMagazines",
"storeUniforms",
"storeVests",
"storeWeapons"
};
storeRestrictedCategories[] = {
"storeAircraft",
"storeArmored",
"storeChopper",
"storeMarine",
"storeStatic",
"storeUAV",
"storeUGV",
"storeWheeled"
};
```sqf
{
if ((getPlayerUID player) in companyGenerals) then {
{
_index = lbAdd [2023005, _x];
} forEach storeRestrictedCategories pushBack _x;
};
_index = lbAdd [2023005, _x];
} forEach storeCategories;
lbSetCurSel [2023005, 7];
Essentially I need the storeRestrictedCategories to only be added to the storeCategories array when the if statement is met.
Hi, do scheduled scripts have much effect on game performance? I understand from the wiki the scheduler allocates 3ms per frame, which in theory should give about 14ms for everything else to run at 60 fps. Are there cases where the scheduler may significantly overrun the 3ms limit, eg if some heavy atomic script command cannot be paused midway through? Is there a way to pause the entire scheduler, or terminate all scripts, to see the total performance effect of all the scripts that were running?
when would I ever want to use a with uiNamespace do construct? I don't really understand its description and what it is for
if it goes over, it pauses the current script and attempts to continue where it left off on the next frame
It looks like it's for switching namespace, so if you're working with a lot of e.g. uiNamespace variables you don't have to do uiNamespace getVariable [ ... all the time
Makes sense. I guess I'm wondering how far past 3ms some scripting commands may push the scheduler. Like what if it begins an operation at 2.9ms which takes a whole 1 ms.
As far as command can freeze the game.
take a look at BIS_fnc_showRespawnMenu. It uses a with do in it but I can't understand why they would use it there. It looks like they use traditional get/setvar with namespaces in there
nearestObjects [player, [], 100000] will freeze the game for like a minute and scheduler won't help you
Basically, running heavy commands inside scheduler isn't going to help. I think scheduler can interrupt and wait until next frame only at ; or something like that.
Ok, that was my worry.
So is there some way to pause the scheduler, or terminate all scheduled scripts? Ie in order to determine if I had expensive things scheduled.
You had it almost right, just have two loops one after another instead of inside another:
{
_index = lbAdd [2023005, _x];
} forEach storeCategories;
if ((getPlayerUID player) in companyGenerals) then {
{
_index = lbAdd [2023005, _x];
} forEach storeRestrictedCategories;
};
lbSetCurSel [2023005, 7];
BI write weird function code? That's unpossible
I've never used it and can't open the game right now so have no further insight. Good luck
sleep is the way to pause, waitUntil is another, it won't guarantee frame/millisecond perfect pauses though.
Sorry that's not what I meant. Is there a way to globally pause/disable/empty the scheduler?
Like pause all scripts even ones I didn't write, to compare game performance with scripts running vs a baseline with no scripts.
Post code snippets
Lots of things run scheduled including base game stuff - the scheduler is a core part of the game. I don't think this is possible.
There are performance diagnostic commands and tools you can use to evaluate how given code is performing.
Gotcha, makes sense. For my own scripts, I suppose I could keep track of all the script handles and at least terminate everything that way, for purpose of performance comparisons.
Thanks for the help.
Thanks, that is a good one.
I've also started tinkering with diag_captureSlowFrame in the development build, but unfortunately I'm not familiar with most of the symbols the call tree includes.
If you think your scripts freeze the game and you're sure its not something in unscheduled, look for heavy commands
allMissionObjects for example is a no-no to use during gameplay, always freezes the game for a bit
nearestObjects with huge radius is another one
You can try capturing normal frame and slow frame, dump both frames into file and then compare timings
Not sure if there are tools to ease the comparison, you can just do it manually
Good idea, I'll give that a try.
Thanks for the tips.
Gotta say, it's often challenging to answer the question "is the game lagging because too many units, or because bad script?"
It can be both
The problem I'm having is when I select "storeAircraft" from the dropdown, a hint show that "storeBackpacks" was selected. My scripts to change Modset and Category all revolve around the "storeCategories" array being used. So how would I add the "storeRestrictedCategories" to the "storeCategories" array when the if statement is met? Or am I doing something wrong?
Ah crap I just found 2 instances of the above mentioned expensive allMissionObjects in my script. allMissionObjects "WeaponHolderSimulated" and allMissionObjects "GroundWeaponHolder"... for a garbage collector. I haven't actually noticed any lag spike from this, but is there a better way to get all such objects?
Then execute:
if ((getPlayerUID player) in companyGenerals) then {
storeCategories append storeRestrictedCategories;
};
```somewhere after you've read your configs and only add `storeCategories` into the listbox.
WeaponHolderSimulated is returned with vehicles and entities "WeaponHolderSimulated" commands.
GroundWeaponHolder can be returned with much less costly 8 allobjects 0 command.
vehicles and allobjects include other objects of course, you'll need to skip them
Ok, so you're saying allObjects should be faster than allMissionObjects and useful for getting "GroundWeaponHolder". I'd definitely like to avoid having the client tell the server when GWH is created, as mentioned in your ticket, and keep it simple.
Run diag_codePerformance on both to see for yourself
Ok, will do π
Is there a vehicle respawn script out there that preserves the wreck? I don't get why the default vehicle respawn module moves all the wrecks to [10, 10, 10]
The results are in:
[
count allMissionObjects "",
diag_codePerformance [{allDeadMen}],
diag_codePerformance [{vehicles select {_x call BIS_fnc_objectType select 0 == "Vehicle"}}],
diag_codePerformance [{allMissionObjects "GroundWeaponHolder"}],
diag_codePerformance [{allMissionObjects "WeaponHolderSimulated"}],
diag_codePerformance [{8 allObjects 0}],
diag_codePerformance [{8 allObjects 0 select {_x isKindOf "GroundWeaponHolder"}}],
diag_codePerformance [{entities "WeaponHolderSimulated"}],
diag_codePerformance [{vehicles select {_x isKindOf "WeaponHolderSimulated"}}]
];
[
922,
[0.0169532,58986],
[2.75482,363],
[40.12,25],
[40.56,25],
[0.0592663,16873],
[0.335683,2979],
[0.0124983,80011],
[0.076063,13147]
];
Will replace allMissionObjects with allObjects for GWH and entities for WHS.
The second one (2.75 ms) could probably be improved too...
_soundSetSource = "SoundSetSource_01_base_F" createVehicle _position;
can anyone reason why creating that takes a 10ms?
like entity generation is expensive in general, but this seems strange to be so heavy
Do you check it with diag_codePerformance?
Might it be because of empty space lookup?
diag_codePerformance [{_position = getPos player; _soundSetSource = createVehicle ["SoundSetSource_01_base_F", _position, [], 0, "CAN_COLLIDE"]}]
```=> `[0.256476,3899]`
```sqf
diag_codePerformance [{_position = getPos player; _soundSetSource = "SoundSetSource_01_base_F" createVehicle _position;}]
```=> `[2.38095,420]`
Yeah, space lookup for that old syntax makes the command 10 times slower
diag_codePerformance [{_position = getPos player; _soundSetSource = createVehicle ["Logic", _position, [], 0, "CAN_COLLIDE"]}]
```=>`[0.0811216,16013]`
```sqf
diag_codePerformance [{_position = getPos player; _soundSetSource = "Logic" createVehicle _position;}]
```=>`[0.102371,10247]`
Entity type also matters, no lookup for "Logic", probably depends on the model? Newer syntax with `"CAN_COLLIDE"` is still faster though.
with a profiler
great thinking - much appreciated πββοΈ will report how much difference it does make in our use case
@meager granite Thanks for the help, that worked like charm
uhm is that a typo?
diag_codePerformance [{_position = getPos player; _soundSetSource = ["SoundSetSource_01_base_F", _position, [], 0, "CAN_COLLIDE"]}]
=>
diag_codePerformance [{_position = getPos player; _soundSetSource = createVehicle ["SoundSetSource_01_base_F", _position, [], 0, "CAN_COLLIDE"]}]
[0.820345,1219]
[22.4,45]
Yeah, the test was for correct code
still the difference is massive
Old syntax: [1.4341,698]
New syntax: [0.193536,5167]
Tested again just to be sure
is there any issues with doing hashValue player?
I was reading https://community.bistudio.com/wiki/HashMap#Unsupported_Key_Types and it says Objects are unsupported but I didnt see any reason on why say hashValue player would not work
Depends on your usage
hashValue of same unit in MP will be different for example Nevermind, its MP-compatible
A hash value remains the same between game restarts but for Object and Group type, their hash being based on their netId.
```Actually, maybe not π€
Just keeping a list of certain units only on server, so I figured using hashmap would be neat cause of constant time look up.
If you have a unit already, why do the lookup when you can store something in unit's variable namespace in the first place?
I have a loop where every so often it will loop over this list of certain units (which I could just use a simple array for). However when that unit dies or killed I should remove from said list, and I was thinking maybe having the units saved in a hashmap wouldnt be terrible idea
If your unit gets deleted instead of dying (or dies and deletes later) and then you do a walk through array of your units, you won't be able to use it as a key in your hash map because hashValue objNull will always return same hash.
are objects even a valid type for hashmap keys?
They aren't, @edgy dune tries to used hashValue _object as key instead
The page says no, but when i tried it gave a hash value back 
oh I was thinking the page also meant using hashValue would also not work
If your unit deletes, you no longer can find its key
A hash value remains the same between game restarts but for Object and Group type, their hash being based on their netId.
Went into SP editor, hashValue still different for different entities, but apparently there are nonetIds in SP
inb4 https://community.bistudio.com/wiki/BIS_fnc_netId and periodical sanitizing by checking if object still exists 
Unless there are and command just returns nothing in SP to appear as there isn't
Or just use isNull
isNull on what?
no netid off non-existing unit
Nothing off null objects with BIS_fnc_netId either
keys _myHashMap select {isNull (_x call BIS_fnc_objectFromNetId)} 
_x would be hashValue in your example though
hashValue and hashmap keys are different things. Not really related to eachother
Objects cannot be keys because they can become null, thats irrelevant for hashValue
it would be netId if objects are added with _myHashMap set [_targetObject call BIS_fnc_netId, "MuhValue"];
it works like BIS_fnc_netId
oh okay I understand, I misread then
well, the problem i'm trying to circumvent by using BIS_fnc_netId is that you can't go from hashValue back to object to see if it still exists 
There is no entity anymore to feed into BIS_fnc_netId to get your key to look up in hashmap
same as no entity to feed into hashValue
hence the "periodical sanitizing by checking if object still exists" part
possible with netId. Impossible with hashValue π€·ββοΈ
Yeah, the only way would be iterating through list/hashmap yourself to check for deleted objects
createVehicle ["Logic", getPos player, [], 0, "CAN_COLLIDE"]; => objNull
wat
Why can't you createVehicle the Logic entity?
apparently they're units π€£
You can createVehicle other units though
Is there a way to move a unit to a marker on the map by using setpos? Or how would i do it?
!quote 5
stop using 'setPos' for the love of god
Leopard20; Tuesday, 10 August 2021
_unit setPosASL AGLToASL markerPos ["markerName",true]; π€·ββοΈ
Works! Thank you!
What is the best way to let time pass during a mission? Eg. move time forward by six hours.
skipTime
Thank you
or setDate if you don't want the weather synchronised (leading to a slight stutter)
got it, thanks
Alright, question time: I've pulled a steam workshop mission into the eden editor using the PBO unpacker thingy, loaded it up, and immediately get hit with a script error. One that doesn't exist when I just play the mission on its own. I know absolutely nothing about scripting or editing other than what I'm seeing here, so I'm a bit lost as to where to start trying to figure this out. Please advise
This is what I get when I load in. Either it's not a lot of information or I have no idea how to read it. Or both
I'm off to steam to ask the original author
Ah, apparently he has "improved scripts" from his github. I will return
these are the 2 errors i get when im in editor trying to get zeus to work when i go into play in multiply that pops up and Zeus does not work. in editor i also can not edit addon options i have had the same problem for 2 days and my zeus module is set up correct
anyone know how to fix it hopefully
hey, how would I remote execute this?
Taki say3D ["haircut", 1000, 1];
the best I got was
[Taki, "haircut"] remoteExec ["say3D", 1000];
but that aint good enough it seems
Due to the missing 1 at the end
i have both in the mod pack
and loaded up?
it is on sog dlc tho i am trying to make this mission for my unit it is in my loaded mods
[left argument, right argument] remoteExec ["command",targets(optional),JIP(optional)];```
<https://community.bistudio.com/wiki/remoteExec>
```sqf
[Taki,["haircut",1000,1]] remoteExec ["say3D"]```
ah okay
that helps
works like, working things
thanks
is the wait/sleep command just exclusive to SQFs or is it somehow possible to have it in a trigger?
Since mouth movements would compliment voicelines well
i put in 3din enhaced but not sure really how to use it but i took out zeus enhanced cause i though it was causing problems but it still continues
Hello people. Quick question here before I commit and spend hours on making a scene for a video that I am working on. I am using some other Arma 3 Machinima videos for reference, but just cant figure out whether this part here is just UnitCapture or if he has created a script for it
ARMA3 Machinima Cinematic Movie by Flawless War Gamer
(The battle for Aachen βΆ World War 2 Cinematic Movie)
Subscribe Link:
(https://www.youtube.com/channel/UCO3rUMBjMZ0Iuo5MfRWIROw?sub_confirmation=1)
There is one thing that you shall never forget !!!
Machinimas is an extremely complicated and time consuming work to do.
Help me in order to ...
switching weapons no longer present on scroll menus or is it just me?
I would guess he is using UnitCapture, but just want to check here before I commit into my scene
The reason im asking is that, you can see each AI move in a different way, and by the looks of it, Im not even sure if that is vanilla movement (player movement).
is there any way to get rid of the reload entries on the scroll menu?
Did you come to a solution? π
sleep commands work in scheduled* code. See the wiki page for the "spawn" command to execute scheduled* code in a trigger
sleep commands work in unscheduled code
β¦no
spawn creates scheduled code π
(I believe you inverted scheduled and unscheduled ^^)
(yes I did)
(thou shalt be spared⦠this time)
I didn't get spared when I tried to explain it and I was right, how come he gets away with it :U
he's the favourite child :p
thats not for reload, its to change type of amunition.
put same mag in the weapon and vest/backpack
Putting together a function that, in the course of use, may spawn several helicopters on the ground in relatively short time frames.
This isnt a problem per se, since theres five helicopter bays that Im using for this, and the array-of-markers thing works... but the bays are large enough that createVehicle will try and pack two into once space before choosing another bay, which is uncomfortably tight.
Is there anything I can do to reliably get it to pick one marker at a time?
The odds of multiple helicopters being created at the same time, or even within a short time, is pretty small, but I want to minimize AI air collisions if possible.
it really boils down to what you want to use as conditional.
you could even sequenciate it instead and just have a predefined order of spawns.
If this doesnt satisfy you, use positions instead of objects and check for space availability.
Doing a distance check to an already existing helicopter should allow you to do this. if you are using object variable names you can even use the distance command
https://community.bistudio.com/wiki/nearObjects
There is a lot of approaches on this issue
posting your code wouldn't hurt either
ist there an easy way to count the number of seats a vehilce has?
https://community.bistudio.com/wiki/fullCrew using the inlcudeEmpty flag gives you an array with the total number of positions in a vehicle, which then you can count the indexes in.
Alternatively just get the info from the config
thank you very much
The config method is quite complicated but there's BIS_fnc_crewCount which is mostly usable.
The code atm is very much in the testing phase, and nominally the same as the example on the wiki, though Im sure as I polish it up ill have more questions and something to show for it.
the fullCrew did work better for me
Noted; was hoping not to go full-bore on it, but rotating through an array of the spawns is certainly an option.
fullCrew's fine as long as you can wait until the vehicle is spawned.
^^ very important detail indeed. Fullcrew only works for existing vehicles.
Ugh. Can already see the excess now. Check if pad 1 is clear, if not, check if pad 2 is clear, if not... if pad 5 isnt clear, wait for a pad to clear
its all part of the creation of a script after all, first get it to work the way you want it and then you can bring your concerns for optimization or design in order to discuss
anyone know why this script isnt working? it gives me the interact option but wont add the item
(this) addAction ["Fill Canteen", {
_item = "Land_Canteen_F";
_count = 1;
for "_i" from 1 to _count do {
player addItemToBackpack "_item";};
},[],6,true,true,"","true",10];
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
!code
(this) addAction ["Fill Canteen", {
_item = "Land_Canteen_F";
_count = 1;
for "_i" from 1 to _count do {
player addItemToBackpack "_item";};
},[],6,true,true,"","true",10];
@velvet knoll you have quotes around _item which makes the game think _item is the classname
just write _item without the quotes since it's a variable pointing to a classname
syntax highlighting catches this kind of thing. The ` key is above TAB and left of 1 on a US keyboard. You type ` three times to make a code block and write sqf at the top to get the highlighting.
this addAction ["Fill Canteen", {
//removed redundant loop
_item = "Land_Canteen_F";
player addItemToBackpack _item; //no quotes
},[],6,true,true,"","true",10];
player addItemToBackpack "_item"; //with quotes (incorrect)
Yeah i was just looking at that myself, wasnt quite sure what i was doing wrong there
thanks for clearing that up for me
The only other thing is make sure "Land_Canteen_F" is an item that can be added to an inventory. Afaik it's not.
and therein lies my other problem
ill have to use the ace item then
thank you!
yw
@open fractal success! thank you for the assist
Hello, sorry for bothering but...
Do you think this would be an alright way to do it in each individual trigger (for decently wide variety of custom loadouts and units) or is this liable to cause problems on a greater scale?
Each trigger is a different type of loadout per squad (patrol, assault squad, platoon etc...) and different squads per faction. I am looking at about 12 different trigger variations total.
_bosPaladinSpawn = createGroup EAST;
paladin01 = _bosPaladinSpawn createUnit ["O_Soldier_F", getmarkerpos "bosPatrolSpawn", [], 1, "FORM"];
removeAllWeapons paladin01;
removeAllItems paladin01;
removeAllAssignedItems paladin01;
paladin01 addMagazines ["24Rnd_MicroFusionCell_Mag", 8];
paladin01 addWeapon "AM_LaserRifle";
//etc. for remaining gear and additional units in the squad...```
i have a problem with some of my code...
if i use allGroups I get an array with every group on the map...
but the following code always has <null> as the first entry in that array... why is that?
{
if (side _x == WEST) then
{
_grouptype = _x call getGroupType;
bluGroup set [_forEachIndex, [_x,_grouptype]];
//bluGroup deleteAt (find "<null>");
};
if (side _x == EAST) then
{
_grouptype = _x call getGroupType;
opfGroup set [_forEachIndex, [_x,_grouptype]];
};
} forEach allGroups;
is there a way to just delete that useless entry?
you're using set with _forEachIndex, first group is not of side west, thus next time when the side is west, set will have to fill in the blanks (because you're relying on _forEachIndex)
removeAllWeapons paladin01; removeAllItems paladin01; removeAllAssignedItems paladin01; paladin01 addMagazines ["24Rnd_MicroFusionCell_Mag", 8]; paladin01 addWeapon "AM_LaserRifle";
just use 1 setUnitLoadout instead of all those lines
is this liable to cause problems on a greater scale?
in what terms?
Oh, that should make things simpler, thanks.
I meant if I have 3 to 10 different soldiers with different loadouts, will it choke if it's all placed into activation field of the trigger in the editor?
Say, when three or more such triggers are tripped at the same time
no. unitCapture cannot capture infantry animations
some of the animations were vanilla. some were not (or maybe I didn't recognize them), which were created in other tools (e.g. Blender)
you can make the AI play the animation using playMoveNow (you also need disableAI "MOVE"/"ANIM" to make sure AI won't rotate or interfere)
if you need to make units also turn as they move, you can do so using setVectorDir command every frame (normally created as part of a path loop)
@torpid mica why delete the message? https://community.bistudio.com/wiki/pushBack
so you mean in terms of performance?
Ah, interesting. Havent seen setVectorDir before
I will have a look
you are right. i did not notice that thank you very much
Yes, I thought of doing it directly in the trigger instead of sqf. I wondered if it hits performance significantly.
addWeapon can be surprisingly slow, IME. Maybe not something you should do in unscheduled code.
Can always spawn it (and ideally pull it out to a function)
commands being slow doesn't are still slow in unschd tho 
Right
Well a single trigger will spawn a group of five (more or less) soldiers plus set all their equipment individually. That was the plan and concern.
well if you notice any problems just switch to schd (using spawn or execVM)
Alright, thanks!
I think the way Arma works you can even get visible hitching when creating units in scheduled code, because it waits for the asset load.
At least it feels like that.
Yeah, I did notice this using a little larger custom unit compositions, even on SSD
And players notice this also in real-time MP
In Antistasi we usually sleep between each unit spawn, but I'm not sure if anyone ever tested whether this helps.
It just might, I noticed how they pop in in quick succession but it never really hitched. The triggers using createGroup seem to consistently give hitches when the unit count is around 10 or more
you simply make spawns happen in different frames, rather than bulks in a single frame, so it does help
This is also very good to know, thank you all!
environment should have no influence on the command's execution
if a command is really expensive to a point where you hang the game, running it unschd or schd will make no difference
You mean a single command?
yes
Difference with scheduled is that if you have 10 slow commands then it'll split them across 10 (not necessarily consecutive) frames.
yes ofc
while if you do that in unscheduled it'll just freeze until the script is done.
yep
Fantastic info
One additional question after seeing things play out in 4 person multiplayer the other day.
bis_fnc_spawnEnemy was used, I tested the triggers in singleplayer and they worked more or less in accordance to the seconds set in sleep, but in multiplayer it took twice or thrice longer to make the triggers work.
For example, ghouls spawn is set to have 30 sec delay after entering the trigger zone and then spawns all the units. However in multiplayer it took up to 3 or even 5 minutes.
Should only happen with very heavy script load.
Could high latency also cause it?
Was this localhost?
dedicated server on windows machine, using... uh... hamachi, and having a friend from US join who gets 250~ ping
Maybe if the server was really struggling on bandwidth.
Right, I suppose it was. It's not stellar to begin with and multiple people use it at times.
seems extreme though. Would be surprised if that was playable.
low server fps + lots of scheduled code = π₯
Yeah, the server did not struggle on the hardware side, it also has the liberty of being a separate machine from the one I play on.
it really borderline wasn't
The trouble with the scheduled script load idea is that the scheduler is supposed to prioritize threads that have slept for longest.
So sleep 1 spammed threads shouldn't delay a sleep 30, for example.
That one was word of mouth from the devs though, so maybe they were thinking of a different game :P
It prioritizes the ones that have slept the longest but does not wait for them to get off sleep, right?
I mean, before moving to non-sleeping one
You mean if the long one takes more than 3ms to execute?
I dunno, maybe I'll reverse engineer the thing some day. Should be able to figure what it's doing with crafted test cases.
but generally you keep the script load low and then everything works :P
I think I meant a more stupid question, if one is set to 'sleep 6000;' then the separate ones are not waiting in scheduler, right?
For the 6000 to pass
it prioritizes the ones that have had least time to run in the previous frame, not sure if that's what you meant with "slept"
hmm no, that's very different.
when you sleep, all you're doing is setting a flag on the current script that this script can only run after (not exactly) x seconds have passed. this flag is then checked everytime the scheduler comes to this script
I am sorry for writing it so oddly.
If there is sleep 6000 in one trigger to delay the enableSimulation, other triggers do not care for the 6000 and work regardless, yes?
Completely separate triggers
Not linked in any way
yeah, the sleep in that thread won't affect other threads/events/triggers.
Haha, alright. Thanks
Anybody ever got around adding mines created using createMine to zeus?
addCuratrEditableObjects seems to refuse to add the mine
createMine creates the "vehicle"
you need the ammo afaik
Guys, is there any reason to use sqs over sqf? Are there some circumstances where unscheduled scripts better than scheduled? I dont understand now, after all discussion.
cannot get it added with any way known to me sadly
actually no it gives the ammo 
looks like it uses the module object
mhh?
i know
so you can only add their modules 
used allCurators to get the logic modules
and getAssignedCuratorLogic
both not yielding the mine created in zeus
anyway, what the module does is just attach the mine to itself
so you can create a logic object and add that as editable object
and just attach the mine to it
nah
think you misunderstand me here
_mine = createMine ["IEDUrbanSmall_F", [0,0,0], [], 0];
{ _x addCuratorEditableObjects [[_mine], true]; } forEach allCurators;
``` this ain't working for me
like I said, can't add the mine (or other projectiles it seems)
zeus mines are the ones that inherit ModuleMine_F which are in CfgVehicles, createMineuses CfgAmmo and afaik addCuratorEditableObjects doesn't support that
urgh ... so no way to create mines which can be defused and be added to zeus ...
im pretty sure that the module ones internally createMine anyway, but the module "unit" is the one you see in zeus interface
_o = "ModuleMine_F" createVehicleLocal getPosATL player;
_m = createMine ["SatchelCharge_F", player, [], 0];
_m attachTo [_o, [0,0,0]];
_zeus addCuratorEditableObjects [[_o], false];
Neat workaround i did not think about
I already said it 
I have a question whether this approach, as I imagine it, can work in principle.
Let me try to explain with a concrete example:
In the vanilla map Tanoa is an airport (Aeroport Tanoa; it would be the one where a plane would land given the command "landAt 0") . As far as i could research this airport is hardcoded in the terrain itself. This includes all the taxi points, landing points and so on.
Could I place a dynamic airport placing it at this very same airport (Aeroport Tanoa) and let my planes land at this dynamic airport (in script form something like plane1 landAt "Dynamic_Airport_XY") or would these two airport interfere with eachother? I am aware that to have this working as intended, you should stick to script form and not using "LAND" waypoints in the eden editor as the AI would search for nearest airport which I could believe the AI would prioritise the vanilla hardcoded airport.
What I would like to achieve with this would be as one idea of many I have:
Create multiple dynamic airports that will have taxioff waypoints leading into the hangars.
If i tell the first plane to landAt "Dynamic_Airport_1" the plane would taxioff in the first hangar. The next plane i would landAt "Dynamic_Airport_2" to go in the next hangar and so on.
I hope I could explain it in a way it is understandable for you guys.
Guys, is there any reason to use sqs over sqf?
No
only reason to do "SQS" by today is if you want to use the buttonSetAction command as that is still taking SQS and not accepting SQF
On the PFH subject, it's supposed to be ran in unscheduled
Are there some circumstances where unscheduled scripts better than scheduled?
yes and no ...
problem with unscheduled scripts is that the engine will block untill the command is done
whilst the scheduled script will only run a few ms per frame but do not pull your framerate down
both has its positives and negatives
it all depends on what you want to archive to select what you need
and to know what you need requires experience
^^
the biggest issue with scheduled atm is that the conditions of your script can change
thats actually just "you have to understand how networking in arma works" @keen stream
On lighter news Added: Scripting commands isEqualType, isEqualTypeArray, isEqualTypeAll, isEqualTypeParams yesterday's dev branch
@queen cargo : Yeah, this takes some time and a lot of errors. :-(
actually it does not ^^
its the locality that does that harm
and as soon as you understood that concept again
everything else is just simple planar network shit
ownership is quite hard to wrap your head around too
once you get it it's pretty simple
in arma 2 both script environments run on the main game thread, is it different in arma 3? i would imagine not, which means the scheduled environment can definitely have an impact on fps
Does the scripting engine provide any kind of mutex lock to prevent multiple spawned scripts hitting the same critical section simultaneously?
Sorry what?
You'll have to script it yourself
Btw, having code inside scheduled environment inside isNil {} will make sure scheduler doesn't interrupt the script until that block is complete
So have your critical sections inside isNil {...code...}; to avoid race conditions
Ok thanks, good to know, isNil {...} should do the trick if it can't be interrupted.
whats en example of such condition @peak pond
I'm just wondering about the general computer science problem of avoiding race conditions when multiple threads access a shared resource. In this case I need to produce unique IDs for some objects that get registered by a logistics thing I'm making, and want to ensure ID collisions don't occur in the rare case multiple scripts create new IDs simultaneously.
fair enough. for stuff like that with potentially multiple clients interacting i just pass things to a server queue, instead of allowing direct function calls
Makes sense using a serial queue, and let server be source of truth.
i'm trying to do isNil {_params call MY_fnc_Function};
But it keeps saying im not allowed to suspend, does this no longer work to run a function in unscheduled?
Means you're trying to do sleep inside unscheduled
I was talking about using isNil inside scheduled code to make sure its not interrupted inside that isNil block
You can have it inside unscheduled but it makes no difference there in that sense, serves its usual function of checking if code block return is nil or not
any idea how i can make my code wait until an animation is finished then?
- Check each frame
- Through event handler if there is any
Is this intended behaviour or more like accidental? Just curious why isNil prevents scheduler from interrupting the script. Does the 3 ms execution limit per frame apply here as well?
Hello, I try to run it in console but I have error that it lacks ";" in function, but it doesn't imo. Any idea what it can be?
void myFunctionShouldSurrender(object unit) {
// Check if the unit is an AI unit
if (unit isKindOf "BOT") {
// Get the unit's group
private _group = unit getVariable "group";
// Check if the group is valid
if (isNil "_group") exitWith {};
// Get the number of units in the group
private _numUnits = count (_group units);
// Get the number of casualties in the group
private _numCasualties = count (_group units - alive _group);
// Check if the number of casualties is greater than 50% of the number of units
if (_numCasualties / _numUnits > 0.5) {
// Play the surrender animation
unit playMove "Acts_Signal_Surrender";
};
};
};
// Register the function to run for all units on each frame
[] spawn {
while {true} do {
{myFunctionShouldSurrender(_x)} forEach allUnits;
sleep 1;
};
};
I don't think void foo() {}; is SQF syntax.
thanks will look this way
if needs to be combined with / include then in SQF syntax, check https://community.bistudio.com/wiki/if
And there's no void either
so I could just "then {};"
Wait what am I reading... Should just turn my brain on
whats a good way in script to handle both default and custom key bindings? in KeyDown event i am looking at something like this, however also considering pulling out "actionKeys" to a variable so it isnt called on each keypress
if (_key in ([199,(actionKeys 'User9')] select ((actionKeys 'User9') isNotEqualTo []))) then {};
Yeah I have no idea what am I reading
every command will have the script to wait until the command is done. so with isnil too
https://community.bistudio.com/wiki/addUserActionEventHandler
Not entirely sure your exact case you want to handle, but is this something you can use?
i should use those more for sure ... unfortunately we cant block default actions with those
Hmm
This is not SQF syntax in general. You could try looking at some examples in existing open source projects
however maybe it is a perfect tool for custom keys
my issue is that player may not necessarily (in fact data shows only a few % of players running my mission use custom bindings) have custom ones set up
so core bindings still need a default setting
probably mostly C++ π isn't SQF based on C++?
More like C itself I believe, C++ is an object oriented language while SQF is not
It has different paradigm
ah, okay, so will have dive more into it, thanks anyway
No worries! Good luck π
did you read wiki at all? :T
it's not based on C++, if you mean under the hood, then yes, otherwise no. it's a simple language with 3 operators and few literals
Use actionKeysEx
isNil runs its block unscheduled. That's how it guarantees no other script will interrupt it (sqf engine is single threaded)
^
why not ask FWG directly (Steam, YT, discord DM)?
Warning Message: Variable 'rscdisplayloading_display' does not support serialization and should not be stored in the mission namespace.
Warning Message: Variable 'rscdisplayloading_progress' does not support serialization and should not be stored in the mission namespace.
from what i understand you need to set disableSerialization; (or store things to uiNamespace)
i am still getting these tho. does disableSerialization have to be set in each scope directly?
disableSerilization disables serialization of script vars. Those errors are for global variables
Don't store displays in global vars
Use uiNamespace instead
But even if you don't those warnings are not harmful. Just ignore them
Technically uiNamespace variables are global too.
I mean missionNamespace global vars
Obviously
well its coming from BI functions. i think as these are launched differently then the standard onLoad
BI is doing this
onLoad = "[""onLoad"",_this,""RscMiniMap"",'IGUI'] call (uinamespace getvariable 'BIS_fnc_initDisplay')";
while we have (also from onload) but within a function:
if (getMissionConfigValue ["...",0] == 0) then
{
// if not, use default script
#include "\a3\ui_f\scripts\Loading\RscDisplayLoading.sqf"
}
else
{
why? actionKeysEx looks way more complicated than i need, is there good reason?
Saving to a variable is probably "fine" most of the time, but you could get in trouble if the user happens to change the keybind after you save it. Up to you whether that's a worthy tradeoff I guess.
isNil differs from commands like call in a way that the command itself waits for the code to finish (which is why we call it "unscheduled" in a way), unlike call which simply pushes a block of instructions on the stack and forgets. the 3ms limit does not apply, isNil <code> will execute whatever it needs to regardless of that, it's no different than running some heavy parameterized nearestObjects for example.
Key Combos
is there a simple way to get a door using cursorObject command?
if i use this animationNames cursorObject it will list all doors but if i do this:
animationNames cursorObject isEqualTo "door_1_rot"
it returns false
That's an array
You're comparing it to a string
They're never equal
Anyway, do you mean you want the door under cursor?
yes
Use lineIntersectsSurfaces
It gives the selection name of the door
Getting the animation is a bit tricky without access to the model.cfg
But if the model is configged properly you can find it in its door actions iirc
okay thank you i`ll test it
usually you can just look for animation having a substring of the selection
anyone has experience with dynamic airports? someone i could have a little chat with? I have some principle questions.
I really doubt your idea could work
but I don't have any experience with dynamic airports, and I doubt anyone has ever tried it, so I guess you should try and see 
what you mean by dynamic airports?
Dynamic Airports is a years-old feature, like the one used in USS Freedom Aircraft Carrier
dynamic airports is a way to define airports on your terrain. the difference because a dynamic one and a hardcoded one is that you can add them later on your map.
for example you have a very flat space in a terrain which normally is not defined as airport. If you wish so you could add it
i thought you might mean that: https://community.bistudio.com/wiki/Arma_3:_Dynamic_Airport_Configuration
i mean that yes
this was the question @proven charm
my specific question is stated here. Besides that i have still some problems comprehending this whole "Dynamic airports" issue.
ah thanks leopard
i see
i wrote this question yesterday at around 24:00. I was researching till the morning. In this period i think i realised i am not fit yet to do this kind of things in scripting. I think i might need to get a better understanding first about classes and about config.cpp as i have never touched them. I need to make smaller steps first i guess. It looks like the "simple" thing i want to do is not that simple.
i did aircraft taxi script once, but it wasn't pretty
setDriveOnPath doesnt seem to work with aircraft?
yeah this is no simple task, you should work on those scripting skills first
if you just started scripting...
yeah. I agree. I got a little bit euphoric.
doesn't work on air and sea vehicles
i would say i have some amount of scripting experience. For sure not as much as many of you hear. I just got a little bit euphoric because my current mission i am testing around with was making fast progress. And i thought just add better airport taxi and everything looks smooth.
@little raptor yeah i expected this. it looks like fixed wing aircrafts work very different from other objects
And i thought just add better airport taxi and everything looks smooth.
if it's a predefined path you can just use unit capture
ah yeah i was also thinkin about unit capture, but there are also some downsides to this. It has it's limitations and for me it seems like to be not consistent with fixed wing objects. For cars it works very well
well yeah the wheels and wing animations won't work but still it should look ok from far away
as far as i can see it i would use the information found here to actually create a dynamic airport: https://community.bistudio.com/wiki/Arma_3:_Dynamic_Airport_Configuration
and combine it with the information here to adapt the airport i just created: https://armadocs.gitlab.io/terrain/03project/3config/airstrips/
Arma Terrain Documentation
and then with commands like: Testplane_1 landat ((allAirports select 1) select 0); or Testplane_1 landat ((allAirports select 1) select 1); i would choose which dynamic airport the plane would land on and having them have different taxiOff paths
well you can try it. it's very easy to make the airport itself. just place two of them side by side in 3den to see if your idea works
this is the first problem π
i do not find the airport as an object in the eden editor
but i need to touch classes and config.cpp for that already right?
yeah
ok
actually you can just use the USS Freedom's to test it
ok so my knowledge is not good enough for this yet. I will go ahead and study these topics first. Thank you guys for your feedback. When i make progress i will let you know. In my research i found many users asking the same/similiar question. So it looks like there would be a need of a step by step tutorial which i would provide (if my brain would finally be able to comprehend all these topics)
i did this. i placed two uss freedoms and set one plane to land on the first one and one plane to land on the second one. I would just need to be able now to move the taxi points to ground to my terrain airport (aeroport tanoa)
ah ok...
seems to kinda work
Anyone know why knowAbout return 0; on 90% of buildings in custom terrain?
but it's iffy
or where could it come from
you mean the event handler? or the command itself?
the command
why do you need the knowsAbout of a building?
if knowabout is 0 cursortarget return objnull
@little raptor your idea would be to place the carriers so that it would set up the airports in the corresponding files? and then adapt the files? sorry if i am completely wrong with my interpretation
on other vanilla terrain knowabout is always 4 on building, i don't understand this.
no. again don't create carriers
create airports
a carrier is just an object composed of several parts. one of those parts is the airport object
I'm pretty sure it's like Land_DynamicAirport_F or something like that
here's how I create the airport: createVehicle ["DynamicAirport_01_F", player]
I created a few of those then rotated them and placed them end to end
the aircraft did follow the path a bit but eventually it got confused 
ok thank you. i will start up the editor and use your information and fiddle around with it
test typeOf cursorObject. I'm gonna guess it returns "" for your custom map buildings
No it return the classname
but knowsAbout for that same object returns 4 in other terrains?
yes
no clue 
but anyway I still don't see why you'd need that since knowsAbout is meant for AI targeting
and AI don't target buildings
its for cursorTarget knowsAbout 0 == objnull
umm, what?
cursorTarget return me a NULL object on these buildings.
Maybe something to do with side centers?
why not just use cursorObject instead though?
Try script-creating all sides and see if it helps?
I know Arma 3 always creates all centers unlike OA, but who knows maybe custom terrain somehow doesn't?
Also, is your unit an Agent? Maybe agents always return knowsAbout as 0? Don't have much experience here, just guessing.
I would like to know why this is happening
I really doubt it's documented anywhere. if you don't find anything just use a workaround for what you want to do
{createCenter _x} forEach [blufor, opfor, independent, civilian]
createSide? 
*fixed
@meager granite thanks ive tried but nothing change. with some building its working fine like this church
another work around, is to use reveal command on all building but is that okay with perf?
Does anyone have a Helicopter Patrol script they can share ?
What do you mean by custom terrain btw?
Are these script-spawned buildings by any chance?
no its done with terrain builder. i dont have the issue if building created with createVehicle
looks like this issue is related with terrainbuilder
Update to what i could achieve so far with your input:
i have created a Testplane flying south east of the aeroport tanoa.
i have placed a gamelogic more or less centered on the runway aeroport tanoa. I put in the init:
dynamicAirport1 = "DynamicAirport_01_F" createVehicle position this;
Testplane landat ((allAirports select 1) select 2);
result: i could achieve that with using Testplane landAt 0; --> the plane approaches from the south east for landing.
if i use Testplane landAt ((allAirports select1) select2) the plane will approach from northwest for landing. Small success but anyways π
hint: i have to use select2 because for test purposes i have placed two uss freedoms. They are already taking the 0 and 1.
In the case of landing on the dynamic airport. It seems the plane is following the Landingposition (ilsPosition) as well as the direction (ilsDirection) as well as the TaxiOff (ilsTaxioff).
However it looks like at one point (my guess is when the plane reached it's last TaxiOff coordinate from the dynamic airport) the plane will prioritize the airport 0 (hardcoded terrain airport). This is leading to that the plane will transition from it's dynamic airport Taxioff to the hardcoded tanoa airport taxioff. Plane will continue the tanoa airports taxioff transition to TaxiIn and afterwards lift up again.
So basically it looks like the priorisation which airport to take is the problem. My next approach is that i would try to make a class inheritence of "DynamicAirport_01_F" and fiddle around with ilsTaxiOff and see if when I extend the path if it would stay on the dynamicsAirport path.
Another approach would be if it is possible to delete all the hardcoded airports. But i think this would be seen as altering someoneelse's content. In this case bohemia interactive's content. Because i think i would need to edit the terrain for that. Or is there a syntax to delete the airports via script that i could put in an .ini?
What is the best approach to start an editor mission at a random time of the day?
skipTime random 24 would do.
perfect, thanks
Best method for detecting if a helicopter has crash-landed and cannot fly any more, but hasnt been destroyed?
Ive got a Killed EH set up, but I want to make sure I cover the edgecases.
CanMove, not sure how reliable it is though
@frank cedar Not that I know of
Ooh, noted, will give that a try!
I am spawning in darter with the following code above the player:
myUAV = [getPos player, 0, "B_UAV_01_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (myUAV select 0);
Is there a way to assign the player automatically to the gunner seat?
IIRC canMove covers dead engine and no fuel cases but not dead/injured driver.
@modern meteor connectTerminalToUAV + remoteControl maybe
myUAV = [getPos player, 0, "B_UAV_01_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (myUAV select 0);
player connectTerminalToUAV myUAV;
Error: Type array, expected object
How can I assign the UAV I just spawned to an object?
https://community.bistudio.com/wiki/BIS_fnc_spawnVehicle
Return value: Array format [createdVehicle, crew, group]
So you need to do a select 0 on the return to get the vehicle.
Or params π _myUAV params ["_veh", "_crew", "_group"];
every command will have the script to wait until the command is done.
There are quite a few commands where that doesn't apply. forEach, call, apply, while,...
Ok, it's working up until here:
myUAV = [getPos player, 0, "B_UAV_01_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (myUAV select 0);
myUAV = myUAV select 0;
player connectTerminalToUAV myUAV;
Now the question is, how to move the player automatically into the gunner seat?
The remoteControl method is probably better for that since it lets you specify directly, e.g. gunner myUAV
Note that "moving the player into the gunner seat" and "controlling the UAV gunner" are not the same thing. I'm assuming you mean controlling the gunner, but if you mean literally moving the player into the UAV, do say so
yea, i mean that the player has the view from the gunner position of the UAV
Hello again, with all your help I arrived at this thing just flexible enough for mostly everything I was looking to do...
https://pastebin.com/TTygugdp
However, I wanted to despawn them once players get too far.
I tried adding this before disabling the trigger simulation, but it doesn't work and I feel like I am missing the point...
_outcastPatrolSpawn spawn {
while {true} do {
sleep 30;
if ((player distance (leader _this)) > 1000) exitWith {
{deleteVehicle _x} forEach units _outcastPatrolSpawn; }; }; };```
player action ["Switchtouavgunner", getconnecteduav player];
This works
Code looks fine. You should print the distance to the rpt to see what's going on
Alright, let me check!
myUAV = [getPos player, 0, "B_UAV_01_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (myUAV select 0);
myUAV = myUAV select 0;
player connectTerminalToUAV myUAV;
player action ["Switchtouavgunner", getconnecteduav player];
myUAV addAction ["Destroy Drone!", {
player connectTerminalToUav objNull;
deleteVehicle getConnectedUAV player;
deleteVehicle myUAV;
player switchCamera "Internal";
}];
When I switch into the drone, I see "Destroy Drone!" in the middle of the screen. How can I avoid the text in the middle of the screen?
myUAV addAction ["Destroy Drone!", {
seems to be the cause for the message, I think (could be wrong) that you can either do myUAV addAction ["", { or myUAV addAction [{ instead
why do you add the action if you don't want it?
or do you mean you just want the action to appear when you scroll?
if so just set the showWindow flag to false
u need waituntil { !isnull (findDisplay 46) };
you're attempting to create a control on something that doesn't exist
so the control is never created in the first place
and it will never be created
that's why the waituntil
put this before the line where you create it
This solved it, thank you
myUAV = [getPos player, 0, "B_UAV_01_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (myUAV select 0);
myUAV = myUAV select 0;
myUAV setUnitTrait ["audibleCoef", 0];
myUAV setUnitTrait ["camouflageCoef", 0];
player connectTerminalToUAV myUAV;
player action ["Switchtouavgunner", getconnecteduav player];
myUAV addAction ["Destroy Drone!", {
player connectTerminalToUav objNull;
deleteVehicle getConnectedUAV player;
deleteVehicle myUAV;
player switchCamera "External";
},nil,1.5,false];
This is what i have now. On spawn, is it possible to give the done the order to loiter with a radius of 100m?
yes. use addwaypoint
then use setWaypointLoiterRadius (or whatever it was called) to make it loiter
also don't forget to set the waypoint type
i tried this but it does not work:
myUAV = [getPos player, 0, "B_UAV_01_F", WEST] call BIS_fnc_spawnVehicle;
createVehicleCrew (myUAV select 0);
myUAV = myUAV select 0;
myUAV setUnitTrait ["audibleCoef", 0];
myUAV setUnitTrait ["camouflageCoef", 0];
player connectTerminalToUAV myUAV;
player action ["Switchtouavgunner", getconnecteduav player];
myUAV addAction ["Destroy Drone!", {
player connectTerminalToUav objNull;
deleteVehicle getConnectedUAV player;
deleteVehicle myUAV;
player switchCamera "External";
},nil,1.5,false];
//myUAV = _grp addwaypoint [position player, 0]
_wp = myUAV addwaypoint [position player, 0];
[_wp, 0] setWaypointLoiterRadius 50;
- _wp is already the waypoint
- you should add the waypoint to the group not the object
- you didn't set the waypoint type
myUAV = createVehicle ["B_UAV_01_F", getPosWorld player, [], 0, "FLY"];
_grp = createVehicleCrew myUAV;
myUAV setUnitTrait ["audibleCoef", 0];
myUAV setUnitTrait ["camouflageCoef", 0];
player connectTerminalToUAV myUAV;
player action ["Switchtouavgunner", getconnecteduav player];
myUAV addAction ["Destroy Drone!", {
player connectTerminalToUav objNull;
deleteVehicle getConnectedUAV player;
deleteVehicle myUAV;
player switchCamera "External";
},nil,1.5,false];
_wp = _grp addwaypoint [getPosWorld player, -1];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterRadius 50;
those setUnitTraits don't make any difference afaik
also loiter radius of 50 is not gonna work
Got it now. Thank you
why not?
Why not?
it's too close for loiter
because those are for infantry
Are there any for vehicles?
Just want to make it invisible for OPFOR
deleteVehicle, same as other objects
try making the UAV crew captives
{_x setCaptive true} forEach crew myUAV;
Oh okay
UAVs have invisible crew
And the crew is what is being detected by OPFOR?
what do you think createVehicleCrew is for then?!
the vehicle is being detected because it's being operated by the enemy crew
got it, i will try this. thank you!
{ deleteVehicle _x } forEach vn_o_air_mig19_ejection_seat;
that's right ??
Hey I am trying to get a custom image for one of the elements of the Orbat that I am making.
Trying to overwrite the type icon with a custom .paa image. its dimensions were 512x512 before converting from png to paa.
Yet it still fails to show up in game. There's just a transparent "texture" there.
This is the code that defines the texture.
texture = "SASG.paa";
So according to rpt:
18:03:16 Error in expression <th { {deleteVehicle _x} forEach units _outcastPatrolSpawn; }; }; }; thisT> 18:03:16 Error position: <_outcastPatrolSpawn; }; }; }; thisT> 18:03:16 Error Undefined variable in expression: _outcastpatrolspawn
I am not sure what is wrong, I tried replacing _outcastPatrolSpawn with the trigger name, first "outcastPatrolSpawn" then simply outcastPatrolSpawn but neither worked.
the "" case was not recognized as valid input, the next one was ignored without error.
Do I have to define every single unit from _outcastPatrolSpawn in [] bracket in that place or am I completely off here?
(edit: I was off a bit indeed... thank you for pointing me in the right direction!)
i'm sorry, is not working, do you have Example ??
I actually used this now and it instantly fixed my issue. Hot damn, thank you!!
in my case it was:
forEach units (paladin01), (paladin02), (knight01), (knight02), (scribe01);
as defined previously in the script
what is your code that is not working?
anyone know why, tested the same picture as jpg on a whiteboard, works perfectly fine.
I noticed that some .paa files have a lot of transparency within their canvas, but only read a portion of it. If you have 512x512, make sure your picture matches the position within those 512x512 compared to the original that is otherwise read. (if you have any original reference, that is)
The whiteboard is a good example. If you fill it's size out completely with an image, it will be across the whole whiteboard and missing a little bit of it's edges. (instead of being the images taped to it you otherwise see)
i try to delete this in my code.
{ deleteVehicle _x } vn_o_air_mig19_ejection_seat;
Yes that helped a bit. Appreciate it. I got the same PAA file to work on two different objects. Now the issue is trying to get it to work on the Orbat Viewer itself to replace a built in Icon with a custom paa image, right now it does not show anything, meaning it is either not detecting the image or what you said, transparency issues. The Official orbat wiki does not state what should be the dimensions of that said custom texture.
texture = "\ca\missions_f\data\orbat\customTexture_ca.paa"; // Custom texture, will replace icon set by 'type' param.
This is all it gives you in terms of how the texture line works in CfgOrbat.
I have tried 64x64 and 512x512
you would need to get a reference to the object, what you have is a classname which is just the type of object and not the object itself. You also wrote a code block for a loop without creating an actual loop.
deleteVehicle _object;
``` would delete whatever object the `_object` variable points to.
for example, if you have a vehicle with `car` defined as its variable name in the editor you do
```sqf
deleteVehicle car;
I assume what you're looking at is a dynamically created object in the mission and not one manually placed in the editor, so to help you reference the object we need to know under what circumstances it was created and at what point in its lifetime you want it to be deleted.
You must have copied code intended for a forEach loop (or any other loop that uses _x as a magic variable) which is not applicable to deleting a single object
More than transparency issues, it is where you place the "visible" piece exactly. It has to be placed precisely where the other working examples have it within the field of transparency to be read correctly. Otherwise it still is there, but does not show because it is "off screen" for that preview. Although, I have no experience with orbat, but other examples work in such way.
One more question. how could I stop the Loiter so that the drone stops moving?
Is the currentwaypoint always 0?
Depends how you create the crew. Sometimes you get a default move to 0,0,0 as waypoint 0.
And then your loiter would be waypoint index 1.
I am using the code above
Can someone tell me why I would prefer deleteVehicleCrew over moveOut _unit; deleteVehicle _unit? deleteVehicleCrew (at least according to biki) has all sorts of locality shenanigans going on that make it hard to use and cause unpredictable behaviour
the locality "shenanigans" are still there for moveOut too
when there's a command that does specifically what you want why would you want to bother to reinvent the wheel anyway? 
I was using deleteVehicleCrew, until I discovered that units weren't deleted properly, even though I was using the recommended remoteExec method. For example, the command will fail if the unit disembarks during the inevitable delay with remoteExec, or the vehicle might change locality, etc
well the wiki itself says:
While the argument is global, you should take extra steps and execute this where vehicle is local as moving units out of the vehicle happens where vehicle is local and you want this to always precede deletion.
so idk if doing that will change anything
maybe it'll help with the soldier disembarking thing
for locality changes you can make a function that makes sure the object is local
if not remoteExecs again
if (isNull objectParent _recruit) then {
deleteVehicle _recruit;
} else {
[(objectParent _recruit), _recruit] remoteExec ["deleteVehicleCrew", _recruit, false];
};
This was the approach I was using, but I got reports that dead crew usually failed to delete
The deleteVehicleCrew is hard to use correctly. It must be executed with remoteExec on the computer where the vehicle is local, but this causes a delay before the code is really executed. During this delay, the unit might have disembarked or the vehicle might have been deleted, causing deleteVehicleCrew to fail. A real world example was in fn_cleanup.sqf where the vehicle was actually deleted right after calling remoteExec. Because of this, around 70% of time the crew was not properly deleted.
Should I just write a function that checks all these conditions and ensures that the unit gets deleted?
idk. maybe
Have you found out if this is possible? I am trying to find that out too π
deleteVehicleCrew is broken right now (should be fixed some time soon: https://feedback.bistudio.com/T167473), looking at my own code, simply using:
moveOut _vehicle;
deleteVehicle _vehicle;
```is enough to delete unit from the vehicle
{moveOut _x; deleteVehicle _x} forEach crew _vehicle;
deleteVehicle _vehicle;
```to delete the vehicle and crew inside
Not sure about moveOut to be honest, but its there.
in arma 2 both script environments run on the main game thread, is it different in arma 3? i would imagine not, which means the scheduled environment can definitely have an impact on fps
A2 and A3 are the same.
fuck this app sucks, no commenting lololol
at max SQF will execute for ~3ms each frame
if only it supported markdown quotes.... CMON DEVS
@grizzled cliff you could just talk to someone like this ^^
it can be longer than 3ms if you have a command that is very intensive (like nearObjects)
the main problem with the scheduler though is not that things excute over time (duh thats the entire point)
it is that it is very greedy
new scripts will push older scripts to the bottom of the excution queue
as such things like sleep become unreliable
and long loops can become very slow
basically it is unreliable in terms of timings
If you have a script checking for a unit, that unit can change if the script doesn't finish in the 3ms
if that happens you break your script
thats why commands need to be atomic as possible in sqf, because it executes statements, not commands in the 3ms timing
so if you do everything in one statement its safer
Does anyone have a healing script? Players go to an AI and get healed or go to a location
or just write your code in a way that doesn't ever use it
which is how ACE and ACRE do it
there are very minimal spawns in ACRE, I think just 2, and thats for situations where no other solution really works.
They also execute once at the start of the mission and then end ASAP.
ACE still has a number of spawns but our core guidelines restrict its usage.
there's 2 AFAIK
There is more than 2, but there might be only 2 that are running all the time
i havent done a script running check in a while on the codebase
player setDamage 0
correction 31
or at least that's the number of time spawns are mentionned in the code
hm, don't the "[] spawn {}" they finish/delete themselfs, when they are finished?
Dscha, yes, but imagine you start a spawn with a waitUntil in it
at the start of the game
every time you call a terminating spawn it will execute with higher priority than the first spawn
hmm
you can actually force an older spawned function to never execute
by every frame adding a bunch of new spawns
thats what i mean when i say the scheduler is greedy
I always wondered why BI wrote their missions in FSMs, now I know
FSM has a similar issue
The timings in FSM can be off because it is affected by the scheduler
the scheduler divides up its load into thirds
SQS/SQF/FSM
FSM code blocks execute non-scheduled
but the conditions are checked in the scheduler
so its subject to script lag
Hi all, need some help with my Mission Complete Trigger. I 'm trying to edit the Text of "MISSION COMPLETE" - chatgbt told me to enter
"Custom mission complete text";
into the On Activision parameter but im still seeing "MISSION COMPLETE"
Because that's not how it works
Do not use AI generation for SQF. It doesn't understand it and the results won't work.
You can't change the basic Mission Complete ending on the fly. What you can do is define a custom ending in description.ext and use that. https://community.bistudio.com/wiki/Description.ext#CfgDebriefing
thanks for your help. This arma 3 scenario making is a lot easier with help. π
guys how can i get AI (in this case "driver1") that is not in my team to drive to "trigger8",
wait for me and my remaining alive team to get in "transport1" and when conditions are met to start
driving to next waypoint in this case "wp1". I don't know to script and i neeed this script in almost every scenario that i make.
i need some help with with a remote exec comand, i am trying to create a comand that removes certain types of weapons from a players inventory when the arsenal is closed. I can get it to work in eden. But i get a remote exec kick when i use it on pub zeus. Is there a way to bypass, or an alternate method?
I would recommend checking out some waypoint tutorial because that's the simplest way to do that without scripting skills
Anyone looked into drawIcon caching? I managed to speed it up by caching entire drawIcon array depending on map's scale (ctrlMapScale) but having smooth map zooms (like when you speed up and GPS zooms out or when you press "center on player" on the main map) produces a lot of unique scale values and floods the cache with like 500 different arrays. Multiply that by amount of entities that need to be drawn you and end up with 10000 of arrays stored in multiple hashmaps. Sure hashmap lookup is pretty fast but storing 10000 arrays doesn't sound right.
Public servers often have security restrictions to prevent abuse, and this is one of them (it's trying to stop you removing everyone's weapons, which could easily be used for cheating and trolling). If you want to limit what people can get from the Arsenal, the best way is to create a restricted Arsenal that only allows specified items to be taken at all.
there is ways to bypass these retsrictions as i have seen this type of script deployed before
In eden editor i know how to make ai drive to a waypoint and wait for me to get in car,
but i have trubble making ai wait for my team beacuse some of them are dead.
If all of my team is alive it works perfectly. is there a way to get arround that somehow
@meager granite I don't know what you are trying achieve here but since drawIcon is slow I would check if those drawn icons are withing screen boundaries before rendering them
Maybe, or you could do it properly and create a limited Arsenal instead of trying to use this janky method.
a limited arsenal will still alow players to load un restricted loadouts
i havent used much waypoints my self but I think the getin etc waypoints should cover dead soldiers
Not sure that's quicker, with SQF sometimes its faster to call one slow command than to have several faster ones
Not sure if calling cached drawIcon is slower than checking the boundaries
even non-cached
Anyway, I'll test it out
private _draw_array = _x get "cache" get _scale;
if(isNil"_draw_array") then {
private _size = (_x get "size") * ((0.05 / _scale) max (_x get "coefMin") min (_x get "coefMax"));
_draw_array = +(_x get "array");
_draw_array set [3, _size];
_draw_array set [4, _size];
_x get "cache" set [_scale, _draw_array];
};
_map drawIcon _draw_array;
This is how I'm caching the "drawIcon" btw. _scale is map scale, _x is a hashmap where "array" is a template drawIcon array, "cache" is a hashmap with keys of _scale and value of ready drawIcon arrays.
nevermind i got it to work
create an array of rendered drawIcons everytime map is moved/scaled ?
thanks i just wanted to know if its possible so i don't waste my time on trying to make this mission.
Means performance will drop during map movement, which is all the time when you have GPS out and driving/moving
oh yes the GPS, didnt think of that :/
Yeah it constantly does these micro zooms in and out depending on your velocity
That's why these caches of 500 arrays per icon form
update the draw icon array every x millisecond?
Hmm, maybe toFixed can help with that, to ignore tiny changes in scale
Didn't try but it might not look as smooth as everything else drawn by the engine
I think the drawIcon should itself have a boundaries check but Idk if it does
@still forum Does the drawIcon do boundaries check? Is it worth it scripting that check before using the drawIcon or the engine handles it better?
Atleast when it gets to drawing it does a check. Probably not in the command tho
How many drawIcon calls are you making per frame here?
not reallocating entire array everytime is already very good, i personally don't cache size stuff
It doesn't allocate it if its cached.
how do i attach a marker to a helicopter so it will show on the map ?
Calculating size and doing set x2 each time is 20% slower than caching code above
But caching generates 500+ cached arrays as soon as any smooth zoom is involved is what I don't like about it
This particular case is 13 calls, but there will be much more applications, so I guess around 50 in real scenario
Full code, non-cached:
params ["_map"];
private _scale = ctrlMapScale _map;
{
if(_scale < _x get "scale") then {
private _size = (_x get "size") * ((0.05 / _scale) max (_x get "coefMin") min (_x get "coefMax"));
private _array = _x get "array";
_array set [3, _size];
_array set [4, _size];
_map drawIcon _array;
};
} forEach game_drawIcons;
``` => [0.0529829,18874]
And cached:
```sqf
params ["_map"];
private _scale = ctrlMapScale _map;
{
if(_scale < _x get "scale") then {
private _draw_array = _x get "cache" get _scale;
if(isNil"_draw_array") then {
private _size = (_x get "size") * ((0.05 / _scale) max (_x get "coefMin") min (_x get "coefMax"));
_draw_array = +(_x get "array");
_draw_array set [3, _size];
_draw_array set [4, _size];
_x get "cache" set [_scale, _draw_array];
};
_map drawIcon _draw_array;
};
} forEach game_drawIcons;
``` => [0.0416858,23989]
20% performance gain, but lots of cache spam
that's what i meant π
If you ditch those _x get blas and use arrays instead it'll be better
e.g. _x#DRAW_SCALE, etc.
Didnt work
What do you mean?
Ah, you mean use arrays instead of hashmaps
Not sure if it will be that much faster π€
anyone know the name of the command that disables ai leg movement but not aiming like stops them pathing completely
I'd say at least 2x faster (at least those parts where you do get)
_unit disableAI "PATH"
Do these icons all have different size/coefMin/coefMax?
They currently don't but might
private _cfg = configFile >> "RscMapControl" >> "Rock";
game_drawIcons pushBack createHashMapFromArray [
["size", getNumber(_cfg >> "size")]
,["scale", 0.08681]
,["coefMin", getNumber(_cfg >> "coefMin")]
,["coefMax", getNumber(_cfg >> "coefMax")]
,["array", [getText(_cfg >> "icon"), [0.1,0.1,0.1,0.8], getPosWorld _x, 0, 0, 0]]
,["cache", createHashMap]
];
```Hashmap contents
Kind of universal, but maybe can be simplified and use the same cache for each
what sort of caching, units or props. i cant imagine caching any unit movement data unless its very brief
Check the code, it caches the array fed into drawIcon
What happens if, for example, objNull is given as a remoteExec target? Is it local nowhere and no execution happens?
hmm
hashmap has some overhead to the lookup, i dont know if id be using hashmap get in a draw event
i mean i actually do, but just not that many
i dont actually know when hashmap overtakes array for lookup, performance wise
like an array with 3 elements is faster than hashmap lookup, statistically (if the elements were all equally likely to be queried
but an array with 3000 elements is slower
π€
i think just the draw event context is not the best for iterating over large/complex data sets. in Draw/3D i try to have as many constants as i can with limiting variables/calculations only to pos/dir/text
pretty sure the hashmap's always faster if you need a lookup and your hash doesn't require additional SQF.
wut? array should always be faster
if you can rely on indices, then do it
what Leo said
its a "get" vs "findIf" comparison
[["a",1],["b",2],["c",3]]
findIf wins when few elements to iterate over, like finding value for "a"
only for that case
no... hashmap is faster even in the best case
why am i even questioning myself π that's two extra sqf commands anyway (already slower)
also i didn't mean array in that way
In this case it's just iterating over the whole thing so you don't need the hashmap.
like you can do _x params ["_cache", "_size", "_coefMin", "_coefMax"] instead.
SQF way of doing structs :P
quick question for adding a cfgFunctions? do i add them like this:
class CfgFunctions {
// add your own functions below
// Cratefiller
#include "KPCF\KPCF_functions.hpp"
};
// Ace Menu view distance
#include "taw_vd\CfgFunctions.hpp"
};
or like this
class CfgFunctions {
// add your own functions below
// Cratefiller
#include "KPCF\KPCF_functions.hpp";
// Ace Menu view distance
#include "taw_vd\CfgFunctions.hpp"
};
first one has a bogus close bracket, second one has a bogus semicolon.
Otherwise, depends what's in the included files.
The { and }; denote the start and end of the cfgFunctions class. You have to put the stuff inside of them.
ah ok and the semicolon is bogus so it hat to look like that?:
class CfgFunctions {
// add your own functions below
// Cratefiller
#include "KPCF\KPCF_functions.hpp"
// Ace Menu view distance
#include "taw_vd\CfgFunctions.hpp"
};
That one is at least superficially correct.
so it should work?
No, depends what's in the included files.
John said about how it's written, not what it does
That looks suspiciously like the functions files from existing mods, so it's likely to work provided it hasn't been messed with
it sort of is @hallow mortar its from vdauphins Hearts and Minds added with KP-Cratefiller and now TAWΒ΄s view distance script
Also depends where you put it :P
since i have more or less NO knowledge with that u can take a look an tell me if it is right:
disregard line 40/41 just saw that now!
ok. Otherwise it looks plausible.
well it worked without the taw_vd before so it should do it now too i check that
well looks like i have some more editing to do "[...] taw_vd\GUI.h 162: .RscText: Member already defined."
and arma makes no sense for me again.... " Line 162: linespacing = 1;" π€£ arma is a fucking hatelove
That means there's duplication somewhere. Impossible to diagnose without seeing all files involved. I don't have time to comb through them - someone else might I guess, if you're nice and lucky.
well i guess its either kpcf as the have a custom hud too for the cratefiller
"#include "KPCF\ui\KPCF_dialog.hpp" but if i dont include the GUI.h in the taw_vd it wont work hope it will run with the duplicate on the server localy i have to close 2 error dialoges then it loads fine
Sometimes with UI conflicts you can undefine to workaround them.
but you'd need to pin down exactly what it's tripping on.
Line numbers tend to be off when you include files.
i try to find it should be another GUI.h right? if not im fucked cause i got around a 100 files with extra stuff for the mission
well .RscText is there
looks like taw_vd is redefining all the RscXXX classes. If they're already defined elsewhere (and hopefully with the same params) you can use import instead: https://community.bistudio.com/wiki/import
well thats WAY to complicated for my brain
i just hope it works with both in place on the server
well localy what has a custom gui still has it ...
Anyone happen to know if theres a way to get class names for the lights on a map?
i dont think they all have a class name, just model name π€
_myLamps = position powerPlant nearObjects ["Lamps_Base_F", "PowerLines_base_F", "Land_PowerPoleWooden_L_F", "Land_PowerPoleWooden_F", "Land_LampHarbour_F", "Land_LampShabby_F", "Land_PowerPoleWooden_L_F", "Land_PowerPoleWooden_small_F", "Land_LampDecor_F", "Land_LampHalogen_F", "Land_LampSolar_F", "Land_LampStreet_small_F", "Land_LampStreet_F", "Land_LampAirport_F"", 100000];
{
_x switchLight "OFF";
} forEach _myLamps;
anyone have any idea why this is getting kicked back when i try to drop it into the init of an object?
says im missing "]"
but for the life of me i cant figure out where
Double " after Land_LampAirport_F is breaking it, it thinks the string hasn't ended
I'm not sure that's going to work though, nearObjects only accepts one classname, not several
Those all inherit from Lamps_base_F so just use that
ah okay cool, will try that. I noticed its not having the desired addect
will adjust and try again
success! Thank you!
Wrong channel, but looks like a very old version of the teamspeak plugin.
#arma3_troubleshooting is closest I guess.
setting the variable value to the string "nil" is a bit weird but not fundamentally wrong in the context of this script alone. In what way is it not working?
At the moment you're setting a variable on the trigger. The variable's name is hostageRescuedByPlayer, it contains the string "nil", and it exists in that state on all clients. That's the only effect of the setVariable line....I'm not really sure what you were wanting it to do, it's a little pointless in its current state.
You mean you want the trigger to be referred to by a varname? That's not what setVariable does
Well, it could, but not like that
When you do _playerByHostage = createTrigger [ ... you are saving the trigger as the local variable _playerByHostage. This is, essentially, a varname, just a local one to this specific script. If you want the variable to be accessible outside of this particular script, just make it a global variable. (If this code is only executed on one machine, you'll have to publicVariable it as well to make it available on other machines)
Editor "varnames" are just global variables, when you choose the variable name you are just choosing the name of the global variable that will refer to the object
Yes
Yes, that's the key difference between global and local variables. (not to be confused with local and global in network terms) https://community.bistudio.com/wiki/Variables#Scopes
What?
There's no particular reason in the code itself why that would be the case.
Where is this code being executed?

