#arma3_scripting
1 messages · Page 111 of 1
I have and did
It only works on the editor
once it goes to my dedicated it doesn't at all
kicks me from every vehicle despite the whitelist
Then there is an issue with your implementation. It is possible to create such a system; it's been done before.
this addEventHandler ["GetInMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
if (
getPlayerUID _unit in whitelistedUIDs ||
!(typeOf _vehicle in IWantToBlockTheseVehicles) ||
(_role == "cargo")
) exitWith {};
hintSilent "You must be in ZR to use this vehicle";
_unit moveout _vehicle;
}];
This is what I'm using
are you testing it in mp
are you broadcasting the global variables
and please dont tell me youre putting this in an init
IWantToBlockTheseVehicles = [
"RHS_Ka52_vvsc",
"rhsgref_ins_BM21",
"I_APC_Wheeled_03_cannon_F",
"rhs_uh1h_hidf_gunship",
"rhs_t15_tv",
"C_Offroad_01_comms_F"
];
are you broadcasting it
I was told to put this in every player init
every single player that joins the server will add an event handler running that same code to that unit
bad
but doesnt matter for anything aside from optimisation
you need to broadcast the global variables unless you define them on each client
which is similarly bad
that's where I get lost
Hey guys, I'm wondering, what would be the easiest way to rotate an object 180 degrees?
_obj1 setDir (mod (getDir _obj1 - 180)); probably
no thats wrong hang on
private _dir = getDir _obj1;
private _newDir = if (_dir > 180) then {
_dir - 180
} else {
_dir + 180
};
_obj1 setDir _newDir;```
probably a better way of doing it but i think that should be fine
publicVariable "myvariablename" broadcasts across network
all there is to it
So I would just do
I'll give it a try, thanks
on server, yes. not each client as if you have a unit join mid-mission they will overwrite it again
meaning if you find something you want to block mid mission it will subsequently be removed again
so in my InitServer throw that there?
The definitions are only here
IWantToBlockTheseVehicles = [
"RHS_Ka52_vvsc",
"rhsgref_ins_BM21",
"I_APC_Wheeled_03_cannon_F",
"rhs_uh1h_hidf_gunship",
"rhs_t15_tv",
"C_Offroad_01_comms_F"
];
so initplayerlocal?
Did anybody yet test the implications of createHashMapObject?
Thinking about using it to enable "disposable" things i just can throw in variable and have it removed once the scope was left.
Sample:
// canSuspend = true
// Blocks UserInterface and other shinanigans
// and returns a hashmap object with `#delete` set
private _lock = [] call XMS_BlackOutSystem_fnc_SetBlackout;
while {/* condition */} do {
sleep 1;
};```
Would this work (like especially in performance branch with the optimizations)? Is that a heavy impact on performance or memory?
(ignore non-related code obviously as it won't end in a while loop doing sleep)
i think leopard is the only one who uses HMO 🙈
So I'd leave this in the players init? or would I add in what IWantToBlockTheseVehicles to the player init line?
no
you would broadcast the variables
on the server
the client then gets said variables
you dont need to define them on the client
dont put that in the players init put it in initplayerlocal.sqf
okay just making sure I'm doing this right
publicVariable "IWantToBlockTheseVehicles" goes in the InitServer.sqf
the other goes in InitPlayerLocal.sqf
yes
so in the initServer put back the whitelisteduids
don't know how
why did you even remove it
They’re back in their yet not getting kicked out
did you publicvariable it
no
then what do you expect
oh okay
whitelisteduids = [blahabalashdasdaldkhsdlahk];
publicvariable "whitelisteduids";```
Okay
I did exactly what you said
still nothing
publicVariable "whitelistedUIDs";
publicVariable "IWantToBlockTheseVehicles";
in the InitServer.sqf
with the UIDS above it
IWantToBlockTheseVehicles = [
"RHS_Ka52_vvsc",
"rhsgref_ins_BM21",
"I_APC_Wheeled_03_cannon_F",
"rhs_uh1h_hidf_gunship",
"rhs_t15_tv",
"C_Offroad_01_comms_F"
];
in initPlayerLocal.sqf
You shouldn't do publicVariable "IWantToBlockTheseVehicles" in initServer.sqf if you're not also defining that variable there.
Either define it in initPlayerLocal.sqf (and don't need to publicVariable it because all players then have it defined locally), or define it in initServer.sqf (and publicVariable it to the clients from there). Doing half of each is unlikely to work properly.
okay got ya
okay I just tried in both
still didn't work
as in I put it in Local took out the public variable
nothing
Put all of it in the initServer.sqf and nothing
with the addition of the public variable
What do you mean by "nothing"? The problem still happens and you get kicked when you shouldn't? The system does not do anything at all?
What exactly - and I mean literally post it - is in initPlayerLocal.sqf?
#include "x_setup.sqf"
diag_log [diag_frameno, diag_ticktime, time, "Executing MPF initPlayerLocal.sqf"];
__TRACE_1("","_this")
diag_log ["DOM initPlayerLocal.sqf, sending this to init player on server:", _this];
if (getClientStateNumber >= 11) exitWith {
diag_log "Dom game already ended... Exiting";
};
_this remoteExec ["d_fnc_initPlayerServer", 2];
if (hasInterface) then {
0 spawn d_fnc_tasks;
};
player enableAttack false;
diag_log ["Dom d_database_found:", d_database_found];
diag_log ["Dom name player:", name player];
diag_log [diag_frameno, diag_ticktime, time, "MPF initPlayerLocal.sqf processed"];
SP1 addAction
[
"spawn Ammocrate",
{
createVehicle
["rhs_mags_crate", position H21,
[],10,"NONE"];
}
];
whitelistedUIDs = ["xxx"];
IWantToBlockTheseVehicles = [
"RHS_Ka52_vvsc",
"rhsgref_ins_BM21",
"I_APC_Wheeled_03_cannon_F",
"rhs_uh1h_hidf_gunship",
"rhs_t15_tv",
"C_Offroad_01_comms_F"
];
obviously not putting the UID's out there
but in it my uid is removed
Where's the EH being added?
Well, that'd be why it's not doing anything
Putting it in every unit's init was not a great way to implement it, but you do still need to have it somewhere
That's probably sensible. You should put it in initPlayerLocal.sqf as well if you do not have respawn-on-start turned on.
anyway different I should write it?
You'll need to change the object it adds the EH to. this will not be valid in the new context; player should work.
this addEventHandler ["GetInMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
if (
getPlayerUID _unit in whitelistedUIDs ||
!(typeOf _vehicle in IWantToBlockTheseVehicles) ||
(_role == "cargo")
) exitWith {};
hintSilent "You must be in ZR to use this vehicle";
_unit moveout _vehicle;
}];
that's what I have rn
The logic appears to be sound. Changing the object as mentioned should be all that's needed.
In the final version, you should give your variables more unique names (it's recommended to use a prefix based on your name, e.g. moz_var_vehicleAllowList, moz_var_vehicleBlockList) to prevent accidental conflicts with other mods or scripts that might use those names.
.
so _player addEventHandler?
Not _player, player
okay
player addEventHandler ["GetInMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
if (
getPlayerUID _unit in whitelistedUIDs ||
!(typeOf _vehicle in IWantToBlockTheseVehicles) ||
(_role == "cargo")
) exitWith {};
hintSilent "You must be in ZR to use this vehicle";
_unit moveout _vehicle;
}];
that worked in the editor
I'll see if it works in the dedicated
any idea how i could go around getting the world aim position of a helicopter turret? [0]
I'm getting this error only while testing in singleplayer?
private _friendlyPlayers = (playableUnits + switchableUnits) select {side group _x == side group player};
{
private _sideNumber = (side group _x) call BIS_fnc_sideID;
...
_marker setMarkerColorLocal (["colorOPFOR","colorBLUFOR","colorIndependent","colorCivilian"] select _sideNumber);
} foreach _friendlyPlayers;
Just noticed they are finally adding support for UI rotation! https://forums.bistudio.com/topic/140837-development-branch-changelog/page-33#entry2930347
its posible to save a variable inside a mission to be used only in 3den?
something that is stored in the sqm i mean
No. They're not connected
Object variable names are also not useable in Eden workspace
"Added: UI rotation commands: ctrlAngle, ctrlSetAngle; config setting: angle, centerU, centerV for CStatic controls"
https://community.bistudio.com/wiki/set3DENMissionAttribute
this cant work? i wanto to save the loaded mods in the 3den, so when i re-opened it and i have some extra mod it show me a message
Ah, if you mean that, I guess that's a thing
I don't see anything that looks SP-specific. 🤔
As a side note, it might be worth throwing in 6 copies of "colorUNKNOWN" at the end of the array of possible marker colours, in case something somehow comes up that's outside the four normal sides.
is there currently any way of detecting a gun hit
as in a bullet hitting a units gun
Good question 🤔 I've never think there is a way to detect a lucky shot
Projectile EHs could probably do it, but that's not very efficient
mmm... wondering what would even get it? unit hit without any damage taken? 🤔
not like weapon is its own object either so cant get a hit eh for that
Maybe add EH to the projectile instead
would rather not have to do that though
fired eh on everything to hitpart eh on each shot 
idea is random chance for bullet to hit mag and cause small explodion, else gun gets dropped/otherwise disabled
(im fucking fed up of gun hits)
I've been having issues with the mod Eden 2.0 the light modules don't carry over their Attenuation settings from eden to ingame, resulting in very flat light colors
Module
_light = "#lightpoint" createVehicle _pos;
[_light,_color,_ColorLightAmbient,_brightness,[_AttenuationS,_AttenuationC,_AttenuationL,_AttenuationQ,_DistanceFade,_Distance],_dayLight,_flare,_flareBrightness,100] remoteExec ["Light_Component_fnc_spawn",0,true]
Function
_light = _this param [0, objnull, [objnull]];
_color = _this param [1, [0,0,0], [[]]];
_ColorLightAmbient = _this param [2, [0,0,0], [[]]];
_brightness = _this param [3, 1, [1]];
_setLightAttenuation = _this param [4, [2, 4, 4, 0, 9, 10], [[]]];
_dayLight = _this param [5, false, [false]];
_flare = _this param [6, false, [false]];
_flareBrightness = _this param [7, 5, [5]];
_flareMaxDistance = _this param [8, 100, [0]];
_setLightAttenuation params ['_AttenuationS','_AttenuationC','_AttenuationL','_AttenuationQ','_DistanceFade','_Distance'];
_light setLightBrightness _brightness;
_light setLightDayLight _dayLight;
_light setLightAmbient _ColorLightAmbient;
_light setLightColor _color;
_light setLightUseFlare _flare;
_light setLightFlareSize _flareBrightness;
_light setLightFlareMaxDistance _flareMaxDistance;
_light setLightAttenuation [_AttenuationS,_AttenuationC,_AttenuationL,_AttenuationQ,_DistanceFade,_Distance];
I don't understand whats wrong
I'm not sure if there is other code somewhere that could be the cause
hey, is there a helper function to make things display above units in game?
drawIcon3D can help you
yeah, I mean is there a helper fn that uses that
something like [_obj, "text"] call bis_fnc_text3d
Is there a way to grab ALL elements inside an array of arrays? i have a rather complex array of array heres and i need to pull just the elements that are strings.
It has a rather strange organization. Any other ideas welcome
[[1,[[1,[]],[0,[["rhs_acc_1p63",any],["rhs_acc_1p29",any]]],[3,[]],[2,[]]]],[0,[[1,[["ace_csw_kordCarryTripodLow",any],["ace_csw_kordCarryTripod",any]]],[0,[["rhs_weap_ak103",any],["rhs_weap_ak103_gp25",any],["rhs_weap_ak103_gp25_npz",any],["rhs_weap_ak103_npz",any]]],[2,[["rhs_weap_pb_6p9",any],["UK3CB_BHP",any]]]]],[9,[["Binocular",any]]],[11,[["ItemCompass",any]]],[12,[["TFAR_anprc154",any],["rhsusf_radio_anprc152",any],["ItemRadio",any],["TFAR_anprc148jem",any],["TFAR_anprc152",any]]],[14,[["ItemGPS",any]]],[3,[["rhs_6b26_green",any],["rhs_6b26_bala_green",any]]],[6,[["B_AssaultPack_blk",any]]],[7,[]],[8,[["ACE_NVG_Gen1",any]]],[10,[["ItemMap",any]]],[13,[["ItemWatch",any]]],[15,[]],[16,[]],[17,[["ACE_Sandbag_empty",any],["ACE_Fortify",any]]],[2,[["ACE_10Rnd_762x67_Berger_Hybrid_OTM_Mag",any],["ACE_10Rnd_762x67_Mk248_Mod_0_Mag",any]]],[4,[["rhs_uniform_6sh122_gloves_v2",any],["rhs_uniform_6sh122_v2",any]]],[5,[["rhs_6b13_Flora",any],["rhs_6b13_Flora_6sh92",any]]]]
https://community.bistudio.com/wiki/flatten is to get all elements
You could maybe create an invisible proxy object and have it be attached to the player in a way that if follows roughly the movement of the gun, and have an EH attached to it for the hit?
do i have to flatten it multiple times?
I do not believe so
Example says not.
create and object in the same sentence for me is a no go
I tried flattening it but its still not one big array, this is the select 0 of the 'flattened' array
[[1,[]],[0,[["rhs_acc_1p63",any],["rhs_acc_1p29",any]]],[3,[]],[2,[]]]
oh its a hashmap in arrays 😰 oh gods
just use brain :P
i hate bran
you just need the keys right
Well the values i guess
private _output = [];
{
_output pushBack _x;
} forEach arrayofstuff;
_output```
oh wait
hang on
this is done by tabs
im on amoled mode which has no syntax highlighting
it should be fairly similar just nest a foreach in there
first foreach iterates tabs, second iterates tab contents
Assuming that it's not an arbitrary pile of hashmaps and arrays, sure.
hmm yeah i'll give that a shot
im eating my dinner ill be at my computer soon
does anyone know what the formula for the velocity of bullets would be at certain distances or times if given its initial velocity and air friction?
You'd need to know how long the bullet has been alive, it's initial velocity (Magazine speed/weapon speed + muzzle coef), its friction coef (bullet config), and/or the distance it's traveled.
Not really a single equation though considering all the values from the config you need to calculate it.
oh well yeah I can get all that,so lets say given
initial velocity, friction, and the distance its traveled, how would I calculate the speed at that distance?
do you know the units of friction and if its constant deceleration or not
There are two different units used in config for different sized rounds.
oh how wonderful
And it's not constant deceleration.
even more wonderful
IIRC you need a differential equation solution even if you exclude gravity.
If you include gravity then I'm not sure there's a direct analytic solution.
gravity is just a "constant" acceleration downwards isnt it
at least thats how i hope BI treat it
yeah but the trouble is that it adjusts the direction of bullet velocity.
then again they use some weird value like 9.6 for it iirc
ah true
though dont think bi handles that
ace adv ballistics does
It does because it's simulated.
oh dear lord
incremental.
@edgy dune what do you want this for because if its tracing a bullet path theres already stuff for that
so i wanted to compare the velocities of two bullets that have the same hit value, but different typicalspeeds ,initial speeds and friction values. whichever bullet has a higher velocity/typical speed will do more damage (since same hit)
same bullet mass?
IIRC the friction coefficient in the bullet config is massless.
oh its just a straight config value?
which is why it has two different scales :P
i would recommend just generating a coef or something based off friction value and muzzle velocity then tbh
not using ace adv ballistic, using ace tho but since no adv ballistic that sohuldnt matter
as that'll scale the same
well im not tryna create something, im just tryna see between two rounds which has the higher velocity/typicalspeed ratio
More observations, if client receives too much damage at the same frame, it might get split:
- Player 2 freezes
- Player 1 hits Player 2 50 times
- Player 2 unfreezes and finally gets the messages
- Player 2 does ~40 HandleDamage cycles one frame, then ~10 HandleDamage cycle fires next frame
Not really sure how you arranged that particular case, but yes :P
_freeze_until = diag_tickTime + 10; for "_i" from 1 to 2 do {_i = [1,2] select (diag_tickTime > _freeze_until);};
oh, that sort of freeze
How can you get a random key from a hashmap (or just the values, whichever works)?
It does not :P
else generate random number based on count, foreach the hashmap until you reach random
Yeah that works, just wanted to check if there was like a cleaner way to do it
Actually hmm, it's for ace so it might use CBA's hashmaps
there probably is a cleaner way to do it its 4am for me
you should take me less seriously than you take me normally which should be not at all
Fair enough
Bed or transformation commands removed (because I most definitely have that ability)
In case anyone else stumbles upon this, ace_medical_openWounds is a vanilla hashmap, not cba
what
The velocity transformation commands you asked for capital ships
selectRandom keys _hashmap
or values
whichever you need
values yeah, I guess I missed that on the hashmaps wiki page
Thought they were, guess I didn't fully pay attention lol
nein is angular velocity access
was already in engine afaik just inaccessible for some reason
probably due to some of the funkiness that it has
hi, i'm running the following script to create a particle effect of a pistol flying from the player's hands:
private _velocity = [(sin (getDir player))*20, (cos (getDir player))*20, 1];
private _particleParams = [
"\A3\weapons_F\Pistols\Rook40\Rook40_F.p3d",
"", /* String */
"SpaceObject", /* String - Enum: Billboard, SpaceObject */
1, /* Number */
5, /* Number */
[.18,0.8,1.4], /* 3D Array of numbers as relative position to particleSource or (if object at index 18 is set) object.
Or (if object at index 18 is set) String as memoryPoint of object. */
_velocity, /* 3D Array of numbers. */
1, /* Number */
5, /* Number */
0, /* Number */
0, /* Number */
[1], /* Array of Numbers */
[[1,1,1,1]], /* Array of Array of RGBA Numbers */
[0.5], /* Array of Number */
0, /* Number */
0, /* Number */
"", /* String */
"", /* String */
player,
0,
true,
.5,
[],
vectorDir vectorRef
];
drop _particleParams;
_velocity is supposed to throw the gun in the direction the player is facing, but for some reason the particle is going in bizarre directions when the player is not facing north. This velocity method works for pushing vehicles around in the direction the player is facing, but it's simply not working with the particle effect. Anyone know why?
animation velocity seems to also be relative to the source object
try _velocity = [0, 20, 1]; or something like that
Not sure if this belongs here or in editor but I am working on a mission and I’ve reached a bit of an impasse. I want to be able to put down a bunch of the same object that creates a marker and runs a predetermined set of script and can sync to a trigger and the more I’m messing with it the more I’m realizing that I’m just describing a module right? Should I just be making my own module at this point? And how is that even done?
i think you're exactly right i will try tomorrow
Modules are cool but you can't create custom modules within a mission; you need a mod for that.
However, you can probably achieve what you want reasonably easily with scripting. For example, you can make a function that does all your stuff, and reuse it for all the objects, and you can run that function from a trigger or have it waitUntil a condition is fulfilled.
was wondering if anyone knows why sqf lineintersectssurfaces is returning all it's data in the format of a 1 item length array
despite the fact that it has more than 1 item of data in it
maxResults: Number - (Optional, default 1) max results to return. -1 to return every result
lineIntersectsSurfaces can report multiple collisions. It returns an Array of Arrays to allow for this:
[[data, about, collision1], [data, about, collision2]]
This format is the same even if there's only one intersection to report, resulting in an array containing one array.
so how would I select a part of the data it returns with that array
since it's just a 1 item array
all i need is the z value of the intersectPosASL from the first intersection
I don't really care about the rest of the data
essentially all i'm doing is raycasting using the lineintersects 10 meters below me to check if there is a surface below the player and I want to know what the height difference is between the surface and my player
[[a,b,c],[a,b,c]] apply {x select 0}
Returns all a values
_results = lineIntersectsSurfaces [blah];
_item1 = _results select 0;
_item1pos = _item1 select 0;
_item1posZ = _item1pos select 2;```
oh I see
so we select into the single item of the return
and that allows me to then select further parts of the return
apologies if i'm a bit slow, array's were never my strong suit
AKA it is how you navigate multi-dimension array
It is an array of arrays. You can do any array thing you like to an array that's inside an array, once you select it.
it wasn't clicking that it was an array nested inside an array lol
thank you!
you are all very helpful
You should count the results (outer array) before selecting on it though; depending on conditions and stuff there could be nothing in it
yes I have a check for that already in case the array is empty (nothing below the player)
okay so I am still running into one issue, I've selected down to an array which has my position values, but it claims it is only a 1 count array, however when I select into that array it only returns the x value]
trying to select position 1 or 2 returns an error as there isn't a position 1 or 2 despite the array now just being [x,y,z]
(formatted as array length count, value of array, and a text break)
oh wait
my debug is bad nevermind
yep my bad, thank you
Is there anyway to hide a selection on an object which is not a simple object?
animateSource maybe. Not my thing.
Yeah, my issue is I'm trying to use ACE interactions on memory points, but need to be able to hide selections on the model that has the ACE interaction
ACE interactions won't work on simple objects unfortunately
Is there a way to do allMapMarkers but for areas placed in the editor? Like the ellipse and rectangle areas?
Those are markers and they're included in allMapMarkers.
_ellipsesAndRectangles = allMapMarkers select {markerShape _x in ["RECTANGLE","ELLIPSE"]};
Anyone know if it's possible to make TFAR short wave radios have infinite range or let Zeus hear all radio chatter without range limit?
Trying to make the items in a ground holder object appear completely level, been messing with https://community.bistudio.com/wiki/setVectorDirAndUp but I don't seem to remember vectors as much as I thought I did
Ah figured it out, I had forgot to put back the sin, cos, etc.
I want to do something seemingly simple but i keep getting myself confused with all the different types of positions and vectors..
I have 2 objects placed in the editor. And I want to get the relative position between them (coordinates, rotation etc) so I can later move object 2 and place them the "same way" even if the first object moved elsewhere.
when I try object 2 either ends up on the other side of the map or inside object 1 and not how i placed it
getRelPos
hmm, that one only returns [0,0,0] in my case, and they are not at the same position
Okay so im back. Sorry for the delay. How does one do this? Reading the wiki it seems like I should put it in the script?
Use diag_log to print the value of player at the moment of execution to the RPT file.
diag_log format ["HAMSCH DEBUG: value of player in <your script file name here>: %1",player];
if it prints <NULL-object>, there's your problem.
Hello again folks. So i had a script that you guys helped me back in 2021. This was the code that is inside the file "initPlayerLocal.sqf". Basicly it sets a certain insignia to the character based on the name. After 3 seconds it will reset to the same insignia as before. The problem is. The 3 seconds delay does not work. How can i fix it?
_player addMPEventHandler ["MPRespawn", {
params ["_unit", "_corpse"];
_insignia = call {
if ("[OR-1]" in name _unit) exitWith {
"insignia1";
};
if ("[OR-2]" in name _unit) exitWith {
"insignia2";
};
if ("[OR-3]" in name _unit) exitWith {
"insignia3";
};
//default insignia in case none of the above match:
"insignia0";
};
[_unit, _insignia] spawn {
params ["_unit", "_insignia"];
sleep 3;
isNil {
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
};
};
}];```
You mean it works but there's no delay, or what?
When i join the mission every player recieved the correct insignia, but if they go to arsenal and change it. The code does not re-apply the correct insignia
What's the correct insignia in that case?
All that code does is set the insignia on respawn. There's no arsenal handling.
for players with "[OR-1]" on they're name should be re applied the "insignia1"
when?
I know there is no arsenal handling. What i'm saying is in case a players goes to the arsenal to change it.
It doesn't goes back to the correct insignia
gives up
We're not mind-readers. You have to describe exactly what you want the code to do.
ok. I'll try again.
When a player joins the server with the custom tag [OR-1] the server will set an insignia1 to that player, if another player has [OR-2] it will set the insignia 2. If none of the above it sets another insignia for example insignia4. While the server is running i want the insignias to be set again to the character every 3 seconds.
Instead of the MPRespawn, yes
My problem is: with the code above, the players when they join the server they get the correct insignia. When they die, they don't recieve the insignia.
add while alive unit on initplayerlocal
I'm gonna check the BIS_fnc_setUnitInsignia code because Leopard's example doesn't make sense if it's really global effect.
and Leopard usually knows what he's talking about :P
theres some problems with setobjecttextureglobal in mp iirc
Exactly, he provided me this code in 2021. After a few years i decided to use it again, but now didn't worked. Idk if i should have anything set on the editor, or is just code.
If executed from an object's init field (which should not be done anyway for GEGlobal commands), execution may happen too early and fail to broadcast over the network and to be JIP compatible.
This is running later, should be fine. Probably :P
we have a few bug reports about it in usp with insignia func
and theres a handful of problems with it in aceax, dunno if those were fixed or not
image that was provided
We currently use the AIO version of the mod and I've noticed an issue when we use bis_fnc_setUnitInsignia
I have a script (I've mentioned it before) that adds the blood type patch for each player to their shoulder using[_unit, "USP_PATCH_BLOOD_OPOS_BLK_ALT"] remoteExec ["bis_fnc_setUnitInsignia", 0];
similar problems got reported to me directly but those were aceax related meaning issue is almost certainly with setobjecttextureglobal
i think i may have brought it up with dedmen at some point but cant be sure
But does this have anything to do with ace ?
no its a bug with the scripting command/bi func
hm... ok
is the insignia being applied at any point atm
yes do what i said with initplayerlocal
when the mission starts they recieve the correct insignia
definitely dont create a new scheduler thread for each respawn
I'm sorry, i'm new... what should i do exactly ?
i did
sshow
i literally said not inside an eh
?
So should i delete anything from the code ?
it shouldnt be inside an event handler
the words event handler shouldnt be in initplayerlocal.sqf
banned
use a while loop instead
this?
no
read the wiki pages i sent you
What should be the condition for the while.. alive ?
already told you
Ok, i'm starting to understand the logic, but how do i type it on the code ? Because the wiki has examples but i don't see how
like this?
no
;_;
is that how any of the wiki examples look
no need for params
oh yeah i forgot this needs to be scheduled
params ["_player"];
[_player] spawn {
params ["_player"];
while (alive _player) do {
//code
sleep 3;
};
};```
But how does it apply the insignia after the 3 seconds ?
What is the code ?
hang on thats written a bit daft let me just rewrite it
Because i also see there " [_unit, _insignia] spawn {"
I can send the file here
params ["_player"];
[_player] spawn {
params ["_player"];
while {alive _player} do {
private _name = name _player;
private _insignia = switch (true) do {
case ("[OR-1]" in _name): {"insignia1"};
case ("[OR-2]" in _name): {"insignia2"};
case ("[OR-3]" in _name): {"insignia3"};
default {"whateveryouwanthere"};
};
_player setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_player, _insignia] call BIS_fnc_setUnitInsignia;
sleep 3;
};
};```
use that instead
in "initPlayerLocal.sqf" ?
yes
ok, testing.
One thing. If the players does not have none of the tags above he should get a specific insignia.
edited for it
Sorry what does that do ?
If a player have none of the tag above receives for example "insignia12" ?
So they will recieve a insignia for a specific tag ?
but in between "" what represents ?
you tell me, its the script you provided
the tag or the name of the insignia ?
insignia
but is in between ""
should it be default {"insignia12"}; or default {insignia12}; ??
quoted
have you changed the insignias to the proper ones
yes
show your initplayerlocal
add:
systemChat str _name;
systemChat str _insignia;
before the call bis_fnc_setunitinsignia
like this ?
yes
got this error
oh
duh
change while (alive _player) to while {alive _player}
brackets go to curly braces
my bad i dont use while i use cba
it's alright i didn't saw it either
testing
it said the name and the insignia. Wich is great. The insignia now appears. But if i go to arsenal and i change the insignia i wanted the server to force the character to have that specific insignia and not the one that was choose from the arsenal
if its still saying the names and not overwriting after 3 seconds thats a problem with bis_fnc_setinsignia
I only got the message when i joined the server.
That's the same problem with the code that Leopard sent me.
change all instances of _player to player
When i join the server the script works. If i die or i change it on the arsenal, it doesnt force the correct insignia
ok, testing.
Same problem.
Does this code keeps updating the insignia every 3 seconds ?
uh
should be yes
I only get 1 message, yes.
try note out the top two lines and the bottom line
with // at the start of each of them
like this right ?
yes
Same problem as before, but this shows up:
It only sends 1 message
get rid of the // and check in a differenet mission file
though its gone 1am so i should probably stop trying to debug its a pointless exercise
issue rests with something in your scenario messing stuff up then most likely
Copy
I'll see what i can do
thanks
how do i delete the messages btw ?
systemchat ?
yeah just get rid of systemchat lines
Found something. There was something that i didn't realised. the script does not loop if i set a respawn point!
For example, I did not set a respawn point, it was looping. I did set a respawn point it did not looped.
Hi guys,
I am trying to teleport players p1, p2, p3 and p4 to the positions of padWest0, padWest1, etc.
But I have problems with the array _getPosWest = getPosASL padWest select _num4;. When I run the code I get this error message: "Error getposasl: Type Array, expected Object". Can someone tell me how to make getPosASL take the position of the selected array element?
_num4 = 0;
teamWest = ["p1", "p2", "p3", "p4"];
padWest = ["padWest0", "padWest1", "padWest2", "padWest3"];
{
_select4 = teamWest select _num4;
_slectPadWest = padWest select _num4;
hint str _slectPadWest;
_getPosWest = getPosASL padWest select _num4;
_select4 setPosASL _getPosWest;
_num4 = _num4 + 1;
sleep 0.1;
} forEach teamWest;
What exactly are padWest0s? Markers?
no, invisible helipads
not to sound rude, but my eyes are bleeding
They should be indicated without quotation marks. With them, they're just strings
Same for p1s too
I tried it but get the same error massage
Well what I've said is not the only error there
Give me a few to point things
"p1"is a string, not an object so it cannot fetch any object info. Same for other objects._num4is not necessary._forEachIndexis a thing to count the current iteration index in aforEach.teamWestandpadWest, if they are only for this script, they should be defined in locally. AKA, put_as prefix.- You are iterating
teamWestusingforEachbut you didn't use_xand have_select4instead._xis the magic variable to use the current item of the iteration. _selectPadWestis unused.getPosASL padWest select _num4should have a bracket to select the current pad sogetPosASL (padWest select _forEachIndex).
- you can get contents of global variable by its string name like this:
private _value = missionNamespace getVariable "p1";
Well that's a thing too, but it looked very workaround for no reason to me
p1/p2/p3/p4 aren't guaranteed to exist if players aren't connected when the code is running
I have stored above in the script only the players in an array which are also on the server. After that I split the array into two new ones. Once for all Bluffer players in teamWest and all Opfor players in teamEast
Thanks for your feedback I try to implement it then
How do you use initPlayerLocal.sqf, do you just create the file in the mission folder and put your code in there or do you have add any default options or wrap the code in something first?
Also how to stop the auto reporting in chat? "Enemy front, 200 meters" thing (Auto reporting in difficulty settings only removes automatic map markers)
disableAI "RADIOPROTOCOL" should do
Hello, I am trying to remove or replace some lights via script. The problem is that both using setdamage, setHit, switchLight, hideObject etc. Nothing seems to remove some lights from the streetlights anymore. The latter can also be destroyed with a tank shot but their light persists
maybe it's a modded terrain that doesn't allow damage to this model?
Hello Lou, no no it was Altis. I'm surprised as well. No mods, the Altis airport's lamps where I was testing
hmm, can you provide coordinates/model, and how you scripted it?
sure just a sec
I shalt wait… this time
{_x allowDamage false; _x hideObjectGlobal true; _x enableSimulationGlobal false} forEach [
_oldLamp
];
private _newLamp = createVehicle ["Land_LampStreet_small_F", _oldLamp getPos [0, 0], [], 0, "CAN_COLLIDE"];
_newLamp setDir (direction _oldLamp);
_newLamp setPosATL (getPosATL _oldLamp);```
(sorry I had my pc off) just a simple example of how it can be replaced with another object. But as mentioned, I could use any method, such as even a module to hide the old lamp or even shoot it from a tank and its light would still persist.
can I show a picture?
the light stays there despite the fact that you can destroy or hide the lamp
isn't that strange?
oh that's because you disabled its simulation
just hide it and it should be fine, or turn it off before doing so 🙂
this was a simple example. I have tried them all. Even just with hideObject, or for example, a module for hiding objects. In this picture I simply used a tank and shot the lamp, without scripts
wat
yep that's weird
investigating [15296.1,17513.1,0.0281658] right now 😄
haha
I mean, I don't want to waste your time forgive me
I was just surprised tbf
omg I feel bad now 😅 I last thought that it might be a problem with some cached files. If the experience should be different for you then that would be the problem
thanks anyway i appreciate it
"Last usage: September 18th" 🕵️
you've been busy, which is a good thing
cursorObject setDamage 1;
```kills the lamp properly
maybe some scripted system?
cursorObject enableSimulation false;
cursorObject setDamage 1;
```yep
that's weird hmm, don't use mods and as I mentioned I can join and shoot the lamp with a tank - my lamp falls to the ground but the light stays on and suspended. I will try to verify cache integrity* and maybe write back to you. I apologize!
no worries
did you try it on a blank new empty Altis, no nothing, no mission or scripts or anything?
yes yes that's what triggered me
I don't know, I'm confuse but at the same time happy that this is not a thing for you
well, I'm using profiling branch too but that shouldn't be the issue otherwise more people would have reported it
I recommend checking Steam files indeed, and if it does not solve it… #arma3_troubleshooting I suppose - sorry I can't help more 😬
I agree and thanks again. Im verifying the integrity and I am at 50%, then I will test again
Hello, once again. Yesterday i showed a script made by Leopard that would force the players to get a specific insignia based on a they're arma name and that would loop every 3 seconds. The problem is, in editor if i set a respawn position, the script would not loop. So i'm assuming, if the player dies the scrip stops looping. Can anybody help me?
code:
[_player] spawn {
params ["_player"];
while {alive player} do {
private _name = name _player;
private _insignia = switch (true) do {
case ("[O-2]" in _name): {"insignia6"};
case ("[OR-2]" in _name): {"insignia2"};
case ("[OR-3]" in _name): {"insignia3"};
default {"insigia7"};
};
_player setVariable ["BIS_fnc_setUnitInsignia_class", nil];
systemChat str _name;
systemChat str _insignia;
[_player, _insignia] call BIS_fnc_setUnitInsignia;
sleep 3;
};
};```
P.S.: I had a scrip that Leopard helped me out in 2021, i've posted that one yesterday. I don't know wich one is easier to work with.
I'm pretty sure I never wrote such a thing
Not thise one.
This one
where are you adding it?
initPlayerLocal.sqf
did it work before?
I guess the MP event is broken somehow (not added after respawn) 
-Yesterday at 2AM i was testing out different approaches and the conclusions that i got with that script you provided me was:
Player with no respawn set. The insignia is not applied, neither refreshed.
Players with respawn set. The insignia is first applied but not looped.
-The one that KJW provided me was:
Player with no respawn set. The insignia is applied and refreshed.
With a respawn set. The insignia is first applied but not looped
consistent to this?
@dark pecan maybe try this instead
fnc_setInsignia = {
params ["_unit", "_insignia"];
sleep 3;
isNil {
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
};
};
fnc_getInsignia = {
_insignia = call {
params ["_unit"];
if ("[OR-1]" in name _unit) exitWith {
"insignia1";
};
if ("[OR-2]" in name _unit) exitWith {
"insignia2";
};
if ("[OR-3]" in name _unit) exitWith {
"insignia3";
};
//default insignia in case none of the above match:
"insignia0";
};
_insignia
};
doubledax_lastPlayer = objNull;
fnc_waitForPlayer = {
while {!alive player} do {sleep 1;};
player addEventHandler ["killed", {[] spawn fnc_waitForPlayer}];
player addEventHandler ["Deleted", {[] spawn fnc_waitForPlayer}];
[player, player call fnc_getInsignia] call fnc_setInsignia;
};
[] spawn fnc_waitForPlayer;
it's not exactly good but 
Ok, and this works with anyone on the server right ?
I'm opening now arma to test it
sorry.
if that doesn't work either:
fnc_setInsignia = {
params ["_unit", "_insignia"];
sleep 3;
isNil {
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
};
};
fnc_getInsignia = {
_insignia = call {
params ["_unit"];
if ("[OR-1]" in name _unit) exitWith {
"insignia1";
};
if ("[OR-2]" in name _unit) exitWith {
"insignia2";
};
if ("[OR-3]" in name _unit) exitWith {
"insignia3";
};
//default insignia in case none of the above match:
"insignia0";
};
_insignia
};
doubledax_lastPlayer = objNull;
while {true} do {
while {doubledax_lastPlayer isEqualTo player} do {sleep 1;};
[player, player call fnc_getInsignia] spawn fnc_setInsignia;
doubledax_lastPlayer = player;
};
sorry for the ping, I wanted to thank you again. Today I learned thanks to your helpfulness that some files can apparently "jump" after a game update -- I assume the last one, since I don't habitually put my hands on the folders. Now module, scripts etc. work, thank you so much and sorry!
well in this case player is local so it should be irrelevant 
I guess MP one runs globally?
maybe that's why it doesn't work
Leopard, one question, does the respawn cooldown has something to do with the sleep 1 ?
you can also try that like this:
params ["_player"];
_player addMPEventHandler ["MPRespawn", {
if (!local _unit) exitWith {};
params ["_unit", "_corpse"];
_insignia = call {
if ("[OR-1]" in name _unit) exitWith {
"insignia1";
};
if ("[OR-2]" in name _unit) exitWith {
"insignia2";
};
if ("[OR-3]" in name _unit) exitWith {
"insignia3";
};
//default insignia in case none of the above match:
"insignia0";
};
[_unit, _insignia] spawn {
params ["_unit", "_insignia"];
sleep 3;
isNil {
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
};
};
}];
no
zero problem, the server is here to help! anytime 🍻
The three scripts the same thing. If i die, it does apply the correct insgnia. While the character is alive it doesn't loop.
Leopard another question. The 3 seconds of delay are also applied when the unit is alive ?
Is there a way to disable respawn for one specific unit?
I have an 8v1 manhunt scenario so I'd love if the solo player either never respawned or respawned instantly/after 10 seconds whereas the 8 hunters have a 2 minute respawn
Not really, but you can respawn everyone instantly, and do the timer afterwards. You can teleport the waiting players into a locked vehicle, or a far away island, etc
How would the timer afterwards work?
Like respawn them instantly and freeze them with enableSimulation false; for X seconds?
spawn/sleep. ah, you can try that, it may not be very friendly to player experience tho.
If I respawned them instantly and then did sleep, they'd still be able to walk around and do stuff no?
You can teleport the waiting players into a locked vehicle, or a far away island, etc
Mm okay
how do I detect if a variable is undefined? I would like to exit if my variable is not yet defined but isNil and isNull don't work unfortunately
you're probably using isNil incorrectly.
if (isNil "myVar") exitWith {}
Note the quotes.
it's not supposed to loop. it's supposed to apply it when you die
it should apply to an alive unit obviously
if you want to loop it:
params ["_player"];
_player addMPEventHandler ["MPRespawn", {
if (!local _unit) exitWith {};
params ["_unit", "_corpse"];
_insignia = call {
if ("[OR-1]" in name _unit) exitWith {
"insignia1";
};
if ("[OR-2]" in name _unit) exitWith {
"insignia2";
};
if ("[OR-3]" in name _unit) exitWith {
"insignia3";
};
//default insignia in case none of the above match:
"insignia0";
};
[_unit, _insignia] spawn {
params ["_unit", "_insignia"];
sleep 3;
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
while {alive _unit} do {
waitUntil {sleep 1; _unit getVariable ["BIS_fnc_setUnitInsignia_class", ""] != _insignia};
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
};
};
}];
I will try it now. Thanks for replying!
made a small change btw while {true} -> while {alive _unit}
Ok, but Leopard if you have time, could you answer this. Why did the script didn-t worked this time? Back in 2021, it would loop after death and even when alive?
curiosity
Back in 2021, it would loop after death and even when alive?
no it shouldn't have
there was no loop in there
Weird... I remember when someone changed the insignia in arsenal after 3 seconds it would be re-applied...
But ok it works now
Is there a way to store a variable local to an individual object? Like if I want a trigger to store who activated it last? And if not then how could I accomplish this?
setVariable yes
👍
Sorry for the noob questions but im messing around with the "setVariable" stuff with ALiVE and for some reason it keeps telling me this line is missing a "]" but I cant see a missing bracket anywhere.
_x setVariable [_sectorOwner, ([getposATL _x, triggerArea _x select 0] call ALiVE_fnc_getDominantFaction), true)];
Last ) shouldn't be there.
I would strongly recommend the Advanced Developer Tools mod. You can paste code into it and it has a very good chance of highlighting the syntax error correctly, unlike Arma itself.
Ive not heard of that
It worked. Sorry for the ping. Just to let you know it's fixed!
Where can I find it?
Once again thank you Leopard.
I only picked up this SQF stuff a couple days ago, only got notepad++ configured for it yesterday
I don't know anything outside Arma that's any good at SQF syntax, unfortunately.
last time I checked a few people are creating new language servers for VSCode in #arma3_tools
didn't have time to test it
It's pretty nice
I was working on one myself but didn't finish it (it's still very far from complete). if that one's nice I don't have to anymore 😅
Just as an example
does it also warn about incorrect args in arrays?
e.g. player addAction [player]
nope
I sort of had that one working (extracted info from wiki)
but since wiki was inconsistent it was broken sometimes
I have some issues with some vector stuff, I want to first save the position of a object in relation to another. save the needed info and later use that to find that relative position again.
It kinda works but I need to make the relative direction work correctly, right now it is always the same direction even if the car has rotated.
this is what I have, it is a test written in the console only so far but I hope you get the idea.
private _vPos = getPos car;
private _tPos = getPos testObj;
vDir = _vPos vectorFromTo _tPos; //not correct..
dist = car distance2D testObj;
//these values will be saved and used to restore Pos later
//vDir = [0.803501,0.326796,0.497584];
//dist = 1.24032;
private _distVector = vDir vectorMultiply dist;
private _finalPos = _vPos vectorAdd _distVector;
testObj setPos _finalPos;
There is getRelDir
Also you could replace those two with vectorDiff. You have potential issues with the Z coordinate either way though.
don't use getPos and setPos. read the wiki page
the correct way to do what you want is this:
_relPos = car worldToModel (testObj modelToWorld [0,0,0]);
_relDirAndUp = [vectorDir testObj, vectorUp testObj] apply {car vectorWorldToModel _x};
// now to go from relative to absolute:
testObj setPosWorld (car modelToWorldWorld _relPos);
testObj setVectorDirAndUp (_relDirAndUp apply {car vectorModelToWorld _x});
a thread for each respawn adding a new loop each time? 🤨
each loop ends once the unit is dead
oh ofc duh
How can I make a music track loop for all players in an MP scenario?
Say I have a song. It's 3 minutes long in total. The music between 0:30 and 2:00 of the track are a big looping segment. When the song hits 2 minutes, I want it to restart at 0:30 until the conditions are met for it to stop looping. When that happens, it just plays through to the end at 3:00 instead and fades out. The song already does this on its own.
How can I do that?
For context, I am using a video game soundtrack from Project Wingman (with permission) for a mission I'm doing. The songs are built to loop. I just need to make them loop in ArmA, preferably without having to open audacity to upload an unnecessarily long 30m "extended" version to my mod list or mission.
wow, thanks! that one worked perfectly!
Leopard. About the mods i've realised something. When i get to the arsenal and i grab any piece of gear the insignia disapear.
But the rest is perfect!
Any reason I am having receiving bool type errors with this?
params["_player"];
_uid = getPlayerUID player;
if (_uid in AdminList) then {true} else {false};
waitUntil{!(isNil "AdminList")};
_isAdmin = player call fnc_isAdmin;
if {_isAdmin} then {
player addAction ["Admin Menu", {execVM "fnc_openMenu"}];
player addAction ["Open Menu", {execVM "scripts\openMenu.sqf"}];
};
the second block is where im having the issues.
cant remember of the top of my head if ; at end of final line stops returning or not
i think it does
i.e get rid of the ; at the end of fnc_isadmin
So Im using a forEach loop to access every trigger in my mission:
forEach (allMissionObjects "EmptyDetector");
However, when I try to run setTriggerStatements on _x it errors saying that its an array not an Object?
_x setTriggerStatements [
Am I misunderstanding something?
no
execVM "fnc_openMenu";
this is wrong
if (_uid in AdminList) then {true} else {false};
can simply be_uid in AdminList
the second block is where im having the issues.
which second block?
anyway, I doubt fnc_isAdmin is defined
No I specifically created a function for it
use allObjects, not allMissionObjects
post the full code
if you type fnc_isAdmin in console does it give you anything?
oh nvm I missed that you're using {} here : if {_isAdmin} then {
should be if (_isAdmin)
I'm not at home, but yes. The first code block is the fn_isAdmin
The 2nd code block is Initlocalplayer.sqf
OH
I appreciate it friend
{
if (typeOf _x isEqualTo "EmptyDetector") then {
//Create Marker on Trigger and Assign it to Trigger
_newMarker = createMarker [format["check%1", str(_count)], getPos _x];
_newMarker setMarkerShape "ELLIPSE";
_newMarker setMarkerSize [triggerArea _x select 0, triggerArea _x select 1];
_newMarker setMarkerColor "ColorWhite";
_newMarker setMarkerDir (triggerArea _x select 2);
_x setVariable ["_localMarker", _newMarker, true];
//Create Flag on Trigger and Assign it to Trigger
_newFlag = createMarker [text(nearestLocation[getPos _x, "nameCity"]), getPos _x];
_newFlag setMarkerType "flag_Poland";
_newFlag setMarkerText text(nearestLocation[getPos _x, "nameCity"]);
_newFlag setMarkerSize [1,1];
_x setVariable ["_localFlag", _newFlag, true];
//Set first owner of area
_x setVariable ["_sectorOwner", ([getposATL _x, triggerArea _x select 0] call ALiVE_fnc_getDominantFaction), true];
//Create Trigger Logic
_x setTriggerStatements [
([getposATL thisTrigger, triggerArea thisTrigger select 0] call ALiVE_fnc_getDominantFaction) isNotEqualTo (thisTrigger getVariable "_sectorOwner"),
switch([getposATL thisTrigger, triggerArea thisTrigger select 0] call ALiVE_fnc_getDominantFaction) do
{
case "LIB_WEHRMACHT": {(thisTrigger getVariable ["_localMarker", "notFound"]) setMarkerColor "ColorBlue"; (thisTrigger getVariable ["_localFlag","notFoundFlag"]) setMarkerType "LIB_Faction_WEHRMACHT";};
case "LIB_RKKA": {(thisTrigger getVariable ["_localMarker", "notFound"]) setMarkerColor "ColorRed"; (thisTrigger getVariable ["_localFlag","notFoundFlag"]) setMarkerType "LIB_Faction_RKKA";};
case "LIB_GUER": {(thisTrigger getVariable ["_localMarker", "notFound"]) setMarkerColor "ColorGreen"; (thisTrigger getVariable ["_localFlag","notFoundFlag"]) setMarkerType "flag_Poland";};
},
""
];
_count = _count + 1;
};
}forEach (allMissionObjects "EmptyDetector");
Thats the whole foreach loop. Im very new to SQF and am messing around with a capture point system for an ALiVE mission I made for some of my friends a while back for context. Probably a lot wrong with it but Im unsure why the _x is being seen as an array
You don't need the typeOf isEqualTo check, since you've already filtered it down to only being "EmptyDetector" objects by using the parameter for allMissionObjects
The trigger statements are being set wrong. They need to be given as strings, because you're trying to pass code to evaluate later, rather than code to evaluate now and then pass the result of that code.
Yeah I just havent fixed that yet
Makes sense
Note: some commands that need code to evaluate later can accept it as a Code type - denoted by {} - rather than a string. It's nice when they do that because you don't need to escape " in the code, but setTriggerStatements only takes Strings. Make sure to check the documentation for a command to see what data types it uses.
When you convert your trigger statements to string, you should either wrap them in ' rather than " as normal, or change the " inside the code itself to be '. Or use double " inside the code. Using the same type and quantity of quotes as delimiters both inside and out will confuse the game.
Hello Leopard sorry for bothering you again. First of all thank you for all the help that you gave me. Seriously. But with playing with the script i've realised something.
So when i get on arsenal if i pick any gear the insignia doesn't get assigned. The only time the insignia appears, is if i select another insignia or if i die.
_player addMPEventHandler ["MPRespawn", {
if (!local _unit) exitWith {};
params ["_unit", "_corpse"];
_insignia = call {
if ("[E-1]" in name _unit) exitWith {
"";
};
if ("[E-2]" in name _unit) exitWith {
"insignia6";
};
if ("[E-3]" in name _unit) exitWith {
"insignia7";
};
[_unit, _insignia] spawn {
params ["_unit", "_insignia"];
sleep 3;
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
while {alive _unit} do {
waitUntil {sleep 3; _unit getVariable ["BIS_fnc_setUnitInsignia_class", ""] != _insignia};
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call BIS_fnc_setUnitInsignia;
};
};
}];```
At least I assume thats what this debug is trying to tell me
_x must be an Object to begin with, because allMissionObjects only returns Objects, and if it wasn't it would fail the typeOf check. It would also fail at any of the setVariables since they can't accept Arrays as namespace targets.
Add a systemChat str _x; both before and after the _x setVariable ["_sectorOwner" ...] line.
Oh, also, you shouldn't use "_varName" with setVariable - it sets global scope variables, not local scope, and trying to use the local scope _ prefix may confuse it.
So youre right, for some reason the _x is becoming an array after that line but why is that happening?
My suspicion is that that ALIVE function is doing something with an _x and not protecting it properly, so it's overwriting your _x.
called code - even functions - is not really a separate scope. It's as if that code were run inline here in your script. It is a subscope, which means there can be crossover if variable assignments in the lower scope aren't done safely.
tfw you forget that selectRandom exists
selectedRoad = _filteredNearbyRoads select floor random [0, count _filteredNearbyRoads / 2, count _filteredNearbyRoads];```
Looking at the function I am calling I think you may be right but is there any way around that? Can I specify the _x Im using?
You can save your _x to a different private variable and refer to that instead
You know that's more likely to pick the roads in the middle of the list...
e.g. private _trigger = _x; at the start of the forEach
I am aware. This is a smaller section of a larger area.
My last Question for today.
On an item I have this
Alpha addAction ["Teleport Map", {execVM "scripts\Teleport_Map.sqf"}];
and what I am trying to format and execute is something like this
onMapSingleClick
{
_Teleports = [Alpha, Bravo, Charlie, Delta] select {(_pos distance2D getPos _x < 10)};
if ((_Teleports isEqualTo [])) exitWith
{
hintSilent "Please select a location to teleport to";
};
selectedTELE = _Teleports select 0;
hintSilent format ["Selected Location: %1", (((str selectedTELE) splitString "TELE") select 0)];
((uiNamespace getVariable "disp_respawnSelectionMenu") displayCtrl 800) ctrlAddEventHandler ["ButtonClick",
{
if ((speed selectedTELE isEqualTo 0)) then
{
hintSilent format ["You have respawned at location #%1", (((str selectedTELE) splitString "TELE") select 0)];
player setPos [(getPos selectedTELE select 0), ((getPos selectedTELE select 1) - 8), (getPos selectedTELE select 2)];
} else
{
hintSilent "Teleport currently unavailable.";
};
}];
};
edit: Reformatted properly.
What's the question?
Oh sorry, How can I get that bottom code block to be executed properly? While I got it formatted I can't get it executed alongside the GUI of the RscMap as well
onMapSingleClick only works on the map that can be opened by M key
replace the waitUntil with just sleep 3 then
Shouldn't this only add the action for independent players?
if (isServer) then
{
_independentPlayers = (playableUnits + switchableUnits) select {side group _x == INDEPENDENT};
[this, ["Sabotage UAV terminal", { 0 spawn sabotageUav; }]] remoteExec ["addAction", _independentPlayers];
};
sabotageUav = {
_bluforPlayers = (playableUnits + switchableUnits) select {side group _x == WEST};
reaper_uav setFuel 0;
"Someone has sabotaged our UAV comms terminal at the airport.." remoteExec ["systemChat", _bluforPlayers];
deleteVehicle reaper_uav;
};
I'm able to use the action as BLUFOR
Also the systemChat message pops up for each Blufor player for some reason?
Hello I am try to use a trigger like a power up in my death race but I can’t seem to figure out how to give the cars the ammo. I figured out the condition part that detects if any vehicle is in the trigger. If anyone has any ideas please let me know. Thanks
because you are remoteexecing it for each blufor player
this
so I'm trying to have a trigger delete multiple objects (t1-t8) at once and I'm using this code:
{deleteVehicle _x;}foreach Trigs;```
however it causes an error, saying "deleteVehicle: type=string, expected object" but shouldn't foreach make it so it effectively does deleteVehicle t1; deleteVehicle t2; and and so on?
No. forEach is indeed operating on each element of the array - but each element is a "string", and forEach does not automatically convert strings into variable names (otherwise you could never use it to do things to strings).
In other words, your forEach is correct, but the array you are telling it to work on is wrong.
forEach is doing deleteVehicle "t1";, but you need it to do deleteVehicle t1;.
yeah, it seems changing it to Trigs = [t1,t2,t3,t4,t5,t6,t7,t8]; fixed the issue, thanks for the help
Hello again :D
Got a new question. In the example below, the parseSimpleArray will encounter a script error as intended and stop parsing the array.
My question is:
Is there a way to detect the error it gives or be able to tell?
So if the parseSimpleArray runs into something it can't parse, then I exit the script.
_arr = [1, 2, 3];
_arr = parseSimpleArray "[4, 5, 6, player, 7, 9, 10 , {hint "codeblock"}, _something]";
_arr; // Value will be [4, 5, 6]
Simple array is array consisting of Numbers, Strings, Booleans and Arrays of all of the above
scripting commands, code blocks and variables aren't any of these
Why do you want that array as a string anyway?
Yes, I am trying to detect if the user has entered something that isn't one of these.
Letting user input arrays sounds like a wrong design
#arma3_scripting message
#arma3_scripting message
TL;DR
I am taking an array from a player to use in a script, and I am using parseSimpleArray to ensure that nothing but Numbers, Strings, Bolleans, and arrays are within it.
So in the script/function I am running, I would like to know or detect if the parseSimpleArray command ran into anything other of the data types above, so if it did, I know to stop and inform the logged in admin, otherwise if all values are safe, then to use the array in the function.
🤔
My first guess was to turn resulting array back into a string and compare, but user can play around with quotes and spaces so it won't match even if valid
Perhaps you can write a regular expression to check?
I suck at those to suggest a good one
Check what exactly with a regex?
The input array
I'm not too good with them either but I've already used them to figure out it's an array, not sure how to go any further.
params ["_unit", "_importPlanList"];
if (_unit in _importPlanList) then {
_statement = {
[
[true,""],
"Import PLANOPS plan",
{
if _confirmed then {
[format["Plan import attempt by: %1 | ID64: %2 | Import text: %3", name _unit, getPlayerUID _unit, _text]] remoteExec ["diag_log", 2, false];
private _plan = _text regexFind "/private _data = \[.*\];/";
if (count _plan >= 1) then {
_plan = _plan regexFind "/\[.*\]/";
_plan = parseSimpleArray _plan;
}
} else {
systemchat "Plan Import Cancelled";
};
},
"Import",
"Cancel"
] call CAU_UserInputMenus_fnc_text;
};
_action = ["Import Plan", "Import Plan", "\A3\ui_f\data\map\markers\military\marker_CA.paa", _statement, {true}] call ace_interact_menu_fnc_createAction;
[_unit, 1, ["ACE_SelfActions"], _action] call ace_interact_menu_fnc_addActionToObject;
};
Please keep in mind this is still WiP >_>
[243896,10070.059095270643,16435.54391209993,"mil_dot","ColorGreen","Alpha",0,1] Is this the typical array user is going to input?
Copied from one of your linked messages
Not exactly, the array the user inputs has 3 arrays inside it which each contain more data:
- 1st array contains Vanilla arma 3 markers
- 2nd array contains poly/lines if I understood correctly
- 3rd array contains markers from a mod and their info
If you know what arrays should be then you can simply validate them by data type and array sizes
If validation fails after parseSimpleArray due to bad array or data supplied, then you don't proceed
Do you have an example? I unable to understand how to do that.
private _arr = parseSimpleArray _user_string;
if(count _arr != 3) exitWith {hint "You messed up";};
_arr params ["_vanilla_markers", "_poly_points", "_mod_markers"];
if(_vanilla_markers findIf {
//...validate each vanilla marker here...
} >= 0) exitWith {hint "You messed up"};
//...etc for other data...
Hi .. I wanted to ask the experts about AI disembarking from helicopters that have doors on both sides. My current system has AI cargo exiting the heli one at a time, via one side. Is there a FNC anywhere in circulation that might utilise both doors so the drop-off can be sped up?
Hi guys, is there a way using SQF to determine the addon which items in cfgweapons belong to ? i can only really see author which isnt definitive
But in that case if the last array of the nested arrays contained an acceptable value first then the 2nd value was wrong it would still result in 3 arrays, now?
so if the _user_string is for example:
_user_string = "[[accepted data here],[accepted data here],[accepted, denied]]";
The result would be:
_arr = [[accepted data here],[accepted data here],[accepted]];
As it would stop once it runs into an error and not just cancel the whole array.
Best course of action imo is to recursively check each element with one of the 'isEqual' commands to determine if each element is acceptable. Validating arrays is best done if you standardize the input array.
It kinda feels like the best way to handle this is with an extension, which can take the initial input and evaluate & validate it in a safe (i.e. not being executed in SQF) context
The issue is if you try to access an array's element, it gets executed.
So in the provided example here:
_arr = [4, 5, 6, player, 7, 9, 10 , hint 'code', _something];
If I were to do:
if (_arr select 7 == something) then {//code};
then the code would be executed if I remember correctly.
Possibly, was hopping to find a way to do it through SQF and specifically through a mission file, but will start looking into other options.
They'll have an error shown to know something was wrong
Where would that error be shown? How would the script detect it?
I know there will be a script error shown tho most players have that disabled.
Oh yeah, not everyone has showScriptErrors enabled
Hmm, what if you count number of square brackets in original string VS in str of parsed array?
Does the scriptError EH fire even if show script errors is off? 🤔
(This is probably not a good solution either way)
Oh yeah, there is a ScriptError event handler now, could be used here
Details please, couldn't find anything like that on the wiki.
Oh I was looking in https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
Hmmm, will see if I can make it work, thanks a lot for all the help so far.
- Parse array, set valid flag to true.
- If
ScriptErrorfires with right error, set valid flag to false - If valid flag is still true on next frame, proceed using array or show an error
Should I add the event handler as part of the script and then remove it at the end of it?
Yeah it should work, up to you though.
Personally I don't like increasing EH index counter
Is there any bad side to it increasing?
And does removing the event handler reduce it?
removing all resets it
I don't think there is a bad side to it
Wouldn't removing all event handlers possibly fuck with ACE or other mods or other scripts?
Yeah it could
Def not an option then
Creating a handler returns the index of the handler
The remove command accepts an index to remove a specific handler, that could work.
Nevermind, it might not fire so you need to store it to delete in either case
Go through CfgAddons in hopes that weapon is listed in one?
What? No. using for example 'isEqualTypeParams' executes nothing. You're inspecting elements based on their type. Not their results? Maybe I'm confused at your goal here. But I would say validate the contents of the array and branch your execution accordingly.
Will take another look once back home.
I thought systemChat only appeared to the client you sent it to? It's appearing 8 times since I have 8 blufor playable units
You can simplify some of the code. For example: private _arr = parseSimpleArray _user_string; if(count _arr != 3) exitWith {hint "You messed up";}; could be : if (_user_string params ["_array",nil,[[]],[3]]) exitwith {hint "You messed up"};
try using remoteexec side West instead of collecting all the units from that side?
Ok, I wrote some lines to make it compat with CBA and now throws me errors, before that arma did not told me about errors
use #arma3_config
this channel is for scripting questions and discussion
its not listed :(
Dear ARMA 3 Scripting Community.
I am in the middle of research for using arma 3 scences in my thesis on computer vision.
Currently I am looping in a variety of articles and scripting tutorials that do not cover my request. ARMA 3's possibilities really seem infinite - wow.
Therefore I want to ask the professionals if there is any chance utilizing ARMA 3 like the Github DeepGTAV project does use GTA? (Not the exact same approach, but a chance to generate a screenshot and to retrieve and store the bounding box data in xml or json)
Example on DeepGTAV: https://youtu.be/h3By_ZOdlAc?si=feogaS4g-xLShcuY
Here we present DeepGTAV, a tool to generate synthetic training data for different machine learning tasks from GTAV. DeepGTAV allows to generate data for entity segmentation, object detection, LiDAR object detection, reinforcement learning and many more.
The application of synthetic training data for different object detection tasks is discuss...
it is possible yes
you need an extension (dll file) to read from/write to a file though
Small issue, if I were to even set the array like:
_arr = [4, 5, 6, systemChat "test2", {systemChat "test"}, 7];
// System chat will say test2 just from the line above.
then array item index 3 will be executed.
So I can not compile the array before I know it is safe to do so, hence the event handlers options seems to be safer right now.
systemChat "test2" isn't any different to, say -7 in that regard
Execute the command, put the result into the array
as in: it gets executed on putting element into the array, not on accessing it
I could have sworn something got executed on access yesterday but yea doing it now it seems that is correct.
None the less, index 4 still gets executed so compiling before verifying is still out of the question.
Thank you for the reply. Should I focus more on modding rather than scripting!? Well this will be hard to achieve 😄
modding? sorry I don't understand the question 
DeepGTA uses a mod and c# code to retrieve the information ingame. I am still locking for the necessary information in Arma3
@little raptor Any suggestions which knowlodge I should build and what kind of tutorials are essential to achieve my objective are highly appreciated. Just asking for hints. Not for the final solution 🙂
ah. yeah you need to make a dll. it can be C# but I recommend C++
I recommend using Intercept: https://github.com/intercept/intercept
it allows you do to native stuff (e.g. you can use libraries for handling JSON) while also having access to scripting features
you probably also want to store the captured screen in a memory buffer instead of writing it to a file (what https://community.bistudio.com/wiki/screenshot does), in which case you need to write your own screen capture code. PrintWindow might work but if not you'll have to capture the D3D11 buffer. idk how that works but looking at open source screen capture software like OBS could give you some clues
I'm not sure what is the most used method for IPC in python (I assume that's what you use for ML stuff), but you can always just use localhost to transfer data between the game and the python code
[obj1, obj2] call BIS_fnc_attachToRelative;
this command says "Local Argument" on the wiki, is that in reference to obj1, obj2, or both?
it makes no sense because attachTo itself says global arg
btw what do you want to use the training data for? driving, flying, etc.?
I am working on object detection models for personal (enemy, friendly, civil).
in that case I don't think you need to learn a lot of scripting. most of your task is passing the data to and from the game
but anyway here's the official wiki page for scripting tutorial:
https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
list of all scripting commands:
https://community.bistudio.com/wiki/Category:Scripting_Commands
Thank you very much for the support. 🙂
I think I need to get some basics to understand Arma 3. I am not totally sure if I should use the editor or if I can use existing scenarios which the camera is floating over by itself.
Btw. is an rifle or backpack object in the hands of a soldier also treated as an rifle/backpack object to obtain this coordinates?
they're proxy objects which are not accessible in scripts
typically you can just get the classname of the weapon or backpack using commands such as primaryWeapon and backpack which return strings
if you need their position, you have to do get the bone those objects are attached to, then translate them to world coords
backpack has backpackcontainer
an example
I don't think the container "follows" the soldier
@cosmic lichen do you have more intel? (the edit https://community.bistudio.com/wiki?title=BIS_fnc_attachToRelative&diff=126324&oldid=119689)
P.S: you can also use this C# port of Intercept if you're not familiar with C++:
https://github.com/killerswin2/RVCSS
I will go for a few arma basics before I take care of the connection to "outside" the system. Maybe this might also help me: https://github.com/overfl0/Pythia !?
it could but you can't call SQF from your Python code directly afaik
XPost @cyan loom CfgPatches should contain the class names of every cfgWeapon a pbo introduces
in those cases where it does not, you are fucked and the mod author fucked up
Doesn't work unless I'm doing it wrong :/
"Someone has sabotaged our UAV comms terminal at the airport.." remoteExec ["systemChat", side west];
["Someone has sabotaged our UAV comms terminal at the airport.."] remoteExec ["systemChat", blufor];
That'll do it, thanks :)
How tf do you trigger the Fire Module
I've made a Trigger and the condition UavSabotaged == true and synced it to the module and I know the Trigger is getting activated but nothing happens
Can someone help me with the syntax of remoteExec?
I am trying to execute the following code with remoteExec so that the task is created globally for all players.
The script is then called by the initServer.sqf and is not displayed at the moment. I guess that the task is only created locally and therefore not visible but I am not sure.
This is the code for the task:
tsk = format ["tsk%1", random 100];
[allPlayers, tsk, ["Hack the watchtower to get information about the position of the opposing players!", "Watchtower", ""], laptop, "ASSIGNED", 99, true, "download", true] call BIS_fnc_taskCreate;
it doesn't need remoteExec
Okay right it has a global effect but why is the task not created when I execute the script with initServer.sqf?
allPlayers doesn't have anything in it at that point, maybe?
If you want it available to all players then just use true
okay this works fine
Thanks
Is there a way to accomplish "deep copies" of a vehicles cargo? For example, if you had a backpack which had items, could you get a full array back of all the items inside the vehicle, and inside of that backpack, and copy it to another container, with all the same items in the backpack?
I imagine you could, but it's probably a horrible process.
How can I make an AI Artillery unit shoot once every 3 minutes for 45 minutes using Zeus? I'm trying to limit the rate of fire for a 2S1 from RHS but _this setWeaponReloadingTime [gunner vehicle _this, currentMuzzle gunner vehicle _this, 0.03]; isn't working for me. I'm missing something.
can't you run a loop that first fires the gun, then sleeps for 3 minutes, and then repeats?
as for the 45 minutes limit part, just run some sort of timer script, there are a lot out there
I'm gonna limit the round capacity to 15 rounds, that solves the 45 minute part, but i do need something to limit the AI's RoF
okay yeah, so have you figured out how to make it shoot 1 round?
just one round when the script gets triggered
Yep, just placing a target and then placing an Artillery Fire Support module on top. But after i set that, it just dumps all rounds without sleeping. what would that script look like?
_artillery doArtilleryFire [_targetPos, _magazineClass, 1];
I personally have never messed with artillery scripting tbh, but i think John has got you covered 🙂
There is not necessarily a solution that includes using the stock Zeus module. That's why we script.
this is what I'm working with here
ok, now how do I set the delay per shot?
make a loop with a sleep in it.
I'll let you know how it goes 
This feels like the least of your problems versus how to get the right variables into the script :P
How does spawn help me? I want an artillery battery to fire once every 3 minutes, not spawn something. 
for the artillery shooty shooty part
Spawn makes a thread so that you can do stuff intermittently without obstructing any other code.
You can't use sleep in an editor init box, for example.
spawn is to start the loop, if you dont use it you will experience immense lag because it runs the loop on every frame or something silly like that, I dont remember the exact reason why anymore
damn john, you're fast 😄
I was hoping there would be an out of the box solution, but I'm already imagining I'm going to have to have a few loops to accomplish this lol
So something like this in the editor init box for the artillery piece:
this spawn {
while {canFire _this} do {
_this doArtilleryFire [markerPos "myMarker", "magazineClass", 1];
sleep 180;
};
};
Obviously you would need a marker called myMarker for the target and you'd need to dig up a suitable magazine class.
this is an excellent starting point, thank you very much you absolute LEGEND!
couldn't I also do
_this addeventhandler ["fired", {(_this select 1) sleep 180}]; or something like that?
No, because sleep only pauses the script. It doesn't have any direct effect on the object.
You could do something like that with enableSimulation but it's not a good idea.
I guess that might be an option if you really wanted to use the zeus fire support thing, but it might just break it.
would look like this:
this addEventHandler ["fired", {
(_this select 0) spawn {
_this enableSimulation false;
sleep 180;
_this enableSimulation true;
};
}];
probably won't work though.
why can't arma just have a built-in "time between shots" thing, Simplex is really hard to use as well ironically
If you want it to be ambient, use modules enhanced. It has a artillery module in it. No units needed, all virtual ATM.
#selfplug
Oh I see you want Zeus though. NVM.
It can be trigger activated and you can call the function directly as well
So in effect, you can use it in Zeus, just needs a work around with ZEN
@unreal hornet https://github.com/hypoxia125/Modules-Enhanced/blob/main/addons/modules/functions/fnc_ambientArtilleryVirtual.sqf
Hey guys, any ideas why this code isn't working?
// Register a simple keypress to an action
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
mymod_fnc_keyDown = { systemChat "123" };
["MyMod", "MyKey", ["My Pretty Key Name", "My Pretty Tool Tip"], {
_this call mymod_fnc_keyDown
}, {
_this call mymod_fnc_keyUp
}, [DIK_TAB, [false, false, false]]] call CBA_fnc_addKeybind;
I press TAB but the systemChat doesn't show up, display 46 definitely exists, any ideas why this is happening? Launching code from console execVm "asd123.sqf", in game
@unreal hornet I sent you a friend request. I've been playing with some cool/immersive artillery scripts that I can share.
please ignore how crap the code is:
removed
why is _militaryUniformed undefined inside of the if? im going slowly insane
gave up i just need to rewrite this whole mod
if (true) exitWith {false};
excuse me
how about you false instead
also that looks like you want it to be a findIf
yes i wrote this ages ago before i knew half of the commands
i need to do a rewrite of imposters as a whole i just dont have the time right now
this isnt even the only place i do it in either
the intention is that if either player's uniform or #uniform are in allmilitaryuniforms it'll go to the next iteration and will only return true if all are found in there
i.e either player vest or #vest as well as player helmet or #helmet
but forEach always goes to the next iteration...
It returns result of the last one
if you want to abort, there is break/breakWith
You clearly already knew that continueWith was a thing
i dont think i knew break was a thing
im rewriting this once i figure out the best metric for how suspicious something (vest) should be
currently thinking inventory space
If you want all to b e true. Then probably do a count and check == 3
nobodys complained about the bug yet so ill just leave it for rewriting
if you fancy crying yourself to sleep tonight
its really bad
I do not :harold:
like wtf was i thinking here
holy shit i add waitandexecutes twice a second if a unit sees you
I can't get the z coordinate for particles to have any effect. Am I using it wrong or should I take this to #arma3_feedback_tracker ?
_position = [0,0,10]; // xy change the offset, z doesn't work, particle stays on ground
_particleParams = [
/* Sprite */ ["\A3\data_f\ParticleEffects\Universal\Refract",1,0,1], // File,Ntieth,Index,Count,Loop
/* Animation */ "",
/* Type */ "Billboard",
/* TimerPer */ 0.1,
/* Lifetime */ 1,
/* Position */ _position,
/* MoveVelocity */ [0,0,0],
/* Simulation */ 0, 0, 10, 0, // rotationVel, weight, volume, rubbing
/* Scale */ [10, 0, 0, 0],
/* Color */ [[1,1,1,1], [1,1,1,1]],
/* AnimSpeed */ [0, 0],
/* randDirPeriod */ 0,
/* randDirIntensity */ 0,
/* onTimerScript */ "",
/* DestroyScript */ "",
/* object */ player,
/* Angle */ 0,
/* onSurface */ false,
/* bounceOnSurface */ 0,
/* emissiveColor */ [[0,0,0,0]]];
deleteVehicle a_source;
a_source = "#particlesource" createVehicleLocal [0,0,0];
a_source attachTo [player, [0,0,0]];
a_source setParticleParams _particleParams;
a_source setDropInterval 0.01;
i recall having the same issue, ended up having to create helper object to attach to
i memb issu wih patrc z
Q: is it possible to optionally include a header file, based on existence? i.e.
#if fileExists('...')
#include '...'
#endif
yes
ah that'd be brilliant, cool. thanks...
cant wait for dedmen to see me function overwriting my own functions
how about recursive functions overwriting recursive functions... 🤣
what
you do not see the humor there, okay... 😉
it's the CS in my background
Had a need for callNextFrame once again and finally decided to make a ticket: https://feedback.bistudio.com/T176428
have you considered making your own frame machine sort of like how CBA does it? I know you don't want to use CBA due to dependency, but it might be something to look in to until they create something like this
Scripting it is of course possible, I'd just prefer the engine side to handle it.
How would a callNextFrame command help if you need to actually perform something X number of frames ahead? Seems superfluous and easy to handle with a simple counter. Maybe I'm missing something?
From my experience you mostly need to execute something exactly on a next frame. There are a lot of things that can be scripted but there is a scripting command for it anyway, the reason is getting a bit of performance and ease of scripting.
How is there a performance increase if the call happens on the next frame anyway? You're scheduling the call. 🤔
If it was exactly one frame you could just bit flip with a bool
*bit
Overhead from adding your arguments and function into an array, storing a frame numbers, then checking frame numbers each frame to then execute the function
Use a single bit.
We're talking about SQF here.
And functions and params can be pointers
Engine would have to do the same anyway.
The less commands you call with SQF, the better. Single basic SQF command is often times slower than whole function done on engine side, that's where bit of performance comes from.
But if you're delaying one frame or multiple frames?
You mostly need to do something exactly one frame after, thus the command.
what is an example of this?
I wanna make items float up like it's zero g. But I can't figure out how. Anyone have suggestions
My arma group: https://arma.coffee/
// Script //
https://pastebin.com/FsmfyPXv
I've been using this script so far
Hey can anyone help im tryna spawn an array of units in a script chatGPT is making with me, getting an error of missing ;
_unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
_groupAlpha = createGroup west;
_infbarracksPos = getMarkerPos "infbarracks";
{
_unit = createUnit [_x, _infbarracksPos, [], 0, "CAN_COLLIDE"];
_unit moveInGroup _groupAlpha;
} forEach _unitTypes;
would appreciate if anyone can explain why this wont work when executed im tryna learn what i can
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "form"];
} forEach unitTypes;
this is what ive ended up with
it works in local exec but not when i try it on an addaction with this addAction ["Spawn Infantry Section", "Scripts\buyunits.sqf", [], 0, false, true, "", ""]; it doesnt show an error, but no spawn of units
Don't use ChatGPT for writing scripts. It does not understand SQF or how Arma works. It is designed to make text that seems believable, and functionality is a second priority at best.
For example, "moveInGroup" is not a real command - ChatGPT has invented this because it seems believable, but it does not actually exist in Arma and you can't use it.
in combination with the wiki and youtube ive had a bit of luck when i know whats wrong but yeah theres mostly just bollocks, im guessing its the addaciton thats fucked then since that above is working in local exec?
addAction ["Exec the file", "scriptFile.sqf"];
I'm surprised the script itself works on its own; it attempts to use the "form" placement mode for createUnit, which does not exist.
If the addAction appears and can be used, then it should execute the script exactly the same as if you did it from the debug console, provided the script is indeed in a file called buyunits.sqf, in a folder called scripts, in the mission folder.
using that format now, why would local exec work but when i interact with the action nil pois
hint "buyunits.sqf executed";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "spawn1", [], 0, "form"];
} forEach unitTypes; yes and the hint displays aswell but no spawning
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
!code
hint "buyunits.sqf executed";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "spawn1", [], 0, "form"];
} forEach unitTypes;
😒
The message generated by the bot explains how to use code formatting. !code is the Discord prompt for the bot to generate the message.
im drownin here save me
The most likely culprit is the use of the supposed "form" placement mode for createUnit. This mode does not exist and I'm dubious of the claim that it worked at all.
The only valid placement modes are "NONE", "CAN_COLLIDE", and "CARGO".
Please just try it with a mode that actually exists. At the very least, "form" is not doing anything and you lose nothing by fixing it.
well for one the form part came from a human on youtube, chatGPT had "CAN_COLLIDE" in it's place, i don't know what any of these things are, im just explaining whats happening https://www.youtube.com/watch?v=1sfJN9AA-8I thats the vid i copied a section of the description from. thank you for your patience but i aint gunna lie about something working in local exec?????
A simple script to spawn units with a trigger. The units will be in a user made group and use markers as waypoints.
-
Place your unit
-
Set up a trigger
-
Place marker (e.g. spawn1)
-
Place a second marker (e.g. waypoint1)
-
Type in the triggers "on activation" field:
group_1 = creategroup west; enemy1 = group_1 createunit ["b_so...
Firstly, be chill and patient.
Secondly, what exactly is the code for addAction?
Last but not least, don't ask ChatGPT about SQF scripts. As it is even pinned.
Look, there are some optimisations you could make, but if the script is actually being executed (as proven by the hint), the invalid placement mode is the only thing I can see that would prevent it from doing anything at all. I assume the unit classnames are correct, anyway.
(and I also assume there is a marker named spawn1)
cool as a cucumber mate im just puzzled. ive recorded a video of it working in local exec but not from the addaction.
this addAction ["Exec the file", "Scripts\buyunits.sqf"];
that is what is on my object in editor
spawn1 is changed to my own marker but yeah
hint "buyunits.sqf executed";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "spawn1", [], 0, "CAN_COLLIDE"];
} forEach unitTypes;
that is what is in the script
omg
for gods sake
sorry guys
i had 2 versions of the file open and basically hadnt saved the changes
That'll do it
I would recommend using "NONE" unless you have a very specific (as in millimetres) position. "CAN_COLLIDE" allows the created unit to be placed without regard for other objects occupying the same space.
Had plenty over time. For example, if you want to get vehicle smokes created by muzzleEffect scripts when you detect smokes, you can't do it right away from Fired EH, because the script is called after that, so you want to queue a function to be called next frame to get all new smokes created by remote script.
Anyone able to help me with addAction? I want to add an action to only Independent players on an object but I can only get it to work for all players or no one (this script is in the init field of the object I want the action to work on)
if (isServer) then
{
{
if (side group _x == independent) then {
[this, ["Sabotage UAV terminal", { 0 spawn sabotageUav; }], nil, 6, true, true] remoteExec ["addAction", _x];
};
} foreach allPlayers;
};
sabotageUav = {
uavSabotaged = true;
reaper_uav setFuel 0;
sleep 300;
"Someone has sabotaged our UAV comms terminal at the airport." remoteExec ["systemChat", blufor];
sleep 300;
deleteVehicle reaper_uav;
};
this is invalid there I think, my first glance says
Just updated the question, the script is placed in the init field of the object I want the action to work on
In recent case, I sent a RE from server that is done alongside HitPart report from shooter client, if its done normally without lag the RE arrives 3 frames later, but if recieving client was lagging, both real damage messages and my RE arrive at the same frame, first RE, then damage messages (and HandleDamage fire), but I need it the other way around, so to work around this, I need to always process that RE frame later so it is consistent with non-lagging scenario.
The ] after the Code parameter of the addAction is in the wrong place and is terminating the action parameters array too early. It should be after the second true.
Like so?
[this, ["Sabotage UAV terminal", { 0 spawn sabotageUav; }, nil, 6, true, true]] remoteExec ["addAction", _independentPlayers];
That looks like _independentPlayers is not [correctly] defined
Oh yeah whoops, I meant to change it to just independent
Also, you could do this more efficiently by operating locally instead of server only; check the side of the local player's group and if correct, add the action locally. This would reduce unnecessary network traffic and the complexity of the code.
Will test again sorry
please dont yell at me but im trying to set up a currency system of sorts even though im clearly out of my depth. Basically in my init.sqf i have
supplyPoints = 100;
I have a trigger displays the supply points amount with
hintSilent format ["Supply Points: %1", supplyPoints];
I want to make it so the script that contains
hint "buyunits.sqf executed";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
Does not execute if there aren't say a minimum of 20 supply points. and also that when it executes it takes off 20 supply points. Im happy to learn to do it myself but if anyone can even point me in the right direction of how i could learn what i need to accomplish this.
could someone help me to restrict the virtual arsenal so only certain classes have certain weapons clothing and so on? if everything works in the end you’ll get a small tip! just dm me if you are interested
That worked, thank you
@hallow mortar You happen to know how to activate a Fire Module with a Trigger as well? Cause I can't get it to work.. I know the Trigger is activated cause I get the hint when I use the action and the Fire Module is synced to the Trigger but it doesn't start a fire
If syncing doesn't work then I don't know, sorry.
https://community.bistudio.com/wiki/if
https://community.bistudio.com/wiki/-
You can also use the addAction Condition parameter to prevent the action from appearing at all if there aren't enough points to use it, if you prefer.
Btw, have you checked the ground below the module, when it's supposed to be activated? Some modules always use ground level regardless of where the module is placed, and this might be one of them.
Oh I haven't no, I'll have a look
So ive managed to get it to subract 20 supply points every time you spawn a group, woooooo. but... ffs. im tryna get my head around the if & then stuff
_retVal = if (1 > 0) then { "It's true" } else { "It's false" }; trying to apply this format to my script to essentially get
if (supplyPoints = supplyPoints > 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
sleep 3;
supplyPoints = supplyPoints - 20;
hintSilent format ["Supply Points: %1", supplyPoints];
}
else (hint "You do not have enough supply points!");
Im just abut to test this im scared haha hope ive understood it
i got error line 2 type number expected bool, is this something to do with needing it to be a string with str somewhere?
please dont feel obliged to help me guys ive been asking so much
I think you can just do if (supplyPoints >= 20) then
As in, if supplyPoints is 20 or more
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
sleep 3;
supplyPoints = supplyPoints - 20;
hintSilent format ["Supply Points: %1", supplyPoints];
}
else (hint "You do not have enough supply points!");
so thank you im entering this and just getting the hint for you dont have enough supply points even though i got 100 supply points showing 😒
nah i got it
I BLOODY DID thank you so much guys buzzing
it take 20 each time until you have zero then no more spawning and the hint
could somebody help me to setup restriction the the virtual arsenal?
Ace or vanilla
ML, computer vision, so basically, what, an open or closed feedback loop? because it seems to be there still needs to be training "what" you are looping "for". i.e. a difference between AI and "AGI" arti general int.
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
editmodule addCuratorEditableObjects [[group_1], true];
sleep 3;
supplyPoints = supplyPoints - 20;
hintSilent format ["Supply Points: %1", supplyPoints];
}
else {hint "You do not have enough supply points!";}
Im not getting any errors when i run this but the new units arent added to the zeus when I deploy them, could it be a mod causing it? units ive already placed and synced with module are assigned correctly though
Would it be possible to disable the option to remove an inventory item (through the inventory UI)? Specifically want to prevent players from removing a facewear item from its slot, preferably w/o preventing access to the inventory itself
still struggling with the above problem 😒 sorry im not knowledgable enough to help you villain
vanilla
pulling my hair out man
please help me 😦 once i get this squad down i can apply it to all my other deployable shit and im a king then
Try [editmodule, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2] and please use code blocks next time you post code here.
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
// [editmodule, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2]
was a test
//
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
[editmodule, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2]
supplyPoints = supplyPoints - 20;
sleep 3;
hintSilent format ["Supply Points: %1", supplyPoints];
}
else {hint "You do not have enough supply points!";}
that's not right is it
The ```sqf part, and the corresponding ``` at the end, is what causes code formatting.
im so sorry
// is a comment in SQF.
Add before ```sqf and to end
```
""sqf
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
[editmodule, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2]
supplyPoints = supplyPoints - 20;
sleep 3;
hintSilent format ["Supply Points: %1", supplyPoints];
}
else {hint "You do not have enough supply points!";} ""
`, not '
` not '
You might find this interesting: https://forums.bohemia.net/forums/topic/178628-lock-uniforms-and-helmets-so-they-cannot-be-removed/
Not sure if that will also work when the player right-clicks on a facewear item in a container, might have to take some additional measures to intercept that (e.g. Take EH).
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
[editmodule, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2]
supplyPoints = supplyPoints - 20;
sleep 3;
hintSilent format ["Supply Points: %1", supplyPoints];
}
else {hint "You do not have enough supply points!";} ```
can you see why im struggling 🤣
Nearly there, you just need to make sure ``` and sqf are on the same line, without spaces, to activate the syntax highlighting
IIRC it bugs out in some cases anyway, possibly when you add the quotes later.
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
[editmodule, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2]
supplyPoints = supplyPoints - 20;
sleep 3;
hintSilent format ["Supply Points: %1", supplyPoints];
}
else {hint "You do not have enough supply points!";}
You're missing a semicolon at the end of the remoteExec line.
thank you i shoulda spotted that damn
Otherwise it should work, assuming that supplyPoints, editmodule and the "infbarracks" marker all exist.
Ah nice, looks promising! Will try this.
Thank you!
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
supplyPoints = supplyPoints - 20;
sleep 3;
[editmodule_1, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2];
hintSilent format ["Supply Points: %1", supplyPoints];
}
else {hint "You do not have enough supply points!";}
this is what im running but sadly the units still aren't editable, im worried maybe it's a mod causing it
BOOOOOOOM
if (supplyPoints >= 20) then
{
hint "You deployed an Infantry Section";
group_1 = createGroup west;
unitTypes = [
"Athena_B_G_Soldier_SL_F",
"Athena_B_G_RadioOperator_F",
"Athena_B_G_Medic_F",
"Athena_B_G_Soldier_AR_F",
"Athena_B_G_Soldier_TL_F",
"Athena_B_G_Soldier_LAT_F",
"Athena_B_G_soldier_M_F"
];
{
_unit = group_1 createUnit [_x, getMarkerPos "infbarracks", [], 0, "NONE"];
} forEach unitTypes;
supplyPoints = supplyPoints - 20;
sleep 3;
[module_zeus_1, [units group_1, true]] remoteExec ["addCuratorEditableObjects", 2];
hintSilent format ["Supply Points: %1", supplyPoints];
}
else {hint "You do not have enough supply points!";}
that was the ticket, name the main zeus module i gave the name of the add objects module
thank you so much everyone for your patience and understanding
We all were beginners with SQF sometime! (Well, except maybe John Jordan, who seems to have been born into it cue the Bane "I was born in the dark, you merely adopted it" clip)
/Im still a beginner
Q: about BIS_fnc_sortBy, if I want to order by, say, a CONFIG "displayName", then I can return the STRING (""), correct?
if I want to order by some other criteria, say a mass or weight, then by display name, then I return and array, in the following shape, [_mass, _displayName], assuming that's [0, ""], correct?
in the algorithm of course. i.e. { ... }.
https://community.bistudio.com/wiki/BIS_fnc_sortBy#Syntax
https://community.bistudio.com/wiki/sort#Syntax
Hello I need help from someone to create the feature so clothing, weapons and vehicles are whitelisted to classes. E. g. pilots only can have SMGs and Pilot clothing and fly jets and helis but the rest cant. Same for Engineer that he is the only one who can carry explosive charges and so on for the Virtual Arsenal. We use Xeno69’s Domination game mode!
Just DM me I you'd like to assist
hey, do you guys think anyones ever made a script that adjusts AI skills based on player performance?
I was looping through articles and stuff to access the topic. Meanwhile I am learning scripting, but struggeling to connect the models boundingBox function results with an displayed box on my screen.
ARRAY does not seem to work...
_y = [
['c', 1]
, ['b', 6]
, ['b', 3]
, ['b', 4]
, ['a', 2]
];
[_y, [], { _x }] call bis_fnc_sortby;
// expected: [["a",2],["b",3],["b",4],["b",6],["c",1]]
// actual: [["c",1],["b",6],["b",3],["b",4],["a",2]]
default "ascend" order, right, does not sort.
although oddly, "descend" order produces this:
// descending order: [["a",2],["b",4],["b",3],["b",6],["c",1]]
seems rather inverted to me. also does not take first element, then second element, into consideration.
when I provide an algorithm, seems better, i.e. {_x select 0}, orders in the correct expected order.
