#arma3_scripting
1 messages · Page 196 of 1
I've meant to use _self set ["active_units", []]; in #create rather than array copy when calling createHashMapObject.
But do whatever
for "_i" from 1 to 3 do { execVM "spawnAgrInfantry.sqf"; };
while { {alive _x} count units east > 4 } do { sleep 2; };
waveCount = waveCount - 1;
if (waveCount > 0) then {
sleep 20; // Wait before next wave
execVM "waveSpawn.sqf";
} else
{
"EveryoneWon" call BIS_fnc_endMissionServer;
}
;```
so, this is my "waveSpawn.sqf" script so far, it generally does work, as in it spawns 3 infantry squads, 1 vehicle, but something i've been figuring out is how i can make it so that
1) it has 20 seconds between each spawn
2) it doesn't end the mission as soon as the 2nd wave spawns. (waveCount is set to 2 in initServer.sqf)
here's what i tried:
sleep 20 was set before the ifelse loop, after the whiledo also, but it didn't really work out. I decided to try putting where it is now as it is taking place after the condition is met for wavecount to be above 0, so it waits 20 seconds after, and then the script executes itself. however, it does it instantly pretty much. is there something wrong with how i wrote it?
when it comes to the victory condition in the else statement, i want it to happen after all of the waves have been spawned, and if it counts less than 4 east units in a specific trigger area (lets say it's called "DefenseZone") as well. will i just need to create a separate script that needs to be executed for it?
I attempted this on a separate script, however I struggle to find enough information on counting or enough knowledge on it. I tried for example `{alive _x} count (units east inAreaArray defenseZone) < 4` and I'm aware this is incorrect but I struggle with understanding how exactly to utilize variables and values with this. As far as I'm aware, this is like putting 2 statements together, and (units east inAreaArray "defenseZone") is the value here. Do I have set 2 count statements to == each other and set a specific number? Maybe like `{alive 3} count units east == count units inAreaArray "defenseZone"`?
Or is it still nonsensical here
(huge delay btwn 2 messages because i been testing things out)
{alive _x} count (units east inAreaArray defenseZone) < 4 looks correct
Since you're executing everything in scheduled environment, your while check happens before your spawnAgr* scripts finish spawning
So your condition meets before you have stuff spawned
Do you do any waits or sleeps or inifite loops in your spawnAgr* scripts?
private _script = execVM "spawnAgrVehicle.sqf"; waitUntil {scriptDone _script};
for "_i" from 1 to 3 do {
private _script = execVM "spawnAgrInfantry.sqf"; waitUntil {scriptDone _script};
};
while { {alive _x} count units east > 4 } do { sleep 2; };
If not, you can try this
Or even avoid spawning separate threads so all your scripts are within same thread:
call compileScript ["spawnAgrVehicle.sqf"];
for "_i" from 1 to 3 do {
call compileScript ["spawnAgrInfantry.sqf"];
};
while { {alive _x} count units east > 4 } do { sleep 2; };
while { {alive _x} count (units east inAreaArray defenseZone) > 4 } do { sleep 2; };
```This condition should also work
With defenseZone being trigger with area where your units are
My bad but I'm not sure I entirely get this
ah wait
I see now
execVM spawns a separate script thread in scheduled environment
I didn't let it run long enough for both to spawn
and these threads execute alongside your main one with no guaranteed order
So your while condition starts checking even before your spawning scripts/thread actually spawn anything
Ahh I see, tysm
scriptDone checks if script has finished, reached its end. In call version of it it simply branches your main thread into that script so its all within same thread and your while never starts checking before all spawn scripts are done.
would I not want the while statement to also be a part of the same thread as well? I'm a little confused as to why I'm not including it mainly as afaik keeping things on the same thread makes it sequential, may be wrong though.
It is sequential in both of my examples, they basically do the same thing, ensure while loop check happens only after scripts are done
In first example separate new threads are spawned and main thread waits until new threads are done
In second example main thread simply calls the functions made out of script files so its all one single continuous thread
uh so, I tried this and I just had like hundreds of vehicles blow up and fly everywhere
I'll try the other one
I have a feeling it could be the sqf I made, I'll show it
What's in your spawning scripts?
_destination = "defensArea";
_enemCarType = selectRandom ["O_MRAP_02_hmg_F","O_LSV_02_AT_F","O_LSV_02_armed_F"];
_enemVeh = _enemCarType createVehicle getMarkerPos _stMarker;
_enemVeh setDir markerDir _stMarker;
_crew = createVehicleCrew _enemVeh;
_wayp = _crew addWaypoint [markerPos _destination,0];
////////////////////////////////////////////////////////////////////////////```
spawnAgrVehicle
```_stMarker = selectRandom ["infSpawn_1","infSpawn_2","infSpawn_3"];
_destination = "defensArea";
_enemInf = createGroup east;
_enemInfArray = [
"O_Soldier_SL_F",
"O_Soldier_F",
"O_Soldier_LAT_F",
"O_soldier_M_F",
"O_Soldier_TL_F",
"O_Soldier_AR_F",
"O_Soldier_A_F",
"O_medic_F"
];
{_enemInf createUnit [_x, getMarkerPos _stMarker, [], 0, "NONE"];} forEach _enemInfArray;
// "SAD" stands for "Search and Destroy" waypoint type
_wayp = _enemInf addWaypoint [getMarkerPos _destination,0];
_wayp setWaypointType "SAD";```
spawnAgrInfantry
for "_i" from 1 to 3 do {
waitUntil {scriptDone execVM "spawnAgrInfantry.sqf"};
};
while { {alive _x} count units east > 4 } do { sleep 2; };
waveCount = waveCount - 1;
if (waveCount > 0) then {
sleep 20;
execVM "waveSpawn.sqf";
} else
{
execVM "waveEndMission.sqf";
}
;```
waveSpawn
Here's the script I was also struggling with finishing the mission on due to counting
```if ({alive _x} count (units east inAreaArray defenseZone) < 4) then
{
"EveryoneWon" call BIS_fnc_endMissionServer;
}
waveEndMission
Its a single if check, if it fails once your mission never ends
oh
Oops, I messed up my waitUntil/scriptDone script
gotta do while?
I don't think you need any conditions at all as you already do count checks in main thread
would it not just end the mission right as the 2nd wave spawns though?
It shouldn't as you deduct waveCount after your main thread's while check
ohh so the issue was due to the fact it was checking while since the beginning
call compileScript ["spawnAgrVehicle.sqf"];
for "_i" from 1 to 3 do {
call compileScript ["spawnAgrInfantry.sqf"];
};
while { {alive _x} count (units east inAreaArray defenseZone) > 4 } do { sleep 2; };
waveCount = waveCount - 1;
if (waveCount > 0) then {
sleep 20; // Wait before next wave
execVM "waveSpawn.sqf";
} else {
"EveryoneWon" call BIS_fnc_endMissionServer;
};
oh there we go
holy crap man you're a lifesaver 😭 tysm!!!
so I assume when it comes to having scripts run before a check I need to run call compileScript so it's sequential?
Yes
You can do it with scriptDone and execVM too, I just messed it up in original script bit
just don't do waitUntil?
Fixed script here: #arma3_scripting message
Oh sweet, thank you
I'll try that
Gotta make sure, I'll be hosting a mission with my scripts for friends
I won't have to go like re-script everything specifically for MP will I?
I'm not exactly sure what requires using global scripts and local
Make sure its only executed on server
So it does all the spawning and checking
My bad if it’s an obvious thing, how do I make sure of that?
From where are you executing the code?
Yeah, where do you call your script from?
i was calling it on initServer.sqf but later I’d do it from triggers
ohh isn’t there a server only option or smth on triggers
There is
There is server only option on triggers
Otherwise just wrap your first call with isServer check
Hello guys. Besides learning with GPT. What are good ways to learn scripting without any coding knowledge at all.
Im a noob but very creative
dont use ChatGPT
Forget ChatGPT and ask us
But I really need a textual guide to learn, it's important for me to read so I can memorize, but thank you.
@hushed turtle i PM-ed you
There is a textural guide. It's called #arma3_scripting
I don't even know what I don't know to know what I should know.
The wiki has a lot of useful information. https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
Some things you don't really need scripting for at all. The Editor provides a lot of tools for doing things without actually writing any code.
There are some tutorials on Youtube but I would be very cautious about them. Literally anyone can poop out a video and there's absolutely no guarantee they know what they're doing. It's a regular thing for people to turn up with awful code and go "but I saw it on Youtube, and that means it's right!"
Generally I'd suggest picking an objective (not too ambitious) and trying to find out how to make that thing happen. It's difficult to start with "I want to learn all of scripting first". It's better to have a task to guide you.
Thank you.
Yes, that's actually what I want to do and how to learn it efficiently. WIth a vision and a task you get more focus while doing so.
I'm trying to setup "Same SR frequency for side" in TFAR global settings but my radio just comes up blank.
Second one is my global settings
when I set "TFAR_SameSRFrequenciesForSide = true;" it just makes my radio blank, no channel no frequency
That’s what I’ve been doing. Trust me, after you get into it a little bit, at least for me personally it’s exponential
Not too long ago I was still learning just counting, in just one day I just learned how to write basic scripts and spawns and waves
It just adds up as you know more and can understand more
I see, thank you very much. (and Jouklik too)
Is it possible to assign (or pass) a function name to a variable and then call it (like a callback function)?
_nextFunction = TAG_fnc_someFunction;
[] call _nextFunction;
Thanks.
Thanks.
Hi, I want to share my new script, which allows AI units to search for ammo and loot bodies when they run out of ammo. 😄
https://steamcommunity.com/sharedfiles/filedetails/?id=3506082227
Does addAction need to be local for players?
Yes.
_paratroopers = crew _xian;
_pilot = driver _xian;
private _index = _paratroopers find _pilot;
if (_index != -1) then
{
_paratroopers deleteAt _index;
};
{
_actionID = _x addAction
[
"Open Parachute",
{
params ["_target", "_caller", "_actionID", "_arguments"];
private _pos = getPosASL _caller;
private _parachute = createVehicle ["Steerable_Parachute_F", [0,0,0]];
_parachute setPosASL _pos;
_parachute setDir (getDir _caller);
_caller moveInAny _parachute;
_caller removeAction _actionID;
},
nil,
0,
true,
true,
"",
toString
{
isNull objectParent _this &&
{
(getPos _this) # 2 >= 5
}
},
-1,
false,
"",
""
];
} forEach _paratroopers;
Got an op in two hours and just discovered on the dedicated server that only the first player gets a parachute
How can I localise this addAction?
You can use remote exec your add action on every client where unit is local and is player.
Yeah so I've used remoteExec before but how would you format it for something with 10 parameters like addAction?
I would use a function.
And
Use getPosATL rather than getPos when check altitude (like you get/set with ATL)
Yeah, better solution.
In this case getPos is better.
Not my code, I got it from someone way cleverer than me on this channel
The same as for other cases.
so like create a new .sqf with this addAction in and then _x remoteExec ["parachuteActionFunction.sqf", _x]?
The first is correct, the last isn't.
which bit isn't correct sorry?
remoteExec doesn't accept file names.
ah okay, how do you format it do pass the player as a parameter and execute the script then?
As I wrote, the same as for other cases:
{
[_x, _actionParams] remoteExec ["addAction", _x];
} forEach (_paratroopers select { isPlayer _x });
so I just need to add
_actionParams =
[
"Open Parachute",
{
params ["_target", "_caller", "_actionID", "_arguments"];
private _pos = getPosASL _caller;
private _parachute = createVehicle ["Steerable_Parachute_F", [0,0,0]];
_parachute setPosASL _pos;
_parachute setDir (getDir _caller);
_caller moveInAny _parachute;
_caller removeAction _actionID;
},
nil,
0,
true,
true,
"",
toString
{
isNull objectParent _this &&
{
(getPos _this) # 2 >= 5
}
},
-1,
false,
"",
""
];
Yes you can do that.
i think that would make the action appear when you look at someone else too
addAction has local effect.
yeah, local effect, global argument
well i guess the condition would make it unlikely, but given this execution, you'd see Open Parachute from looking at another player if they satisfied the condition
wait, ah nevermind i missed the target you wrote there
ignore me 🙃
Exactly.
In terms of remoteExec, addAction doesn't have 10 parameters. It only has 2. The left argument, and the right argument.
_object addAction _parameters;
_left command _right;
[_left, _right] remoteExec ["command"];
[_object, _parameters] remoteExec ["addAction"];```
Is it possible to pass a private array variable as a reference to a function (different scope), and still be able to change the original array within that function, not just a copy?
private _globalArrayVar = [1,2,3];
_globalArrayVar call TAG_fnc_reverseOrder;
Thanks
yes because its passed by reference
But when I use a param or params command inside the fnc, it is converted to value or is it still a reference?
it should be still reference
OK, thanks, I think I got it.
I need to copy this and save it, so it's a simple and readable example of remoteExec.
_this variable inside function is gonna be reference to the same array as _globalArrayVar, but variables created by params? I doubt it.
Have you tested it before?
In the logs of the dedicated server, I often began to notice that these kinds of messages appear.
20:24:24 Road not found - (9117.232422, 18.814486, 11945.744141)
20:27:32 Road not found - (9117.232422, 18.814486, 11945.744141)
20:27:39 Road not found - (9117.232422, 18.814486, 11945.744141)
I checked the position (ScreenShot)
player setposworld [9117.232422, 11945.744141, 18.814486]
I have a suspicion that the nearRoads script command is giving an error.
yes i did, so i know it works 🙂
_arr = [1,2,3];
[_arr] call
{
params ["_a"];
_a pushback 777;
};
hint str _arr;
``` prints [1,2,3,777]
Yes that's true, but look again what the dude is doing. If he wants to edit his array he needs to do it like _this set [0,100]. You are passing array in array. He just passes array of numbers.
not sure what we are talking about here but if you pass array like this: _arr call then the first element of _arr goes to the _a (so not passing the whole array)
It gets passed into _this variable, that's where params is taking variables from
ofc
private _fnc_test = {
params["_first","_second"];
_this set [ 0, 100 ];
_second = 200;
systemChat ("In call: " + str _this);
systemChat ("_first: " + str _first);
systemChat ("_second: " + str _second);
};
private _numbers = [0,0];
_numbers call _fnc_test;
systemChat ("After call: " + str _numbers);
Prints:
In call: [100,0]
_first: 0
_second: 200
After call: [100,0]
Yeah, those params declared private vars are taking the values of the array, although, if the _first input was an array, it would probably be still a referrence. Thanks for your reply.
I can't see the attached changelog in this wiki post https://community.bistudio.com/wiki/allVariables since bistudio has been down, but is there any reason why we can't use profileNamespace or uiNamespace in multiplayer? I understand those variables could be set from other servers and they can't be implicitly trusted but it would be very helpful from a cheater prevention standpoint if server owners could still check these.
uiNamespace typically contains variables that are extremely machine-specific and can't really be transferred over network in a useful way (i.e. UI control references).
profileNamespace can contain a lot of stuff; it's not mission-specific or server-specific and a lot of things store data in it. Exposing the entire contents with allVariables could cause issues with the amount of data to be transferred over the network, and it may be a security/privacy issue.
It's only using allVariables with them that's disabled in MP. If you need to check a specific variable, you can still do that with getVariable.
Historical changelogs are also available here: https://dev.arma3.com/spotrep I don't have time to go digging right now, but 1.40 will be in there.
are you using this fnc? https://community.bistudio.com/wiki/BIS_fnc_addRespawnPosition
you can just teleport the entities of that group to the new position when they respawn
make the respawn_west your "base respawn" and then you teleport the rest of your guys where you need them
Hello, Im not sure if this has already been discussed before but is it possible to add a custom inventory item for a mission using scripts? or would it need to become a mod? Currently working on a mission
Has to be a mod. Config only.
From my understanding allVariables used to work for those namespaces in previous versions. I do hear the security and privacy issues though. I do still think in spite of those though we could see a net benefit if we were able to use allVariables on those namespaces
Cheers
I wouldn't be surprised if a lot of cheat devs were using the uiNamespace and profileNamespace to avoid detection
idc = 14563;
text = "Entrar no Discord";
x = safeZoneX + safeZoneW * 0.22;
y = safeZoneY + safeZoneH * 0.56;
w = safeZoneW * 0.36;
h = 0.04;
onButtonClick = "openURL 'https://discord.gg/HWh4sqRQ5E';";
};```
Would this be the correct way to add a clickable discord link? That directs the player to the group when clicked?
i made a faction with a loadout randomizer script that relies on setUnitLoadout in a script that is run from the unit init, it works perfectly locally but not in multiplayer (all inventory items are missing while the rest of the loadout works fine), does anyone know why that could be?
There's an issue floating around about calling setUnitLoadout during weapon switching but I haven't seem enough detail on that to know if it's related.
OK ill implement that check from the wiki
will spawning planes in the air on getMarkerPos work on markers I put into the air in the 3d editor (if i can do that, not at the pc rn cant check)?
i simply copy pasted this from the wiki and replaced player with the proper unit variable, but i get this error?
It is not an error. It is just the highligher is not recognizing 2.20 command
ohh ok thank you
btw should i do remote exec for this command?
even though its supposed to be global?
remoteExec what?
setUnitLoadout
It is GA GE so no
ok thank you
do you think it might be the weapon reaload thing causing this @warm hedge or do you think it could be something else?
#arma3_branch_changelog message
You may try profiling
that looks scary 😮 but good to know its being worked on
my script runs from the unit init, so i can imagine that is what might be happening
can someone help me how to make a laser marker that shows in map when you open your weapons laser in arma 3
?
what are you trying to do?
at that point, I'd probably just use my own loop rather than a trigger
[] spawn {
waitUntil {
private _area = [getPostATL _vehicle, 10, 10, 0, false, -1]; // [center, a, b, angle, isRect, height]
_monster inArea _area;
};
// Do something
};
add sleeps if you want to slow down the waitUntil
lol just had the funniest bug so far. i was using my spawn script, and set it to spawngroup east, and put an array of independent units. the commander was fragging his entire squad lol on all spawns
Hello, I am trying to recode the laser system on the khot server. I currently have something like this. It does not work on vehicles and frankly I do not even know how I did it.
lazermode = false;
player addAction ["Lazer Marker Aç/Kapat", {
lazermode = !lazermode;
hint format ["Lazer marker %1", if (lazermode) then {"AKTİF"} else {"KAPALI"}];
}];
[] spawn {
private _markerName = "lazermark";
while {true} do {
sleep 0.05;
if (lazermode) then {
private _unit = player;
private _startPos = eyePos _unit;
private _dir = _unit weaponDirection (currentWeapon _unit);
private _endPos = _startPos vectorAdd (_dir vectorMultiply 1000);
private _hit = lineIntersectsSurfaces [_startPos, _endPos, _unit];
if (count _hit > 0) then {
private _hitPos = (_hit select 0) select 0;
_hitPos set [2, 0];
if (markerType _markerName == "") then {
createMarker [_markerName, _hitPos];
_markerName setMarkerShape "ICON";
_markerName setMarkerType "mil_dot";
_markerName setMarkerColor "ColorRed";
_markerName setMarkerText name player;
} else {
_markerName setMarkerPos _hitPos;
_markerName setMarkerText name player;
};
};
} else {
if (markerType _markerName != "") then {
deleteMarker _markerName;
};
};
};
};
is that AI generated code? i think you need to use https://community.bistudio.com/wiki/lineIntersectsObjs instead for vehicles
Okey but howw it to hard 😭
my hunch was right then 🙂
weird that the AI has such issues with ARMA3 scripts
help us
you could ask someone to write the code for you.... (but no quarantees anyone will)
ai cant make arma 3 scripts ai is too much idiot for arma 3 i think
ye i ask act but no one say anything about it
might be because there are so many scripts out there and a lot of them are probably not working and the AI is not able to differentiate - because in other areas it does really, really well. It is a shame somehow as it would be a tremendous help if it actually could provide working scripts
I have never seen working AI code posted in here
this is ai generated and working 
If anyone found out what we did to make it work, I would be tried for violence against AI.
In short, if anyone can help us with this issue, I would be very grateful. (I don't like to leave favors unreturned, maybe I'll send a wheel of cheese)
Generative AI (LLMs) do not understand the actual meaning of things, why or how the code works. They just generate sequences of words that are mathematically plausible based on the dataset. For languages with a lot of complete examples of working code, this turns out "okay" (some of the time). SQF does not have a large dataset of working code - and also, SQF depends heavily on knowing how the game works (or doesn't), which is impossible for an LLM.
If you got working code out of an LLM, you're literally just lucky, and there's a strong chance it's not good code.
I wonder if the following is possible (bit complicated): I have a group of soldiers put down in the Editor that are "connected" to their leader via the "bis_fnc_attachtorelative" function (to force them to stay where they are, which works perfectly for what I need). But I wonder if it is possible if one of them dies that one could spawn a new soldier taking the place of the one that died (i.e. using the same attachedto info).
Would also be better if I could generate/spawn an entire squad linked like that (so I do not have to place every single one of those special cases in the Editor). Hope that makes sense.
Yes, that's quite possible. createUnit, a few sets of relative positions or some light vector maths, attachTo, and an event handler.
Do you actually need attachTo, though? If the group as a whole is not moving, it would be preferable to just disable the AI's pathing or movement.
if you want to stop ai moving use
MyUnit disableAI "MOVE"; instead, attaching AI doesnt sound like a good idea
if id code this I would give every soldier Killed EH and when they are killed create new unit in the eH. though not exactly sure what do you want
Yup I did try it with the disableAI "move/path" actually, but this did not do the trick in this case as the AI hates close formations and I also need them to be actually able to move off to adjust their heading or close some distances to the player and his units. It is a bit rigid but that can not be helped. Their moving though is also "forced" so they do not run around like mad chickens.
I am sure you would laugh out loud of how my current "test" setup is, working with triggers and not really calling "outside" scripts. My goal is to simulate line formation fighting (hence the force the ai to stay put), and so far I have been able to get a few things done (but there is still a lot of work to do and I apparently suck at scripting and it takes me ages to do even simple things lol)
It's quite easy, but not a scripting problem. Try #arma3_questions or #reforger_questions
tnx brother .
Is it possible for the leader to die as well? This becomes slightly more annoying if so, because then you have to transfer all the other units to the new replacement leader
doStop this; - in the init of a soldier should do the trick
that I noticed quickly, so for now I did set it so the leader can only die if the rest of the squad is dead (to avoid all that hassle);
btw this reminds me: can one querry for "panic"? (i.e. that an AI panics and decides to flee)? did look around but could not find an eventhandler to match this
thanks Kerc, god I must be getting blind with age! (or I am just trying to do too many things at once)
group eventhandlers are kinda new (new by arma 3 standards, anyway, so a couple years old lol) so its easy to miss them
Basic implementation specifically for line formation. Not tested in-game so beware typos. I am aware I'm probably just taking the first shot in a round of code golf so be prepared for corrections from others. https://pastebin.com/xkWKLTSs
yeah see there's a typo already. Line 27, _offset should be _unitOffset
Thanks mate, will have a look how you did things and compare it to what I cobbled together so far (am pretty sure your's will be a million lightyears ahead of what I have). Will get back to you guys when I have the time to test.
so, explain the idea further, I'm doing a CAS Menu and I had to make a way to detect laser if I want to mark targets
also the offset maths is wrong. The intention is alternating positive/negative offsets to fill out the line on each side of the centre unit, but because the offset is increased by each unit, not just by units on the same side, the gaps get bigger when they shouldn't
and the offset for lines other than the first isn't being applied properly. And those lines will have a gap in line with the parent unit.
Probably should just ask someone good at maths to do this
And the horizontal offset is being applied to the Z value, not the X value 🙃
This version has a number of fixes. https://pastebin.com/7AiyVy6C
It's still not necessarily perfect, and I wouldn't be surprised if there's a more graceful way to do this. (Attaching units together to make them move in formation is not graceful in general, though...)
I found out the reason my loadout randomizer script doesn't work is the locality of the command addMagazines, but i saw there is only addMagazineGlobal not addMagazinesGlobal, any suggestions here? I just have an array like this and am trying to globally add it to AI units:
{
{"magClass", 3}, {"magClass", 1}, ...
};
you cannot, only via button click
indeed. It takes the default values by reference. So all your objects are referring to the same underlying Array.
The fix is to set units in #create, won't be able to fix that before 2.22
do i really have to make a double for loop to add every magazine globally by itself? It seems so terribly inefficient
its a bit annoying to always copy the array for safety. Because you only need the copy if you actually end up editing it :/
Bit of a waste of performance/memory, for something people could handle in constructor, I'll probably leave it the way it is
Little later we figured out the issue was objects sharing same units array. For a while I believed it somehow created just one object instance, because same array was used to create both of them 
Why do you randomize remote units though?
But yeah, just run a loop with addMagazineGlobal
Use https://community.bistudio.com/wiki/addMagazines, it is a GA/GE command
its a little niche thing, its a faction made especially for small unit COOP with efficient unit spawning. Made a faction based on a large amount of items from a mod, the result is actually really satisfying 😄 here is a picture. A custom function called from the unit init, with faction and role abreviation (For example "ftl" or "gl") looks up array data in the arma Config and selects weighted random items, and some other things based on parameters. Some fun things in there like chance for primary, secondary, launcher, vest, helmet, facewear too. And a couple "pass through" functions for more specific loadouts. It results in consistent roles but with random equipment and weapons from predefined pools 😄
the above you see 5 sets of all roles in the faction. As you see they have very nice degree of randomization, but AA launcher guy always has an AA launcher, MG always has an MG and so on
What unit init? CfgVehicles config? Inits are global so each client is gonna run your randomization code
These guys are all the same "Rifleman Light AT" role 😄
in the CfgVehicles entry for the unit
What is the best way or place to call this script on the newly created unit? Is it not that?
You can put a locality check in the function so it'll immediately exit on every client except the unit's owner
ahh thats the if (!isServer) stuff i think ive seen before, right?
something like that
Or better call local
if !(local _unit) exitWith{};```
okay very nice, i will do that for sure
but i am not sure if this would address the issue with addMagazines not working in multiplayer, right?
addMagazines does work in multiplayer
The script works very well in local, ive tested it in every possible situation, the data fed to addMagazines is ALWAYS correct. setUnitLoadout works perfectly too, but then the step afterwards thats supposed to add the magazines does not seem to work only when hosted multiplayer
any idea why that might happen?
are you running dedi?
yes
thats only when i discovered the problem. When "testing solo" in editor, hosting local server from the game, the scripts work flawless
So then i was excited to play with my buddies only to find out that the loadouts generated by the script had completely empty inventories. These commands seem to not do what they are supposed to, in multiplayer. Or at least in my situation
addMagazines, addItemToBackpack, addItemToVest, addItemToUniform
yeah you must check the commands argument and effect to use them properly. some commands needs to be run on client while others on server
addMagazines, addItemToBackpack, addItemToVest, addItemToUniform
All these have Global Args and Global Effect,
So those should work when you execute event like Sa-Mantra and NikkoTJ said
if !(local unit) exitWith {};
//do stuff
or
if (local unit) {
// do stuff
}
must be some other commands then or the way the scripts are executed
thanks guys, gonna try this now
just added if !(local _unit) exitWith {}; to the top of my script right below the parameters
_unit being the parameter that refers to the unit, it was already there
that should do it ?
that wont do it because you are just denying the code to run. what you need is more of running the appropriate code for each player
i have no idea what that means, sorry im very new to arma script
the only way i could find to do dynamic loadout stuff inside a faction was by calling a script from the init= field of the CfgVehicles entry for the unit
what is the better way to do it ?
also i just tried it, now it has the inventory but not the uniform etc 😄
basically exact reversal from my previous problem
CfgVehicles init with a locality check is a correct way of doing it
I believe we've already established that other code in the same function is working correctly
Is there a way to hide remote controlled stuff, like UAVs etc from the terminal?
I would like to have 2 operators from the same side but they should only see specific UAVs from the list.
There is https://community.bistudio.com/wiki/disableUAVConnectability.
Note that it is actually specific to the terminal, not to the unit, so if players have some way of getting new terminals, you need to monitor and update over time to stop them bypassing it.
There is also locking the UAV, but locking commands are global, so it's a huge hassle to make it work.
Other than that there's not really any good solution, unfortunately.
I might be the only one that uses hashobjects, but I think it would be worth changing.
What If you want your object to reference something by default?
I would probably pass that to the constructor
hi guys im trying to make ai sniper, with m107, fire with 5 seconds breaks, between each shot, but unfortunately hes successively semi auto firing, what do i need?
Pastebin if it's long, hard to view on phone without downloading the file.
im trying to mimick .50 cal bolt action rifle behavior cuz i simply cant find any .50 cal bolt action rifle mod , for cup
But I bet you didn't disable the correct AI stuff
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.
Here is the pastebin
check out https://community.bistudio.com/wiki/forceWeaponFire if you havent already
yeah im using that and doing sleep 5; but hes still firing very fast
oh sorry i thought you wanted to get rid of auto fire. well maybe you can disable the AI that slows him down 🙂
completely disable it?
Yeah you are only disabling path. You need to disable targeting, autotarget, autocombat
Or any combination. Can't test atm
I saw they added fire weapon to the disable list in 2.18 as well
hmm i added it and he still fires quick
// Configure AI behavior
_sniper disableAI "PATH";
_sniper disableAI "TARGET";
_sniper disableAI "AUTOTARGET";
_sniper disableAI "AUTOCOMBAT";
_sniper setCombatMode "RED";
_sniper setBehaviour "COMBAT";
Try turning him to hold fire. You are already controlling when he shoots.
Can you log when you tell it to fire, vs when the AI is doing the firing?
thanks, i guess there would be a issue if players traded terminals as well?
I don't have any arsenal or similar, so i would have to check on respawn and find some event for if the terminal slot changes, or at least something that covers that as well
There is a SlotItemChanged EH
perfect! that should work then. thanks again 🙂
it seems likei had to add something in to the fired event handler?
Without dotarget he cant aim properly, with dotarget he fires successively, even when i have
// Configure AI behavior
_sniper disableAI "PATH";
_sniper disableAI "TARGET";
_sniper disableAI "AUTOTARGET";
_sniper disableAI "AUTOCOMBAT";
_sniper disableAI "FSM";
_sniper disableAI "AIMINGERROR";
_sniper disableAI "WEAPONAIM";
_sniper disableAI "COVER";
_sniper disableAI "SUPPRESSION";
_sniper setCombatMode "RED";
_sniper setBehaviour "COMBAT";```
If you just want to block the guy from firing for 5 seconds then there's disableAI "FIREWEAPON" since 2.18
okay and then i renable it
wow this worked!
if (!isNull _currentTarget && alive _currentTarget) then {
// Debug message
if (VILLAGE_SNIPER_DEBUG) then {
systemChat format ["Sniper targeting %1 at %2m", name _currentTarget, round(_unit distance _currentTarget)];
};
// Aim at target
_unit doTarget _currentTarget;
_unit doWatch _currentTarget;
// Wait a moment for aiming
sleep 1;
// Fire the weapon
// _unit forceWeaponFire [primaryWeapon _unit, "Single"];
_unit disableAI "FIREWEAPON";
// Wait 5 seconds between shots
sleep 5;
_unit enableAI "FIREWEAPON";
if (VILLAGE_SNIPER_DEBUG) then {
systemChat "Sniper ready for next shot";
};
} else {
// No targets found, wait and try again
if (VILLAGE_SNIPER_DEBUG) then {
systemChat "Sniper searching for targets...";
};
sleep 3;
};
};```
i need to make it more structured
and put it in eventhandler
Oh, if you're using forceWeaponFire then blinding the guy might be better.
(disableAI "CHECKVISIBLE")
ok
forceweaponfire is not aiming at target like dotarget
Yeah, if you want him to actually shoot at people then the 5-second FIREWEAPON loop is good.
i now have this in the unit init in cfgvehicles
init = "if (local (_this select 0)) then
{
[_this select 0, ""bb_fac_kla_civarmed"", ""sl""] call BlaBer_fnc_setUnitLoadout;
};"
on a single line, but it's not working in local testing
can i not make a faction that works both locally and dedicated?
it has to be one or the other?
Is this the isSwitchingWeapon problem?
i didnt have my thinking hat on last night, the setUnitLoadout part of the script works perfectly fine, it's the adding of magazines and items in a different way after that which fails
see here
after the setUnitLoadout part of the script, two arrays are known with the extra inventory items and magazines that should be added to the unit, they are added with addMagazines and addItemToUniform/Vest/Backpack in a forEach
but that doesnt seem to work on dedicated server only
so just earlier this was suggested as fix,
addMagazines works in general. I use it routinely in Antistasi.
We don't do anything in init handlers though.
If you have a replicable issue then boil it down until it's clear exactly what the problem is.
ill recap once more what my issue is, its fully consistent and replicable:
- script is passed 3 parameters, the unit, the faction and side
- script grabs data from config based on parameters and sets up a unitLoadout array
- while doing that, the arrays _li_items and _li_magazines are filled with
{"className". #}# being int amount - unitLoadout is set on the unit with setUnitLoadout
⚠️ all above steps work perfectly in both local and dedicated - items are added to available container space (addItemToUniform, addItemToVest, addItemToBackpack)
- magazines are added with addMagazines
⚠️ these last two only work when hosted local, and not when dedicated
so then i got this suggestion, and it just results in nothing happening at all at least when hosting local, about to test on dedi now
here is how i implemented the suggestion in CfgVehicles, but its a single line
init = "if (local (_this select 0)) then
{
[_this select 0, ""bb_fac_kla_civarmed"", ""sl""] call BlaBer_fnc_setUnitLoadout;
};"
shouldnt that be just this and not (_this select 0) ?
Nah, it's this one: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Init
ah ok
@snow viper The same addMagazines code works fine from the debug console though?
this is just getting weirder, i just tested this on dedicated, and it now tells me that a private variable is not declare when it very much is
usually means that you're setting that variable to a nil value.
it even works dedicated now
but now the setUnitLoadout no longer works due to this
ive tested the script fully, everything is working
there is no bad data being passed
well, until i introduced this
Paste code, paste error.
apearantly my interpretation of this was wrong but i have no clue why, this is all chinese to me
{
waitUntil {!isSwitchingWeapon _this};
_this setUnitLoadout _tempLoadout;
};```
can sombody give tips how to fix it ?
You are only passing unit in args to spawn,
Your _temploadout its not available in spawn because it's local variable.
[_unit,_tempLoadout] spawn {
params ["_unit","_tempLoadout"];
waitUntil {!isSwitchingWeapon _unit};
_unit setUnitLoadout _tempLoadout;
};
I had this same problem with setUnitLoadout, I solved it by setting a time for verification, what happened to me was that fnc_stripGear was executing after fnc_loadGear, setting the loadout before cleaning
waitUntil {
sleep 0.25;
alive player &&
!isNull player &&
!isNull (findDisplay 46) &&
!(isSwitchingWeapon player)
};
diag_log "[loadGear] Aplicando setUnitLoadout...";
player setUnitLoadout _loadout;
// Aguarda confirmação de aplicação (ex: uniforme presente)
waitUntil {
sleep 0.25;
uniform player != ""
};```
interesting @idle violet thanks for sharing
thanks
If you are using stripGear, make sure it is called before setUnitLoadout and it will work, put a waitUntil in your loadout code, so that it is called after the cleanup!
i'm not actually, i'm setting up fresh units from CfgVehicles, so they spawn without anything to begin with, and should then be given the stuff from the script
oh sorry, I thought you were calling loadout saved in database like me
its still always useful to see some examples of t his stuff in different context and what not
but yeah im back to the mystery
but even so, try to put a delay in its loading to test, it might work
Ill repost my summary from earlier with newly added insight, got into a new depth of mindfuckery with this just now
ill recap once more what my issue is, its fully consistent and replicable:
- script is passed 3 parameters, the unit, the faction and side
- script grabs data from config based on parameters and sets up a unitLoadout array
- while doing that, the arrays _li_items and _li_magazines are filled with
{"className". #}# being int amount - unitLoadout is set on the unit with setUnitLoadout
⚠️ all above steps work perfectly in both local and dedicated - items are added to available container space (addItemToUniform, addItemToVest, addItemToBackpack)
- magazines are added with addMagazines
⚠️ these last two only work when hosted local, and not when dedicated
so then i got this suggestion, and it just results in nothing happening at all at least when hosting local, about to test on dedi now. here is how i implemented the suggestion in CfgVehicles, but its a single line
init = "if (local (_this select 0)) then
{
[_this select 0, ""bb_fac_kla_civarmed"", ""sl""] call BlaBer_fnc_setUnitLoadout;
};"
No change in result from the list above
then i got this suggestion, but implemented it wrongly
_unit spawn
{
waitUntil {!isSwitchingWeapon _this};
_this setUnitLoadout _tempLoadout;
};
this resulted in the magazines, grenades and items being added but NOT the setUnitLoadout command being set. I added pics of the last two situations below here
and just to prove the script actually works here is the expected result from local
You have script to share pastebin or here
i'll send it to you in DM
ah you don't take DM's prisoner, could you send me one first?
Pastebin and post it here would be better, that way everyone can see it
Nothing you're going to post in the dm is going to be some new "revelation" of code. Just post it here lol.
that way we can all laugh if the code is bad 😉 jk
Looks like there is no way to change buildings destroyed state in SQF. Besides settings damage to 1, which switches state to most destroyed model, but no way to get partially destroyed ones without hitting it by something.
Or is there a way?
Change LOD?
No, buldings switch model when you damage them enough. They usually have couple of different models(like missing parts of walls)
Before switching to most destroyed model
Try setHit or setHitPointDamage
There is an Editor module that can do this, and that will be doing it through SQF somehow. You should be able to find the function that module uses and see how it's done.
There is module, that's true
The module is wonky, especially for modded maps. Haven't taken the time to redo it/fix it. But go ahead and try it.
The module uses setHitPointDamage
It's hardcoded to a couple of specific hitpoint names, which is why it doesn't work with all buildings. If the building has a more complex damage model...or is just set up inconsistently...the module won't work or won't be able to access all the damage states. But since you're doing your own thing, you can target whatever hitpoints work for your buildings.
How did you find out it which command it uses?
Inspect module in Config Viewer -> function attribute -> open Functions Viewer -> search for that name -> scroll through the function until you find the part that sets damage
Had no idea you can inspect modules like that, thanks 
lol @proven charm hahahahah, that was funny
Is there a way to calculate the PositionRelative of an object from another object's model center? trying to update BIS_fnc_attachToRelative to work with the newer followBoneRotation param but having trouble finding out how to find the proper array to pass. Alternatively, is there a way to just completely omit a parameter of a command?
lol asked the question then immediately found the answer
attachedObj attachTo [baseObj, (baseObj worldToModel (getpos attachedObj))];
getPos isn't correct for worldToModel (or anything much, really)
baseObj worldToModel ASLtoAGL getPosASL attachedObj would be correct.
Unless water is involved then getPosATL will return the same thing.
If you can guarantee that attachedObj is standing on terrain then getPos and getPosATL should return the same thing, but then getPosATL is much faster.
yeah i was just trying to get anything that would return even vaguely close to start
my issue now is finding a way to calculate the relative position of the base object to a specific memory point on the model
I assume I'll need to use selectionPosition
The base object's model or the other one?
the base object
the idea is basically to rewrite the fnc so you could use it to say attach an object to a vehicle's turret and have it move and rotate with that bone while still being able to use 3den to manipulate the object and not have to sit there and figure out the right offsets by hand
I would have thought you could shortcut that with the memPoint parameter of attachTo.
but yeah, otherwise selectionPosition.
yeah the hold up I'm having is figuring out how to calculate the attached object's position relative to the selectionPosition
It doesn't just do it automatically if you specify mempoint?
The offset is applied to the object center unless a memory point is provided, in which case the offset will be applied to the memory point position.
Oh I see, you want it to keep its current relative position.
the issue is going back to trying to make it work like the attachtorelative function
yeah
yeah in that case just do a vector subtract with the selection position.
(after doing the worldToModel, and then both values are in model space)
vectorDiff
But if it's already rotated then I'm not sure what's going to happen.
i have a diff solution for that part that should work
something like this? (baseObj worldToModel ATLtoAGL getPosASL attachedObj) vectorDiff (baseObj selectionPosition ["otochlaven", "Memory"])
works like a charm thx
If you wanna compare answers afterwards https://gist.github.com/ampersand38/1f3d52fedeb9e76ac7e9647072b8e49e
Im trying to make a patch for Pook's Arty where the VFX on launch of the SCUD and the Iskander are like those of the FIR Cruise Missile , ive tried a lot of things but couldnt get them to work , ended up breaking the mod several times with patches , does anybody know the general way to get this to work ?
Hey, I am trying to remove a main rotor from a helo. Like they do when they hit a building. I just want a helo to spawn without a rotor.
So far I tried
_this setHitPointDamage ["hithrotor", 1];
It did damage the rotor, but its still there.
I am testing this on a Standard GhostHawk btw
I don't think you can by script. Create it far away, engine on, next to a VR block. Then when the rotor is destroyed, move it to where you want it.
But than the question is, how does the game handle it? There must be a way
Not all of the game engine is exposed to script or modding.
Another way is simple object if it just needs to be visual.
https://community.bistudio.com/wiki/setHitPointDamage
Use the 6th argument
Oh....Okay, I didnt notice that before
Thanks I will try
yup
_this setHitPointDamage ["hithrotor", 1.0, false, objNull, objNull, true];```
and its beautiful
hello folks, quick question.
Are units spawned by a Zeus local to the zeus machine or to the server?
By default they're local to the Zeus that placed them. However, they can be transferred; if the Zeus player disconnects, for example, or if a script force transfers them (e.g. headless client systems).
ty!
call {SL sidechat ''Arriving in a couple! I'll pick you guys up and bug out!''};
it still says missing }
what?
what is wrong with this line of code
try adding ; before }
Not required
it still says missing ]
You shouldn't need call { } at all tbh.
It's possible the issue is actually in the line before this, and this is just where it's getting picked up.
Is it missing ] or missing } ? The difference is important.
when i put } its missing }, if i change it to ] its missing ]
both sides i put the [ ]
im using the trigger system block
Within the context of this line only, { } are correct (if unnecessary since call { } is not needed). Using [ ] would be wrong.
In SQF, {} are used to denote Code data type. [] are used to denote Array data type. They cannot be interchanged.
okay i will do it without
"System block"?
the trigger flag
trigger, you know the blue flag
in the description thats where i put this code in
if that helps
ok so i removed the {}, now its says missing;
crazy work
It probably doesn't matter for the purposes of this error, but triggers have several code fields in their attributes, and none of them are "description".
Is this the only code in...whichever code field you put this in?
provide all your code?
If you remove the {} you need to remove call as well, they're part of the same structure.
now its
call SL sidechat ''____________________'';
oh
i missed your last message
ok
stil missing;
SL defined?
oh let me check if i did
its headquarters entity
i named it in variable names ''SL''
At this point, just take a screenshot of your trigger and headquarters module
Is the error happening when you exit the trigger attributes in the Editor, or when the trigger activates in the mission?
If it's the first one, then it's unlikely to be an undefined variable, as I don't believe the in-Editor syntax test actually checks for undefined variables.
you are using '', not "
Your alleged " is actually just two ' next to each other
copy-paste "
This is also two ' in Discord by the way. It just looks like ".
Screenshot wins as usual
If you're pressing the " key on your keyboard and it's outputting two ', you have a problem with your system. It's not supposed to work like that.
its not outputting in 2 seperate here
i have " at number 2 key
its just arma being a psycho bitch
It is. You can individually select them. It just doesn't look like it.
alright]
the fault is my own doing
Hey people 😄
Did someone implemented a custom sound and can say me
why my Arma say "Member already defined" with following
input in description.ext:
//Benutzerdefinerte Geräuscheffekte
class CfGSounds
{
sounds[] = {}; // OFP required it filled, now it can be empty or absent depending on the game's version
class test
{
sound[] = { "EBER\Funktionen\Sirene\KrankenwagenSirene1.ogg", 1, 1, 100 }; // file, volume, pitch, maxDistance
forceTitles = 0; // Arma 3 - display titles even if global show titles option is off (1) or not (0)
};
};
class test,
Change that to eber_test
I bet some where , someone, something is defined in cfgSounds class test (which is not good define for unique class)
Does anyone have a pointer for any scripting functions for the Radio Protocol stuff https://community.bohemia.net/wiki/Arma_3:_Radio_Protocol ?
Ideally, I would like the player to say/radio the messages defined in the RadioProtocolENG (GRE, CHI, etc)
Got the problem together with a friend. Its a already defined and included CfgSounds in another file
@foggy stratus do you have a pointer for this perhaps? I know you created a script once and put it on the bis forums - but they are offline for the time being.
hey guys how is everyone today, im very new to this scripting stuff on arma 3 and wanted to make a ww2 bomber mission where a group of bombers fly to target position and release the bombs (ofc ai controlled) is there a script or a mod for that sort of stuff??
I suspect I already know the answer to this, but is there not a way of reading/writing to a txt file without an additional mod or extension or using SQL for something like storing persistent player data?
No, you need an extension to do any external writing.
eww
You could store "persistent player data" in the profileNamespace / missionProfileNamespace of client/server tho.
https://community.bistudio.com/wiki/missionProfileNamespace
https://community.bistudio.com/wiki/profileNamespace
Here's my jboy_speak function. It covers most vanilla command/responses, and will speak the line in the language of the unit's speaker.
2 sample calls:
[_unit,selectRandom ["CheeringE_3","CheeringE_2","EndangeredE_3"]] call JBOY_Speak; [player,"Halt"] call JBOY_Speak;
that's really interesting
does anyone know how to turn on building interior lights? specificly on CUP chernarus 2020 buildings?
Fantastic, thanks much!
Are you sure the buildings actually have working interior lights?
Since lights go through walls in Arma, most buildings don't have them.
i just put a fireplace under the building or in where the fireplace would go
looks cool a fire burning in the fireplace
i raise the firepit or fireplace up to fit right where the fire should go in the fire place of
the building, and the building hides the rocks that are around the fire pit and it looks cool
imho
particle effects?
no no just the regular fireplace
Haha I thought of this approach too. But it might be more efficient but it's handing is worse.
I can recommend creating a centralised DB reader/writer which can write/read DB Data.
Also I do highly recommend reading out non (only) player related at the server start and saving them in variables locally on the server so you don't spam too much requests.
For me there are currently (highly dependent on player count ofc) like 250-20k read requests a day and like up to 1-2 mil update requests due event based saving.
I did not ran in any DB Update issue yet but would also be interesting to have some other feedback about that 🙂
@pallid palm huh ok
roger m8
the building hides the rocks that are around the fireplace and it looks cool
havent noticed that my self
I guess he means the rocks of the fire place are in the building -> not visible anymore?
yeah if you raise the fireplace up to fit in the fireplace in the building the building hides the rocks around the fireplace
only on buildings that have a kinda fire place in them
cool
yes i love it
and you can even turn the fire off if you want also
or on
because its a regular fireplace from the game
ok
Oh and ofc you can stack the update requests too if you have issues with too many at once (for me this wasn't necessary yet)
Also try avoiding multiple update requests for 1 single event.
But for simple settings or so you can also use the other approach. But when it comes to stuff like being able to edit data when not having direct access on the server you have to do it that way I guess or write other extensions on your own
i guess thats good for survival players they can warm themselfs up 😉
lol yeah lol
plus its looks so cool from far off
it looks like people were getting ready to cook lol
it realy gives you the feeling that people are in that building
and the sound is there also
ya eat too
yes
and at night woooweee look out lol
looks so cool
on that one 2 story building in Arma3, i use it all the time you know witch one i mean
ive only noticed fireplaces in takistan tbh
Is it possible to make interiors dark without making it dark everywhere?
i sometimes board up the windows and that helps some
You would have to spawn light sources yourself. And these are local, so have fun syncing them in multiplayer. Or you can use Scotty's workaround
I just found it weird, that tunnels from SOG have normal light inside of them. Unless I switch time to night.
set gamma to dark when inside building - probably a bad idea and undoable
i make SOG missions with vanilla no Mods needed
What about AI? Their visibility seems to be affected by amount of light. So, wouldn't it be bad, if I just make it dark for players?
little challenge is always good 
yeah thats right ai can't see in the dark
the other day i did a night mission with just flashlights and holy moly WOW
you can set AIs skill such as "spotTime" "spotDistance" via https://community.bistudio.com/wiki/setSkill
I think that's workaround at best. It might be better to change time of day when entering a tunnel and change it back when leaving. This would only make sense in singleplayer though, since weather and time is synchronized in multiplayer
yes agree
And you can make nights really really dark in Arma. At the right time, when there is no moon. Nights are literally pitch black.
and you can also make nights really light in Arma 3 if you set the date for a full moon WooHoo
Bark at the Moon lol
It needs a little more brightness using colour correction, if you want to have nights really bright
no no i just set the date to a date that has a Full Mood and wala its light at night
In opened areas, it seems to be true. But in buildings or woods - not so much
Maybe setAperture if that could be a good workaround
Color correction code.
#sog_prairie_fire message
How it looks during full moon
#screenshots_arma message
Awsome
there are some buildings in vanilla that have fireplaces
i hear ya
ok cool
i love the fact that my missions need no mods to play, and you only need vanilla, that way its all good for everyone to play, at any time
and you can have mods if you want also
same
yep, same 😎
i have like CBA loaded but I hope im not using any one its features or my mission wont work for people without CBA XD
I also do the same for my scripts, but for modding, yeah, CBA is the guy
the Guy that started CBA was a good friend of mine and i still don't use the CBA lol
it still amazes me that i hear of all the things going wrong with pepoles game, i never had 1 thing go wrong ever with Arma 3
maybe cuz i started way back in OFP
i would like to fix the distance of the holdAction in ArmA3
but i cant get it right yet
Yes, Arma is perfect, without any problems at all and always has been
I've literally send you edited version of that function with lowered distance
yes Arma 3 is the best game in the World
That's being said, it's weird you can't just change it using parameter
usually distance check is in conditionShow parameter for holdactionadd
yeah im working on it
how can I set a speed boost for aircrafts? they took off so slow in aircraft carrier and just fall into the water
Is it the vanilla aircraft carrier? there are catapults on the deck
modded ones, and for ai
oh i see i got it woohoo thx man @atomic niche
hell yeahhhhhh Arma 3 woohoo
"_this distance _target < 5",// Condition for the action to be shown
"_caller distance _target < 5", // Condition for the action to progress
Ok, that's not bad
it's because you don't do complex sh*t
what you want to achieve? You want AI to take off from the carrier?
yes
@thin fox oh really, what makes you think i don't have complex Scripts you might want to rethink that, and how would you even know what i do or how complex my stuff is, its kinda funny your just like me, i speak with out thinking sometimes too, and also i was not taking about you, or anything you said, or did, when i said that:
well i dont know about you but simple is way better then complex
like this?
yeah, and a cargo plane that paradrops people
depends on what you mean by simple
i mean like neat and clean
and good scripting
im not saying im a master mind but from all the help i got from the guys in discord make my missions Awsome
when I get home I will share my working functions for AI talking off from carrier
thanks!
Just adding some extra velocity during takeoff or do they use the catapults?
adding velocity, i tried the catapults one and they steer the plane like badly
they do use catapults
I use bis functions but I had to modify a thing or two to work on IA and some modded aircraft with bad launch config
[herc] call BIS_fnc_AircraftCatapultLaunch;
[herc_1] call BIS_fnc_AircraftCatapultLaunch;
[a1] call BIS_fnc_AircraftCatapultLaunch;
[a2] call BIS_fnc_AircraftCatapultLaunch; I used this on the mission file sqf something
it's because you need other functions to make this functional.
The catapult launch just do the launch, but what actually maintain the aircraft in the right track is a function that locks the aircraft to the catapult, by getting the memory point from the hull of the carrier, and that I needed to script
ohhh okay thanks for the info
Description:
N/A
I count on you to document it 
I call Photoshop or AI manipulation
off-topic, please stick to discussing Arma 3 scripting in this channel :D
help
Reverted: setUnitLoadout will now abort if a unit is in the process of switching weapons (may be revisited in future) - FT-T167015
when I finally finish adjusting my mission, this update comes
😂 that's why I mentioned function viewer, let's blame Lou
Always blame Lou 
How do i make waitUntil my unit is not in vehicle anymore? So once he exits vehicle other script runs
isNull objectParent _someUnit
objectParent would return the vehicle _someUnit is in or objNull if they're not in one
or "GetOutMan" EH
Question, looking to have a scroll wheel option for one object to have equipment such as weapons, explosives, etc then another object have the uniforms. Anyone have a script or way of doing that ?
what do you mean by that? boxes with items?
Like arsenal boxes
why not just use the Bis_arsenal box
this addAction ["<t color='#ff1111'>BIS Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal},"",1,false,true,"","(_target distance _this) < 5"];
If you want boxes with items, there are commands for that, but you can fill them in the object's attributes as well
Hey!
Hi :D
RydHQ_Excluded = RydHQ_Excluded - [_value];
parseNumber is weird, this prints 1: ```
parsenumber "1abc";
What would you expect it to do?
yeah can't do that now, some code might depend on it :P
lol must be weird code
It's probably an old C library thing anyway. You give it a string pointer and it attempts to get as much number out of it as possible.
right
The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function.
now how to check if character is letter or digit?
regex, at a guess
oh man i hate regex 🙂
but good thing i dont have to do a loop when using regex
googled this sqf if(count (_text regexFind ["\D+"]) > 0) exitwith { 0 }; // Only digits allowed
thx 🙂
I did something with parseNumber to only accept digits in one of my controls
(displayCtrl 3631400) ctrlAddEventHandler ["EditChanged",{
params ["_control", "_newText"];
// https://community.bohemia.net/wiki/Talk:parseNumber
if (!((parseNumber _newText) == 0) && (count _newText == 6)) then {
ctrlEnable [3631603, true]; // Enable Grid button
(displayCtrl 3631603) ctrlSetToolTip "Select grid position";
} else {
ctrlEnable [3631603, false]; // Disable Grid button
};
}];
thx the regexFind seems to work fine
these are all the function that handles catapult launches of my w.i.p cas menu, now time to study them
sorry for the long file list, blame discord 
thanks
Why not just make Git repository ? 😄
I'm still editing stuff before putting there, not much familiar to github
IT gives you version control so you can rollback if need be and see the changes you or somebody else makes if your repository is open or if you let people in if its private.
Its easy to learn you just need some practice at first if its your firt time using it. I would recomend to download Github Desktop and just use that app if you are just starting with Github.
Thanks for the recommendation Legion, I will download it. When I start a project or I'm in a middle of it, I edit lots of stuff, minimal sh*t, like missing a ";" or a wrong letter in some variable, and had to reupload/merge the file everytime, that's why I'm just holding on to upload it later
you just push and commit when you are done editing you dont have to push and commit every little change.
so github desktop helps with that?
I mean I can save the files without push and commit
Yea its as easy as pressing 1 button 😄
by any chance, does anyone know if the
https://community.bistudio.com/wiki/addCamShake
command acts on the display 46 of a player or if its bound to something else?
I'm having some issues with persistent screen shaking even after restarting the mission I'm testing and im wondering if im missing something here or if this is a plain ole´ bug. This is happening on a machine that is running the game "natively" in Proton, doesnt seem to happen on a pair of windows based machines I have tested with
Hi, will this mod be MP compatible ? https://steamcommunity.com/sharedfiles/filedetails/?id=3451978697
There is comment from "R. Gonzalez": ||Won't the "hasInterface" condition make dedicated server and HC local units NOT be affected by the mod?|| which makes me worried. I would like to use it for 40+ plp event, but if it wont work with dedicated.. 🫣 😦
That comment (and the code) doesn't mean the mod won't work on a dedicated server. It means that units which are local to the dedicated server or headless client won't benefit from the mod - unconscious collision will not be disabled for them.
This isn't a problem because the only units that are local to the DS/HC are AI, and AI pathfinding doesn't care about unconscious collisions anyway.
Basically, the mod operates on the machine of the player who wants to walk over the body (let's call them Player A). The mod running on Player A's machine detects when any unit enters the ACE unconscious state, and disables that unit's collision - only on Player A's machine (the command is Local Effect). Player B, who is not running the mod, is unaffected; the unconscious person still has collision on Player B's machine.
Because the mod works like this, it doesn't need to run on a DS or HC. DS and HC machines, by definition, cannot have a player who might want to walk through unconscious people, so they don't need to disable collision.
Does anyone have a work around for flyInHeight not being ASL and being ATL? Need it for a UAV Loiter type waypoint and haven't been able to come up with anything to keep it steady. I wish we could get the VBS variant of flyInHeight that has the option for ASL in it.
Thank you so much @hallow mortar , its important for trench warfare, when we were moving unconscious player from btr it happens also that vehicle got blasted off, or jumped into the air, can we hope this will be solved too ? I know, could be hard to tell. (We also have bmp2 jumping, when driver is leaving the vehicle, it can be prevented by opening hatch for some reason
)
i thought allPlayers was fixed to update the player list faster (in MP), but i guess it wasnt?
maybe its server only fix then because i just tested in dedi and client was slow to update it
I want to make crashed huey with dead crew in it, but everytime i place unit in huey which has disabled simulation it turns back on, anyone knows how do i do it, i remember it didnt happen before
@dire star so can you explane more about the mission on whats going on before the crashed huey
or do you just want to put a huey somewhere and then crash it or damage it or expload it,
@dire star don't disabled simulation, just put the huey somewhere with the crew in it and then expload it, then as long as you don't have a clean up script, or the CorpseRemoval on, the dead guys should still be there
in some cleanup scripts you can exclude named guys or dead guys, then you can have Corpse Removal on
So mission is that my team recovers downed crew and i've made huey that has 10% health and i've positioned it on side (rotated) so it looks like it crashed and i just wanted when my team reaches crash site there's dialogue going on ab dead crew so i just wanted to add some details like copilot died in crash and stuff like that
oh i see hmmm i need to think about that one lol
In my Black Hawk Down mission i use same script and heli stays out of simulation once i unhide it that's why i dont understand why it's happening
hmmm yeah i see
maybe the crews not in the huey till your team gets to the huey
and maybe then the crew gets spawned is the huey when your team is at a distance from the huey
just a guess tho
You could try attaching the helo rather than disabling its simulation
(Might also need to disable damage on it to stop it exploding from being clipped into the ground, I don't remember exactly how attached objects respond to that)
It wont bounce or move around after that right?
As long as whatever it's attached to doesn't bounce or move around
has anyone figure out how to use playSound3D on moving objects ?
You can't. (Well, you can but the sound won't follow the object.) If you want a moving sound, you need say3D or createSoundSource.
I think createSoundSource should do it, thanks
can you make the Diary Record have clickable link that opens webpage? I found ctrlSetURL from the wiki but that probably cant be used
thx
If it doesn't work, you may need to allowlist the URL. I don't remember whether structured text links are affected by this. https://community.bistudio.com/wiki/Description.ext#CfgCommands
hmm however this does not create link ```sqf
_index = player createDiarySubject ["testEntry","TEST"];
player createDiaryRecord ["testEntry", ["Info", "<a href='http://arma3.com'>Arma 3</a>"]];
The documentation says the links aren't marked in any way, they just look like plain text. Have you tried clicking on it?
I guess briefing doesn't support all the structured text tags
Weird, I thought I'd seen URLs in briefings before
you can have clickable links there but they only execute code
How does the object Transfer Switch work (the one from the Contact dlc). How do i make it so on hold button it sets the switch to the up or down position? I'm trying to make a mission where players have to use it to "switch on" a radio antenna but can't find anything regarding scripting this
It's just animations
You can inspect the object in the Config Viewer to see what animations it has
And for the hold action of course you'll want https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
Ok i'll check it out, thank you
I think I broke it.
[isServer,clientOwner,owner player]
[true,5,2]
I need your help. Is there a script that will lower the NVG onto the eyes but keep the view normal? (like without any googles?)
I'm curious if anyone has come up with a way to automate AI "hunting" players if they do something like crash land, eject, or get spotted?
I would give AI squad a "MOVE" waypoint to the crashed aircraft
Well... I mean yes ultimately, but I'd like to detect that automatically and spawn or task a group to searching. It might just be something I have to write myself, just figured I'd see if anyone has already done it first
You could use GetOut or GetOutMan EH to detect when player exited his vehicle
Does anyone else use doMove command in their mission? Did you notice that it is being ignored on dedicated server with the last update? 🤔
All my scripts that are using it suddenly do not work anymore and I'm looking into reasons and ways to fix this.
do you use lambs danger AI mod? they have some scripted stuff to hunt down players, you just need to call it in a script
whats clientOwner?
I'm guessing I'm not the first one to realize this but I just tested it and was surpised just how well it works (apart from the ugly syntax): app = {_x = (_this select 1); call (_this select 0);};
Any guesses what that does/what it's for?
^ no idea
whats clientOwner
returns the clients owner id. It breaks in resumed MP games apparently.
It's the basis for lambdas in SQF. Well, really, really ugly lambdas, and I'm not even sure if you can get full lambda out of it
(\x -> x 5) (\x -> x + 4) turns into [{[_x,5] call app},{_x + 4}] call app;
Surprisingly (well, not really, once you think about it) you can even get the result back out: _result = [{[_x,5] call app},{_x + 4}] call app; will in fact return 9
uhm
I'm not quite sure how far (nesting) this actually works, though. Would have to be way more awake for that
What's it for? It looks beautiful.
In SQF it's just a toy. In theoretical computer science, Lambda Calculus is a super important theory of computation. It's also the basis/inspiration for so called "functional programming"
Some other non-functional (i.e. more mainstream/standard) languages also have "lambda function" support since it allows you to quickly write down a function without worrying about a name, variable names, etc. You just go func foo = \x -> x * cos(x) * 2 + 17*x; which is something we already do all the time in SQF.
and it works great, very overlooked behaviour tbh
Actually, I'm an idiot. "app" isn't even necessary, just use _this instead of _x and "call" will do exactly what we need.
I'm going to blame this on it being the middle of the night 😛
iiiiinteresting
Stalk looks just like lambs stalk just with more precision on how it works, I'll definitely be using that.
I think the hard part is figuring out when to do it, since gameplay wise it wouldn't be all that fun if you started getting hunted on a normal dismount
its a little wonky but I guess I could do something like use a trigger in the relevant area to add a LandedTouchedDown EH to the aircraft and write some spawning logic in there
Could possibly use knowsAbout to determine if their position was known when they touched down- hmmm that might be the answer
Only thing I don't like about it is parameter radius. Because this number gets passed into addWaypoint's radius parameter, which is in my opinion very strange, since it creates waypoint, which seems to usually be placed close to the center of the radius. Rather than having even chance of being placed close or far from radius center.
You might not mind this, but think it's worth pointing out. It took me some time to figure this out.
That is good to know, I'll have to experiment with that to see if will cause problems
Fairly frequently. No issues. Generally the only trouble with doMove is that it can be overridden by other doMoves.
Maybe after enemy spotted the aircraft and aircraft landed in enemy controlled territory?
Your "app" worked because of dynamic scoping (http://foxhound.international/arma-3-sqf-private-variables.html) but you'd want to make sure _x is local to that scope when doing things like that.
yup thats what I'm thinking, if knowsAbout` is high enough and it lands. I dont know how that would account for ejecting and parachuting from a plane but at least for helicopters it should (hopefully) work
does anybody have a code snippet for selecting only roof positions of building ?
Do these positions exist in as a building position or are you trying to do something more general
trying to select from existing building positions
Player lands in enemy territory after plane he jumped from was spotted? Or he was spotted himlself like on parachute
_positions select { lineIntersectsWith [ _x, [ ( _x select 0 ), ( _x select 1 ), ( _x select 2 ) + 20 ] ] };
simple enought ?
you're on the right path
i personally use lineIntersectsSurfaces but I'm actually doing the opposite of what you do, determining if there is a roof over a position:
@tribal crane: Yeah, that's the article that actually gave me the idea for this. But I'm still not sure if you can actually get full lambda calculus out of it, at least "neatly"
Either he was known about before ejecting, or he was spotted on the descent. The whole map wouldnt reasonably be populated so spotted on the descent is less likely but if he gets shot down it makes sense that his rough position would be known
Quick question how do i get animation Duration. The lenght of animation ?
There is this Duration in Animation Viewer but i dont know how they got that duration ?
I believe the Animation Viewer list is built from config, and the animation's duration is defined in its config
CfgMovesMaleSdr or CfgGesturesMale would be the places to look
Yea i was looking there but there isnt anything about duration of animation:
https://community.bistudio.com/wiki/CfgMoves_Config_Reference?useskin=darkvector
For State type animations it's determined by dividing 1 by the animation's config speed value
I can't figure out how it's determined for Action type animations
Okay no, I misunderstood. Animations in CfgMovesMaleSdr >> Actions is not a distinct category from CfgMovesMaleSdr >> States. "Actions" entries have corresponding "States" entries, and that's where the speed property lives for all of them. For all animations, duration is determined by abs (1 / _speed).
I dont think that is correct formula becouse i got this:
/*
-anim name: "Acts_Abuse_Lacey"
-anim length: 26.206
*/
TAG_fnc_getAnimDuration = {
params ["_animName"];
private _animSpeed = getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> _animName >> "speed");
private _r = abs(1/_animSpeed);
_r
};
private _test = ["Acts_Abuse_Lacey"] call TAG_fnc_getAnimDuration;
//resoult: 86.2069
systemChat format ["%1", _test];
BIS_fnc_animViewer, line 516:
_cfgAnim = configfile >> BIS_fnc_animViewer_moves >> "States" >> _anim;
_file = gettext (_cfgAnim >> "file");
_speed = getnumber (_cfgAnim >> "speed");
_duration = if (_speed != 0) then {abs (1 / _speed)} else {0};
BIS_fnc_animViewer_animData = [_anim,_file,_duration,time];
_duration value is then passed to BIS_fnc_secondsToString to generate the displayed duration
The actual Acts_Abuse_Lacey animation clearly plays for substantially longer than 26 seconds, so clearly there's some error being introduced somewhere
yea becouse i was confused we are using the same code but got 2 diffrent values.
You'd have to check by timing it properly, but I suspect that the basic formula is correct, Acts_Abuse_Lacey is actually about 86 seconds long, and BIS_fnc_animViewer is screwed up somehow. I can't find where it's screwed up though, so 🤷
myb worth makeing a ticket ?
I mean it can't hurt, unless a ticket already exists. But the BI anims viewer has been terrible for ages, I avoid it as much as possible
@real tartan yes look for the SHK_buildingpos.sqf
the script has full instructions on how to use it in the script
im trying to set up objectives to where the players need to kill all of the enemies, so I'm using "!alive infantry1" as the group's variable, this is giving me an error though. is there a way to go about it for the group as a whole without me having to name each individual soldier?
could i use something like this?
{alive _x} count units infantry1 == 0
units infantry1 findIf {alive _x} == -1;
Negative speed means seconds.
speed = 10; and speed = -0.1; are same
I am looking for a way to multiply the base amount of ammo in turrets across an entire vehicle, ideally by something simple in the object init. I've tried a couple (e.g. setVehicleAmmo) and have had no success.
Anyone know a way?
"Multiply" as having more magazine or having more magazine capacity?
can you set dialog above the chat messages?
They are just UI so probably yes
By creating a dialog over it
Yeah, I see now. The chat window is always on top.
ya
could it be possible to hide the chat temporarily? Im trying to find in which dialog the chat is , probably in some overlay (i found "RscDisplayChat" but havent been able to figure the right display/control) (NVM thats not the right display)
Hello everyone, I am looking for something, that can change cargo parachute opening height.
do cargo objects have a parachute by default? 🤔
I mean the parachute that opens when you, for example, throw the vehicle out of the plane
yea i get you, was just thinking if thats vanilla arma behaviour or some mod
Vanilla. Added in APEX if I remember correctly
dont know then
I dont know much about coding but im trying my best to learn through the editor.
Im trying to do getPosATL and getDir on a Sign_Arrow_Direction_Blue_F but it always comes back as the words "[array,scalar]" with no actual data inside. Why is this?
pls show your code
Team1_Armr = []; ; Team1_Armr = [getPosALT _this, getDir _this];
And im putting it on the prop itselt
in the init field?
i think you should use this without the _
it depends where you put the code, init fields use this instead
is there any other odd formatting like that for init fields i should know of?
not sure , im not init fields expert 🙂
I am using endeavourusOS (based on arch linux) to run arma 3 (very good performance btw) but I am lost to linux paths, for example the path to mpmissions folder. Any help from experienced linux user?
Relevant intel https://community.bistudio.com/wiki/Magic_Variables
search suggest
~/.local/share/bohemiainteractive/arma3
there is no folder bohemiainteractive at all...
@split ruin check out the linux channel, propably more help there https://discord.com/channels/105462288051380224/105464899567669248
So I am using this mod, which gives you tactical vision, I have an issue with it.
Here is the code: https://pastebin.com/RcXZDBTr
Here is the issue for what it does: https://i.ibb.co/4wVgbn4g/107410-20250607223937-1.png
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.
Try putting sampeling to 114% in your video settings
It aint my screenshot, but a few players we play with has this issue
Tell them to do that and see if that fixes the issue. I had a similar problem with ace and kat and when i did that it fixed it.
Also how would ace_interact_menu_fnc even be related to it?. Apparently it only happens with that mod. I assume that the code calls to create ACE self interaction multiple times instead of one, when closing the inventory, is my theory
yeah, i would definitely suspect the action wasn't removed as intended
have you tried adding just one action when the player is first registered, and using a condition to check if they have the right headgear/goggles to display the actions?
For a mod, I think you'd want to use some event handler that fires whenever the player is updated (PlayerViewChanged? CBA player events? don't ask me 🙃), so you can add the action exactly once. The vanilla/ACE conditions are sort of close enough that you can reuse them in one code block too: ```sqf
private _condition = {
params ["_target"];
headgear _target in VTO_tacvis_devices
or goggles _target in VTO_tacvis_devices
};
if (isClass (configFile >> "CfgPatches" >> "ace_interact_menu")) then {
private _parent = ["TacVis", "TacVis", "", {}, _condition] call ace_interact_menu_fnc_createAction;
// ...
} else {
player addAction [
"TacVis",
// ...
toString _condition
];
};```
Figured I'd try asking myself, any info on what might cause a lobby slot to break indefinitely in this manner? It's been a very frequent issue in I&A to this day, and I have no idea what triggers it.
I couldn't reproduce this in my own gamemode, at least not with light traffic, so I don't know if it's caused by a script issue or if it can occur in any JIP scenario naturally.
Is there a sure fire method of monitoring units and detecting a group change?
Im trying to prevent AI from being left behind in their own groups when a player leaves the group and only AI are left behind. But If I use the unitleft group event handler on the group to check for and delete the units of a group if there is no player presently in that group - It works a few times but eventually it crashes the game for some reason.
I do not want to have to add a loop to the mission and would rather it be handled by event handler
What about UnitJoined EH?
I need to capture when the player leaves a group, because only AI will be left behind. If I used join it would only check the new group which a player has just joined
Sadly there are no groupchanged events to capture for units
If I am adding an event handler to a group how exactly does that work? Is the event handler being applied to all units of a group, and then stays with them when they leave the group, or is it only while they are presently still in the group it was applied to?
Unit must be in a group. Meaning if it leaves it must join other one. So no real need for groupChanged EH
Yes I meant a groupchange detection applied to only a single unit instead of entire group
Because when a player leaves a group, creates a new group, the event handler is gone.
But If I use the unitleft group event handler on the group to check for and delete the units of a group if there is no player presently in that group - It works a few times but eventually it crashes the game for some reason.
Send your code.
_plgrp = group player;
_plgrp addEventHandler ["UnitLeft", {
params ["_group", "_oldUnit"];
private _aisLeftBehind = {
!isPlayer _x && {side _x in [west, east]}
} count units _group == count units _group;
if (_aisLeftBehind) then {
{
deleteVehicle _x;
} forEach units _group;
};
}];```
It will work flawlessly but then in some random instances it causes a crash for the person leaving the group
I will try that and a few other things. Does locality change for the AI if the original owner leaves the group and they are left behind with another player?
Try using spawn.
Ok I will try that. The crash only happened frequently in MP too, almost never happened when I was testing in editor
I guess the reason of crashes is that you are doing group manipulations in the handler itself. Using spawn may help.
Okay so spawn for each unit of the group
I should also mention I am using the BIS Dynamic Groups feature. I do not know how stable this is
If in fact the crash is simply just from this system
This would be my instinct here.
No, spawn the entire code:
_group addEventHandler [
"UnitLeft",
{
_this spawn { ... };
}
];
In event handler code you need to be a bit careful about triggering other event handlers.
Oh okay gotcha
I think someone reported this not long ago.
You can try to find in #arma3_feedback_tracker.
Oh really? So basically an example would be that the unit being deleted is triggering the event again then I suppose since they also left the group, and maybe it is crashing because they no longer exist 😅
That code probably shouldn't crash. It's not like it's gonna run out of stack like something horrible we did once.
but it's certainly a possibility
Yeah its Arma anything is possible but I also have half a clue of the depth of knowledge most of you have so I will try a couple of these suggestions
Also the person who crashes was almost always the other player joins existing group and then left
If you have any repeatable crashes then it's worth sending the .mdmp to Dedmen.
is it possible to force players and all their models (clothing, armor, equipment, face) to only use a specific LOD at all times?
i noticed selectionNames can be used to force an LOD for one model from dedmen's example
hey guys, would like to ask help again with this issue as its still not fixed
the absurdity is compounding, i just set up a new dedicated server on the same pc as my arma game, ran the server, tested, and got the desired results https://cdn.discordapp.com/attachments/1386766581564051687/1388644577954500619/image.png?ex=6861bb8b&is=68606a0b&hm=b15833d7c63497f1913f8bde3333f8751cd0f4eb52aca66a62ad9e5949a9a9d1&
i then went back to my actual dedicated server machine to test with that again
Anyone know a best bodycam or helmet cam mod
there the items and magazines are missing again
here is my script
are you doing any logging?
i have, if you look in the original post im refering to, this is all working 100% in thorough testing, except in dedicated those addMagazines and addItems fail. Or well, in the dedicated server on my own machine it does not fail. I just have no clue anymore about any of this. Arma scripting is like a haunted house
One of the newer ctab mods, the original has issues with mine detectors because the items aren't implemented correctly
| except in dedicated those addMagazines and addItems fail
| Or well, in the dedicated server on my own machine it does not fail
these statements contradict each other. did you mean its failing on dedicated and is fine on listen server? Or did you mean fails on a dedicated server box from a service but is fine on your own dedicated box
if I was in your position right now, you know that the top part works and you start failing at handling items. I would start my logging to see if _lo_items and _lo_magazines is populated and correct wherever this unit is local. Additionally, I would log each iteration over those arrays to verify. These commands can silently fail, and give you no information, so you have to make your own information
// Handle Items
private _lo_Items= [["FirstAidKit", 1]];
_lo_Items append (getArray ( configFile >> "CfgLoadoutsBlaBer" >> _unitFac >> "loadoutRoles" >> _unitRole >> "items" ));
+diag_log "_lo_Items::Immediately After Config Lookup";
+{
+ diag_log format["_lo_Items:: %1 | %2", _x#0, _x#1];
+} forEach _lo_Items;
{
private _itemClass = _x # 0;
private _itemCount = _x # 1;
for "_i" from 1 to _itemCount do {
if (!isNull uniformContainer _unit && _unit canAddItemToUniform _itemClass) then {
_unit addItemToUniform _itemClass;
} else {
if (!isNull vestContainer _unit && _unit canAddItemToVest _itemClass) then {
_unit addItemToVest _itemClass;
} else {
if (!isNull backpackContainer _unit && _unit canAddItemToBackpack _itemClass) then {
_unit addItemToBackpack _itemClass
};
};
};
};
} forEach _lo_items;
// Handle magazines
+diag_log "_li_magazines::Immediate Before Adding";
+{
+ diag_log format["_li_magazines:: %1 | %2", _x#0, _x#1];
+} forEach _li_magazines;
{ _unit addMagazines [_x#0, _x#1]; } forEach _li_magazines;
sorry was AFK to do another test scenario
here is what i meant:
✅ testing in editor, singleplayer
✅ testing in editor, multiplayer
✅ testing a3dedicated on same machine
❌ testing a3dedicated on my game server machine
❌ testing a3dedicated on @stable dune's game server machine
this is what ✅ looks like
just tested the same exact code from console on my server where this happens, and it succeeds
Something another person suggested which i feel may be true, is that , setUnitLoadout takes place after the adding of magazines and therefore empties the inventory? Then again would the radio be there in that case? (its automaticly added by ACRE)
setUnitLoadout was fixed in the last hotfix
when was that released?
OOoOooOOOOoooo
i just hit update on FASTER server manager
and it downloaded stuff
i am hoping that was the hotfix
i think release was 25th? i dont think ive had time to look at this since, i am hoping this is why my local machine dedicated server (just updated) is working, and my game server (last updated before 25th) does not work
the script i mean
let's hope that you can fix your script with that only
didn't the hotfix only revert the change where setUnitLoadout would be cancelled if the unit was in the middle of switching weapons?
well yeah, but keeping the server updated also helps haha
1:30:40 "_lo_Items:: FirstAidKit | 1"
1:30:40 "_li_magazines::Immediate Before Adding"
1:30:40 "_li_magazines:: rhssaf_mag_br_m84 | 1"
1:30:40 "_li_magazines:: jna_20rnd_762x51_m77_mag | 5"
1:30:40 "_li_magazines:: UK3CB_BHP_9_13Rnd | 1"```
here is the rest
hmm, is the function executed on the server or on your client?
should be on the server, recently i was given this suggestion
init = "if (local (_this select 0)) then {[_this select 0, ""bb_fac_kla_militia"", ""lmg""] call BlaBer_fnc_setUnitLoadout;};";
in cfgVehicles
so that is
if (local (_this select 0)) then {[_this select 0, "bb_fac_kla_militia", "lmg"] call BlaBer_fnc_setUnitLoadout;};
i think this theory could be true, but to test that, could you spawn your function and add a short sleep just before it adds the items? sleep 0.5 should be sufficient
it seems to be related to the fact that the script runs on init
i cant reproduce the issue in any other way than looking at a freshly inited unit, calling the function or running the function code in console always works no matter the server
which button did you click to execute it, just Local Exec?
can you try a different loadout but remoteExec it on the server? e.g. sqf [player, "...", "..."] remoteExec ["BlaBer_fnc_setUnitLoadout", 2];
does that reproduce the issue, or does it still work as intended?
this is with a differen faction and role, i tried again doing your version but with the same parameters as previously, and it same yet again
hmm, that suggests to me that locality is the issue there, but given that the item commands are supposed to work on remote units, it may be a race condition that only exhibits itself if there's enough latency for setUnitLoadout and addMagazines to run out of order
do you mind making this change and uploading it onto your DS?
do you mean spawn the entire function?
around where you first define _lo_Items should be fine to put that sleep in
that, plus the sleep
OK
ill have to look up documentation on the wiki how to do that
do you have a link maybe?
just replacing call with spawn should be fine for this test
oh huh interesting
forgot to add in the sleep lol so i had to go and redo the whole thingy again, will be back soon
thanks for your help btw @errant iron this is more new insight than ive had for days
i think thats it
i was confused because i got wrong magazines in one of the loadouts, checking now if thats due to my own error or because of somethign odd happening with the data
but i had magazines in a loadout on init, and then this works too now
if that sleep resolved it, then it's almost certainly a locality + network latency issue
yeah this is odd
on mission init, the loadout consistently has the wrong magazines
its like the script is running twice now
once to do setUnitLoadout, once to add the items and mags
this always results in the proper magazines
that's with init="[...] spawn BlaBla_fnc_setUnitLoadout" right?
correct
iirc init fields execute on every connected machine, so that'd be your client + the server
class bb_fac_kla_militia_rat : bb_fac_kla_ai_template
{
faction="bb_fac_kla_militia";
editorSubcategory = "EdSubcat_Personnel";
scopeCurator = 2;
scope = 2;
side = 1;
displayName = "Rifleman (Light AT)";
class EventHandlers {
init = "if (local (_this select 0)) then {[_this select 0, ""bb_fac_kla_militia"", ""rat""] spawn BlaBer_fnc_setUnitLoadout;};";
};
};
oh, you do have the local check though
hold on, sombody said something the other day that might be relevant
admittedly i cant really comprehend this but maybe you can
lol, that's the theory i was agreeing with
However this won't work as intended because the setMagazines etc chunk will likely run before the setUnitLoadout.
is there any straight forward way to address this?
hmm, instead of doing the if (local ... thing in init=, can you remove that and do the check inside the function instead? as in: ```sqf
// Your config:
init="[...] call BlaBla_fnc_setUnitLoadout;";
// fn_setUnitLoadout.sqf:
params ["_unit", ...];
if (!local _unit) exitWith {};
...```
you can remove the sleep too
some here said that was ill advised
but honestly i dont know why that would be
i think because they said the function shouldnt be called at all unless by the server on the unit when it spawns
but im willing to try anything at this point
hmm doesn't sound right to me, that might have been misinterpreted
the goal is to make sure the function never runs on a remote unit, because adding items to a unit that's simulated on a different computer introduces network latency that we're theorizing could cause your commands to run in the wrong order (i.e. addMagazines -> setUnitLoadout = wiped items)
the weird part is that doing the local check inside init= should have been exactly the same as doing this, so im not sure why that didn't work
the first thing that comes to mind is "because its arma"
are you saying i should do call again in stead of spawn btw?
if the local check is in the function then it probably shouldn't make a difference, but yeah call would be preferred there
alright yeah i did switch it to call since i figured you would probably not put that by accident
still an empty inventory
🥴 maybe the locality problem isn't the only issue then, cause it did work when it was spawned with the delay...
or wait, when you did this test, did the init= field already have the local check in it?
yeah that was there since my last 'session' working on this some days ago
i opened up the .pbo on the server to make sure i actually properly built and uploaded the new file
and i did
so yeah the problems in the code still 🥴
hmm, what about units spawned in after the mission started? do they get the wrong loadout too?
or is it just units that were initially placed in the editor?
^ assuming the code still looks like this
you can spawn in a unit with debug console too
here's one to spawn the unit on your client: sqf _pos = player getRelPos [5, 0]; _unit = group player createUnit ["bb_fac_kla_militia_rat", _pos, [], 0, "NONE"]; and another to spawn it on the server with remoteExec: ```sqf
_pos = player getRelPos [5, 0];
_grp = group player;
_args = ["bb_fac_kla_militia_rat", _pos, [], 0, "NONE"];
[_grp, _args] remoteExec ["createUnit", 2];```
the top command creates an enemy with proper magazine/item inv, the bottom one has the problem
very weird 🤔
top command
bottom
(his launcher is also there, just landed away from his body)
had to shoot them to check their inv cause im not on the same team lol
if there is the racing thing going on, couldnt we just strongarm the problem by putting in that delay?
maybe 2 seconds or something before the mags and items are added?
these are supposed to be enemy AI anyway, no chance in hell that they would be seen so soon after spawn
so your setUnitLoadout should be running on correct locality given that this was added, and it works on units local to your client, but units on DS don't get addMagazines and etc., both for editor placed and scripted units...
here is the log again
i followed this suggestion and put in the logging
we get this log output even on the second command, that results in the empty inventory
_grp = group player;
_args = ["bb_fac_kla_militia_rat", _pos, [], 0, "NONE"];
[_grp, _args] remoteExec ["createUnit", 2];```