#arma3_scripting
1 messages · Page 18 of 1
you can send them the format, and the keys
ah ok, like an extra array
You send ["%1 %2 %3", "$STR_TAG_myText", "test test", "$STR_blaBla"]
then
format (_input apply {_x select [0,1] == "$" then {localize _x} else {_x}})
interesting
damn translation is a bigger task than i thought 😄
i mean adding multi language support to comms methods
isLocalized is a thing
BIS_fnc_localize as well
just sayin'
would a default setter for localize be useful?
hint localize ['$STR_TAG_myText','my default text'];
meh?
I see the idea, but "if you use localize, then you at least fill one language" no?
it would also make it harder to spot non-translated strings
localize ["STR_myString", "default string"];
```if the result is `MISSING TRANSLATION: default string` why not 😄
@still forum Does OBJECT getDir OBJECT use render time positions or simulation time positions for angle calculation?
I also wonder about same question but for OBJECT distance2d OBJECT
I don't think there is alternative syntax with getDirVisual?
Yeah, there is no
Alternative syntax to return angle between two objects
Ah looking at the wrong thing
simulation too then
Thanks
https://www.youtube.com/watch?v=PdeVXQlZv4o
Semi-smooth MP-compatible dead body dragging! 
👀 ACE team would probably be interested in that
How its done: switchMove and attachTo to createVehicleLocal object each frame on the dead body
Since helper object is local, attachTo doesn't send any network messages, thus no network spam
Yeah, insert is a bit quicker than arrayIntersect but it's still clearly O(N^2). 1000 entries is 100x slower than 100 entries. 10k with hashmaps is faster than 1k with either array method.
insert is O(N) if we assume that setting an element of hashmap is O(1). And it well should be, because inserting would be "get a hash of new key, try to insert - get a collision - check if the collision has the same key - update the value", which doesn't go over the whole list at any point 🤷♂️
or was the 100x slower figure achieved via actual testing and i'm talking from my bottoms?
actual testing. This is with a pair of equal-size arrays, hence O(N^2) vs O(N) rather than O(N) vs O(1). Note that hashmaps seem to be slightly worse than O(1) insertion in practice.
Converting to a hashmap just to insert one element may be a bit too much overhead :P
oh yeah, what would be really good is a hashmap method to bulk-delete keys, so you can use them to replace arrayA - arrayB as well.
and i somehow get close to linear results from keys (array createHashMap []) 🤔
0.05 ms for 100 unique elements (numbers from 1 to 100);
0.1 ms for 200 non-unique (double the previous array) - double;
0.68 for 1000 unique (numbers from 1 to 1000) - 14x which is closer to 10 than 100;
1.13 for 2000 non-unique (double the previous array) - 23x which is closer to double the 1000;
but that's for deduping one array
There may be edge cases depending on how it's arranging the hashmap.
It probably doesn't use a fixed table size.
well if i go collisions-only with 100 and 1000 length arrays of ones ([1,1,1,...,1]) i get 0.016 ms for a hundred and 0.145 for a thousand. Close to linear again 🤷♂️
And for arrayIntersect on those same "unit arrays" i get 0.01 ms for a hundred and 0.58 for a thousand. Which looks closer to quadratic
well, not "collisions-only", but "same key only", as collisions should probably be used for hash collisions and i'm for sure not smart enough to get those :3
oh, I was using mostly-unique arrays.
Like floor random (10 * arraysize)
arrayIntersect is gonna do pretty well on arrays of ones :P
well, i've tested that and it's ahead by roughly half its runtime on a 100-length and slower by roughly 300% of hashmap runtime on a 1000-length "unit arrays". Which pretty much lines up with a typical usecase proposed above
can I remove/override an "addAction" thats baked into a mod for a specific vehicle?
Delete it in the config?
Override the config class and then add your own instead.
can I do that in a mission?
For what I'm trying to do: 3CB WMIK have by default the "raise flag" addAction, that raises the union jack. I'm attaching UN flags to all vics via CBA class EH, but once hidden the UK flag appears.
Might just add a second Addaction to all vehicles so players can just choose.
Use the action EH and override the call to raise flag?
You could try https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/inGameUISetEventHandler#Action Check if it's raise flag , raise your own flag and return false to block 3CB?
ah good idea
Is there a way to move an object (somewhat) smoothly with setPos over MP? When I try to raise an object it just jumps from the starting position to its end after some time
just normal parse error
setTowParent?
Will it even work with men?
no
All scripted in my case, lots of lineIntersectsSurfaces and ifs
SHIFT pressed during game start. No 'GameConfig'.cfg mods will be loaded!
oh, didn't know that 👀
d:\bis\source\profile\futura\lib\network\networkserver.cpp ClearNetServer:NOT IMPLEMENTED - briefing! boo
setVelocityTransformation would work fine and smooth in MP if you set velocity correctly
Interesting, no network messages from setVelocityTransformation on remote entities
Gonna keep it in mind
Wanting to use this Ghosthawk door opening at altitude script https://forums.bohemia.net/forums/topic/174180-snipplet-open-ghosthawk-doors-based-on-altitude/, but have it for several classnames of reskinned versions rather than in the init of vehicles individually, how would I accomplish this?
Could I just change this line SQF _unit = _this select 0; to SQF _unit = "classnames here";?
No
you could remoteexec a script that moves a local object on each frame
Could I use a class event handler from cba then? Or is there a better way to convert this script to classnames?
I'll try that next time, thanks. Though I think it's an issue with a specific object I'm using
Could I use SQF ["ghosthawk1blak", "init", {null = [this] execvm "scripts\ghosthawkdoors\ghosthawkdoors.sqf";}, true, [], true] call CBA_fnc_addClassEventHandler;
ghosthawkdoors.sqf```SQF
_unit = _this select 0;
_doorstate = false;
while {alive _unit} do {
_alt = getposatl _unit select 2;
// If under 20 altitude and doors are already closed, open them.
if ((_alt <= 20) && !(_doorstate)) then {
_unit animateDoor ['door_R', 1];
_unit animateDoor ['door_L', 1];
_doorstate = true;
};
// If over 20 altitude and doors are open then close them.
if ((_alt > 20) && (_doorstate)) then {
_unit animateDoor ['door_R', 0];
_unit animateDoor ['door_L', 0];
_doorstate = false;
};
//Slow the script down some. This is not a critical loop.
sleep 3;
};``` Doesn't seem to work however
I think it's to do with the _unit variable
this isn't defined inside the EH, though?
so would null = ["classname"] work?
Due to us using a factory script I need this to apply to all ghosthawks that get spawned which means I can't use specific vehicle inits
So I basically want to add automatic door opening to any ghosthawk, current or future in the mission
Might not be explaining well, for all intents and purposes I want to try and work out how to make _unit = an array of classnames and then have that work in the mission, not sure how to do that, sorry if unclear
You are already using a CBA classname EH. If you slap that on the baseclass of all Ghosthawks then it will fire.
for all of the Ghosthawks. Probably need the re init parameter to catch Ghosthawks that got placed in Eden.
Also remove the execVM and just put the script in the EH directly it will be faster and save performance. execVM is actually a file operation. So for EVERY time that EH runs, it will load the file from disk -> Parse the file -> Process the file to runnable SQF and then run it. Don't do that.
Ah you use a while true loop aswell. Hmm, just wrap it in a spawn instead of the execVM
["B_Heli_Transport_01_F", "re init", {null = [this] "scripts\ghosthawkdoors\ghosthawkdoors.sqf";}, true, [], true] call CBA_fnc_addClassEventHandler;```Like this? Sorry I am VERY amateur at this
That will apply to ALL classes inheriting from transport heli
perfect, I have 5 retextures of the ghosthawk so that's fine
Use the first Ghosthawk class, the one all other Ghosthawks inherit from
That is the class my retextures inherit from
Is that the classname of the Ghosthawk?
According to CfgVehicles WEST it's the UH-80 Ghost Hawk
Just the plain black OG one
Huh. Sorry Just haven't looked at a vanilla classname in a while. Pardon me
No its not right
Give me a hot min
To start of, the documention for CBA function can be found on the CBA site. For this one specifically it's https://cbateam.github.io/CBA_A3/docs/files/xeh/fnc_addClassEventHandler-sqf.html
If you look at that page you can see your function call isn't correct.
["B_Heli_Transport_01_F", "init", {
params ["_vehicle"];
[_vehicle] execVM "scripts\ghosthawkdoors\ghosthawkdoors.sqf";
}, true, [], true] call CBA_fnc_addClassEventHandler;```
That's should work, and no not just in init. That would mean you add that EH on all machines. So every helicopter gets the loop added server + connected-clients amount of times not good. Better to wrap it in an
if (isServer) then {
};
That way it only gets added once, on the server side!
So like ```SQF
if (isServer) then {
["B_Heli_Transport_01_F", "init", {
params ["_vehicle"];
[_vehicle] execVM "scripts\ghosthawkdoors\ghosthawkdoors.sqf";
}, true, [], true] call CBA_fnc_addClassEventHandler;
};```
ow yeah right, params is an easier way of writing select 0 and such.
No
Wrap the EH in the If statement, don't put it below it.
The { } forms a code block, the if statement only has effect on code inside the block.
Ow sorry you did that, yu just forgot to remove the original }; @distant belfry
Edited the above, is that better?
Should work, try it out
Yeah that worked perfectly, thanks so much!
No problem. Just get rid of the execVM and it will be pretty good.
Replace the execVM line with [_vehicle] spawn { }; and paste the code from the file in the { } does the same as execVM minus all the bad things execVM does basically.
Really appreciate it
Hello
Lets see if anyone can help me
I am useing this:
call{nul = [f10] spawn {while {true} do {(_this select 0) say3D "argentinos"; sleep 80;};};}
To make a vehicle have a music sound. It works fine, but when I get inside the car, I cant hear anything.
If I use say2d I can hear it, but also its hear on the hole map
Problems:
If the player is in first person view inside a vehicle at the moment of command execution, the sound created is greatly attenuated.
afaik no
you can try say2D
and kill the sound when the player gets out of the vehicle
no
Ho.. well..
Not any other way around it?
Maybe with something like this: https://community.bistudio.com/wiki/createSoundSource
don't you read? it has the same problem
Take it easy, english is not my first lenguage, and this coding is hard eanaph.
I am a creating a fnc to make a particular group forget about their targets:
params [
["_unit", objNull, [objNull]],
["_dist",300,[500]]
];
private _nearEnemies = [];
_nearEnemies = _unit nearEntities ["CAManBase", _dist];
if (_nearEnemies isNotEqualTo []) then {
{
if (([side group _unit, side group _x] call BIS_fnc_sideIsEnemy)) then {(group _unit) forgetTarget _x;};
} forEach _nearEnemies;
}; ```
But I am guessing that if instead of using nearEntities there could be a command that brings an array of targets that the group knows about so I can just make them forget those it would be more efficient... does such command exists?
something like: ```sqf
private _knownEnemies = []; _knownEnemies = (group _unit) knownEnemies;
targets
Thanks! That is much better! sqf private _targets = _unit targets [];
if you want enemy targets you should do targets [true]
Ok perfect! Thanks! Fnc is so much better now!
Final product: ```sqf
params [
["_unit", objNull, [objNull]]
];
private _targets = [];
_targets = _unit targets [true];
if (_targets isNotEqualTo []) then {
{
(group _unit) forgetTarget _x;
} forEach _targets;
}; ```
if (_targets isNotEqualTo []) then {
this check doesn't really do anything
iteration over empty array has no cost
also idk why you split the assignment
Ok that is also good to know... The check and the splitting of the array are old customs of mine that I guess make no sense anymore
another way is to clone the group and add the units to the cloned group
They forget the enemies of the previous group by doing that? I guess there is always several ways of achieving a goal in Arma!
i find forgetTarget works better in theory than in practice
probably because you didn't run it unscheduled
and the target was reacquired
So I should use the isNil thingy?
this forget Targets fnc I run when Ai units leave a vehicle with an getOutMan EH, it is meant so that Ai units don't immediately engage enemies after leaving vehicles
I guess that since it is called from the EH it is almost as the isNil "hack"
yes
Also maybe you made a single unit forgetTarget when it is best if you use it for the whole group, otherwise the group just gives the target back to the single unit who you made forget and so it re-acquires the target too fast...
Removing the group's radios might also help making the delay more significant...
So im currently making a Mission for my Unit, im wanting to have something where theres a locked room, but in order to have it unlocked, they have to have a code, is there anyway I could possibly use a trigger for or something?
my script is crashing the game, with exit code STATUS_ACTION_VIOLATION. Does anyone know what this means?
It just means a generic error. The error itself doesn't contain anything useful to solve issue, so you'd need to post the code as well
I think this is the code causing it... it is only crashing when there is only 1 player:
private _playersList = (allPlayers - [player]);
{
lbAdd [2001, name _x];
} forEach _playersList;
uiNamespace setVariable ["TRI_duelPlayersList", _playersList];
I'm guessing it cant handle forEach []?
forEach [] will just skip it
Are you sure that it caused it?
I see no addAction here, so you'd need to post the entire after all
called in initServer.sqf:
[duelsAgent, ["<t color='#7f0000'>Initiate Duel", TRI_fnc_duelMenu, nil, 6, true, true, "", "true", 3, false, "", ""]] remoteExec ["addAction"];
fn_duelMenu.sqf:
https://sqfbin.com/sajafawazupodevipuju
DuelMenu.hpp:
https://sqfbin.com/okabebisiliqipisuxoq
should have used sqfbin, one sec
So you got the crash until the line of uiNamespace setVariable ["TRI_duelPlayersList", _playersList];?
hmm
I'm not really sure
the dialog opens, and then the game crashes a few seconds later
You need to comment out some part so you'll see what part causes the error
do you interact with it in any way?
is that the only function that interacts with the dialog?
I don't see anything that can crash the game.
e.g. if you deleted a control or modified a control inside an EH it would be possible
but since you don't interact with it there is nothing that can crash it as far as I see
ok I figured out when its crashing
the buttons and everything are working fine
the gui only crashes when I interact with the list box
or RscCombo, rather
private _playersList = (allPlayers - [player]);
{
lbAdd [2001, name _x];
} forEach _playersList;
```This is the code for the `RscCombo`. Everything works fine when there are multiple players.
you mean the combo is empty?
no
So, let me clarify, if you have the empty combo, and try to click it, will crash?
yes
not on the combo
test a new combo with a new dialog (don't use EHs and don't add anything to it either)
if you can repro the crash report it
wouldnt that effectively just be changing the config values?
or do you mean with a completely different set of controls?
did your dialog add any EHs in the config?
Good morning,
Is there object type to "streetLight", i mean if i want shutdown lights from city.
Do i declare all light type in array or is there simpler way to get all type of streetlight etc.
if you want it to be compatible with all mods I recommend config reading
ahh, I see
basically you should check for objects that have reflectors
also be sure to try it with createDisplay too
Good to know, thanks for these
okay, so the combo is only deadly if this code gets executed:
{
lbAdd [2001, name _x];
} forEach _playersList;
if _playerList is empty
I think?
then I don't think it's empty
Can you add some debug commands like diag_log or systemChat to make sure it does get executed?
private _playersList = (allPlayers - [player]);
yeah doing that now
it might not be empty
e.g. if you have headless clients
Like systemChat str _x
I dont..
okay, so _playersList is returning [] and the code in the forEach loop is not being executed
private _playersList = (allPlayers - [player]);
systemChat ("_playersList: " + str _playersList);
{
systemChat ("_x: " + str _x);
lbAdd [2001, name _x];
} forEach _playersList;
Returns:
_playersList: []
Yet if you click the combo, still crashes?
lets see
nope
not crashing anymore
funny how it did it 3 times just to screw with me
Hm, I just tried to recreate what you say using your code. No luck, it doesn't even crash
like I said the crash is not happening by your script
you might have a mod
nah
or another script elsewhere 
yep it's crashing my game again lol
Trioxide , are you trying add player to ct_combo list?
// UI control
onLoad = "uiNamespace setVariable ['_listCtrl',(_this #0)];
params ["_control"];
disableSerialization;
_control = uiNamespace getvariable '_listCtrl';
lbClear _control;
{
_control lbAdd (name _x);
_col =
[0,1,0,1];
_side = side _x;
switch (_side) do {
case (east): {_col = [1,0.6,0,1]};
case (west): {_col = [0,0.7,1,1]};
case (independent): {_col = [1,0.7,1,1]};
};
_control
lbSetColor [_forEachIndex, _col];
_control lbSetData [_forEachIndex, str _x]
} forEach allPlayers;
This works for me (using CT_listBox)
don't you have a dead player in the list? as name _x on a corpse that doesn't have identity will fail (well ideally not crash)
I seem to be having trouble deleting a map object
terrain object if you may
deletevehicle doesn't do anything to it
You can't AFAIK. Just hide it
alright so how is the proper way to hide it?
I have edit object https://imgur.com/h1Gb0rD
what should I put in Object init or Global Object init field?
so that it hides for everyone in mulitplayer without issues
Guess hideObject ing everyone (not hideObjectGlobal variant) with Global Object Init is a better way?
Yeah that's what I thought too
Don't use the module.
@drifting portal (<position> nearestObject <building type>) hideObjectGlobal true
example to hide that weird bunker in the mountain on Malden
([4779.35,5697.9,0.0012207] nearestObject "Land_Bunker_01_HQ_F") hideObjectGlobal true
There is a Hide Terrain Object module (not Edit Terrain Object) which works fine in MP
can't
you should use object IDs instead
Object IDs are always not recommended as it could be changed
that’s why 2.10 has TONNES of changes, because A3 is dead
none of which had anything to do with assets
99% were scripting features
also I'm just stating the facts. I have many terrain mods, none updated during the past year
a lot of arma mods (terrains, etc) are mostly complete. i doubt there are many large unreleased projects in development, but for mission makers the new stuff is great
and indeed for mission players the new stuff is cool
Reforger release has put the brakes on a lot of arma 3 mod activity as some of the modders start to move to the new systems
Asset makers are naturally gonna switch to Reforger faster than mission makers, because mission makers need assets first.
Is there a way to tell that moveInCargo failed on remote vehicle during a bit of a lag? (because of no seats left for example)
You execute player moveInCargo _remote_vehicle, some time passes until server reply arrives, how can I tell that the request was resolved?
Positive reply would mean that unit is in the vehicle, but how can I tell that it failed?
can it fail?
Yes, two clients do moveInCargo at once, only one succeeds
Not sure how this command works behind the curtains, but it seems that it can fail with original syntax even for empty vehicle
I think that both clients see seat 0 empty, whichever's message arrives first gets it, another one doesn't get anything, trying to figure how to tell that it failed
what do you mean for empty vehicle
Lots of cargo seats, all empty
two clients do player moveInCargo vehicle at once, both seem to try to get to cargo seat 0, only one succeeds
oh so both trying to get into the same seat
Yes, in case of original syntax without specified cargo seat index
Didn't try with moveInAny
also make a ticket pls
No, had original syntax, in practice it fails when several players try to get into the vehicle at once, got curious if there is a way to tell that command failed
not sure if there is a way to return this information but am going to look
would help to debug
Gonna have to reproduce real server lag somehow to test
But thinking about it, if server selects that "any seat" then it should work fine. If client does, then it will be the same as moveInCargo
afaik server has authority in this but maybe it could be improved
Nope, nothing is being added. The array is empty.
I am using the VVS vehicle spawn script suite on a dedicated server and have modified the spawnvehicle script so that it reads "h1 = _className createVehicle _position;" .
My issue is if i spawn/create a vehicle the newly created vehicle does'nt activate my trigger that uses "h1 in thisList or h2 in thisList;" as the condition.
The vehicle that starts the mission does all this perfectly but not the newly created vehicle.
The newly created vehicle IS being renamed as i have "gunner1 moveingunner h1" in use successfully.
The trigger just wont activate for some reason.This is on dedicated server.Singleplayer and host myself MP works fine.Sounds like a locality issue maybe?
Any ideas?
Thanks.
one idea is: vehicle gets spawned on a client and a trigger runs server-only. And h1 only gets changed on a client 🤷♂️
yeah, it seems sumthn like that.Any ideas for a work around?Iam not a pro scripter.
if it's that, then inserting publicVariable "h1"; as the next line should help
uhm? "Next line" as in right after the h1 = _className createVehicle _position;, so it becomes sqf h1 = _className createVehicle _position; publicVariable "h1";
yes, in the create vehicle script
ive tried putting that into that script but in other places.
any need to write anything else in an init or anything?
ive set up public variables for trigger activations before and had to add them to the init scripts thats all.
I'll try that tommorow.Its almost 4 in the morning.Been trying everything...lol
Thanks for the help.
well, that's just an unconfirmed theory at this point. Maybe i should take a look at the actual script to understand what's really going on there
have the script ready for paste but not know how to add it here
"" sumthn like that isnt it?
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
also:
h1 in thisList or h2 in thisList
if h1 doesn't exist, your trigger should throw an error for undefined variable
(not isNil "h1" && { h1 in thislist }) || (not isNil "h2" && { h2 in thislist })
```would be "nicer"
yeah its strange.I have co-piolt moved into it upon spawn but the trigger will not fire.Only on spawned vehicle
you think that might help?
🐮 PERHAPS
which function seems to be spawned by user pressing a button in GUI (literally onButtonClick = "[] spawn VVS_fnc_spawnVehicle";), which is definitely client-side 🤷♂️
please use https://sqfbin.com
k.thnx
any idea how to make the server know of its creation?
dont know what to do with that sqfbin??
loacality issues are a pain in the butt..
paste your code, press the "save" button top-right, the URL changes → post it here 🙂
yep, what I posted 😄
and here's the post where i've got a full (?) suite: https://forums.bohemia.net/forums/topic/157077-virtual-vehicle-spawner-vvs/?do=findComment&comment=3451964
also, is the sqfbin URL the same because it was copied, or because the same-content is somehow detected server-side and it gives the same URL when trying to post again?
I'd guess a hash yes 🙂
it's where i got what i believe is the starting code without your modifications
cool.no worries
I'll give those edits a try and get back to you guys tommorow.Thanks again!
'night!
what code are you using?
no not what language, what does you code look like?
yeah just like you intended, create an array of created vehicles and delete the first entry when a new one is created, so something like
TAG_spawnedVehicles = [];
addMissionEventhandler ["EntityCreated", {
hint "A vehicle spawned just spawned";
private _newVehicle = ...; // replace "..." with however you want to create your vehicle
TAG_spawnedVehicles pushBack _newVehicle;
if (count TAG_spawnedVehicles > 10) {
private _vehicleToDelete = TAG_spawnedVehicles deleteAt 0;
deleteVehicle _vehicleToDelete;
};
}];
``` todo is add failsafe if a vehicle is not deleteable
well, "EntityCreated" should fire at the point when the new entity is already created, no? So something like this, probably? sqf TAG_spawnedVehicles = []; addMissionEventhandler ["EntityCreated", { params ["_entity"]; if (typeOf _entity != "TargetClassName") exitWith {}; hint "A vehicle spawned just spawned"; //private _newVehicle = ...; // replace "..." with however you want to create your vehicle TAG_spawnedVehicles pushBack _entity; //if (count TAG_spawnedVehicles > 10) { while {count TAG_spawnedVehicles > 10} do { //for the unlikely case of private _vehicleToDelete = TAG_spawnedVehicles deleteAt 0; deleteVehicle _vehicleToDelete; }; }];
it should exit from it, not restart 🤔
as in "stop the loop (possibly with value returned from it) and continue with whatever is after it"
while {true} do {break;};
hint "Haha, i get executed!";```
is there even a return command in SQF? I can't find one
no
if (true) exitWith {} exits current scope (as in: loop, code block, etc.)
continue to stop the current iteration and start the next one. I.e. sqf _x = 0; while {true} do { _x = _x + 1; if (_x == 2) then {continue}; systemChat str _x; if (_x > 10) exitWith {}; }; should print the numbers starting from 1, skip 2 and stop after 1011
what? why?
why add event handler in the endless loop?
absolutely. The code of event handler gets executed once for every new created entity
also, _entity is Object. To check its type you need something like (typeOf _entity == "TargetClassName"). And yes, = is assignment == is comparison. And yes there's probably no else if
also, params ["_entity"]; is mandatory to get the _entity as a variable. With no params you'd need to access it like _this#0 
_duelers remoteExec ["TRI_fnc_duelHUD", _duelers];
fn_duelHUD.sqf:
disableSerialization;
private _duelHUD = (uiNamespace getVariable "DuelHUD");
{
[_duelHUD displayCtrl 1003, parseText "<t align='left' size='1.5' font='PuristaBold'>0"] remoteExec ["ctrlSetStructuredText", _x];
[_duelHUD displayCtrl 1004, parseText "<t align='right' size='1.5' font='PuristaBold'>0"] remoteExec ["ctrlSetStructuredText", _x];
[_duelHUD displayCtrl 1005, parseText "<t align='left' size='1.5'>You"] remoteExec ["ctrlSetStructuredText", _x];
[_duelHUD displayCtrl 1006, parseText (format ["<t align='right' size='1.5'>%1", name ((_this - [_x])#0)])] remoteExec ["ctrlSetStructuredText", _x];
} forEach _this;
Does anyone know why this display update is only happening for non-server players? _duelers is an array of players.
- your remoteExec is targeting specifically the players in
_duelersso if the server player isn't in that array, they won't receive it - you're remoteExec'ing
TRI_fnc_duelHUDto all players in_duelers......and then each copy of that function is also remoteExec'ing every command in the function to all the other players in_duelers. That's duplicative and unnecessary, just remoteExec the function to all of them and have it affect only the local player.
I've never worked with functions before in a mission file, only in mods. Where would it get the tag from in the case of the mission file?
class CfgFunctions
{
class CBRN
{
class test{};
};
};
in this case would the tag be CBRN?
so CBRN_fnc_test in this case?
or wait, I think I need to go one class deeper
I do have this
class CfgFunctions {
class Authentification {
tag = "auth";
class Functions {
file = "auth";
class ask_account {};
class ask_players {};
};
};
};
you define your own tag I guess
and in my exemple
auth_fnc_ask_account
I know you dont need to explicitly define the tag, it gets taken from one of the classes
oh well maybe
from the wiki:
class CfgFunctions
{
class TAG
{
class Category
{
class myFunction {};
};
};
};
yeah I think I was just one level too shallow
ima slide over to #arma3_config since this is probably more appropriate there, being a cfg and all
Might not be the right place, but I'm new to using the Eden editor and no matter what I try, I can't seem to get the arsenal to work right. Whats the scripting to make an ammobox an arsenal that includes all modded weapons, uniforms, ETC.?
https://community.bistudio.com/wiki/Arma_3:_Arsenal#Virtual_Ammo_Box
["AmmoboxInit", [name_of_ammobox_here, true]] spawn BIS_fnc_arsenal;```
The mode string is case-sensitive so watch out there.
sorry, I should have clarified that the server is in _duelers. And yeah, I just realized that I forgot to change the code after I put it into a function...
Hello, any simple script or something to make a gun non lethal? Thanks.
that's more of a config question i think
Every question is a scripting question if you are brave enough. 
This is a way to do it via scripting, two examples, one simulates friendly fire so no damage and the second one a taser gun:
Taser gun is what a I need
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
☝️ There you go...
I dont even know what to do with that, sorry, I am noob with scripts
Well, this is quite advanced scripting you are asking for. Your best bet is to get one of the taser mods from the workshop, but you can run this code from initPlayerLocal.sqf if you even know what that file is... basically at your mission's root directory.
Yea, I guess so.. thanks anyway, appreciated.
Anytime Cerrito. I would advice to learn scripting slowly. Most will soon move to Enfusion scripting which is totally different so perhaps it is best to focus your mind resources there 😉
I am looking to replace our good old sqf waitUntil {behaviour _aiUnit != "COMBAT"}; with one of the new group EH, but it seems that sqf addEventHandler ["CombatModeChanged" won't cut it because it doesn't detect changes in the group's behaviour and only its combat mode which is not changed by the group when it goes into combat. Additionally the enemy detected Eh seems to fire too often, unlike the COMBAT behaviour which changes mostly once every 5 minutes or so....
Any new group EH that could mimic what I am looking for?
Would anyone have any ideas on why in a live server this does not work like it does in the editor? I ran debug on it and everything seems to be working but visually the lights freeze for a good 5 to 10 sec. debug info showed it was running thru the code eachframe spitting back updated positions and directions but was not visually updating eachframe. I would use attachTo but the object im using does not accept attachTo so im trying to get these lights to move with this object by eachFrame eventhandler. Also open to any suggestions on other ways to go about doing this.
CATlightpoint2 = createVehicle ["reflector_cone_01_long_white_F", (CATlocalcar modelToWorld [-0.7,+5.89,-0.25]), [], 0, "CAN_COLLIDE"];
CATLightFrames = addMissionEventHandler ["EachFrame", {
private _localCarDir = getDir CATlocalcar;
CATlightpoint1 setDir _localCarDir;
CATlightpoint2 setDir _localCarDir;
CATlightpoint1 setPos (CATlocalcar modelToWorld [+0.7,+5.89,-0.25]);
CATlightpoint2 setPos (CATlocalcar modelToWorld [-0.7,+5.89,-0.25]);
}];
iirc you need to use “createvehiclelocal” and have every client run that code
Hej Folks! hope u are all fine!
I have a question, i'm trying to do that if any player goes to an enemy body and tries to take something from the enemy inventory, that the Inventory goes blocked/closed leaving the player without the posibility to take anything from the dead body.
I have this script, but i have some kind of error that i don't know, could someone give me some help? i would really appreciate it!. Here is the Code:
if !(hasInterface) exitwith{}; player addEventHandler ["InventoryOpened", { if (_this select 1) iskindof "man"; [] spawn { waitUntil {!isnull findDisplay 602}; (finddisplay 602) closedisplay 1; cutText ["No loot", "PLAIN DOWN",0,true,true]; } }];
PD: The error says me that it's Type Object and awaits Bool.
Best regards and thank you in advance!
Semper Fi
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
The error is caused by a misuse of if. Check out https://community.bistudio.com/wiki/if and https://community.bistudio.com/wiki/then to see how to construct a proper if check.
aight, i'm not really good with scripting, but i gonna check it out! thank u for ur time @warm hedge
thx u so much for the source! 💪
Hello, still trying find out how to get result 1 object from take EH.
even using condition
if (_blockItem findIf { _x == _item } > -1 && _container == (_unit getVariable 'container')) then {}```
I get result 4 if i have 4 bananas in container.
So is there somekind of workaround to get take eh only effect to 1 object , not all of kind of object which is in container.
So if i take 1 banana, it delete that from player, and from container , but adds 4 back. So after take i have 0 in player invertory and 7 in container
I'm gonna say it has nothing to do with the EH firing multiple times, but rather you adding multiple EHs
you add an EH every time the player opens a container
let's say he doesn't pick up anything
your Take EH will stay in place
now let's say he opens another container
Aaa, i didn't realize that
So there is in bad case 10 eh for nothing on player
or several hundred yeah
Very good point.
So is there any way to do something what Im trying.
To get player blocked get specific items from containers
just add 1 EH
either use a lock guard, or add the EH outside the ContainerOpened EH
except "Take" EH didn't fire on every item pickup last time i've checked (in 2.08 iirc), only on some
What you mean with lock guard? Do you have some example of this
You mean i add take EH on player 1st, but does this effect for all containers? I mean if item is specific i can block that from player with this
this addEventHandler ['ContainerOpened', {
params ['_container', '_unit'];
_unit setVariable
['container',_container];
if (_unit getVariable ["has_EH", false]) exitWith {};
_unit setVariable ["has_EH", true];
_unit addEventHandler ['Take', {
params ['_unit', '_container', '_item'];
private _blockItem = ['ACE_Banana', 'itemMap', 'ACE_morphine','ACE_EarPlug
s'];
if (_item in _blockItems && _container == (_unit getVariable 'container')) then {
systemChat format ["Player %1 %2 %3",name _unit , 'you are unable to loot',
_item];
_unit removeItem _item;
_container addItemCargo [_item,1];;
_unit removeEventHandler [_thisEvent, _thisEventHandler];
_unit setVariable ["has_EH", false];
(findDisplay 602)
closeDisplay 0;
};
}];
}];
it prevents you from adding more than 1 EH
Nice
but like I said just add 1 EH
Yeah. Thats what I gonna do.
Thanks for advices.
why even bother adding a EH inside another EH at this point? Just move the "Take" EH outside into, like, initPlayerLocal.sqf :3
this addEventHandler ['ContainerOpened', {
params ['_container', '_unit'];
_unit setVariable ['container',_container];
}];
this addEventHandler ['Take', {
params ['_unit', '_container', '_item'];
private _blockItem = ['ACE_Banana', 'itemMap', 'ACE_morphine','ACE_EarPlug
s'];
if (_item in _blockItems && _container isEqualTo (_unit getVariable ['container', objNull])) then {
systemChat format ["Player %1 %2 %3",name _unit , 'you are unable to loot', _item];
_unit removeItem _item;
_container addItemCargo [_item,1];;
(findDisplay 602) closeDisplay 0;
};
}];
can't repro on the current development, though. Please, ignore my ramblings
well, "Rearm at X" action doesn't seem to fire "Take"/"Put" EH
Apparently setVelocity doesn't update over the network if you apply it to local shotShell shots 🤔
aren't shotshell is local?
Not sure. Aren't they slow enough to be global? deleteVehicle on remote-created shotShell deletes it for everyone at least.
Testing with createVehicle-created shotShell
which object do you create?
class rhs_ammo_3d17_shell: Grenade
{
simulation = "shotShell";
Went to investigate why RHS's scripted remote smoke shells don't move, that turned out to be the reason
Guess they need to change setVelocity to be remoteExec'ed
Vanilla vehicle smokes are shotSmokeX so setVelocity updates through the network fine
rhs_ammo_3d17_shell what is it?
Vanilla uses shotSmokeX for smokes
But you probably can reproduce it by creating any shotShell projectile
why RHS wont use shotShellX?
I guess because their shell explodes after some time and creates instant smoke vs continuous smoke from the shotShellX
private _shell = createVehicle ["Sh_120mm_APFSDS", player modelToWorld [0,5,5], [], 0, "CAN_COLLIDE"];
_shell setVectorDirAndUp [vectorDir player, vectorUp player];
_shell setVelocity (vectorDir player vectorMultiply 100);
Vanilla asset
Shoots forward properly for creator, floats in place for remote clients
Talking about possible engine solution would be a proper createVehicle command without ancient marker crap, where you could provide everything that's included in the create message - class, positions, orientation, velocity
But this particular issue case can be solved with remoteExec call
private _shell = createVehicle ["Sh_120mm_APFSDS", player modelToWorld [0,5,5], [], 0, "CAN_COLLIDE"];
[_shell, [vectorDir player, vectorUp player]] remoteExecCall ["setVectorDirAndUp", 0];
[_shell, vectorDir player vectorMultiply 100] remoteExecCall ["setVelocity", 0];
```is MP compatible
OBJECT = createVehicle HASHMAP with parameters that you need in the provided hashmap!
A man can dream
Thinking about it again, with this many arrays that createHashMapFromArray takes, such command would probably be a lot slower than flat arrays that most commands use right now, so its not that good of an idea.
Does it sync position after at some point?
No, never
Further setVelocity calls don't do anything either
Maybe it was meant to be local when engine fires it?
Sh_120mm_APFSDS is fast vehicle so it wont have network sync
is nearTargets, targets and targetsQuery basically the same / operating on the same target data - with the nearTargets only providing a distance filter, targets and targetsQuery (no distance - only position) to offer more filters?
also targetsQuery has the comment "This command could be CPU intensive." - should be still less than doing filtering in sqf land, right?
how exactly can I make params accept a config entry?
I tried params ["_config", configNull, [configNull]]; but it throws the following error:
12:26:36 Error position: <params ["_config", configNull, [configNu>
12:26:36 Error Type Config entry, expected Array,String
shouldn't that be params [["_config", configNull, [configNull]]]; added another [] there
yes
thanks. so the "This command could be CPU intensive." comment is not really correct
like it should be rather along the lines "using a combination of filters may extend the execution time considerable"
and still kinda doubtful this is true for anything you do via sqf instead
well it could be correct
targetsQuery also gets the targetKnowledge afaik
will do some measuring of the relevant command set and report back
Any clues what might trigger this bug? Units appear on top of the vehicle in some static animation.
Happens in real server all the time, seems to be happening A LOT more with RHS
Just had it locally with listen server and client, but couldn't make it happen again. Looks like some kind of lag triggers it (left two clients open for hours doing nothing with one in the tank)
Did some experiments when seen this on live server - switchMove on unit does nothing, unit is properly in the vehicle (included in crew, in command returns true)
Thought it would be the most competent channel to ask in
Big game breaker as you can easily shoot out the crew out like this
Also one observation, I constantly seen this happen for units in mortars with vanilla assets. Maybe something config-wise triggers it to happen more often that mortars and RHS assets have
vehicle animation
like doors
I've seen that a lot
and no clue why it happens
I seen this happen all the time with mortars in vanilla game in multiplayer
but I know a workaround for fixing it
Like 90% times I look at player in mortar, they're in this default animation
Been few years ago though, started seeing this all the time again in RHS once started playing and watching it.
What's the workaround, something scripting?
just doing a switchAction 
with a getIn event handler...
I did that for my AI mod to fix that bug
you should use switchAction and supply the correct action
Lemme try
Did switchMove "" on crew side, turned into such animation, but only for them, other clients don't see them like this, even after rejoin
probably need to retrieve gunnerAction etc from the config and apply that, i've seen it appear too but have no idea what the cause is
i've also seen switching seats in like a vehicle keeping the previous positions animation
@meager granite this is the old code I used:
https://sqfbin.com/apevonimaxovituhukox
I have a newer one but it's in C++ and useless here
it also has a assignAs* part but that's because it's a full code for mounting the AI unit
animationState returns proper animation name for the unit
yep
Yet unit is in broken animation
I just noticed that in my own code 😅
Joined live server, checked out random tank -> animations broken
so the bug was the unit animation, not vehicle animation
for some reason it doesn't "jump" (switch) properly
so wait, does unit switchMove animationState unit fix it?
Speaking of bugs, 5 years later and naked units bug still happening 
no, it can be applied to anything
wat?
it behaves a bit differently in vehicles I noticed
the global effect for example doesn't seem to work
switchMove, playMove, playMoveNow => do nothing
It gets applied to remote units but reverts once animation update arrives from unit owner
So effect is local and temporary, depending on what unit is doing
Huh, what's interesting is that I can no longer get this issue again for 10 minutes of trying
My bet is that happens due to asset streaming
Once all tanks in the round loaded, even rejoining doesn't trigger it again
let me try to restart the game and see
Maybe it happens because some LODs don't have proxies for all seats?
I always do it like this: sqf [_unit, "InBaseMoves_patrolling1"] remoteExec ["switchMove", 0];
If unit happens to render in such LOD, it breaks the animation?
Doing guesswork here, I'm a total noob with models
Restarted the game and guess what, it happens again
Seeing some correlation here
This might explain why vanilla mortar had this bug happening all the time, vanilla tanks are mostly okay and RHS tanks are always bugged
probably something in model makes it trigger more often
Or is it unit animation not being streamed in time? 🤔
So, applying "switchMove" does work
You just have to apply some another animation first, then proper animation
Just seen unit bugged like this in lower LOD for a moment, then it updated to top LOD and unit disappeared into the vehicle
Another point towards my LOD theory
Maybe some kind of update arrives while unit renders in problematic LOD, then unit stays in such broken animation?
PS: no need for , 0
My brains blanked and google isnt helping, what is the line to change one of the values in a position array?
ex. [125,31,4] want to make the 4 a zero
Sorry for wall of text guys, these long going gameplay and immersion breaking bugs irritate me to no end, I would LOVE for them to get fixed.
set [2, 0]
ah yes, thankyou
A combo of broken animation AND no uniform, welcome to Arma!
https://i.imgur.com/JXYFCzK.png
So yeah, animation can be fixed, you have to set some another and then proper one next frame
Having a fix in the engine would've been better of course
is there any way to apply a texture on player in the clan selection? Basically force a squad.xml logo on a unit
either by mod config, or a mission script?
Yes, you can set a texture on the clan selection using setObjectTexture/Global, by using "clan" instead of a numeric selection index.
Note that custom textures applied to units may not persist through uniform changes, Arsenal opening, etc. - handling that would be up to you.
An array can contain anything. But if you're giving it to a command as an argument, that particular command may expect it to contain only numbers.
Since an array can contain anything, you can pushback anything into it.
that code doesn't make a lot of sense
when an entity is created, if the entity matches that classname the classname string is added to the end of the array, and while the array count exceeds 5 it will remove the first string from the array and then use deleteVehicle with a string?
["B_MRAP_01_F","B_MRAP_01_F","B_MRAP_01_F","B_MRAP_01_F","B_MRAP_01_F"] this is what your array will look like
why
do you mean to delete the object?
TAG_spawnedHunters pushBack _entity;
did you write this code?
TAG_spawnedHunters = [];
addMissionEventhandler ["EntityCreated", {
//code executed whenever an entity is created
params ["_entity"]; //defines _entity as the object that was just created
_hunterClass = "B_MRAP_01_F"; //hunter classname to match with typeOf
if (typeOf _entity == _hunterClass) then {
//exits the script and executes this code if the entity type is your defined classname (above condition)
TAG_spawnedHunters pushBack _entity; //appends hunter to array (will not happen if classname doesn't match)
};
while {count TAG_spawnedHunters > 5} do {
//will only run if the count exceeds 5, will loop if the count still exceeds 5 after execution (seems redundant)
_hunterToDelete = TAG_spawnedHunters deleteAt 0; //remove first added hunter from array, stores to _hunterToDelete
deleteVehicle _hunterToDelete; //deletes stored object from previous line
};
}];
@granite haven
the while {} do {} can probably just be if () then {} but it'll work anyway
wait
no you don't want exitWith
changed
the exitWith will skip the while portion
im going to reorganize this real quick
and the exitWith
also i have a typo with the last local variable. fixed*
TAG_spawnedHunters = [];
addMissionEventhandler ["EntityCreated", {
params ["_entity"];
if (typeOf _entity != "B_MRAP_01_F") exitWith {}; //exits scope and does not continue script if not hunter
TAG_spawnedHunters pushBack _entity;
if (count TAG_spawnedHunters > 5) then {
deleteVehicle (TAG_spawnedHunters deleteAt 0);
};
}];
deleteAt 0 will delete the oldest hunter
deleteAt 6 will delete the newest one
actually no
don't deleteAt 6
if the array has six elements the last indexed element will be 5
since it starts at 0
almost got me there
yeah, pushback adds to the end of the array so deleting the last element will be last in first out
yo, everyone a noob here; does anyone have a good tutorial for arma 3 scripting?
Im getting the error "4 elements provided, 5 expected" for the createUnit line, and I can't figure it out for the life of me...
Any help is appreciated!
_grp = createGroup civilian;
_grp createUnit ["B_Soldier_A_F", _town#0, [], 0,"NONE"];
nvm its just working now...?
Thanks to @south swan and @winter rose for your help.I added the public variable "h1" and it works fine now!!
I've got a question for changing the value in a hashmap. I have a hashmap value that looks like this ["key", [[1,2,3],15,False]]
I want to change just the "False" to "True" but I don't see any examples on the wiki that use set to change something thats nested. Is this possible?
Arrays are accessed by linkreference, so (hashmap get "key") set [2, true] should work.
Thanks! I'll give that a shot
It works well, thankyou!
I'm also trying to use getTerrainHeightASL however it ends up being a position very high above the ground... Is there perhaps a more accurate way to get this value when position2d is provided?
Hmm, maybe the issue isnt that getTerrainHeightASL isnt working. It could be that createUnit uses a different type of position, like ATL. The wiki doesnt say, I'll try it though
^this was in fact the issue, ASLToATL fixed it
getPosATL could be used instead
createUnit seems to be claiming that it uses AGLS. Not sure if true.
huh, if I blow up this particular truck it consistently returns false for isTouchingGround :P
Arma
oh, doesn't even matter where you put it. HEMTT cargo consistently returns false for isTouchingGround after being destroyed.
that command is not reliable from my experience
use getPos 😛
I was getting the pos based on a 2d location. The wiki suggests that getPosATL only works with objects
you can set the 3rd value to 0
e.g
private _2dPos = getMarkerPos "marker"; // [123,456]
_2dPos set [2, 0]; // [123,456,0]
Hello 🙂 I'm extremely new to Arma 3 scripting. I'm currently using a chemical warfare mod that has three types of gas, and according to the mods wiki, you can define the type of protection you will need (be it just a mask, or a full CBRN suit). Thing is, I think I need a script for that and I don't really know how to get started.
This is the wiki: https://github.com/Dankan37/ChemicalWarfare/wiki . Please not that I'm not really asking for someone to make the script for me, just point me in the right direction
Is this for use in a mission you're making yourself?
It's explained there how to do it
What I'm looking for is in the ''editing gas types'' section
I don't know if it's done the same way.
yea just add them to init.sqf
On a line on init.sqf?
And that would be it?
lmao
Wow, it really was that easy. Thank you!
you see the values there, that gets loaded on mod initialisation
but you can just overwrite it by adding them into init.sqf of your missionfile
Hey, can someome help me out here?
Trying to add actions to objects for Pub Zeus, except...
addaction isn't used on the pub servers, according to the wiki?
What do
should ask in #zeus_discussion maybe, nothing we can help with here, unless you can execute code in the pub servers, which i doubt 
I can execute local code.
Nothing serverside, unfortunately.
i suppose you can't execute it on other clients either
so, that means it won't work
Yeah.
Like, if I could figure out how
the arsenals do it
that'd be awesome
and I would just... steal that method lol
as I type this, I realize that I am stupid
and totally cxan
*can
{
[_x, ["Test Action", { hint "Hello" }]] remoteExec ["addAction", -2];
} forEach curatorSelected # 0;
you can give it a try, but i doubt it will work, select an object and run that code
Yeah, it seems like it uses remoteExec
Is there a way to just... put that into the object?
Have that be a part of the object?
you can use https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#EntityCreated that is, if the remoteExec is allowed
I am a little stupid when it comes to scripting sorry
but no, you can't just have objects have the action by default, that would be a mod
hello, I know that the wiki saids its for editor only, but is there anyway to make the setObjectScale for multiplayer? Thanks
check the notes on the page
Hoo... yes, sorry. You are correct. So, is laggy. Thanks
is there some way to create a marker that is only visible through zeus?
I see createMarkerLocal, but I dont think thats what I am looking for
you can set marker alpha locally
are you thinking setting that alpha on curator open and close?
that was my first thought when you said that. Idk if thats the best way but it definitely would be a way
yeah. I dont see event handlers specifically for that though
honestly it really doesnt need to show, I just dont have any visualization method for the curator to see the area which the script effects (in this case chemical warfare stuff)
Dreaming about new commands again:
hashMapCache = createHashMap;
someCachingFunction = {
private _return = hashMapCache get _this;
if(!isNil"_return") exitWith {_return};
_return = call {
// Some complicated calculation
123;
};
hashMapCache set [_this, _return];
_return;
};
```How hashmaps help with caching calculation results by key
```sqf
hashMapCache = createHashMap;
someCachingFunction = {
hashMapCache getOrSet [_this, {
// Some complicated calculation, executes only if _this key doesn't exist, sets it to hashmap and returns the value
123;
}];
};
```How a new command can speed this up.
hashMapCache = createHashMap;
someCachingFunction = {
// exit scope with value if _this key exist
hashMapCache getAndReturn _this; //Other names: returnIfSet, returnIfGet
// calculate and set _this key if doesn't
hashMapCache set [_this, {
// Some complicated calculation
123;
}];
};
```or like this
Purpose is to save on these variable initializations, ifs, isNils and exitWiths that are needed for such caching function
Move it all to the engine side
as in "lazy getOrDefault"?
Not just default but also set
All in one command
get if key exists, if it doesn't execute the code, assign its result as key and return it too
getOrDefault can set since 2.04
yep
so doesn't really save any code for expensive default calculation. Still pretty useful in some cases
You can also draw icons on the map
Thank you I was able to get the lights to work with a client side code using remoteExec like you suggested and made it way simpler than I originally had it coded. ```
private _CATlocamotiveCar = missionNameSpace getVariable "_locamotiveCar";
private _CATlocalCar = [_CATlocamotiveCar] call ATRAIN_fnc_getTrainCarLocal;
if ((typeOf _CATlocalCar) isEqualTo "ATS_Trains_Steam_Large") then
{
private _CATlightpoint1 = createVehicle ["reflector_cone_01_long_white_F", (_CATlocalCar modelToWorld [+0.7,+5.89,-0.25]), [], 0, "CAN_COLLIDE"];
private _CATlightpoint2 = createVehicle ["reflector_cone_01_long_white_F", (_CATlocalCar modelToWorld [-0.7,+5.89,-0.25]), [], 0, "CAN_COLLIDE"];
_CATlightpoint1 attachTo [_CATlocalCar, [+0.7,+5.89,-0.25]];
_CATlightpoint2 attachTo [_CATlocalCar, [-0.7,+5.89,-0.25]];
Well for one thing your array is not closed
For the other, I'm not sure what you're trying to do with that function
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
also wouldn't he need to remove the player from the original grp first before joining a new group?
No
The outermost array is not closed
So you want getOrDefault ["key", {}];?
Do you mean it already works like this and executes the code if key doesn't exist?
no i think it will set it to {} but what i mean you want code execution for default?
conditional/lazy code execution
Execute code if key doesn't exist, return its result AND assign result to that key
All in one command to use hashmaps for value calculation caching
getOrDefault ["key", {}, true];? true is treat code as conditional expression
it would assign the code variable to the key, not the result, though
that is how it is now
If such thing is to be implemented, I think it should have a new command name instead of modifying existing one
changing that can break stuff for people if they actually use hashMaps to store code, though
no it wont and default is false
hashmap getOrCall ["key", {}, true/false]:
- Return value by key if exists
- If doesn't, execute {}, return it
- If 3rd argument is true, also save new value in hashmap in that key
i was under the impression that the implied change was "make getOrDefault ["key", {code}, true] assign the return value of code to the key 🤷♂️
3rd arg force update?
correct
In my command idea?
yes
false - just execute the code and return its value (default?)
true - execute, return and assign value to key
so force update existing value
Not force, it won't even get to that if key already exists
force init
hs = createHashMap;
hs getOrCall ["key", {111}]; // 111
hs getOrCall ["key", {222}, true]; // 222
hs getOrCall ["key", {333}]; // 222
hs getOrCall ["key", {444}, true]; // 222
Don't like the command name that much though
getOrLazyDefault getOrLazyCall getOrSetCall
getOrSet might be bit misleading if somebody would expect code to be set and not executed
but you have getOrDefault for that
And personally I'd prefer 3rd argument to be true by default as that's why I'm going to use it most of the time, hard to imagine why you won't want something set
or add the 4th argument to getOrDefault for calling the code that's in default 🤷♂️
why even use a hashmap? 
//fn_someExpensiveFunction
private _resultName = _fnc_scriptName + "_result";
if(!isNil _resultName) exitWith {missionNamespace getVariable _resultName};
// get result
// ...
missionNamespace setVariable [_resultName, _result];
_result
Less commands called
Right now I use these caches to save and get properties for CfgAmmo and other config classes
Very useful when you need to check classes for your needed properties very often like in "Fired" event handler
instead of getting config values and comparing them against something each time
Can be turned into single command with that idea:
private _is_projectile_guided = isProjectileGuidedCache getOrCall [typeOf _projectile, {
// lotsa configFile >> stuff
}];
Yes its all possible right now with isNils and exitWiths but seeing getOrDefault made me wish for a lazy call version of it
Not critical, but a QOL and a bit of performance saver feature
(And yeah I get the idea of universal function caching through mission namespace)
getAndSetIfDefault
getAndSetIfNotExist
getSet
I like the last one
hm getSet [“key”, {code}];
or getSet and getSetCall
one just gets and sets if not exist another does the same but executes code instead if not exist
getSet [key, anything]
getSetCall [key, {anything}]
though getSetCall is enough
just do getOrCall
and provide the hashmap as _thisMap as a magic variable in the code
no need to set anything automatically
let the user do it
hashMap getOrDefault [key, defaultValue, setDefault]
or _map getOrCall [_value, _code, _setDefault]
getSet then since there is getOrDefault
getSet [key, {anything}]
unnecessary 3rd arg really
what if what if
but I can see getOrCall being useful
his case is what it will be used for mostly
Why you'd want execute something and not set it?
exactly
why you'd want to do getOrDefault and not set it?
inb4 callWithMRUCache :3
you don't always want to set
For simple value that don't require much calculations
it should have had true by default
no
yes
yesn't
then use setDefault true for getOrCall
always set otherwise you can test if key exists
"if anything expects the key to be there then it probably should" vs "let's try and see" 🤣
but either way the user should be able to opt out of setting
too many options can get confusing unless they are nescessary
What should've been default true is flag in merge
I think it needs call in the name to show that it will execute the code, not set the code as value
tic tac toe
u looz
getSetCall sounds like: get value, then set value by code. kinda like what A++ does (get value, then increment)
getOrCall explains what it does better: get value, if not exists, call code
getOrCall doesnt say it will set it
Anyway semantics @meager granite could you make a ticket plz
neither does getOrDefault
flag in the argument does for both
yeah lets add more sh*tty names
Nothing can surpass WFSideText 
getOrInit. Except it doesn't say "and returns the new value"
oh. and getSetCall is not sh*tty?
setConstuction
Sure. Honestly wasn't expecting that it will be picked up, but I definitely have real world usage for it.
no it actually describes perfectly waht command does
it gets and it sets and it calls code
it is a good addition to hashmap
getOrDefaultCall to be in line with getOrDefault even more
if we do getOrDefaultCall i will add 3rd arg and make it consistent with getOrDefault
will make leo happy
I also think it needs 3rd argument
Is there no good way to have a similar effect of https://community.bistudio.com/wiki/setPlayable
in Arma 3?
I want to create a unit mid-mission and have it selectable in the multiplayer lobby
There is not
You could perhaps selectPlayer with a custom UI if you want to e.g. allow dead players/spectators to reslot, but a) it's sketchy in MP and b) it doesn't change the actual slotting screen
well in my case, I wanted to make it so that the pilot would transfer to a ground unit for a single task, then when the task is done he can go back to being pilot
I thought there was a way to disable pilot slot and replace it with the ground unit for a bit, but I guess a JIP script that checks if the event is on and if a player is a pilot then switch the pilot as they select the slot will be sufficient enough
trying to figure out how the particle drop function works. Trying to get them to spawn the particles on a specific point, but if I try to make the reference object objNull, I just dont see them spawning at all
drop [
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 0, 8],
"", "Billboard", 1, 3, // animationName, type, timerPeriod, lifeTime
_location, // position relative to referenceObject
[0, 0, 0], // velocity
0, 0.005, 0.003925, 0.1, [4, 4], // rotation, weight, volume, rubbing, size
[[1, 1, 1, 1]], // colors
[1], // animationPhase
0, 0, // randomDirectionPeriod, randomDirectionIntensity
"", "", // onTimer, beforeDestroy
objNull // referenceObject
];
this doesnt seem to spawn anything. If I stick with the wiki example of the reference object being the player, and a fixed position for the position paramater, then it works
position relative to referenceObject
objNull
?
from the wiki
If this parameter isn't objNull, the particle source will be attached to the object.
I guess it doesnt describe what happens if it is objNull, I just assumed it would use the position itself
I may just spawn a barrel or something to use as the reference object
iirc it does have a position parameter
yeah, it does. But as far as I can tell its relative to the reference object, I dont see much info on what it does when there's no reference object
no I meant a separate position parameter. looks like I was wrong
If this parameter isn't objNull, the particle source will be attached to the object.
it seems to suggest that objNull should work as well
yeah, thats what I was thinking
5 position Physical Array format Position
which one, though?
I wish the actual docs for drop had comments in the example
I might look into using a particle emitter instead of drop. My issue with it was making them spawn randomly in a given area, but particleCircle doesnt seem to do that
yes, there's some stuff in there that I cant seem to get working
specifically using objNull in the reference object spot
use the source itself
(which ofc doesn't work with drop)
interesting
why isnt the dedi server finding any of the DLLs? is it not supposed to? client finds them....
<offtop> turtle is barely modified sofa 🛋️ </offtop>
battleEye blocking it
is the dedi hosted on your own PC?
yes
and RPT says extension not found?
yep
are you sure you've loaded the mod properly?
is there a way to modify the properties of an individual particle after spawning it?
I'm hoping to make the particles fade out instead of just popping out of existence
setParticleParams again?
would that effect the specific particle? or all of them?
all
depending on how it should look like you can use just 1 particle params
mmmm. I think what I'm trying to do might be trying to find a way to mask an engine limitation
e.g color takes an array
oh?
oh
my hope is that at the end of the lifetime, its alpha gets set to 0 over a short period of time
yes you can do that
I have no idea how
is it a part of particleArray?
I'm thinking of the script fields for onTimer and beforeDestroy, that might not be the right way though
colors
ohhhh the array of arrays
it doesnt actually say what the nested arrays do, is it the starting, middle, and end colours?
it builds a linear profile with those
it doesn't have to be 2 or 3
it can be more
Wish there was a way to disable reassignment of setVariable on respawning units, so much headaches from such a "convenience"
If it didn't change lately, these variables on respawned units stop being JIP too
Thanks Arma, very cool
allPlayers gets you all playable units including any headless clients. You will have to find some trait that will let you narrow it down to just a single character
Get rid of the headless clients with _players = allPlayers - (entities "HeadlessClient_F")
"player" or "all players"? Imagine server with 70 players. Is the intent to do something to each of them or only to specific one?
You can't use player on a dedicated server because it refers to the local player. On a DS there is no local player and it has no way of knowing which of the connected players you're talking about. There is no "the player" to get.
Instead, you need to figure out which unit you're actually talking about and pass a reference to that.
If this is remoteExec'd from a client (e.g. [] remoteExec ["my_fnc_serversideFunction",2]) then you can do player on the client and pass that as an argument to retrieve on the server
// on client
[player] remoteExec ["my_fnc_serversideFunction",2];
// in my_fnc_serverSideFunction
params ["_unit"];
createVehicle [_className, _unit, [], 0, "NONE"];```
how you suppose one can tell engine not to transfer vars?
You mean if such feature existed?
Hmm, difficult question since some mods might rely on this behaviour and simply disabling everything might be too problematic.
Listing variables that shouldn't be reapplied is very close to simply resetting them on "Respawn" event handler
Just double checked, looks like JIP issue is fixed
Still, disabling reapplying of all variables even for specific entities is not THAT useful, might as well add Respawn event handler and reset needed variables yourself.
Was mostly ranting that I forget again and again that new entity doesn't mean fresh variable namespace and it bites me in the ass
Antistasi transfers all the vars manually on respawn and I'm leaving it there because I'm worried that it's working around weird bugs :P
//diag_codePerformance - ms - count
["units west",[0.041],233]
["units independent",[0.005],40]
["units sideLogic",[0.001],4]
["units sideUnknown",[0.001],0]
["switchableUnits",[0.005],24]
["playableUnits",[0.009],0]
["allPlayers",[0.001],1]
["switchableUnits + playableUnits + allPlayers",[0.014],25]
["entities",[0.038]]
["entities CAManBase",[0.042],251]
["entities SoldierWB",[0.049],232]
["entities SoldierGB",[0.027],19]
["allGroups",[0.009],119]
["allUnits",[0.040],275]
["allDead",[0.032],47]
["allDeadMen",[0.026],45]
["agents",[0.018],2]
["vehicles",[0.012],85]
["entities AllVehicles",[0.051],293]
["entities Cars+Tanks",[0.038],13]
["8 allObjects 1 - Normal entities: vehicles etc",[0.036],2]
["8 allObjects 4 - Out vehicles: objects that are not listed anywhere else, holders, etc",[0.161],2]
["8 allObjects 8 - Vehicle map: ordered vehicles.",[0.001],2]
["nearTargets",[0.159],143]
["targets - west",[0.007],6]
["targets - independent",[0.008],8]
["targetsQuery - sideUnknown",[0.020],17]
["targetsQuery - west",[0.024],17]
["targetsQuery - independent",[0.023],17]
would you think its worth caching values fetched from config classes? (to missionNamespace)
at what point its also worth to cache units set to a GV even within the same frame?
isKindOf check probably also worth to cache
Anyone ever made a "enter code" to teleport script... example...
player walks up to tablet... enters pin number then it teleports them to room (invisable helipad)
if you have care to share?
you can make a gui like the examples here https://github.com/ConnorAU/A3UserInputMenus
that calls a function to teleport the player if the input matches
and you don't need a physical object like an invisible helipad to do this stuff idk who keeps telling people this
you can right click > copy location data
under log
or make a game logic entity
that looks way above my knowlefge level
i will look it over thanks
why complicate it... if the easy way works... toss down a helipad name it and teleport to it... both methods work.. just cause its not the way you like to do things doesnt make it wrong
It's not strictly necessary but it is a good way to have a visual (and moveable) reference for the destination in the Editor
invisible helipads function as a way for ai to identify landing zones, so it can lead to "why is my pilot landing here?" in the future if it becomes a habit. Niche but it can be avoided by just using a game logic entity instead
it's not more complicated at all in fact you can probably find a GL entity quicker in the browser
by the same token if you are worried about heli landing on your invisable helipad... you can also use empty markers as locations... will function the same way... again your way is not the only way to skin this cat
all I'm saying is there isn't a reason to use an entity intended for a different function. I've seen tutorials specifically telling people to specifically use this object for no reason
so what is the correct way to use special symbols in text/
for instance, format ["%1 progress at 15%",tag_var];
%1 is the tag_var, but 15% is the progress
Escape the % symbol.
In other languages it's usually \
Before the character you want to escape.
ahh like regex
More like every single programming language that ever existed.
Excluding ASM and a few esoteric languages.
format ["%1 progress at 15%2",tag_var, "%"];
I think I tried \ and it didn't work
yeah, that's the only method I tried that worked.
nice, glad im not the only one encountering issues like that 😄
Was kinda expecting %% to work, but it doesn't.
Pretty silly there is no escape for strings..
does stringtable/localization work in mission.sqm?
It does
description=$STR_KOH_LobbyPlayer;
3DEN replaces it with plain string on save though
So you have to fix it afterwards to be localised string again
nice ty @meager granite am I able to mix using STR and $STR in stringtable?
had some issues with description.ext when using $STR, after using mostly STR for everything else
pass "%" as argument
I am having a recent issue where I run on impact with ground
_pod attachto[_otherThing,[0,0,1]];
``` where `_pod` is falling very fast (like 50 meters/s) causes `_pod` to go [0,0,0] on map. Is that something thats expected to happen if `_pod` is going fast?
50 m/s is not "very fast"
and what kind of object is that _pod?
it is a staticTurret
are you sure it goes to [0,0,0]?
yea, that would be the bottom left hand corner of the map
cause after it does go to the corner, if I then run the attachto again, it works fine
well I mean did you actually see it there?
Yes
so I was thinking maybe the speed of the pod for some reason makes attachto freak out, cause this only started to happen recently after 2.10
does _otherThing go under the ground?
no its at ground
then report the problem
report the problem?
oh like the channel or to https://feedback.bistudio.com/project/view/1/
the site
Okay will do once i wake up lol
i wonder if this would fix it
In markers and other Eden Editor fields (e.g Mission Name), translation keys should be prefixed with @, without any quotes around - e.g @STR_myMarkerName. Casing does not matter here either.
what do you mean
How come I cannot get doArtilleryFire to work in multiplayer?
Have a script (which works as everything else in it works), that gets fired with an addaction.
The script and doArtilleryFire works in singleplayer and on local hosted multiplayer.
doArtilleryFire is Local Argument, which means you need to make sure it runs on the machine where the artillery unit is local. Since it's AI, that's most likely the server, but you can target it automatically by passing a reference to the unit as the remoteExec locality parameter.
This isn't an issue in SP or local MP (without other players) because everything is local to your machine.
So I can just remoteExec in the current script, with the remote exec pointing (a separate script) the doArtilleryFire?
Maybe? I don't know, I haven't seen the script. Almost certainly you need to remoteExec the doArtilleryFire command in particular
addAction points to script, containing:
remoteExec "Scripts\GunSaluteFire.sqf";
That script is this:
Gun1 doArtilleryFire [getMarkerPos "Fire", "RHS_mag_m1_he_12", 8];
Gun2 doArtilleryFire [getMarkerPos "Fire", "RHS_mag_m1_he_12", 8];
Gun3 doArtilleryFire [getMarkerPos "Fire", "RHS_mag_m1_he_12", 8];```
which gave me an error in expression
remoteExec does not take string, and filename would not work like that anyway https://community.bistudio.com/wiki/remoteExec
that explains that, though I still have no clue on how I'm supposed to get it to work?
proper way would be to make a function and remote exec that, but if you want to stick to filename, you can remote exec execVM it
also you shouldn't need to execute this on every machine, only where the GunX are local, which i suppose a single machine should be owning all?
Presume that the server
yeah so
and tried execVM before coming here, then tried remoteExec
"Scripts\GunSaluteFire.sqf" remoteExec ["execVM", 2]
loading mission.sqm with description=$STR_KOH_LobbyPlayer; and then saving it will save it as description="Player";
was issue with 2d editor too iirc
Didn't know about that
it still doesnt address the main issue tho ... stringtable.xml is not read until after player proceeds from lobby
so translating text visible in lobby (such as role description) doesnt work
only after player connects, then if they abort to lobby they can read the translated text
custom stringtable for mission or global one?
for mission
if you set it to any globally localised string it works from the first join?
im guessing it would since the global would be read at game launch
find me global for "Select role ingame" 😄
i dunno what one can do mission is not loaded in lobby
nothing need be done, we have made it this far without
TBH i dont use lobby at all, i only have it due to instability of the "skipLobby" option. lobby slots can get bugged and leave client stuck on "Receiving Data" screen
without the lobby they are forced into the same bugged slot over and over ... with lobby it allows to navigate around the bugged slot
but wait, surely client should already know what mission lobby belongs to since you already have mission.sqm read
there is some info passed thru, and yes mission.sqm is read when player is in lobby ... just stringtable is not
maybe this can be fixed
it prints something?
yea there is something about Unsupported language or Context or somethign
i’ll have a look if it is just a simple tweak to move it earlier
its very low priority imo
yeah but still if it is simple enough
i doubt even raised on the tracker at all in all this time 😄
I would like to know more about why client might get stuck on "Receiving Data" when joining particular lobby slots
and it is slot based. any player entering the slot gets stuck for a little while, until the slot repairs itself (client ID gets recycled?)
without that bug i would use skipLobby
unfortunately its a "busy MP" bug which doesnt manifest on test servers
im certain its some client ID/owner ID issue where the lobby menu shows an empty (joinable) slot while there is a bugged/losing-connection client still in the slot
to start debugging it, id have a look at the code where connecting client evaluates the slot as empty and joinable, and relevant sanity checks
is there a way to determine if Eden with editor is launched (vs without or MP hosted from Eden)?
there was one newer sqf to get the mission phase one is in, but cant find it - maybe one can determine it that way
get me a repro
is3DENPreview
does the localization of custom chat title work as expected?
[is3DEN,is3DENPreview,is3DENMultiplayer]
SP: [false,true,false]
SP+editor: [false,true,false]
MP: [false,true,true,]
from all three as shown
anyhow solution is:
if (is3DENPreview && (isNull (findDisplay 37)))
is there any point in removing EHs from killed units/vehicles?
highly doubt it
artillery piece is only firing if player is near it... Dynamic Simulation is off. The artillery piece should be being simulated no matter what. Why? Solutions? [artillery1, target1, "2Rnd_155mm_Mo_Cluster", 10, 2, 10] spawn BIS_fnc_fireSupport;
Also interested in this, to add ontop: If i delete a alive unit/vehicle do i have to remove EH's before ?
@sharp grotto @velvet merlin If the unit is no longer Alive... I dont think it matters... I mean if its dead... killed outright, on fire and exploded.. Its no longer being simulated i think.
well one can still interact with dead bodies or wrecks via PX
might be separate to EHs tho
I think I know what you mean. If you do not set respawn for units in multiplayer options then if unit dies it is removed from roles list. so you are connected to the server but have no unit to spawn into. May spawn into seagull but I think this has to be somehow configured too. If you dont want ingame respawn you can create virtual units as placeholders that never die and transfer player from them into real units
Bit of a weird one, trying to implement something similar to this https://www.youtube.com/watch?v=KOD4nvIWvBE, however because it's a multiplayer mission with respawn enabled with a timer value, the cinematic isn't showing until players have to wait and spawn in. Is there a way to call Intro.sqs beforehand? I've tried putting it into the initServer.sqf which doesn't solve it :/
This is an Arma 3 Eden editor tutorial on how to create an Intro.
Below is a link to the Intro.sqs file in my Dropbox:
anyone know how to get the duration of a particular animation from configfile?
EVHTMP = player addEventHandler ["AnimDone", {
params[ "_Unit", "_Anim" ];
if(_Anim == "AinvPknlMstpSlayWrflDnon_medicOther") then{
diag_log (time - START_TIME);
player removeEventHandler ["AnimDone", EVHTMP];
};
}];
START_TIME = time;
player playMoveNow "AinvPknlMstpSlayWrflDnon_medicOther";
I can always do this, but I would like to get it from the configfile if possible
@gaunt tendon I knew I had seen an answer to that question not long ago ... here it is: #arma3_scripting message
Anyone happen to have a script that models an IED going off and disables the vehincle without injuring crew?
Everytime ive tried it i manually i kill/ maim the crew
just set the crew invincible?
allowDamage
So just in the init for vic i would just type "allowDamage" and i should get the desired effect?
When it comes to scripting i know almost nothing
why put it in the init
are you using a trigger or anything for the ied?
