#arma3_scripting
1 messages ยท Page 737 of 1
an event handler is executed somewhere else
hi i have a problem with "playsound" without the gas mask the sound start again. so the problem (i think) it's the execution of the sound (with cba_fnc_waitandexecute)
player addEventHandler ["InventoryClosed",
{
if ("G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)) then
{
if (!(gas_mask_effect_sound_playing)) then
{
no_gas_mask = false;
call BIS_fnc_VRFadeIn;
gas_mask_sound_put_on = playSound "gas_mask_put_on";
"RscCompass" cutrsc ["RscCompass","plain"]; // Show digital compass
"gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
_function =
{
gas_mask_effect_sound = playSound "gas_mask_effect";
[_this, _this, 19] call CBA_fnc_waitAndExecute;
};
[_function, _function, 20] call CBA_fnc_waitAndExecute;
//gas_mask_effect_sound_playing = true;
if ((backpack player) == "B_CombinationUnitRespirator_01_F") then
{
(backpackContainer player) setObjectTexture [2, "a3\supplies_f_enoch\bags\data\b_cur_01_co.paa"]; // Show hose segment
};
};
} else
{
no_gas_mask = true;
deleteVehicle gas_mask_effect_sound;
//gas_mask_effect_sound_playing = false;
"RscCompass" cuttext ["","plain"]; // Hide digital compass
"gas_mask" cutText ["", "PLAIN"]; //Overlay off
if ((backpack player) == "B_CombinationUnitRespirator_01_F") then
{
(backpackContainer player) setObjectTexture [1, ""]; // Hide hose segment
};
};
}];
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
woah
player addEventHandler ["InventoryClosed",
{
if ("G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)) then
{
if (!(gas_mask_effect_sound_playing)) then
{
no_gas_mask = false;
call BIS_fnc_VRFadeIn;
gas_mask_sound_put_on = playSound "gas_mask_put_on";
"RscCompass" cutrsc ["RscCompass","plain"]; // Show digital compass
"gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
_function =
{
gas_mask_effect_sound = playSound "gas_mask_effect";
[_this, _this, 19] call CBA_fnc_waitAndExecute;
};
[_function, _function, 20] call CBA_fnc_waitAndExecute;
//gas_mask_effect_sound_playing = true;
if ((backpack player) == "B_CombinationUnitRespirator_01_F") then
{
(backpackContainer player) setObjectTexture [2, "a3\supplies_f_enoch\bags\data\b_cur_01_co.paa"]; // Show hose segment
};
};
} else
{
no_gas_mask = true;
deleteVehicle gas_mask_effect_sound;
//gas_mask_effect_sound_playing = false;
"RscCompass" cuttext ["","plain"]; // Hide digital compass
"gas_mask" cutText ["", "PLAIN"]; //Overlay off
if ((backpack player) == "B_CombinationUnitRespirator_01_F") then
{
(backpackContainer player) setObjectTexture [1, ""]; // Hide hose segment
};
};
}];
beautiful ! thanks
so.. you can't solve this?
_function =
{gas_mask_effect_sound = playSound "gas_mask_effect"; [_this, _this, 19] call CBA_fnc_waitAndExecute; }; [_function, _function, 20] call CBA_fnc_waitAndExecute;
this keeps looping and never stops
how can i fix it
no
check your variable "no_gas_mask" or something
ยฏ_(ใ)_/ยฏ
with CBA_fnc_waitUntilAndExecute ?
in CBA_fnc_waitAndExecute before looping again.
but didn't it have a condition already? 
oh in the _function
i think init.sqf is calling TAAG_fnc_startMission before description defines that function
no. functions are initialized before everything else
if you use CfgFunctions that is
working ๐
player addEventHandler ["InventoryClosed",
{
if ("G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)) then
{
if (!(gas_mask_effect_sound_playing)) then
{
no_gas_mask = false;
call BIS_fnc_VRFadeIn;
gas_mask_sound_put_on = playSound "gas_mask_put_on";
"RscCompass" cutrsc ["RscCompass","plain"]; // Show digital compass
"gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
gas_mask_effect_sound_playing = true;
_function =
{
if (gas_mask_effect_sound_playing) then
{
gas_mask_effect_sound = playSound "gas_mask_effect";
[_this, _this, 19] call CBA_fnc_waitAndExecute;
};
};
[_function, _function, 20] call CBA_fnc_waitAndExecute;
if ((backpack player) == "B_CombinationUnitRespirator_01_F") then
{
(backpackContainer player) setObjectTexture [2, "a3\supplies_f_enoch\bags\data\b_cur_01_co.paa"]; // Show hose segment
};
};
} else
{
no_gas_mask = true;
deleteVehicle gas_mask_effect_sound;
gas_mask_effect_sound_playing = false;
"RscCompass" cuttext ["","plain"]; // Hide digital compass
"gas_mask" cutText ["", "PLAIN"]; //Overlay off
if ((backpack player) == "B_CombinationUnitRespirator_01_F") then
{
(backpackContainer player) setObjectTexture [1, ""]; // Hide hose segment
};
};
}];
not a game bug, that's for sure
"Functions\startMission.sqf" call BIS_fnc_execVM; will this work
=_= Good day, I'm trying to pack and run server side mod, but my init scripts never fire and I don't get it why. I do have config.cpp with
class CfgFunctions {
class SOMETAG{
class initServerMod{
file = "initServerScripts.sqf";
preInit = 1;
};
};
};
And as I understand, it must be called automatically on mission start, but that just never happens and I do not see any error messages in log files, it just.. not working. Any helb please?
it worked
wtf? just use execVM
also if that worked then you can try spawning it
[] spawn TAA_Fnc_blabla
ok
If i add an EH to a playable unit in an MP mission, does it still work if that player respawns or would that be a new unit with no EH on it?
how do you know it never fires?
Added debug 'diag_log' at the very beginning
Is there an event that detects the end of task?
does it even work if you call it manually?
why would you need an EH for a task?
aren't you the one who controls the task?
Mmmm you mean does the sqf content working as it should? Yeah, when inside the main project - it does. (called from initServer.sqf)
this is missing the category
it's not a function
Pardon? I don't quite get it
read the wiki
I did =_= ok, guess I'm missing something, thanks
and here's an example
i want to delete task when its state become "FAILED" or "SUCCEEDED"
you're the one who controls it. you don't need event handler for it
but i don't know how to control it
but anyway I don't think it has one
wut?
[_HVTobj getVariable "asdfTask", "FAILED"] call BIS_fnc_taskSetState;
you're doing it
it's not magically "failed"
uh
so
i wanna make
if every task are "SUCCEEDED" and "FAILED",
I want to delete every task
keep a list of all tasks
when one succeeds or fails, check if all are succeeded or failed
while (true) do {
if ("task" call BIS_fnc_taskState isEqualTo "SUCCEEDED" || "task" call BIS_fnc_taskState isEqualTo "FAILED") then {
blablablabla
break
}
}```
like this?
no. when did I say use a loop?
using a loop when you're in control of something is stupid
it's like you're the one who presses a button, but you're always asking has the button been pressed yet? 
I told you already
Anyone know?
Okay, now I also added a category but it keeps telling me that the script is not found... while it is literally there. wtf =_=
your path is incorrect
class CfgFunctions
{
class Main {
class init {
class main {
file = "\init\fn_initServerScripts.sqf";
preInit = 1;
};
};
};
};
the file's address is itself is in
ROOT\init\fn_initServerScripts.sqf
And the error message is
Warning Message: Script \init\fn_initServerScripts.sqf not found
Like... what path is incorrect T_T
is that in a mod?
Yes
you must start with the addon prefix
also even if this was in a mission file it would still be incorrect
when you start a path with \ it means addon path, not relative path
Thanks, I guess I understand now.
systemChat "Happy holidays!"
actually, better yet
["Happy holidays!"] remoteExec ["systemChat"];
_snowMan = "snowman" createVehicle [0,0,0];
_fireworks = [];
for "_i" from 1 to 10 do {
_fire = "fireworks" createVehicle [0,0,0];
_fire setVelocity [random 5, random 5, 100];
_fireworks pushBack _fire;
};
sleep 3;
{
_x setDamage 1;
} forEach _fireworks
๐
perfect
is there a parent class for submersibles ?
SDV_01_base_F?
it's a bad practice to check the "parent class" for objects
mods can create their own parent class
than i will use PositionASLW to check i guess
wat? 
if its a vehicle and its beneath the seabed then its a submarine but i have to add a check to see if its damaged or not
so a rock under the sea level is a submarine. so are sharks and turtles and fish 
rocks are classified as terrain objects or do they ? well then i have to add a 3rd check to see if a unit is in side lol
ever heard of config reading? 
that's what you should do
for example, check the simulation of the object
A lot of terrain objects don't have configs :)
exactly. you get nothing for those. so it's definitely not a submarine! ๐
Ah yeah I was misreading, that's the intention then
Do event handlers of the same event type fire in the order they are attached? Or is it unpredictable?
yes
but UI EHs fire in reverse order
Awesome, thanks for the info!

Is there any way in MP to check if a player has finished Prologue Bootcamp when they join mp server?
is there a quick way using scripting to force AI to seek cover?
i dont want to make my own script, if necessary
is there a way to get the class type of a terrain object? ex, using nearestTerrainObjects, you can filter by a ton of object types such as "TREE","BUILDING","BUSH","HOUSE", etc. I've find you can use object isKindOf type to check if an object is a specific type but oddly I can't find an SQF function to find the type of a terrain object? I tried using BIS_fnc_objectType but it only returns houses and not rocks or trees
my only solution is to create a list of all the class names i want to search for, then use nearestTerrainObjects on each individual classname in the list and save the found objects across the entire map in a hashmap where each key is the object type (ex "brickwall_01_l_5m_d_f.p3d") and its value is the class name (in this case, "WALL".) It takes 10+ minutes to run, but I only need to run it once per game map. Then, I copyToClipboard, save it in an sqf, executing the sqf file returns a hashmap with every map terrain object type and their specific classname so i can easily find any objects class type
"TREE", "BUILDING", "BUSH", and etc. are not class names, they're just filter strings for use in commands
many terrain objects do not have an associated config class, but if they do you can find them via typeOf like any other object
if you really want to just categorize them according to those strings you could just do something like this
private _categoryHashmap = createHashMap;
private _categories = ["TREE", "SMALL TREE", "BUSH", "BUILDING", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL", "CROSS", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE", "BUSSTOP", "ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD", "ROCK", "ROCKS", "POWER LINES", "RAILWAY", "POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL"];
{
_categoryHashmap set [_x, nearestTerrainObjects
[
[worldSize / 2, worldSize / 2],
[_x],
worldSize * sqrt 2 / 2,
false
];
];
} forEach _categories;
thats pretty close to what i did at first, but then i realized that if i had a specific object and wanted to find what category it would be in, you would have to search the list in each hashmap key (the tree category itself is 1.48866e+006 elements long) and that could take a long time for multiple objects and ruins the entire point of using a hashmap for speed
That's true but the overall approach is a death sentence for speed anyways
why do you need to store every single terrain object?
well, i wanted to be able to characterize the surroundings of an AI so it can better chose where to take cover based on the type of terrain object
Should probably use the existing AI functions rather than rolling your own cover-seeking algorithm
the engine already has support for this type of thing
Well, i was looking online and couldnt find anything. All the commands such as 'findCover' and 'setHideBehind' are broken commands that aren't implemented. I know the AI commanding menu has a seek cover action, but it doesn't seem to be available through SQF
What you want is AI behavior
Depending on the behavior type they will dynamically find appropriate cover
I tried experimenting with different behaviors but I didn't notice a difference, I think because I am making the script for civilians. I'm not necessarily trying to create a complex cover system, just tell civilians to run and hide behind the first solid piece of cover nearby or run away based on the environment
maybe with mission keys yes
Hey lads
Please help with dedicated server playable unit..
What's the idea: A player gets close to a locked house and a trigger checks if he has a key object in his inventory and if yes, door is opened.
This is half the code, I just need the end of it ๐
What is the proper command so the server checks the specific unit that activates the trigger if it has a key?
{'Keys' in (uniformItems _x + vestItems _x + backpackItems _x)}...
true in (thisList apply {'Keys' in (uniformItems _x + vestItems _x + backpackItems _x)})
``` Assuming this is the Condition of the trigger
thisList findIf {'Keys' in (uniformItems _x + vestItems _x + backpackItems _x)} != -1
but better use uniqueUnitItems
just post some bad code and you'll get an answer immediately ๐
Mine was worse
Thanks a lot!!
if (true)
then {
while {true}
do {
if (cameraOn == objectparent player && cameraView =="EXTERNAL")
then {sleep 2;};
};
//bunch of code
};
i wanted to execute a bunch of codes once the cam view isnt External however it seems that it does not work
if (true) - why? just start with the while
in the place of that (true) im going to replace it with a variable so when it is enabled the while will start checking, even though i tried with while directly and didnt work either ๐ฆ
cameraOn looks for an object
objectParent player will return <NULL-object>
try ```sqf
//check if in 3rd Person
if (_someVariableReturningTRUE) then {
while {true} do {
if (cameraOn == player && cameraView == "EXTERNAL") then {
sleep 2;
};
};
//bunch of code
};
//check if not in 3rd
if (_someVariableReturningTRUE) then {
while {true} do {
if (cameraOn == player && cameraView != "EXTERNAL") then {
sleep 2;
};
};
//bunch of code
};
that will fire when in 3rd person
to run everytime when not in 3rd person change cameraView =="EXTERNAL" to cameraView != "EXTERNAL", for example 1st person
I'd suggest you make some variable in the while so you can "destroy" it also 
cameraOn == player, means that when you are in a vehicle it wont activate as player != vehicle player, also != "EXTERNAL" is the same as == "INTERNAL", the "bunch of code is a little long thats why im trying to disable when External, sadly your code didnt work either ,i will try to add the variable inside the while and see what will happen ๐
did with no luck though objectparent player = vehicle player :))
What you after exactly?
once that CBA variable that i will replace the true with is enabled via checkbox, the while code runs, and when it does everytime the player is in EXTERNAL view it disables the rest of the code via sleep command.
I wanna see it all cuz im sure theres a better way of doing it
Just at a glance i think you just be setting a variable and then running code depending on if its True or False
Hello, I have a problem running a mission on a dedicated server. After selecting your roles you will start loading in but the mission wont begin unless the admin disconnects. here is the RPT file https://steamuserimages-a.akamaihd.net/ugc/1854918723262569721/3DE923C846A5A579FC4DCEC5828C39B027514800/
Hey Good men
DEDICATED SERVER issue ๐
I have this script, when I'm pointing my gun on a specific civilian, he's doing some stuff I need (surrender and start to talk)..
((cameraView == "GUNNER" && (cursorObject == naknik) && player distance naknik < 5 ))
As you know, player is not something that dedicated servers like (or know..). What exactly should be there instead of player, so all playable units that "threaten" this civilian can do the same thing?
Maybe you could execute it locally on each client?
initPlayerLocal.sqf?
Would it work on dedicated? I have my concerns because of the player stuff
as long as its executed locally you should be able to use player without issues
do the checking locally on each player's machine and handle talking on server
initplayerlocal is fine, see https://community.bistudio.com/wiki/Event_Scripts
So in the line of coding, do you guys think it'd be possible to create a working lightsaber?
Thanks man, I'll try
No, you will also need a model and animations in addition to code that handles the melee damage mechanics.
You could see how some other mods do it. Here is an example: https://steamcommunity.com/sharedfiles/filedetails/?id=2323185592
Personally, I would use plasma-sword in my mod so that Disney doesn't take me to Tatooine, but they probably won't notice anyway.
What can you do in a remoteExec addAction that would result in a kick from a server with battleeye?
Hey, is there any way to make clickable diary records?
E.g. where you can click on certain specified text inside of a diary entry
And it'll execute code
Working on an idea for a reinsertion system to help my guys have a better time in ops
Hey, so another question
I'm looking to have a serverside script, that will remote execute another script on the machine of the logged-in admin
Any idea of the quickest way to grab a list of all machine IDs in a session?
does https://community.bistudio.com/wiki/allPlayers and https://community.bistudio.com/wiki/owner sound right?
Could probably check allPlayers using owner, yeah
Is that the most efficient way to do that?
Maybe something like this?
allPlayers findIf {
admin owner _x == 2;
};
Oh wait
Fixed to use allPlayers
this is a bit of a weird question, but lets say you have an FSM running. and then lets say that FSM uses 'call' on a function, which then calls a subsequent function that has an error because it tries using something that's nil
will this function continue?
basically, in an FSM for ALiVE, it makes this call: [_this select 0,"cleanupduplicatesections"] call ALiVE_fnc_OPCOM;
this function, near its end, iterates over a list and makes this call: [_logic,"resetObjective", ([_objective,"objectiveID"] call ALiVE_fnc_HashGet)] call ALiVE_fnc_OPCOM;
resetObjective does this, which can return nil, but then tries to use that nil value later: private _previousTacomState = [_objective,"tacom_state"] call ALiVE_fnc_hashGet;
How does using a nil value actually work in arma 3 sqf? Will this cause the whole call chain to fail, will just the one statement that uses the nil value fail?
will the fsm exit?
not entirely certain who to ask or where to look for this
Got it figured out!
@brazen lagoon Setting something to nil in and of itself is not an error, it's actually a perfectly valid statement you can use to "delete" variables
_thisVar = nil;
// _thisVar no longer exists
the problem is the repercussions of said deletion
if you're using that deleted variable later on, you will get an undefined variable error which will terminate the script
@tough abyss yes that is the question I'm asking
it won't return to the calling script
it'll just kill it?
That is generally how exceptions work, yes
if you don't want that to happen you need to do exception handling
yes, that was how I thought they worked in sqf, I'm just double checking my assumption
because assuming things about sqf is a bad idea I've found
it does a lot of things subtly differently than other languages..
so anyway. let's say you have something like
actually lemme go to my computer so I can do some proper typing
test1 = {
params ["_print", "_setNil"];
_setNil = Nil;
hint _setNil;
hint _print;
};
["test", "test1"] call test1;
with my understanding of sqf, this will log a script error and hint nothing, correct?
but then lets also consider this situation:
test1 = {
params ["_print", "_setNil"];
_setNil = Nil;
hint _setNil;
hint _print;
};
test2 = {
["test", "test1"] call test1;
hint "fn called";
};
call test2;```
Will this hint 'fn called'?
yes it does
even more confusingly: ```sqf
test1 = {
params ["_print", "_setNil"];
_setNil = Nil;
hint _setNil;
hint _print;
};
test2 = {
["test", "test1"] call test1;
};
call test2;
this doesn't do anything (I think because sqf is lazy evaluated): ```sqf
test1 = {
params ["_print", "_setNil"];
_setNil = nil;
_print = (_print + _setNil);
};
test2 = {
[1, 2] call test1;
};
call test2;
But if we try to add `hint str _print` to test1, it will throw "generic error in expression"
why are you overwriting your function arguments? _setNil = nil;
anything after that line means _setNil is empty now
so your method is now trying to add 1 to nil
@buoyant elm yes, I wanted to see what this would do in the calling function
this hints 'fn called' even though you would expect the script failure to percolate up
my understanding is that depending on where you ru nthe script you can end up in a threaded or non-htreaded environment
well this is using call not spawn
i think running them from the box in zeus is threaded, and non-blocking
also for sure scripts are not compiled unless you binarize them, in which case i don't know if it would tell you you have runtime errors
Not all script errors kill/exit the script immediately
that too, there's plenty of non-fatal errors you can have
A game crash :D
I can't think of any
lmao
the scripts seem pretty safe, it's just that each error you generate can slow down script processing in general
so this code block here:
private _previousTacomState = [_objective,"tacom_state"] call ALiVE_fnc_hashGet;
[assume _opcomID, _objective, _side, _factions are all successfully gotten (not nil)]
private _event = ['TACOM_ORDER_COMPLETE', [_opcomID,_objective,_previousTacomState,_side,_factions, false, []], "TACOM"] call ALIVE_fnc_event;```
if _previousTacomState is nil, it will whine about an unknown variable
but will this also crash the script that is calling the function this code is in?
set it to {} ?
Yeah, but won't exit. It will just also nil
Not necessarily, depends on how it's used
If it ends up returning a nil because of that, that can cause issues in the parent script
The way Arma handles errors and exits or not exits Scripts is mysterious and complex
Best to just not have errors
lol
honestly, you should always be nil-checking and not jsut assumnig you have a useful value
ye, i've learned this the hard way
no need to even call functions sometimes if all yoru data isn't there, saves a stack call
im looking into a bug someone found, not my code
I think when it was written they should have put a default value in the first call to hashGet but they neglected to
a single nil-check would solve it
yep
lazy scripting, or newbi programmers who weren't taught to distrust all data
never trust user input, and never assume your values are valid if they're important
tbh sometimes people just forget
its a shame too because this would be a function that would be relatively easy to test if there was an sqf test harness that existed
actually that seems like a @still forum question: can you run sqf scripts in any way outside arma? Like lets say I wanted to run tests against an sqf codebase
CBA has one
no kidding? I'll have to look into that
There is SQF-VM, a external SQF thing that can run code and aims to be as close as possible to Arma itself
CBA runs theirs ingame though
https://github.com/SQFvm/runtime this I assume?
Ye
yeah, the cba thing is all in game. I was hoping for something you could have run against pull requests on github
SQF-VM can run most of CBAs unit tests.
Just not the ones that actually need to be ingame, with Units and Objects ans stuff
right right
so stuff where you mock out objects and such could easily run in sqf vm
Yeah
It has some support for objects, like setPos/getPos maybe.
But its aim is to implement SQF, not a whole game running behind it
the real pro tip is to make sure all of your code runs in factorial time ๐
all my code is O(1)
O(N!^(N!)) is supreme
oof
honestly
the hottest take is
for small N it doesn't matter
even horrendously inefficient/expensive algorithms can be good enough if your N is small
who cares about scalability right
ofc the flip side of this is also true, even very small improvements can make a huge difference on something that runs every frame
just assert(n < 5) and be done
no, but I just mean like... don't waste your time optimizing something that runs once at mission start and takes a few seconds, yknow?
indeed I'm just being a smartass
:^)
also arma is a great situation to prove uh... I'll need to double check the name of the law, but it's the one that says "as things become more parallelizable, the stuff that can't be will become the limiting factor more and more"
amdahl's law
Well and sqf also has the natural bottleneck of being an interpreted language rather than a compiled one
with a lot of functions taking runtime-compiled code params
in theory Arma supports an infinite number of AI, just keep throwing more HCs at it. In reality, you'll run into the server's single core + network being the limiting factor at like.. probably 200-250
What is remoteExec restriction #23, and is there a reference to what battleeye restricts and what it does not?
could be related to CfgRemoteExecs thingy
I just read through the CfgRemoteExec page on the wiki and in the config viewer, but sadly I couldn't find any concrete examples of what battleeye is looking for when it is filtering through the script code.
I genuinely have no idea what's causing the issue. I'm going to paste the problematic code here, and hopefully someone knows what battleeye is fussing about.
https://pastebin.com/W6Dm8YNS
check your battleye filters
I've tried finding them but have had no luck. Where are they supposed to be saved?
Disregard.
Well... It could also run those, given the proper problems are known (eg. Eventing is indeed a problem, but could be solved too using specialized operators)
do you guys think the enforce scripting language is better than sqf? i always find myself wanting to use objects and inheritance when im using sqf
I seem to have cracked it.
_bootme = getStatValue "BCFirstDeployment";
This will return 1 if the player has done Bootcamp campaign. So you can use an if statement and then alert the player that they need some exp before playing your mission. Would be very useful for Warlords...
Seems to work in MP from EDEN.
Nice code.
if (_bootme != 1) then {
_message = _message + "Please finish the Bootcamp campaign before playing.<br /><br />";
} else {
_message = _message + "Welcome to Afghanistan Zeus ops.<br /><br />";
};
they say it will be, but as someone who only knows SQF, learning something new is gonna annoy me lol
It's better for sure, but i hope it gets improved in arma 4, there are definetly some half baked features imo.
@fair drum @chilly bronze simply by having hashmaps on release and functions with parameters that aren't hacked in its gonna be better honestly
the OOP features I'm worried about because I don't generally like OOP overuse. but it could still be useful in a lot of ways to have objects considering its common to hack in objects and polymorphism into sqf like some kind of horrifying amalgamation of tcl and C. like don't get me wrong it rocks that it works and I'm constantly impressed by the community, but it'd be so much more readable if it was native
I'm using __Eval( selectRandom[..7 indexes..]) but its only selecting index 1 and index 5. Any ideas why? It's done inside a non bin config
it depends on the seed
maybe try __RAND_UINT8__ instead? 
Ahhh disnt know it existed :) will try when I get the chance, thanks for the info tho I can work woth it now 
actually better use a sqf command instead
e.g systemTimeUTC
and compute a new seed
yes
e.g. _time = systemTimeUTC; _seed = _time#6 + _time#5 * 1000 + _time#4 * 60000
#define BACKGROUND_IMAGE __EVAL([..arrayOfImages..] select ((systemTimeUTC#6 + systemTimeUTC#5 * 1000 + systemTimeUTC#4 * 60000) random 7))
When checking the config, its returning text = "any";. Now, I know these images work because my old method works, just only gives me 2 of the possible 7 (see above).
Is it possible random might not work in __EVAL?
you must floor it
Oh right course ๐
SQF is compiled, but into a intermediary bytecode
also I don't think # works in any preprocessor macro
just for my future reference, is there a list of stuff that doesn't work in preprocess on wiki?
Problem with that is, I never finished bootcamp after almost 10 years of playing A3
And I know 4 other people that played since then, who also haven't
But if you additionally check the 200 hours achievement, that should fix that
Yeah, seems like that was related. select (floor (((systemTimeUTC select 6) + (systemTimeUTC select 5) * 1000 + (systemTimeUTC select 4) * 60000) random 7)) was the final working fix ๐
ty for helping!
does it also randomize correctly now?
Yeah, in the middle of just checking it shows all of them, eventually, but so far its done 3
Its a background randomizer on rscDisplayStart so can imagine its a bit tedious haha
So its done all but 1 so i'm gonna say yes it is randomizing correctly
remove (systemTimeUTC select 4) * 60000 from the seed, see if it randomizes more
It seems to favour index 2-5
Will test also
Yeah seems to "duplicate" less often now
But still seems to favour certain integers
Anyhow that doesn't bother me really, glad its randomising properly now ๐
Ah, right, I guess I should've specified that it's more of a JIT system
Hello, can anyone explain the highlighted line in this code? From testing it won't do anything but make it slower. And if i understand correctly it will just go through every element and add it to the new ResuppMags?
//GetMags script for resupply crate
ResuppMags = [];
{
ResuppMags = ResuppMags +
(magazines _x) +
[(currentMagazine _x)] +
(primaryWeaponMagazine _x) +
(handgunMagazine _x) +
(secondaryWeaponMagazine _x)
} forEach (playableUnits + switchableUnits + allPlayers);
ResuppMags = ResuppMags select {count _x > 0}; <------------------
ResuppMags = ResuppMags arrayIntersect ResuppMags;
copyToClipboard str ResuppMags;
hint str ResuppMags;
it's returning the mags whose count of characters in their name > 0,
so it's always returning the whole array
(magazine names are never empty)
also that's horribly inefficient
(I mean the script itself, not just that part)
the part that's slowing it down for you is ResuppMags = ResuppMags arrayIntersect ResuppMags;
not the select
arrayIntersect is a single command and runs unschd
if the array is long it'll freeze the game
So it's useless?
Okay, thanks a lot for the explanation :)
how would one fetch the side of an object from cursor target?
im using
_flagging = "cursorObject == (side == west)";
in an if ()
side cursorObject 
side is a unary command
it needs args
you can't write it like that
"side west" right?
it takes an object/group
not side 
you're doing side SIDE
it should be side OBJECT or side GROUP
(side cursorObject == west);
yes
thankyou
it was staring me in the face
im angry at myself rn
thankyou so much leopard
next question. how would one move a players weapon into the WeaponInHand action
as currently
player action ["WeaponInHand", player];
``` does nothing
alas
i tried 1-15
and 97-102
all it does is either switch to secondary or put on back
not the gun to chest aiming at the floor
WeaponInHand / WeaponOnBack
Description: Soldier 'unitName' does nothing, 'target unit' moves his weapon from/to the safety position (gun held across chest pointing at the ground).
Change is persistent with player, but AI units will change back to suit their current behaviour mode. AI generally keep their rifles safe unless moving or targeting.
Syntax: unitName action ["WeaponInHand", target unit]
unitName action ["WeaponOnBack", target unit]
Example:
SoldierOne action ["WeaponOnBack", SoldierTwo]
@little raptor
what i was following
having a browse of them rn
is it possible to force an input action?
inputAction "toggleRaiseWeapon"; this would work if i could "force" the player to do it
no
how about safety? is it possible to flick that off and on?
God I wish
unbinding certain things then like primary fire maybe?
also getting an error here
waitUntil { side cursorObject =! west };
saying missing ;
=! ---> !=
i feel like im having a stroke now. looking through my code there is a bunch of these tiny mistakes. half of my conditions have != and the other half have =!
ty โค๏ธ
No, but you can delete projectiles
Or force lower stance on a player
how would one go about creating a trigger on certain coordinates? I've been googling it for an hour now
a loop + createTrigger
yea, but in createTrigger where you set the position, what should go in there?
createTrigger ["None", getPos [0,0,0]]; for example doesn't work
I know I know, but not even google could help me out
first of all the default trigger is EmptyDetector
and second of all:
{
_trigger = createTrigger ["EmptyDetector", _x];
} forEach [_pos1, _pos2,...]
_pos1, _pos2, etc. are your coordinates (each in format [x, y, z])
I have nightmares about _x 
No need for a loop if this is onetime
Unless i missed some part of the convo
I assume I have to declare the positions manually with another line?
you can just inline them
like that? forEach [(0,0,0)]
also I still don't know if you want just one or multiple triggers
no
Just one
then no need for loop
Ha, I was right :3
_trigger = createTrigger ["EmptyDetector", [x, y, z]];
you should never use getPos anyway
Help please!
Any way to create a laser target so an AI can fire laser guided missile?
Didn't manage to pull this off, at all
I don't need the player to do that, just via script (cinematic purposes)
create a laser target object
What do you mean? Did I miss some editor object that simulate laser target?
is there altis discord
no. the laser target is an object. I don't remember its type, but if you create a player, lase, and use this command, you'll find out:
https://community.bistudio.com/wiki/laserTarget
I think it was B_laserTarget or something
what does it have to do with this channel?
Thanks, will do
It's a arma server
trying to find it's discord
That's what it has to do with this channel

this is an Arma 3 server, but channel is dedicated for scripting. If you check the left column you can see many "#" symbols and text next to them, the text has meaning.
make sure you know the full name of the server you're looking for, because Altis is a map, and you have thousands of Altis Lifes etc.
I've got two trigger which is meant to only activate when there is a civilian present.
Set up as such:
Type; None
Activ; Civ
Activ type; Present
Not repeatable
Server only
Condition; this
Different activations are either
"GRFWin1" call BIS_fnc_endMissionServer;
"BLFWin1" call BIS_fnc_endMissionServer;
& 25 on timer countdown, all timer values
Both of these triggers are also the spawnpoint of the Blue & green teams
After mission start & 25 second passes - one of the two triggers gets activated, which one is on random, even through neither of them have any civilians present
Why, how, and what do I do to fix it?
maybe animals are activating it for you ๐คฃ
I thought about it, since it's above water, so it could be fish))
But it's 1x2x1, hovering above the sea, so don't think it's the fish either
Unless Arma has added flying fish in a stealth update ๐
change the condition to:
this && {thisList findIf {_x isKindOf "CAManBase"} != -1}
see if it makes any difference
Alright, will try
The mission didn't end after 25 seconds, so I assume it worked, thanks!)
I have a marker (an ellipse) and I need it to slowly move on the map from its current position to a set position. Is there a command that can help me with this? If not, I might need a little help with the math. I just need to be pointed in the right direction.
Old position, new position, interpolate by time
There is a interpolate command afaik?
You just need to come up with a 0-1 value that indicates the process of the move, you could just base that on current time
(time-_startTime)/10
10 seconds for it to move from pos1 to pos2 for example
And then you need to repeatedly update the position with the interpolated one
but seeing as you (should be able to?) treat it as an object you could also just go with setVelocityTransformation
though if you're working with positional coordinates
https://community.bistudio.com/wiki/BIS_fnc_interpolateVectorConstant
might be the way to go if you can't use the above
it's a marker, not an object
we already have vectorLinearInterpolate or something like that
well if BIS_fnc_interpolateVectorConstant doesn't use vectorLinearConversion under the hood it could be slower I guess 
well, what confuses me is that I need to interpolate a position, not a number. so which should I use?
both can interpolate positions
so do I give it an array instead of a number?
wut? you need array anyway
numbers are for interpolation value
Some BIS functions are drastically better than their command counterpart and vice versa
the arrays (vectors) are the start and end vectors
Syntax:
vectorLinearConversion [rangeFrom, rangeTo, rangeValue, vectorFrom, vectorTo, clip]
Parameters:
rangeFrom: Number - start "from" range
rangeTo: Number - end "to" range
rangeValue: Number - variable range value
vectorFrom: Array - start "from" vector
vectorTo: Array - end "to" vector
clip: Boolean - (Optional, default false if true, range value will be clipped to stay within "from" - "to" range
Return Value:
Array - interpolated vector
This says it returns a vector.
No clue for this one, though lerp is fairly cheap regardless
but could that be a position?
ohhh
a position is a vector ๐
hmm
okay so it basically interpolates any set of 3 numbers so what it is being used for is irrelevant?
Sure
when you define an origin for a vector it becomes a position (so to speak)
okay
Just think of it as a vector from [0,0,0]
Or whatever arbitrary origin
Same as a position
ok
What are these parameters for? and are they not used if clip is set to false?
rangeFrom: Number - start "from" range
rangeTo: Number - end "to" range
rangeValue: Number - variable range value
A2OA: Is it possible to get the AI to target and fire upon a position (or game logic??)?
and then:
_interp = (_val - _from) / (_To - _From);
_newVec = _start vectorAdd ((_end - _start) vectorMultiply _interp)
that's what it does
if you use clip it clamps _interp to the range 0 and 1
so _newVec will always be between _start and _end
doTarget works in A2, no?
can they target invisible things? Some kind of game logic or something?
not those hidden via hideObject. but you can create an invisible target yourself.
A3 CBA has an invisible target
you should be able to port it to A2 with no problem
can it have a side so that anybody whose side is its enemy will open fire upon it?
this is a tank actually
(uses the tank simulation, so AI will target it with their launcher too)
is it a tank in order to get guys to use AT weapons against it?
yeah
and _interp is the interpolation value? the slice?
I don't know what you mean by "slice", but yeah
I'm wondering if those invisible tank targets were already in CBA for arma 2.
but anyway even if they don't it's extremely easy to create one
I presume it is. But I don't know how, so I'll have to find that information.
all you need is a model with only view LOD
it can be created in object builder in like 10 seconds
this is the one CBA uses
but you also need some kind of config for it, right?
yes
I don't know where to look to find a working example of a config
arma 3 has a vanilla one
check if A2 has one too
B_TargetSoldier
I think I found cba's invisible target config for A3. But I have a number of questions about it.
class B_TargetSoldier;
class CBA_B_InvisibleTarget: B_TargetSoldier {
author = "$STR_CBA_Author";
displayName = CSTRING(InvisibleTargetSoldier);
scope = 2;
scopeCurator = 2;
scopeArsenal = 0;
model = QPATHTOF(InvisibleTarget.p3d);
icon = "CBA_iconInvisibleTarget";
class HitPoints {};
};
class CBA_B_InvisibleTargetVehicle: CBA_B_InvisibleTarget {
author = "$STR_CBA_Author";
displayName = CSTRING(InvisibleTargetVehicle);
model = QPATHTOF(InvisibleTargetVehicle.p3d);
crewVulnerable = 0;
type = 1;
cost = 1000000;
}; ```
There's no reference to 'simulation' first of all.
Anything not referenced is inherited
Inherited from what?
The target itself inherits B_TargetSoldier
the target vehicle inherits CBA_B_InvisibleTarget
so the vehicle targets are using whatever simulation B_TargetSoldier is using?
Anything not overridden is inherited, yes
I'm going to need to find an example written for A2.
I've found one from "zeu". However, they don't have a vehicle invisible target. Also, their config is really long, and uncommented, and it's not clear to me what parts are actually necessary to include, or if they have a purpose in conjunction with use as an invisible target.
this is the full CBA config:
https://sqfbin.com/oyawiraxepopokilumom
anyone got any suggestions for a racing script? Like something that lets you (programatically) place a start, checkpoints, and an end?
you could use waypoints
not really the same thing I dont think since there's no penalty for skipping checkpoints is there?
also, an idea I had was for destroyed vehicles to spawn at their last checkpoint, so waypoint wouldn't work for that I don't think
how many checkpoints do you want to have?
not sure, lets say a few dozen
okay. I will just write you a script for 5 and you can edit it
just showing you one way you could do it
okay
so you could have a variable for each player that keeps track of their progress
and put a trigger at each checkpoint
make the trigger activation for any player, and make it set that player's variable to true for that checkpoint or something
idk
and in the trigger code, they only get to complete a checkpoint if the LAST checkpoint is also complete. Else it just gives them a hint and says they need to complete the last checkpoint
Nice script, this prints your total Arma 3 playtime in-game.
_daysplayed = getStatValue "GamePlayedDays";
if (_daysplayed > 365) then {
player sidechat format ["You have played Arma 3 for %1 years total.", round(_daysplayed / 365)];
} else {
player sidechat format ["You have played Arma 3 for %1 days total.", _daysplayed / 365];
};
You have an error in your display of days.
Does findEmptyPosition return ATL or ASL?
Neither. AGL
ugh
Just a warning, this command could take up to 15ms if player never go around the position you are looking at or used https://community.bistudio.com/wiki/findEmptyPositionReady until it return true
Does anyone happen to know the code that is executed by the default heal/repair action and the conditions under which they are shown?
Basically can someone tell me how the addAction-code of the heal/repair actions would look like?
well the heal action im pretty sure is when your health is under 75%, and it heals you to 75%, for repair, no clue
Where can I find a sqf syntax highlighting plugin for notepad++
Thanks, the VS Code one is really nice, I will use that instead of notepad++
well I'm using it centered on a player position so I don't expect that to be a problem
Hi, all the defaults are listed here.
https://community.bistudio.com/wiki/addAction
to give you an idea of โโa code to repair or heal here :
player addAction ["Repair", "{cursorObject setDamage 0}"];```
What I mean is the actual in game actions because if you move while someone is trying to heal you you don't get healed to it's not as simple as cursorObject setDamage 0;...
When the player is treated and he is moving I think it is normal that the action does not work. As for the code that I sent, it doesn't matter if it moves because with this addaction it is instantly heal
the heal addAction uses the "heal" action (or some other variant)
and the repair one uses the "repair" action (or some other variant)
the actions themselves are engine codes, so hard to say what they do
what causes 'error zero divisor'?
is that an empty array? iirc if the index is out of range it'll say as such
yes, out of bound
suppose _path is an array of waypoints: _path set [count _path - 1, _waypoint];
if this is returning 'error zero divisor' is it likely that _path is an empty list?
I am just messing around with a localhost exile server. Is there a way I can spawn in an indy squad ai in my group? I am using NSS Admin console to execute scripts.
yes
I have no idea what you mean by "indy squad"
sorry, the faction for players in exile is indifor. so I can spawn in indy ai but they are not grouped to me so I cannot control them etc
how do you spawn them?
_trg setTriggerStatements ["this", "_unit = group player createUnit ['I_G_Soldier_AR_F', getPos player, [], 0, 'FORM']", ""];
this should already spawn them in your group
Hmm... maybe the mission doesn't support it
I think you don't get it. I DO want the standard code. If I just needed something as simple as the thing you send I wouldn't have asked.
Ah, ok. That's unfortunate since I would have loved to add heal/repair-actions for different (body)parts.
idea: what rank are they?
maybe they outrank you and you're not the group leader
hi, can we get a "callback" with remote exec ? example : "I want to get a result of a function only on the server"
literally call it back by the server
oh ok but the "back" is an other "remote exec" in the first remote exec ?
?!
you can write something like this:
//fn_remoteExec
params ["_args", "_fncName", "_callback"];
_result = _args call (missionNamespace getVariable [_fncName, {}]);
[_result] remoteExecCall [_callback, remoteExecutedOwner];
[_args, "my_fnc_bla", "my_fnc_callback"] remoteExec ["MY_fnc_remoteExec", 2]; //execute my_fnc_bla on the server, and return the result to my_fnc_callback on the client
oh yeah i see so thanks you for your help i will modify my function
i'm in a bit of a pickle. i'm looking for a way to make use of the virtual arsenal's garage that works with multiplayer. so far, all i've been able to manage is clientside vehicles that are indestructible. any ideas?
There are a few mods that use thay sort of thing
I could find them tomorrow and show you but I donโt know
Is there a way to attach a parachute to a memory point on a container rather than use in game script?
Is there a function to detect whether MROT are spinning/engine has fully powered down?
no. you can use engine on and off event handlers and guesstimate the engine state using timers
Not even like an animState?
I don't think so. you can try 
if the rotor has a mem point you can use selectionVectorDirAndUp and check if it's still changing. if not the rotor has stopped spinning
Hello, I have a simple question about breaking out of loops. I have this function that I want to completely break out of its foreach loop when the if statement is triggered. I've looked up "Break", "BreakOut" and "exitWith" but all of these break out of the if loop instead and the foreach loop continues. Am I using them wrong?
unitTargetFunc=
{
params ["_unit","_arrayIndex"];
{
//select unit from array
targetedThreat= (_x select 1);
targetStatus = targetedThreat getVariable ["Targeted", false];
//if unit is not already being targeted then do stuff
if(!targetStatus)then
{
//unit is targeted and being shot
targetedThreat setVariable ["Targeted", true];
_unit disableAI "autotarget";
_unit disableAI "target";
_unit doTarget targetedThreat;
systemChat format ["%1 targets %2",_unit,targetedThreat];
}
//else statement triggers for some reason
else{
//systemChat format ["unit is already targeted"];
};
}
foreach Threats;
};
if loop
what on earth is an if loop?
all of these break out of the if loop instead and the foreach loop continue
no.breakwill end the loop, andbreakOutwill break all scopes up to thescopeNameit corresponds to
exitWith will only end its own scope.
Did I say if loop? damn I'm worse than I thought. Sorry I'm a bit sick and can't think straight. Rookie mistakes today are expected
in any case break is what you should use
Thanks you, Much Appreciated
what is the easiest way to get ammo left in a tank? should I just loop through the turrets or is there a better way?
magazinesAmmo and magazinesAllTurrets
thx will try those
I dont have high enough version for the alternate syntax :/
any tips on how to detect machine gun / cannon mags? and exclude smoke etc
23:54:25 Error in expression < selectRandom _buildings;
selectRandom (_building buildingPos -1);>
23:54:25 Error position: <_building buildingPos -1);>
23:54:25 Error Undefined variable in expression: _building
23:54:25 File path, line 15```
```sqf
params ["_taskLoca", "_vehicleName"];
_finalPos = [];
_radius = random [300, 500, 700];
_angle = random 360;
_rdPos = _taskLoca getPos [_radius, _angle];
_nearObjects = nearestObjects [_rdPos, ["HOUSE", "BUILDING"], 100];
_buildings = [];
{
if (_x buildingPos -1 isNotEqualTo [] && {_buildings pushBack _x >= 4}) then {break;};
} forEach _nearObjects;
_building = selectRandom _buildings;
selectRandom (_building buildingPos -1);```
what..?
_buildings was empty, if its empty, then _building will be undefined
interesting maybe I can use the ammo "simulation"
Hi, is there a situation where ASLtoAGL getPosASL _unit would function differently than getPos _unit? I want to replace getPos due to its inconsistent performance and I am wondering if that would break anything
getPos is AGLS, so it's almost completely different
but you must stop using getPos anyway
also unless you specifically need AGL, I suggest you use ASL instead
most commands need AGL / ATL afaik
but no setter command uses AGL
and almost no command uses ATL
it's mostly ASL and AGL
alright, thanks
is it possible to create an eventHandler that checks if a unit is in an area?
no
you have to loop
how do I execute code that is active when a player is in a trigger?
I basically want to change a variable when a player gets into the trigger area
and for it to be repeatable
add the code to the trigger onActivation statement
not that simple. the code is being executed on all clients separately.
basically I'm making a covert script, where if player enters an area, it causes a variable to drop.
do I make an function
set the trigger to server-only, and broadcast the variable to the clients
I told you already. there's no such event handler
i meant a function, sorry
up to you
if all you need is changing the variable on the clients there's no need for a function
you can just use something like publicVariable
although it should work just fine if you use a client-side trigger as well
so, If i want it to be diffrent for every player, i just put a client side trigger, and it won't affect the other players
yes
ok thanks
why while command does not work inside Getin and GetinMan eventhandlers ?
it can. but not in a "time-varying" way
the real question is why sleep doesn't work
and it's because event handler codes run unscheduled
does all event handlers runs in unscheduled environments ?
and is there any alternatives as a solution ?
yes
spawn the code
that worked, thanks ! ^ ^
once i put the code in a spawn inside the event handler i cant use the params of the eventhandler
you have to pass them obviously
how do i do that ? :))
_this spawn
player addEventHandler ["GetInMan", { [_this select 0] spawn {
params ["_vehicle", "_role", "_unit", "_turret"];
//code
}];
still doesnt work 
You forget a }
Guys anyone know how to use the restriction module?
if (isnull objectparent player) then {
player addEventHandler ["GetInMan", { [_this select 0] spawn {
params ['_vehicle', '_role', '_unit', '_turret'];
if (_vehicle iskindof "tank") then {hint "daTank"};
while {_vehicle iskindof "car"} do {hint"you are
in Car"; sleep 0.3}
};
}];
};
still not working :3
why on earth did you change it?
I said _this spawn
not [_this select 0] spaw
tried with _this spawn didnt work, as soon as i changed _vehicle with objectparent player it worked, it seems that the variables are not registered
Need help with disabling a trigger and having it re-enable for activation when an object is within the trigger area after a script has ran, if that makes sense?
So, a trigger that activates only when a certain object is within the trigger area, and then it'll fire a script to run through addAction which in the script will enable another trigger but not activate it until said object is within the trigger area
(hope this is understandable haha)
will enable another trigger but not activate it until said object is within the trigger are
wut?
that's the very definition of a trigger
I see wht he means (I believe anyway)
U want another trigger ready to be fired but not until the thing is in the area, just bind the addaction script to a variable and add it to activate condition with an && thislist
yes exactly haha
Yeah just make a variable and broadcast it to the server via publicvariable
object activates trigger>trigger activation runs a script>script will enable a trigger but not activate it until certain object is within the new trigger area
I have tried:
trigger condition: triggerName
script:
triggerName = true;
publicVariable "triggerName";
(this activates it regardless if the trigger is in the area or not)
object* not trigger
Yes as your basically telling the server "fire away" rather than give it a checklist before firing
yes, exactly. trying to have it wait until object is in the area ๐
Something along the lines of
Condition == true && object in thislist
this would go in the script?
No, activation condition of the one u want to be ready to fire
I hate train wifi
Give me a second and I'll write out how you should do it
First trigger
Activation = whatever
On activation
_Condition = true;
Publicvariable "_Condition";
2nd trigger
Activation =
Condition = true && object in thislist
On activation
Whatever else
Dont quote me exactly on the syntax (don't copy paste it directly and expect it to work), as I mention on mobile so scuffed writing = true
But that's what your looking for
yeah. the triggers will be disabled right?
What you have basically done is make it need both requirements met
So the object could be in the zone. But if _condition isnt true then no dice. Wont fire. And Vise versa
I just need the triggers disabled until a script is ran to enable them and then the object placed in the 2nd trigger area will be allowed to activate it
If the _condition is true but object isnt in zone. Wont fire. It waits until both are true then boom. Triggers
ohhh, okay. ill give it a go and subsitute what you wrote and let you know ๐
alrighty, thank you bud. ill let you know ๐
hope you have a fun train ride as well
Cheers, Londoners dont understand covid regulations so fingers crossed
If u need any help I can offer it in my limited capacity. I'm free for the next 2 hours
yeah. and oh okay. ill test this and let you the outcome
Probably worth mentioning that doing things in the form of boolean == true or boolean == false is bad practice
boolean values are usable directly in conditional expressions
so writing it as just boolean or !boolean is better practice
depends on readability ofc, in some (rare) cases it's better to ==
true, always exceptions to things
if (alive player == true)```
I feel like ```sqf
if (alive player)
is more readable
of course, I was kidding with this one :D
not just better, but also necessary
does anyone know how to deactivate a trigger?
only thing i know is deleteVehicle triggerName but it deletes it
oh, how?
A trigger should deactivate immediately after its code is run unless u done some loop stuff
On deactivation exists also if you want to do cleanup after the script runs
maybe you should try exitwith {};
wheres that go
in the triggers activation
if ("the condition to deactivate") exitwith {};
No, triggers remain activated until the condition is no longer fulfilled.
if (isnull objectparent player) then {
player addEventHandler ["GetInMan", {_this spawn {
params ["_vehicle", "_role", "_unit", "_turret"];
if (_vehicle iskindof "tank") then {hint "daTank"};
while {_vehicle iskindof "car"}
do {hint "You are in"; sleep 0.3}
};
}];
};
still cant get the variables inside the params to work 
I thought repeatable had to be ticked for that to happen
Well. The more you know ig
so if I have a trigger starting on !alive mySuperUnit, I'd have to end it with deletevehicle _triggername some time later?
Oh, looks like you are right: https://community.bistudio.com/wiki/2D_Editor:_Triggers#On_Dea.28ctivation.29
Only repeatable triggers deactivate.
What do you want to end with that? The On Activation expression?
I think so, some code first, then a bit of sleep and deleteVehicle
You can't suspend (e.g. sleep) in a trigger.
A trigger being activated means that triggerActivated returns true and that the trigger will not activate again (until it is deactivated). This is only related to the On Activation expression in the sense that that expression is executed once every time the trigger is activated, but the code in the On Activation expression is not tied to the trigger otherwise.
i can do the sleep through spawn, technically. but away from this, how can I deal with a one-time trigger if it doesn't delete itself then?
The only issue I can spot is that the parameters for GetInMan are ["_unit", "_role", "_vehicle", "_turret"] according to the wiki: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetInMan
good eye !, i switched from getin to getinman i thought they have the same parameters in order :p
Oh you can of course delete it with deleteVehicle if you want to delete it. I thought you wanted to delete it to stop its On Activation expression from running or something ๐
yeah my bad, I expressed myself wrong
when you want to compare the state of a condition to another one:
_condition1 == _condition2
enableSimulation
The only case I can think of where doing a direct comparison w/ true/false with a boolean value is truly necessary would be in a language w/ operator overloading
but it'd be extremely gross to overload == for a boolean value
wat? what does it have to do with operator overloading? you're comparing the state of some boolean to another
e.g.
_state1 = alive player;
while {true} do {
_state2 = alive player;
if (_state1 != _state2) then {
hint "state changed";
_state1 = _state2;
};
sleep 1;
};
that's not the best example ofc, but you get the idea
there is also a case where you have some unknown type, you can do _val isEqualTo true for example, probably a bit different from the topic, but still
I wasn't talking about your example
I was talking about a case of boolean == true and boolean == false
which is what this was initially about
the topic was never about comparing two boolean variables, that obviously would require ==
ah true (ofc)
(beside some ugly && and ||) that's the cleanest ๐
A simple speed ended up doing the trick ๐
if a script is local to a server, and you remote execute a command to the server, does it take up any network traffic to tell itself?
I'd imagine not, but why even remoteExec to begin with then?
hey guys. so im having trouble with getting a trigger to return a groupID. (truth be told i dont know how to ask the trigger for a groupID) any ideas?
Just get the group of whatever activated the trigger via group and feed that into groupId
is there a way to insert the players name (or rather, the one thats reading it) in a structured text?
example: blah blah blah thanks [name of whoever is reading it]
Depends which name you want
if you want the one set as their identity use name
profile name is profileName
steam name is profileNameSteam
profileName is what I want
my only question is.. how do i incorporate that into a structured text with it.. working?
format["Thanks %1!", profileName player];
or could vary depending on your exact usage
I apologize for my silliness, can someone help me with this script - https://forums.bohemia.net/forums/topic/188449-ai-auto-rearm/?tab=comments#comment-2987434
If I understand right, it should add ammo to all AI units. How can I put it in an endless loop on a timer, every 10-15 minutes
[] spawn
{
while {true} do
{
sleep 900;
{
_x setUnitLoadout typeOf _x; //Reset unit's loadout back to what is defined in its class
} forEach allUnits - allPlayers;
};
};
Given that all units have the default loadout of their class you could do this. @quaint star
When i run this on the server, the netID of uniformContainer & vestContainer is still starting with the clientOwner ID.
Shouldn't it be "owned" by the server instead of client ๐ค
_player = objectfromNetID "2:43206";
_player setUnitLoadout (getUnitLoadout _player);
When i do this the netID of uniformContainer is starting with 2:xxx ("owned" by the server).
_player = objectfromNetID "2:43206";
_player addUniform "U_B_CombatUniform_mcam";
Much appreciated, it works well !
Is there a way to make it work with custom loadouts? Maybe a script that will always keep 1 magazine for the main weapon.
You can use the original script for that and also wrap it in while (true) do
no. it's correct
netID doesn't change. it shows the original owner
Thanks ๐
I am very sorry for silliness again. I understand very little about scripts, almost nothing, Can you please show me what an original script with a 10-minute cycle should look like.
[] spawn
{
private _cfgWeapons = configFile >> "CfgWeapons";
private _mag = "";
while {true} do
{
sleep 900; // Sleep time in seconds. 900 / 60 = 15 min
{
if (handgunWeapon _x != "") then
{
_mag = (getArray (_cfgWeapons >> handgunWeapon _x >> "magazines")) select 0;
_x addMagazines [_mag, 3];
};
if (primaryWeapon _x != "") then
{
_mag = (getArray (_cfgWeapons >> primaryWeapon _x >> "magazines")) select 0;
_x addMagazines [_mag, 8];
};
if (secondaryWeapon _x != "") then
{
_mag = (getArray (_cfgWeapons >> secondaryWeapon _x >> "magazines")) select 0;
_x addMagazines [_mag, 2];
};
sleep 0.1;
} forEach (allUnits - allPlayers);
};
};
Like this (not tested)
@quaint star
using weapons can make this shorter (tho you get same number of mags for all):
_unit = _x;
{
_mag = (getArray (_cfgWeapons >> _x >> "magazines")) select 0;
_unit addMagazines [_mag, 2];
} forEach weapons _unit
this channel is for SQF scripting questions, not Python
oh dear, doing this weapon and magazine thing in scheduled will absolutely cause duping or unwanted magazines and probably sqf errors due to null units
Oh that wasn't mentioned anywhere I've looked. My bad
see the channel description
#arma3_tools i guess
Thanks bro
Thank you very much, it works.
But now I encountered another problem, maybe Arma bug - AI refuses to switch pistol to main weapon and reload it. Same bug was when I tried mods that allow AI to rearm from crates.
Your first script works well without issues. Thank you again
Using the Ace Cargo framework, I've applied make an object carriable, any thoughts how I could increase the interaction distance .
You can't (https://github.com/acemod/ACE3/blob/master/addons/cargo/functions/fnc_canLoadItemIn.sqf#L38)
Is anyone here familiar with arrayIntersect? I need to find a way to get the same result without excluding duplicate objects.
Example:
_arr1 = [1,2,3,4,5,2,3,4];
_arr2 = [4,5,6,1,2,3,5,6];
hint str (_arr1 arrayIntersect _arr2); // [4,5,1,2,3]
I need it to keep the multiple 2's and any other multiple numbers that are in both arrays
Side question: Can I subtract the contents of one array from another simply by doing (_arr1 - _arr2)?
Reading syntax 3 is seems like it should work, but no examples refer to it after that, so I guess ill assume it is working.
For the first question I had, Ive done this as an alternative and I think its working correctly, any input is appreciated.
for "_j" from 0 to (count _visibleObjects - 1) do {
_loc = (_visibleObjects find (_visibleCache select (_j)));
_stillVisible pushback (_visibleObjects select (_loc));
};```
This should be making _stillVisible into an array of all elements that are in both _visibleObjects and _visibleCache
is there a way to reload compositions manually without restarting the editor session?
_arr1 - (_arr2 - _arr1) ?
#arma3_editor might be better, afaik no just reload the same mission
yeah, I just think it'd be a scripting command if there was
think compos is handled by fncs
hmm I could give that a try, not sure if it will give the same result or not. Also did you mean to type _arr1 = (_arr2 - _arr1)?
no
And you think that would give me an array containing things that were the same between the two arrays
it gives you the elements of _arr1 which are also present in _arr2
private _arr3 = _arr1 select {_x in _arr2}; won't exlude duplicate objects
ill give both of these a try, thankyou
hmm yours didnt seem to work Untelo, it just shot back the same list as _arr1. Ill give SebsterBL's a try now
I believe your method is working SebsterBL, thankyou both for your help!
damn I was hoping this would solve my problem, it did not, ill keep looking
what SebsterBL said does what you asked
I know, I commented on it working just before I thanked them. That comment there refers to it solving the overall issue which is something else. I was hoping fixing this problem would fix the big picture, but it did not
okidoo
its not worthwhile asking in here for help with the big thing I dont think, too much stuff, would require a one on one or something
you can try
im trying to dynamically hide certain objects based on players line of sight, ive come across an issue where objects flick in and out of existence
im gonna try some stuff here, just thought of another approach to it, will let you know if it doesnt work out
I think it has to do with not saving the list of hidden objects correctly
Is there a script command for "Scan the Horizon" to execute instead using the GUI?
Like as example _unit doWatch bla bla
I dont want to use the doWatch stuff, just simple the Horizon stuff.. cant find any infos about this in the web /BI sites and here.
Maybe someone knows it, would be cool
Edit://
Its for automated defense turrets to give them some life but needs to be simple (addon integrated via Eventhandler Init)
Does waitUntil work inside an array? This is my code
{
waitUntil {((_x distance killer) <= 10)};
_x say3d "heartbeat";
} forEach [p1, p2, p3, p4, p5, p6];```
Nope (https://feedback.bistudio.com/T152946) ๐ฆ
Yes, waitUntil works in forEach-loops.
thank you ๐
found this at this page by Leopard
_unit doWatch objNull
maybe this will do it, just need to get the turret looking around without any big looped scripts
does that mean I can have multiple that are one after each other?
or should I have each in its own file?
hello, i've got a question - in a multiplayer game i have a noticeboard, and that noticeboard has a script like this one: ```sqf
this addAction ["Means CVPI LB", {
private _vehicle = createVehicle ["M_CVPI", [14909,13771]];
_vehicle addAction ["Last 112 call", {
[caller_position] spawn gps_fnc_main;
}];
_vehicle addAction ["Last 911 call", {
[caller_position2] spawn gps_fnc_main;
}];
}];
depends on what kind of items you are adding
I'm pretty sure addItemCargoGlobal works for most
medical supplies, some explosives, a backpack, portable ladder, etc
well, for items like the meds and explosives, use _vehicle addItemCargoGlobal [item, count]. For backpacks you need to use addBackpackCargoGlobal.
allright so with this script a player can walk to the noticeboard, spawn a car and the car will have those items in its inventory
is that correct?
yep
ok, thank you ๐
np
how can I check if a position is unobstructed? I am placing several objects at random positions in a building via buildingPos. I do not want any two objects to be put in the same location, so I need to check if the chosen position already has an object.
I don't understand what you mean. Can you provide an example?
like
{
waitUntil {((_x distance killer) <= 35)};
_x say3d "heartbeat";
} forEach [p1, p2, p3, p4, p5, p6];
{
waitUntil {((_x distance killer) <= 25)};
_x say3d "heartbeatfast";
} forEach [p1, p2, p3, p4, p5, p6];
{
waitUntil {((_x distance killer) <= 15)};
_x playsound "chase1";
} forEach [p1, p2, p3, p4, p5, p6];```
@willow hound
_position = _center findEmptyPosition [0,0,"B_Boat_Armed_01_minigun_F"];
@past wagon
thanks
I think I'll use onEachFrame instead
u should put sleeps in waitUntils
otherwise it is executing the check as fast as it can wasting resources
so like a delay?
yeh uiSleep or sleep
uiSleep uses uiTime not simulation time im not gonna pretend to know what it means but uiSleep is usually more reliable
Suspend execution of script for given uitime. uiSleep is a sleep method to delay script execution where script time/simulation time is stopped. uiSleep is basically using the system time (uiTime more specifically) and not simulation time. So in the cases where sleep command would get stuck indefinitely, uiSleep can still be used to effectively delay script execution. For example in a mission briefing or an editor or when simulation is paused in general.
ok
looking more into it, waitUntil is something that only happens once, so I think I'm going to use onEachFrame to check the distance instead. Thank you though!
@warm swallow actually i was dumb before that wont work
is possible to make a script that gives loadout when you aproach an object
all itll do is on the first loop wait for the first player in the array to get with 35meters then itll play the sound and then wait until the 2nd player in the array gets within 35meters
yes
you would have to get classnames of everything in loadout, (export loadout from arsenal), and use code like
addVest _vest;``` for each part you want
i saw that fault as well
i wish there was an event handler for distance
like this
[["GOLD_M4_Mk8_10_5_2","rhsusf_acc_nt4_black","CUP_acc_ANPEQ_15_Black_Top","rhsusf_acc_eotech_xps3",["rhs_mag_30Rnd_556x45_M855A1_Stanag_Pull",30],[],"GOLD_acc_MAGPUL_MVG_blk"],[],["CUP_hgun_Duty_M3X","","CUP_acc_CZ_M3X","",["16Rnd_9x21_Mag",17],[],""],["tfl_new_blk_fs_uniform_g",[["FirstAidKit",1]]],["M_MAR_CIRAS_Ranger_v3_1",[["16Rnd_9x21_Mag",4,17]]],["BDU_RangerBelt_v6_1",[["CUP_PG7VL_M",2,1],["CUP_PG7V_M",2,1]]],"Maritime_Cover_ComtacIII_Arc165","USP_BALACLAVA2",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","Louetta_GPNVG_1_blk_alt"]]
you could just create a dummy ai with all the gear that you want your player to have when he enters the area, and use
player setUnitLoadout [getUnitLoadout loadoutplayer, true];
@astral lynx
onEachFrame
{
_d1 = p1 distance killer;
_d2 = p2 distance killer;
_d3 = p3 distance killer;
_d4 = p4 distance killer;
_d5 = p5 distance killer;
_d6 = p6 distance killer;
}
``` I have this, and I know I need to use if statements to play the sounds, but how will they fire if I only run the file its in at mission init
never mind I can use a while loop

{
While {(_x distance killer) <= 35)]} Do {playsound "heartbeat"};
} forEach [p1, p2, p3, p4, p5, p6];``` i have this now
will still only play for the first person if they meet the conditions
for each only goes to the next element after the code has completed
so until the while {} condition isnt met itll continue to stay on that element until they no longer meet the condition
hmm
{
[
_x,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{
_caller playMoveNow "Acts_carFixingWheel";
remoteExec [titleText ["A Generator is Being Repaired", "PLAIN", 2]];
},
{},
{
params ["_target", "_caller", "_actionId", "_arguments"];
remoteExec [titleText ["Generator has been repaired", "PLAIN", 2]];
_target say3D "s2";
remoteExec [titleFadeOut 5];
_target setVariable ["repaired", true];
execVM "repaired.sqf";
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _x];
} forEach [g1, g2, g3, g4];```
im using forEach here in a difference instance, but it can go in whatever order,
just got home. lets see what yall been chatting about today.
Howdy!
don't use uiSleep in most cases. sleep is fine.
hi, to my previous question i would like to ask, if there is any script that i can use to set a dynamic simulation for the spawned vehicle? for example when a player spawns the vehicle and dies so the vehicle is abandoned i don't want to drain performance on spawned vehicles that nobody uses
i would make this all local instead. this wouldn't work anyways because you would have to remote execute stuff.
should I put it in InitPlayerLocal?
nah, rewrite it. let the local machine run the loop. no need to be sending potentially a lot of remote executes for a sound that will take up network traffic
There's various issues with this. Aside from locality, forEach in sqf is not parallelized so you won't actually be creating multiple while loops at the same time as it seems you're assuming. Not only that, but your while loops will immediately end as soon as the player is outside of the 35m range and then never activate again unless this code runs again.
sounds and ui, keep it local
got it.. how would you suggest I do that
i would use onPlayerRespawn.sqf to create the loop and use while {alive player} do {} for your condition. it will exit when the player dies, and a new loop will be spawned when they respawn.
can i use this for that?
https://community.bistudio.com/wiki/enableDynamicSimulation
will it work?
yes, you will use this command
or do i have to generally disable simulation first?
ok thanks
dang, on this particular mission, the players don't respawn, its sort of like a 1 life kind of thing
then modify it accordingly and put it in initPlayerLocal.sqf
you can yes
nice!
while {alive player} do {
if (random 1 < 0.3) then {};
//etc
};
one more question, how do I get sound to play on one client only. Like if I don't want everyone to hear it, only one player
do you need more guidance?
playSound is local
oh
i appreciate your offer but this time i think i can handle this on my own ๐ i feel like it's a pretty straight forward script ```sqf
this addAction ["Means Sheriff Charger NEW", {
private _vehicle = createVehicle ["M_Charger12_NEW", [14909,13771]];
_vehicle addAction ["Last 112 call", {
[caller_position] spawn gps_fnc_main;
}];
_vehicle addAction ["Last 911 call", {
[caller_position2] spawn gps_fnc_main;
}];
_vehicle addBackpackCargoGlobal ["B_Bergen_hex_F", 1];
_vehicle addBackpackCargoGlobal ["TFAR_rt1523g", 1];
_vehicle addBackpackCargoGlobal ["CUP_B_SearchLight_Gun_Bag", 1];
_vehicle addBackpackCargoGlobal ["CUP_B_SearchLight_Tripod_Bag", 1];
_vehicle addBackpackCargoGlobal ["ACE_TacticalLadder_Pack", 1];
_vehicle addItemCargoGlobal ["TDD_Talon_Mag", 6];
_vehicle enableDynamicSimulation true;
}];
so something like this @fair drum
While {alive player} Do {
if (player distance killer <= 35) then {playSound "heartbeat"}};
remember to put a pause in there
where would I put it exactly?
and in this script, will the audio file called loop ***after ***it has ended, I don't want it to keep restarting you know?
no, as it is, every time that if statement is true, its going to start the hearbeat file from beginning
so your pause needs to be at least the length of the sound file
check your locality of enableDynamicSimulation
local effect, what does it mean for me?
if its local, will other players experience its effect?
๐ค you're right they won't, you got me ๐ so how do i solve this?
can I also ask while I have your time, sometimes sound files that I put into the mission will at first will not be found, and then randomly sometime later stop working, its super annoying. And I check multiple times for typos, what else could it be?
how do we tell other clients to do a command?
remote exec?
thank you @fair drum ๐ will do it
...but tomorrow, it's already 3:45 am
check to see if they exist in CfgSounds when you load up the game (if its just a mission, preview and use a in-preview config viewer)
got it
While {alive player} Do {
if (player distance killer <= 35) then {playSound "35"};
sleep 23.55};
is this the correct utilisation of sleep?
it can work that way. obviously it depends on how critical the accuracy of the time is. you can always do it unscheduled if you need more accuracy.
hmm
how would I switch it? and do you think it would be fine do have mutliple different While loops in initPlayerLocal for varying distances. Like 35, play one sound, 25 another, and so on?
use a switch
Sorry to cut into the existing convo here, but im trying to spawn an object on another objects position with createVehicle, but the object is off by a significant margin, is there a accurate position variable I can use? I tried visiblePosition, position, and positionASL
i thought about that but I would have to also include the sleep, thus if the player gets closer than that it wouldn't work
look at the parameters. by default the last parameter is "NONE". Use "CAN_COLLIDE"
I was about to edit my message with collision being the issue, thankyou for the fast help!
in mind, this may cause things to be arma'd
all good in this case, its just for reference
ok,.
alright tarkov's back up. fades away
Major problem, when hiding objects in a while loop it causes the object to rapidly appear and disappear, causing a flickering affect. Is there a method that doesnt cause this?
lets see the code
while {_render} do{
for "_i" from 0 to (count allObjects - 1) do {
if !(worldToScreen getPosASL (allObjects select (_i))
isEqualTo []) then{
//if (([player, "VIEW"] checkVisibility [getPosASL player, getPosASL (allObjects select (_i))] > 0)) then {
_visibleObjects pushback (allObjects select (_i));
//};
}
else {
_notVisibleObjects pushback (allObjects select (_i));
};
};
//systemChat (format ["All:%1", count allObjects]);
//systemChat (format ["Vis:%1", count _visibleObjects]);
//systemChat (format ["notVis:%1", count _notVisibleObjects]);
{_x hideobject false} forEach _visibleObjects;
{_x hideobject true} forEach _notVisibleObjects;
};```
@fair drum
for "_i" from 0 to (count allObjects - 1)
forEach
_visibleObjects pushback (allObjects select (_i));
why do you make an array only to loop over it all over again? do it all in that loop
causes the object to rapidly appear and disappear,
that's how schd environment works
you have to use unschd env
and last of all, why are you doing any of this in the first place?
also your calculations are wrong
Im new to advanced scripting, and using a for loop with "_i" let me specify only certain ones to go to _visibleobjects. I imagine there is a better way to do it with foreach, I just dont know it. Ill look into running it in an unschd env, didnt know that was something to take into account. And what do you mean the calculations are wrong
worldToScreen getPosASL (allObjects select (_i)) isEqualTo []
iirc correctly this happened when object was offscreen
an object has bounds. just because its position is offscreen doesn't mean it should stop rendering
(or was it when it was behind the camera?)
using a for loop with "_i" let me specify only certain ones to go to _visibleobjects
allObjects select (_i)
that's literally_xin a forEach loop...
I was trying to fix the flickering issue before moving onto getting the bounds to work. I originally tried all of this with checkVisibility but for some reason that function detects almost nothing
that still doesn't answer what you're trying to achieve with this
again, im new. While that might seem like an obvious solution to you, it is still something im trying to figure out
Im trying to save performance in cluttered areas of my mission
{_x hideobject false} forEach _visibleObjects;
you wrote it here
It seemed simple there
you do realize that every engine in the world already does what you're doing here, right?
I doubt you'll save any performance
not rendering performance at least
that's for sure
tho when you hide an object it also disables part of its simulation
regardless of my reasoning behind it, ive been at it for a couple days now and would like to reach the end of it. Your help so far has been exceptional
This is something I came across early on and is unfortunate for what im trying to do. I looked but couldnt find a way to retain collision while also hiding it, or a method of forcing a specific lod to be loaded. You wouldnt happen to know a way?
hmm, ok. I thought that might be the case, ill work around it then
@little raptor im looking into the scheduling, it says code in triggers runs unscheduled. This code is spawned through a trigger, would it not be unscheduled then?
I suggest you look at simple objects
and dynamic object loading and unloading based on a grid system
similar to Old Man
this could never work in a trigger, because of the while loop
unless you've spawned it or something
[] spawn J3FF_fnc_checkObject;
and if you read spawn it says it's schd
Oh I see, so the fact its in a trigger doesnt trump it then
is there a quick and dirty way to call it in game then
as a "quick and dirty way", ditch the spawn, and write the trigger code like this:onEachFrame {call J3FF_fnc_checkObject}
it runs the code every frame
and unschd
also never ever use a while loop without sleep ever again (unless it's meant as a constant-time loop)
for performance sake?
yes
and remove the while in this ofc
Thankyou for all your help tonight!
what if I have findIf inside a forEach and I want to use the _x from the forEach?
assign the _x from forEach to a variable
am i doing something wrong here?
if ((side group cursorObject) != (west))
0 errors but doesnt do anything when not aiming at a blufor unit
Context?

)