#arma3_scripting
1 messages ยท Page 604 of 1
SetLocation
you mean the command?
which function does this command fill? ๐
No, I mean the operator
the medium-endian defragmented CPU
So Im using MCC modules and I set up an IED. Im trying to put people to attack once the IED is exploded without them attacking prior, but I cant really figure that part out since they attack even if they are hidden behind rocks or cover.
hmm, how to easily get a random normalised vector? for example, in any direction
vectorNormalized [-1 + random 2, -1 + random 2, -1 + random 2]```?
This way it won't be completely isotropic but it will do 
It's an interesting question
๐ค
Don't want to dive deep into this now. But you can for instance generate an array for one 1/8 of variants (for x>0, y>0, z>0) (in matlab or somewhere), store it, then select a random element from there, then randomly flip signs of x,y,z components
looks decent, what you trying to achieve with it?
Isn't it obviousโฆ Fireworks, of course! ๐
ooo nice
with light effects. Just no sound
why not? Just detonate some bombs nearby :Z
@winter rose I found a paper which seems to answer your question, not sure if I can post since its just a link to a PDF which chrome automatically downloads
as long as it is legal and descriptiveโฆ otherwise dm
DMed
โฆI will stay with my method atm ๐
sounds fair :Z
โฆI'm stoopid with maffs
same here, thought I understood it. Then I read more of it
and then I realised it wasnt the best thing to be implimented into SQF
IDK how complex the math you are talking about but it's a good solution to use pre-generated values in such cases
then you just do selectRandom one of them
what, you don't like my```sqf
vectorNormalized [-1 + random 2, -1 + random 2, -1 + random 2]
TBF I dont see anything wrong with it
I was talking about and then I realised it wasnt the best thing to be implimented into SQF
TBF I dont see anything wrong with it
position is uniform, but is angle uniform? I don't think it is
although it doesn't matter much I agree
I sent him some paper from some russian mathematicians with a solution which techincally does what he wants
but was way over our heads
Setting a vehicle's texture in a custom mission for MP, do I want to set that in the vehicle's init, initPlayerLocal.sqf, or initServer.sqf?
do it through Eden Editor properties?
some lines can be seen I guess, but that's for an awful number of dots
not always - good enough
do it through Eden Editor properties?
@winter rose Thanks! It's just that I've read some threads online saying that only host could see the vehicle textures and not the other players.
changes through Eden are sync'ed, no worries
I have found that https://community.bistudio.com/wiki/nearestLocations searches for locations on 2D plane, not in 3D space, Z coordinate is ignored
But it's not stated there ๐คท
well, i mean, is it needed?
if you are on altitude 5000, and you use nearestlocation, you get the same, as if you use it on altitude 0
I don't know if locations can be effectively set to an altitude though @astral dawn
tried with getPos ?
yep, Z is -1 anyway
locationPosition returns 3 components
I don't even understand what it means, it means that its Z component is actual Z component multiplied by -1?
ah wait
Anyway I can set position of a location to a 3d position and it returns a 3D position
it means that altitude cannot be set to locations I think
therefore, a 2D search is the smart choice
wait, you can?
sure
ah, then a wiki edit is in line
(getpos player) params ["_x", "_y", "_z"];
gLoc setPosition [_x, _y, 9000];
locationposition gloc returns [6251.91,4762.31,9000]
@astral dawn are you suresuresure so I can press the button? ๐
yes, a location 9km above surface can't be 50 meters away from me if it was 3D ๐ค
ok ๐
Thanks Lou ๐
updated - thanks for bringing it up, testing and confirming ๐
Hi I want this text to appears for 2 sec "Kill every soldier in this outpost to weaken the enemy" I'm trying this but it doesn't work titleText ["Kill every soldier in this outpost to weaken the enemy", "PLAIN", 2];
https://community.bistudio.com/wiki/titleText
@dusky cairn your example should work - you most likely have another issue in your script
It does not go away. The only problem is that it doesn't go away
@winter rose
otherwise the script is working
yes
weird
I took an old backup. It's working but thanks anyway
The third parameter or 'speed', as it's called in the description, refers to the amount of time the message will be shown on-screen. Multiply each number by 10 to get the number of seconds it will be shown. You can even use floats as input, like 0.1, to show a message for only 1 second.
I bet it would go away if you waited 20 seconds
The main description of the parameter says it's the "time in seconds", but if that comment is correct (and it says it was tested so it probably is) then that should probably be changed to say it's a multiplier
Hello guys. I'm setting up a multiplayer mission and I'm trying to have some specific, playable units have an addAction for a loadout. I cannot figure out how to limit this addAction to the unit itself and only itself. This is what I have in the unit's init:
this addAction
[
"<t color='#008000'>Normal Instructor Loadout</t>",
"InstructorLoadouts\Instructor.sqf",
6,
0
];```
I've tried setting the radius to 0 and 1 but it has no effect and just defaults back to 50 meters. Any help?
try using the initPlayerLocal and onPlayerRespawn files. Give the unit a variable in the editor.
if (player == unit) && (!isNil "unit") then { insert your addaction here };
Can anyone help me with my "While" loop? I'm trying to stop it but it doesn't stop even though the variable changes to false.
// This will give _inTrigger a value of true since script is ran while player is within trigger area
private _inTrigger = [AreaTrigger, player] call BIS_fnc_inTrigger;
while {_inTrigger} do {
// Checks to see if variable needs to be set to false if player left trigger area in hopes to stop the loop
private _inTrigger = [AreaTrigger, player] call BIS_fnc_inTrigger;
// Debug to tell me variable status in-game (true or false)
hint format["_inTrigger set to: %1",_inTrigger];
// !! --> Right here is the problem: If the variable is now set to false, the While loop will still keep looping.
// !! --> Confirming in-game that the variable is now false and keeps looping telling me it's false
Sleep 5;
};
Have you tried removing the second private?
Will try right now
@fair drum What if I have multiple units (specifically 7)?
Do I just use an array?
Like, sqf if (player == [unit1,unit2,...])...
You might have to do some FindIf stuff
Have you tried removing the second private?
@fair drum Wow. I'm completely stupid. It worked! Thanks a lot!
be careful of private usage
Sorry if I haven't put it out there yet but I'm a beginner to SQF so it'll take me some head scratching
FindIf will go through the array and look for something that satisfies the code, it will then return the index of that array that satisfied. If nothing returns, then it will result in -1. So if you wanted it to be true for any of them, and not a specific index you would want to get your result != -1
And since I don't want it to be true for all units, the result should be unit1, unit2, etc...
for starters, I would just name all 7 of them and write it out for each of them, its good practice, then when it all works, then optimize it
Hmm, that's quick & dirty, but hey it should work ๐
if (([unit1,unit2,unit3,...] findIf {player == _x}) != -1) then {};
If any of the units = the player, find If will return the index. So if unit1 was a player it would result in 0 and if unit 2 was a player it would result in 1 and unit3 2 etc etc. So if you want the statement to be true for any of the units in the array, you would want != -1 so that any indexes 0 to inf works.
player in [...] or if you want index, [...] find player, no need for predicate
Hypo, just throws an error saying my second unit is an undefined variable. Lemme try removing all units except for one, see if it works
do sharps way, its simple
if player in [instructor1,instructor2,instructor3,instructor4,instructor5,instructor6,instructor7] findIf {player == _x}) != -1) then {
// Insert addAction here
you'll probably run into the same issue. if a player is currently not active in that unit, it technically doesn't exist. so you'll need to add a
(!isNil "unit2")
etc. it can get complicated for multiplayer scripting
player in [instructor1,instructor2,instructor3,instructor4,instructor5,instructor6,instructor7] findIf {player == _x}) != -1) what is this? missing (, and then <BOOL> findIf <CODE> doesnt exist, choose one, either use findIf, or in
what is this?
๐ I'm sorry you have to look through that!
Sorry if I haven't put it out there yet but I'm a beginner to SQF so it'll take me some head scratching
only use if (player in [array]) then { ...
Trying to mash together the if in and findif methods like that is not what you want and will not work. Also, regardless of being sqf, brackets must always be a matched open/close pair. Don't leave em hanging.
if (player in [instructor1,instructor2,instructor3,instructor4,instructor5,instructor6,instructor7]) then {
//Insert addAction here```
throws me an undefined variable on instructor2
hmm let me check if in
That means instructor2 doesn't exist
No don't check if in that was just me referring to the method you are now using
It does, I'm looking at the unit in the editor rn
And is the variable name exactly and specifically instructor2?
like I said, if you go into game and that unit is not a player OR a AI, it technically doesn't exist as a playable unit
you'll have to add something to skip the code if they don't exist
Alright let me try with AI
So, it didn't throw any errors, but it didn't show any of the addActions either
paste the whole code you have so far
DMs?
you can just link a pastebin or something
you got an extra squiggle on line 2
also, this for multiplayer or singleplayer?
Works!
but now take AI out and it won't. so are you doing multiplayer or singleplayer and do you want AI
btw... assuming you run that code in the init field, make sure the if statement also uses this instead of player.
Otherwise it will be added on all units when one player is in that list (since the init field is executed by every client)
If it wuz me I'd run it in initPlayerLocal.sqf. still need to resolve the non-existent units problem but at least locality would be easier
i'm not sure how you would go about doing an isNil through an array actually
Probably run through with a forEach and add the ones that do exist to a new array
Or something. 2am brain no work
lets say you had a forEach into an exitWith {}. Wouldn't the forEach cancel the code if any of the array was nil instead of just 1 element?
for initPlayerLocal.sqf it's simple:
params ["_player", "_didJIP"];
waitUntil {!isNull _player};
private _namesArray = ["unit1", "unit2", "etc"];
if (_player in _namesArray ) then {
_player addAction [...];
};
and since it only runs when actual people join the mission you won't have issues with AI or non-existing players
lets say you are the first player and no one else joins. wouldn't you still throw an undefined in line 6 because unit2 isn't defined yet due to it not spawning yet?
or is there something with using a string instead of an object in line 4
doesn't matter, it will check if player is in the array, not the other way around
doesn't matter, it will check if player is in the array, not the other way around
Have doubts about this reasoning since the exact same check (using non-string array elements) was previously causing undefined variable errors
Strings would certainly prevent the errors since, you know, they aren't variables that can be undefined - as long as whatever you're comparing them to is a data type that can be compared with strings
if it would return errors, you can always use
if ((vehicleVarName player) in _namesArray) then {
to make it String vs String
Hello! I'm trying to learn how to call a function, specifically this one: https://github.com/gruppe-adler/grad-persistence/wiki/clearMissionData
Can anyone help me run this? I've checked the wiki and am still confused on how. Please @ me, thanks :)
@astral dawn
http://sqf.ovh/sqf math/2018/05/05/generate-a-random-position.html
can probably pretty easily turn this into 3D.
Examples of getPos and random usage.
@unborn drum confused? there is a example you can literally copy-paste 1-to-1, I don'T understand the problem.
@astral dawn
http://sqf.ovh/sqf math/2018/05/05/generate-a-random-position.html
can probably pretty easily turn this into 3D.
@still forum
Yes second variant with square root should be correct I think?
Another idea - generate 3 random numbers x,y,z until position x,y,z is within sphere, then normalize it? I think it should give uniform direction too?
Is there any way I can execute a script whenever someone places a marker in the map (not when lines are drawn but only when an actual marker is placed) and pass the marker that was just placed as an argument to said script?
yeah
in the marker creation window (Don't know if its in vanilla too? I'd assume so?) just add a eventhandler to the "OK" button
How do I find that window? (How exactly can I add an eventhandler to it?)
its somewhere in config I'd assume, can't guide you to it besides telling you to search for it
Ok, could you tell me by any chance how those windows are generally named in the configs (in case there's some sort of naming convention)?
oof
maybe it's not that heavy, otherwise you would notice it on your profiler already ๐
won't notice in profiler if no marker EH's were added, it only starts the PFH on first EH being added
yeah, just looking at the code.
allMapMarkers every frame, should not be that heavy.
I guess it just references some internal array and gives copy of it?
dunno how workz ๐
It just bรถrks away
@Dedmen Thanks.
Hey @fair drum and @hallow mortar, sorry but it was 4 AM my time and I had to sleep. Hypo, yes this is for multiplayer, no I don't want AI. The code is in initPlayerLocal.sqf
If it's in initPlayerLocal.sqf then I'm interested in what this ended up referring to
An error, I'll need to refer this to the unit variable names
Would [instructor1,instructor2,...] = this select 1; work?
No. the operator = means you are trying to set the variable before the operator to the output of what comes after the operator.
Yeah (minus the squiggle on line 2)
i.e. _yourVar = 2 sets the variable _yourVar to 2
this will be a undefined variable
Yeah, I need to tell initPlayerLocal what this is
or just.. not use this and instead use what you intended to use
So instead of this, [instructor1,instructor2,...] addAction...?
I don't think an array would work there
No, you can't do that. addAction only works on one thing at a time
Oh, so instructor1 addAction then instructor2 addAction and so on and so forth right?
wat
yes, BUT you will also need to account for the possibility of those units not existing.
Should all instructors have all the actions?
The actions appear to be different for each instructor unit.
Yeah I want the instructors to have the actions BUT I don't want other units to have said action
Then just add the actions to the instructors
Wait wait wait, let me clarify something
Init field? Tried it, other units can still walk to the instructor and get the action
But the "how" depends on your answer to my question
instructors can use the action on themselves?
Basically what I'm trying to do is have a "personal action menu" that only the instructors can access
Ah
why overcomplicate it then?
you check if player is a instructor
you want all instructors to have the action on themselves
player is a instructor
thus.. add the action to player.
player instead of this. Done.
It looks like each instructor has a different action they need to receive
No no, all instructors have the same actions
Yes, but you still need to work out the undefined variable problem right at the start
Okay, so if no one is in the slot, it will still give the action to the other slots right?
Like, if instructor1, 2, 3 are occupied, but 4 isn't, 1 2 and 3 will still get the actions?
Yes but that's not the problem
it may just error out, because you try to access a undefined variable (if instructor7 didn't spawn yet, the variable will be undefined)
The problem is that your array to check against at the start, may consist of units that do not exist - hence the undefined variable error
Go back to here and have a look: https://discordapp.com/channels/105462288051380224/105462984087728128/732407644198928435
Change your very first line to this:
if ((vehicleVarName player) in ["instructor1","instructor2","instructor3","instructor4","instructor5","instructor6","instructor7"]) then {```
That is what the change I just posted does
but only if you do it like that - player doesn't return a string so you can't compare it directly with a string (using this method)
might aswell check if vehicleVarName contains "instructor" ๐
easier than above, and just as reliable (or unreliable)
But why "vehicle"? Wouldn't that be for a car, helicopter, or stuff like that?
Dedmen's proposal would be
if ("instructor" in (vehicleVarName player))```
so everything is a vehicle... that sounds redundant but what do I know...
When you play as a unit you are actually an invisible brain controlling a human-shaped vehicle.
Well now that you put it that way, that makes sense...
you never wondered why the command to delete anything is deleteVehicle?
Both if ("instructor" in (vehicleVarName player)) and if ((vehicleVarName player) in ["instructor1","instructor2","instructor3","instructor4","instructor5","instructor6","instructor7"]) then { have worked! Thank you guys, appreciate it!
You can set object variable to every instructor and check it, when you add action:
// in instructor init field
this setVariable ["isInstuctor", true];
And when you add action:
if (player getVariable ["isInstuctor", false]) then {
//add action to player here
};
more code, more effort, more inefficient
why not use player setUnitTrait ['instructor', true, true] ๐ฎ
[player, ["instructor", true]] remoteExec ["setVariable"] // !
oh wow. That remoteExec would be a great code obfuscation technique
like sqf [player, false] remoteExec ["allowDamage", player]?
probably wonโt event get send to the server
If you can use the player var, then your are already local to the players machine. Why would you remoteexec on the same machine you are local to?
remoteExec has special handling for local yeah
@still forum I donโt know where to copy paste it. Iโve tried multiple places with no avail.
@unborn drum still trying to call a function?
depends on what you intend to do with that function. init.sqf maybe
Are you sure you are giving the function the correct oarameters, the function exists and your code is executed?
@unborn drum
im gonna tag him again. how dare he ask and then go offline
btw, are knowsAbout values still abstract and are not able to extract precise information from it?
or does someone have new insight?
like, 3.75 = knows side and location but not gun and 1.33333 = knows side but not location
What the heck could go wrong with script commands so fog started looking so?
https://i.ibb.co/NC3BMdM/unknown.png
Too little information
Could be anything with just the screenshot
Starting from a faulty gpu, corrupted game etc.
Need to know what you have done to know
And if it occurs on other systems too
can some explain why this script wont work?
i want player setcaptive false; when rating increases >0
Codeblocks
srry
while {true} do
{ rating player;};
that does nothing but looping endlessly doing basically nothing
Reassign _score inside the loop
i know
so fog started looking so?
I think thats "normal"
thought it needed constant re-checking.
but you're not really checking anything
didnt need it before but nothing wanted to work now ๐
It does nothing because the loop doesnt check anything
you are grabbing the rating, and throwing it away again without doing anything with it
Well, it doesnt get any new values
I guess you want to move your "if" inside the loop
delete rating player?
CODEBLOCKSA
Currently you are running a endless loop, and after the endless loop is over you check the score.
But a endless loop is never over
im trying sorry
what Nica means with codeblocks is see pinned messages for how-to example
You are getting a value, then checking the value in an endless loop
Youre never updating the value
not even checking anything, just getting the value
while {true} do
{ rating player;};
if (_score > 199) then {
player setcaptive false;
};
freaking hidden apostrophe
so.
You grab the score and store the store.
Then you endlessly loop, grabbing the score and throwing it away without doing it anything.
and after the endless loop is over which it never will be, you check the previously stored code
What you probably want is to endlessly loop, grabbing and checking the scope every time. inside the loop
Also true-while loops are bad
Make score some smart public variable and set it inside the loop to rating player
Then set the if as a reverse condition for the loop
And add the if statements script after the while
Not "clean", but ok
Well we don't know what he needs, and what you said can be done easier
Indeed
I would not use a while loop
But an EH
There is a player score eh or similar
is the intention "wait till score goes above 199 and remove the captive" or "constantly check the score and repeatedly remove the captive" ?
remove the captive
both my things say that
just become enemy
which one
the first
so the first.
waitUntil {rating player > 199};
player setCaptive false;
wait until, the players rating is above 199, and then remove captive
aha
๐
Telling someone who doesn't know basic scripting to use a EH, before understanding basic scripting is not the best idea ๐

start small, grow bigger over time
ive used EH. not difficult, but too much thinking :S
Telling someone who doesnt understand scripting to use loops isnt smart
They'll clog up the scheduler and reduce performance
loops are easy
yeah bruh
Nro 1 reason for the "arma 3 runs bad" myth
and when writing like, a dozen lines of code the minimal performance impact doesn't matter much
Not good
clogged up scheduler won't reduce performance by that much, its limited to 3ms anyway
Teach good practise from the start
also true
start small, grow bigger over time
What are you talking about here Furmen?
But that doesn't just magically happen suddenly
There's also mvp that you sometimes use
Teaching a basic thing well can make a big difference in the end
Which for a beginner often works ok, then after you can refine
You have to teach also what are the correct ways
When you start learning how to ride a bike, you don't learn how to crouch down when going 40+ downhill to be as efficient as possible against the wind and keep your maximum momentum.
You learn not to fall over.
Bad example
There is nothing "incorrect" about not having a sleep in your waitUntil, its just not most efficient
and for beginners it literally just doesn't matter
makes no difference to the function of the script
When you learn to ride a bike, you learn to break with the bike breaks instead of the soles of your shoes
sometimes you just have to go "here, this will solve the problem you are currently having" and not worry about teaching a full scripting class on the fly
It matters ALOT
I love my event driven stuff, but it's not like if a beginner puts a singe while True in suddenly you get 0 fps
I think this is the moment where we agree to disagree
And a dozen waitUntil's running won't do anything.
Now if you write lots of scripts, or mods, and end up with hundreds of waitUntils, it does matter ALOT. But in this case that's obviously not the case and thus not required.
Teaching bad practise and not explaining the good one will lead to the person repeating bad practise over and over and over because they dont know better
I'd also add that using pfh style stuff is not an instant fix to any performance problems a beginner might create
There is no bad practise here
if I may offer my own take, i kind of learn by doing the quick and dirty method
Eventhandlers and PFH's are great for the professionals, but a beginner can F up big time with that, while they can't really break anything with a simple while true loop in scheduled
There is no bad practise here
Can i quote you on this in the future?
some of us aren't professional coders in our day jobs and just want to overcome the immediate challenge so the mission works how we want it
Doesnt mean you cant guide correctly
I dont mean Dedmens example is bad, it's adequate
The important thing about such stuff is to know when to apply them and when not to.
But it should be noted that a more appropriate method exists
if all you're doing is literally a single while... and you're not running other massive modsets that might a ton of whiles themselves
... it's not really more appropriate though
Do you know that?
Do you know that?
If someone comes here, obviously working on some kind of framework or a mod, I'll darn well put some fire under them for not taking performance seriously.
But a guy writing 5 lines of code for his quick mission that he's making where performance of this literally won't make any noticable difference... Don't waste time for that, let him learn and don't throw tons of stuff at him that literally doesn't matter right in that moment.
Especially when it costs cpu time
and you're not running other massive modsets that might a ton of whiles themselves
if you do, your own while won't matter anyway. The mods will make out a bigger chunk
The point still stands
A waitUntil is not wrong, but it should be noted that for continued use, more appropriate measures exist
Noted
If you want to teach beginners hundreds of things that they currently don't even care about, instead of simply telling them what they need and want to know then go ahead. Just doesn't make much sense.
Then youre a bad teacher, but a good signboard
Some point the way, some guide the way
๐คทโโ๏ธ
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}]; ```
Where do I put "player addrating 50;" ?
My teachers first taught me how to add and subtract, and told me negative numbers weren't will be gotten to later and are currently not possible.
When they made sure everyone understood that, they moved on to explain negative numbers.
@austere granite where did i say that?
Just reading between the lines while 'avin a giggle is all
Let me stop derailing
@wary dome depends on what you want to do.
But I don't see how Fired handler is applicable here, or do you want to punish players simply for shooting? not for hurting anyone?
what's "this" ?
@still forum your teacher was with you for the whole of the way.
If your teacer told you that negative numbers dont exist and sent you on your way, you would have a lot of problems. Stop giving irrelevant examples that dont apply
I give up. no sense in trying to argue with you, we know that already
But, i have taken this too far. You guys have a fine night
go ahead and hold his hand and teach him everything, I'm out.
"this" was player, but I just put it in to units init field.
I want setcaptive false to happen once fired accumulates
He can feel free to DM me and i will help
think of it like a police holdup
Im not looking into talking here where propper pedagogical methods are frowned upon
after a few warning shots - suspect shoots at us
@ebon citrus maybe its just an issue of preference? some of us prefer to be told all of it off the bat, others just what we need atm. I dont know.
wow.
oh, it goes between the curlies
player addrating 50;}]; ````
Thats what i needed
im realized that im just using score to count events until player setcaptive becomes false
maybe theres a better way to change setcaptive by doing other things, obviously i want the enemy to not shoot at first, but after whatever (havent thought of what yet) shooting breaks out
think of it as a police "put up your hands!" gone wrong.
adam_playerShotCount = 0;
player addEventHandler ["Fired", {
adam_playerShotCount = adam_playerShotCount + 1;
if (adam_playerShotCount > 12) then {player setCaptive false};
player removeEventHandler ["Fired", _thisEventHandler];
}];
waits till over 12 shots, then removes captive, and removes the eventhandler as you don't need it anymore
once too close boom
maybe player distance to enemy?
thats relatively hard
You'd need to find nearby units, and then filter if there are enemies
yeah. i just understood what playershotcount is. much better than score lol
while i have your attention, would that code block be repeatable like if there where multiple "confrontations" per missons?
you could just use a sleep 30 for simplicities sake
you can only remove captivity once
yes to have it reset to true again
if you readd it some way, just paste that exact code again, it will add the eventhandler again, and start counting shots from 0 again
i see
Sometimes there is a need to remove several elements from a list at once, not caring about changing elements indexes.
I've wrote a simple function to do it.
Maybe someone could find it useful.
/*
Function for deleting list entries by indexes or by passed condition.
Input params:
_list - the target list.
_params - can be a list on indexes (int) or a condition with _x magic variable (like {_x > 6}).
Result: modified target list.
Examples:
[[3,6,5,2,0,1],[2,4]] call fnc_RemoveFromArray --> [3,6,2,1] (removes third and fifth elements)
[[3,6,5,2,0,1],{_x > 2}] call fnc_RemoveFromArray --> [2,0,1] (removes all elements which are > 2)
*/
fnc_RemoveFromArray = {
params ["_list","_params"];
if !(_list isEqualType [] && ((_params isEqualType [] && {(_params findif {!(_x isEqualType 0) or (_x isEqualType 0 && {(_x < 0) or (_x % 1 != 0)})}) == -1}) or _params isEqualType {})) throw "Invalid arguments";
private _sorted = [];
if (_params isEqualType []) then {
_sorted = _params;
_sorted sort false;
} else {
{
if (call _params) then {_sorted pushbackUnique _foreachindex};
} foreach _list;
_sorted sort false;
};
{
_list deleteAt _x;
} foreach _sorted;
};
For example, you have a list of vehicles in convoy, and I want to check it and remove dead/nonexistent ones from the list.
[_vehiclesList,{isNull _x or !(alive _x)}] call fnc_RemoveFromArray
I've found it extremely useful for my campaign.
afk. btw thank you. All. ๐ what a way to join a channel. i
and thank you all again for the help
@unreal scroll
(removes third and fourth elements)
you mean third and fifth
; true} count
that would be slower than a simple forEach
[_indexes,[],{_x},"DESCEND"] call BIS_fnc_SortBy;
ALOT slower than a simple sort
fnc_RemoveFromArray = {
params [["_list", [], [[]]], ["_params", [], [[], {}]] ];
if (_params isEqualType []) then {
if (!(_params isEqualTypeAll 0) || {selectMin _params < 0} || {selectMax _params >= count _params}) throw "Invalid arguments";
{_list deleteAt _x} forEach (_params sort false);
} else {
private _indexes = [];
{
if (call _params) then {_indexes pushBack _forEachIndex};
} forEach _list;
{_list deleteAt _x} forEach (_indexes sort false);
};
};
If you could just return the altered array, you could just use apply for the code case and return result, which would probably be faster
Thanks
If you sort anyway with BIS_fnc_SortBy, in the code case you could just sort by code. Then you have all the false at start, and true at end, and then you can just deleteRange/resize all the true's away
Ah seems like sortBy requires a number return, not a boolean
turning the bool into 0/1 will probably make it quite a bit slower..
though parseNumber is quite fast.. maybe
or (_x % _x != 0)
that can never be true.
_x % _x is always 0.
I assume you want to check if the array elements are in bounds.
You can use selectMin/selectMax, and check that min >= 0 and max < count
and if you want to check that _params only contains numbers, you can just use isEqualTypeAll
"that can never be true"
Yes, thanks, it is my typo - it should be _x % 1 - to check if it is int, to select the element with it.
don't need to be rounded to full number to select
select 0.1 also works as select 0
but 0.1 in the array will probably be a typo of the intended 0,1
Ah, didn't know, thanks. But from the user's point - it should be the typo in passed params too (or just an error in a script for calculating indexes), so it is better to check it, I believe.
Hey everyone, maybe someone can help me with this as I don't understand what's going on. Probably some stupid novice mistake. If I run this in the debug console, it works:
_objectiveMarker = "marker_target_0";
_objectiveMarker setMarkerType "mil_objective";
_objectiveMarker setMarkerColor "ColorBlack";
Where marker_target_0 is an invisible marker on the map. However, when running it on a script inside an if statement, I get an "undefined variable in expression" error when it tries to change the marker type:
if (_missionPosition isEqualTo "marker_insertion_0") then {
_objectiveMarker = "marker_target_0";
};
_objectiveMarker setMarkerType "mil_objective";
_objectiveMarker setMarkerColor "ColorBlack";
I've checked if the if statement is working, and it is. I could change the characters position by using setPos inside it.
yep. variable is undefined
You're doing that
you define _objectiveMarker inside the if scope, then it goes out of scope and is deleted, and then you try to reference it after its gone
fix
_objectiveMarker = "some default value or whatever?";
if (_missionPosition isEqualTo "marker_insertion_0") then {
_objectiveMarker = "marker_target_0";
};
_objectiveMarker setMarkerType "mil_objective";
_objectiveMarker setMarkerColor "ColorBlack";
OK, got it, it makes sense. Thank you very much.
What's the best way to find the starting indices of multiple strings within a string. For example I wanna retrieve all indices where _display starts in this string:
// The display
private _display = findDisplay 313;
// Validate display
if (isNull _display) exitWith
{
"Unable to get 3DEN display" call BIS_fnc_error;
};
// Input handling
_display displayAddEventHandler ["KeyDown", {_this call BIS_fnc_3den_onKeyDown;}];
_display displayAddEventHandler ["KeyUp", {_this call BIS_fnc_3den_onKeyUp;}];
hello guys i was wondering if there was a script that made it possible for players to dont get shot when not having a wheapon on them? since i was planing on making a mission with players destroying and enemy force to the point where the military could move in.
pls ping me if you guys would like to help
@mortal wagon Just spawn them with captive=true flag, and disable it when needed.
@cosmic lichen I'd probably do it in a similar way to how CBA_fnc_replace works, and instead of replacing substrings it returns an array of indices.
Thanks for the hint, I m gonna check that out
private _fnc_findStringsInString = {
params ["_string", "_search", "_index"];
private _searchLength = count _search;
private _return = [];
private _i = 0;
while {_index = _string find _search; _index != -1} do {
_string = _string select [_index + _searchLength];
_i = _i + _index + _searchLength;
_return pushBack _i - _searchLength;
};
_return
};
something like that probably, reference: https://github.com/CBATeam/CBA_A3/blob/master/addons/strings/fnc_replace.sqf mentioned by Connor
Is there an easy way to disable a Gunner turret without kicking someone inside it?
is there a script that when an ai squad is killed(led by a player squad leader) they can respawn on a select few markers? also would there be a way to remove one of the possible spawn markers once a certain object is destroyed for example !alive commander_e;
sorry im very new and ive only made a few barebone missions so far
is it possible to return ammocount for mags in Cargo inventory ?
magazinesAmmoCargo
Anyone know how to fix a player respawning with a blank face and no identity? I set each different player with a unique identity via class CfgIdentities in the Description.ext file. They're set correctly at the start of the mission and have this set on each players init:
p1: this setIdentity "p1";
p2: this setIdentity "p2";
p3" this setIdentity "p3";
p4: this setIdentity "p4";
I've tried adding the following in onPlayerRespawn.sqf but it's doesn't work. It doesn't give me any errors either.
_unit = _this select 0;
player setIdentity "_unit";
PS: Each players variable name is p1, p2, p3, p4,etc..
And each identity set is named according to each player: p1, p2, p3, p4,etc..
Also, _unit returns the correct player's variable name
So it SHOULD be translating it to: player setIdentity "p1"; if the player is "p1"
// awful solution:
_unit setIdentity str _unit;```
So it SHOULD
nope, as _unit is an object reference
if you setIdentity "_unit", you set the identity to the string "_unit", not "the unit but as a string"
Just learned something new, thanks!!
@still forum {_list deleteAt _x} forEach (_indexes sort false);
Interesting. It doesn't work for me at all.
Seems like we need to sort it before starting foreach cycle.
{} foreach _indexes;```
Ah, yeah, sort returns bool.
I thought _indexes returns sorted, yeah it doesn't derp.
Yeah needs to be done in a seperate statement before then
๐ค https://community.bistudio.com/wiki/setGroupIconsVisible anyone know if that has local or global effect?
know, no, but I would say local
aL eL I think
of course, if you can test and come back with resultsโฆ ๐
or aG eL
anyway, it should be a combination of a[G|L] / e[G|L] ๐
just tested on my dedi. it's eL
aG?
arguments are boolean, last time i checked those dont have locality :P
(what am i missing?)
hah, I half-read it (thought there was a group param at some point)
(my bad, am @ workz)
Thanks for testing! ๐
@jaunty zephyr Can you test https://community.bistudio.com/wiki/addGroupIcon as well?
I guess it's local too
loooks like it ๐ค
atm i dont have any more players there so if theres any glitches i wont catch them, but as far as playing with getters/setters on dedi/local goes, it looks everything is eL here
Ah, yeah, sort returns bool.
@unreal scroll
No it doesnโt
would maybe be convenient if sort returned reference to the sorted array. But many people will probably just get confused and assume it returns a copy
@winter rose setGroupIconParams does have a group parameter, and it's aL eL
thanks
I would have expected aG eL
Thanks ^^
Have done a plenty times of search, but can not fine; can we use blacklist/whitelist in virtual garage??
Even["Open",false] call BIS_fnc_garage;comes up with all vehicles.
Tried code by Larrow at https://forums.bohemia.net/forums/topic/181683-bis_fnc_garage/ But no luck.
bis_fnc_garage_data is overrided after garage opened.
//CARS
[
//model
"\a3\soft_f\offroad_01\offroad_01_unarmed_f",
//config paths of classes that use above model
[
config.bin/CfgVehicles/C_Offroad_01_F,
config.bin/CfgVehicles/B_G_Offroad_01_F
],
"\a3\soft_f\mrap_02\mrap_02_gmg_f",
[
config.bin/CfgVehicles/O_MRAP_02_gmg_F
]
],
[], //ARMOR
[], //HELIS
[], //PLANES
[], //NAVAL
[] //STATICS
]```
and running this code comes up with error
When using playMission command and regarding the second parameter which is the mission, can I specify a file path such as:
J:\Arma 3\...
To eventually get to the mission? Otherwise where does it start as the base directory?
@slate cypress see examples
https://community.bistudio.com/wiki/playMission
@vernal dust please use pastebin
In what way does it not work? Does it throw an error?
also, you started with \class, is this wanted?
class CfgRadio
{
sounds[] = {};
class RadioMsg1
{
name = "";
sound[] = {"\sounds\Intro.ogg", db-70, 1.0};
title = "Alright we infil in 3 mikes, get ready and gear up fast.";
};
};
{
sounds[] = {};
class RadioMsg2
{
name = "";
sound[] = {"\sounds\Intro2.ogg", db-70, 1.0};
title = "The HVT might leave the compound so we need to move quick.";
};
};
// should be
class CfgRadio
{
sounds[] = {};
class RadioMsg1
{
name = "";
sound[] = {"\sounds\Intro.ogg", db-70, 1.0};
title = "Alright we infil in 3 mikes, get ready and gear up fast.";
};
class RadioMsg2
{
name = "";
sound[] = {"\sounds\Intro2.ogg", db-70, 1.0};
title = "The HVT might leave the compound so we need to move quick.";
};
};
description.ext is not a script; it is a config - you define resources in it
Another idea for in operator:
string in object
Given that objects are hash maps, it's a good alternative to !isNil {object getVariable string}
neat idea, should be usable for any valid namespace tho.
Yeas agree 
I am hoping someone might have a suggestion for me. I am trying to create a script to check if a vehicle has any players in it. the helicopters will be flown by AI and the ones that have no players in them should be shot down. I have a script that works for shooting them down and I have the AI doing what they are supposed to but I don't know how to see if any player might be in the vehicle without checking if each player is in each vehicle.
fnc_hasPlayerCrew = {
params [
["_vehicle", objNull, [objNull]]
];
(crew _vehicle findIf {isPlayer _x}) != -1 // return
};
someVic1 call fnc_hasPlayerCrew;
something like this should work
awesome thank you! I'll give that a shot here in a bit
How do I know if a given object is a terrain object or dynamicly created?
..and another one: how do I know that a given object is a tree?

you can check if object is in nearestTerrainObjects
I don't remember about any specialized commands that allow for easy detection if object is an terrain object.
Wow that's a whole new branch of thinking emoji evolution
that's a big thiiiiiink
That's arma face when I do nearestTerrainObjects and it returns six thousands of them and I start iterating them
it's more like

๐คฏ
welp it's retarded but I think there's no better way.
Unless terrain objects have special netId or smth
you should be able to use typeOf, which should return an empty string when it's a terrain object
not always
Houses will have classes
and a lot of other stuff too.
but some bushes or trees or rocks might not have them.
but the object itself (which is placed in terrain) doesn't have a config entry, even when they exist in the configs
but the object itself (which is placed in terrain) doesn't have a config entry, even when they exist in the configs
houses do
hmm... so the only way to be sure is with:
_object = "<some_object_you_want_to_check>";
_search = nearestTerrainObjects [getPos _object, [], 1];
if (_object in _search) then {
return true;
};
something like this, the if in then will most likely not work
yeah I guess so... thanks
typeOf <obj> == "" should work for most of the vegetation and rocks I think.
but if you want to be 100% sure...
what's the use case?
replacing the check _object in _terrainObjects, while _terrainobjects is a huge array, I am iterating all objects within a large area
nearestTerrainObjects has a "tree" filterโฆ
If I place the following in initServer.sqf, it would show up for every single player, right?
player addMPEventHandler ["MPHit", {
params ["_unit","_causedBy","_damage","_instigator"];
hint "Test: I got hit!";
}];
Yes, in the sense that that hint would appear for everyone whenever anyone got hit
No
@tough abyss initServer runs on the server only, and player is objNull for a dedicated server
@hallow mortar
add this to the init.sqf only, should be fine
Also check out https://community.bistudio.com/wiki/Event_Scripts
add this to the init.sqf only, should be fine
@winter rose Thanks for the clarification!
Player is a variable that only exists on the local machine of each player. Therefor it can only be used if the code is run on each client. F.e. through init, initPlayerLocal etc.
Got it, thanks!
is there a way I can tell an if X then Y option to do nothing?
if (y) then {}, or better, no code at all
Hey guys, have a problem here. Is there a way to change or cancel Curatorโs selecting? For example, I have some Unit Vasya, which I donโt want to be selectable, but need to be editable by Curator. I know there is curatorselected, which returns an array of selected objects. Maybe I can somehow change it?
theres no command to insert an element to a specific index in an array, is there? i found BIS_fnc_arrayInsert though
there is "set" but not insert
not sure if fnc_arrayInsert is efficient, aka using the new select ARRAY thing
thats what i am a bit concerned about but in the end the script will not be time critical
@Dedmen I think I found the right display and I think I can work out how to add the event handler but how do I get the marker that has been place after the 'Ok'-button has been clicked?
๐ค
store previous markers (can grab them when the display opens), grab all markers after ok button click, diff
@Dedmen Isn't that very expensive? Basically what I am trying to do is autometically add a time stamp (in-game time) to the markers description so that if someone places a marker with the description "ZSU-39 Tigris" on the map you always know how old the intel is because the marker description would state the time it was placed (e.g. "ZSU-39 Tigris [0600]").
if (y) then {}, or better, no code at all
@winter rose simple but effective, thanks
@fervent kettle Why would you even what to do that? Or better what do you actually what to do?
What's the deal with filepatching, do the files have to be in the game directory same as the mod or without the @modname/addons/
Using a juncture directly from pdrive to the game directory, would that work?
game directory
and then same path as inside the pbo's
Using a juncture directly from pdrive to the game directory, would that work?
yeah
P:\x
->
SteamApps/common/Arma 3/x
symlink is what I do (somewhat, not actually)
//v1
arma3/modname/pboname
//v2
arma3/pboname
the pboprefix
Aah, okay. Perfect!
Thanks
@fervent kettle Why would you even what to do that? Or better what do you actually what to do?
@vague geode that is what I did, dont mind the "//s"
_items = items player;// legt Namen fรผr Parameter fest
if ("ACE_EarPlugs" in _items) then {}// รผberprรผft ob sich Item "ACE_EarPlugs" im Inventar befindet
else {
player addItem "ACE_EarPlugs";// fรผgt Item "ACE_EarPlugs" dem Inventar hinzu, falls oberes negativ ausfรคllt
};
if ("TFAR_anprc152" in _items) then {}// รผberprรผft ob sich Item "TFAR_anprc152" im Inventar befindet
else {
player linkItem "TFAR_anprc152";// fรผgt Item "TFAR_anprc152" dem Inventar hinzu, falls oberes negativ ausfรคllt
};
//รbersetzt: falls sich "TFAR_anprc152" im Inventar des Spielers befindet, mach nichts, ansonsten fรผge dem Spieler Item "TFAR_anprc152" hinzu.
// if ("TFAR_anprc152" in _items) then {} else { player linkItem "TFAR_anprc152";}
So basically you just want an else?
It is working like that, so yea
Why don't you instead of
if it has it, don't do anything else add it
just do a
if it doesn't have it, add it
if !("ACE_EarPlugs" in _items) then {player addItem "ACE_EarPlugs";}
That TFAR radio thing won't work btw
It does, tested it
the classname will be changed right after you add it
no it won't
TFAR dev here btw..
Oof, isnt there a way to say like ANPRC-152 is XY
easiest way, just check if player has a handheld radio. Thats what you want to check right?
I want to check for that exact one radio type, the ANPRC-152
oof.. thats a bit more complicated
Btw I think items in radio slot, are not returned by items command, so that also won't work
but when I tested it and dropped the radio it gave me a new one in that exact slot
in singleplayer it might, in multiplayer it will constantly spam new radios
ah the code for that is so annoying
_items = [player] call CBA_fnc_uniqueUnitItems; // If player has lots of items, this is faster and more efficient than simple items player;
if (_items findIf {
(_x call TFAR_fnc_isRadio || {_x call TFAR_fnc_isPrototypeRadio})
&& {
[_x, "tf_parent", ""] call TFAR_fnc_getWeaponConfigProperty == "TFAR_anprc152"
}
} == -1) then {add tfar radio}
Think that might work
or atleast.. that would be the correct way to do it
Due to how TFAR is currently built, you could do
_items = [player] call CBA_fnc_uniqueUnitItems; // If player has lots of items, this is faster and more efficient than simple items player;
if (_items findIf {"TFAR_anprc152" in _x} == -1) then {add tfar radio}
But that might break when TFAR updates
We are using the (BETA!!!) version, wich didnt update in a while
Yes I know
but I'm the one pushing the next update soooo..
just telling you, you don't have to listen
@fervent kettle Yeah, that's needlessly complicated.
As Dedmen said just negate the expression with an expression mark (! == not) so instead of
if ("ACE_EarPlugs" in _items) then {} else {player addItem "ACE_EarPlugs";};
(if "ACE_EarPlugs" is in _items do nothing, else add the item "ACE_EarPlugs" to the player)
put in
if !("ACE_EarPlugs" in _items) then {player addItem "ACE_EarPlugs";};
(if "ACE_EarPlugs" is NOT in _items do add the item "ACE_EarPlugs" to the player).
Yea, I am still pretty unskilled when it comes to arma scripting, thats why mine always end up... different lol
Yeah, sometimes you just have to think less complicated. Not always though... XD
https://de.wikipedia.org/wiki/Logikgatter#Typen_von_Logikgattern_und_Symbolik
I dont remeber why but i use" find" and not "in' as well. Iirc it produced more reliable results back when i first tested the diffrerent methods.
Correct me if im wrong.
Keep up that style of commenting. ๐
upper/lowercase maybe?
both are case-sensitive
find returns the position the needle was found, -1 when not
in returns true when found (false if not)
How would i delete a respawn module point when a trigger activates
the wiki says
[west, 1] call BIS_fnc_removeRespawnPosition;
but i'm not sure what it means by the "1" being the ID and needing to be a number.
I've got the respawn module called "RS1", but yeah i haven't figure out the right way to do it yet.
when you use BIS_fnc_addRespawnPosition you get an array back with [target, id], which is the same array needed for BIS_fnc_removeRespawnPosition
so there isn't a way to remove respawns placed in the editor via the module, I'll need to use the AddRespawnPosition?
you should be able to get the ID since it's stored in the logic
_logic = "Respawn Module Logic";
_respawn = _logic getvariable ["respawn",[]];
_respawn = _respawn param [0,[],[[],""]];
if (typename _respawn == typename []) then {
if (count _respawn == 2) then {
_respawn call bis_fnc_removeRespawnPosition;
};
};
_logic is the variable name of the module?
that should work, but I'm not sure (I just copied that code from BIS_fnc_moduleRespawnPosition)
uh, how would i even use that?
and readying through it, it seems to imply that the respawns are just giving an id i assume from 0 then upwards based on where they were placed?
if this works for respawn modulus i guess i just need to run the delete function for 0, 1, 2 to get rid of the 3 i want since i placed them first.
i'll do a test
_logic = "Respawn Module Logic"; //probably the variable name of the logic module, set in editor, replace the string text with your var name
_respawn = _logic getvariable ["respawn",[]]; //gets variable of the logic module
_respawn = _respawn param [0,[],[[],""]]; //assigns "names to variables for further use
if (typename _respawn == typename []) then { //checks if _respawn is an array: error avoidance
if (count _respawn == 2) then { //error avoidance again
_respawn call bis_fnc_removeRespawnPosition; //delete logic module
};
};
@torpid quartz check it out again, i commented on how i think it works
you use it by copy pasting the code and replacing the string in line 1
um, where would i run it though? should i just have something that triggers when the game starts, how am i going to get the info this finds does it print it on the screen?
typename _respawn == typename []
-> _respawn isEqualType []
Where you place the code depends on when you want it to run
if you run it at the start of the game, it will remove the respawn position right at the start.
Which to me doesn't make sense, might aswell just remove the module
OH right this is the code to remove the module, right, i thought it was to find the respawn ID lol
bis_fnc_removeRespawnPosition
removes respawn position
typename _respawn == typename []
->_respawn isEqualType []
Blame the BI dev who wrote that ๐คฃ
true
its just old code
Text text = "text"
just to clear things up.
thank you all for coming to my ted talk
so uh, for the _logic = "Respawn Module Logic"; was i supposed to but the respawn module variable name in the "respawn module logic" part? or in the ["respawn",[]]; part on line 2?
_logic = "RS1";
_respawn = _logic getvariable ["respawn",[]];
_respawn = _respawn param [0,[],[[],""]];
if (_respawn isEqualType []) then {
if (count _respawn == 2) then {
_respawn call bis_fnc_removeRespawnPosition;
};
};
I'm using this at the moment but i'm getting an error when it runs
What error
Also, you can (and should) debug stufff like that, with stuff like diag_log and hint str
Hm wait is diag log unity or sqf
Umm
diag_log works in Arma.
Just for my understanding, how is rs1 a string? Is it a string variable with the name RS1 that holds a string?
@torpid quartz
chec that stuff out, it makes your life better
https://community.bistudio.com/wiki/Debugging_Techniques
thanks i'll have a gander at it now
also, get dedmens Debug engine mod from steam workshop, and get yourself visual studio code with the "sqf language","sqf lint" and "sqf debugger" extensions to create an IDE
you do it wrong, that's why!

player; // reference to an object
"player"; // string with "player" value
str player; // "stringified" player object (e.g "Alpha B-1-1 (Joe)"```
Well, debugging and ide s are noob friendly bc it actually helps them
Just knowing that stuff exists is a milestone
str(player); Not necessary but nice to do. Completely up to you if you do it or not in this case
in sqf it matters not, but in other similar languages it does
So varnames are actual variables that hold strings
oh and while i'm here might as well ask, I was using markers to set random start positions, however i want an object to spawn randomly in one of multiple locations inside different buildings and markers aren't good for that.
Is there a way to have SetPos move an object randomly to one of multiple locations, or just set a bool to a random state? because using that I could get an if else type situation going.
actually could set a civi up in a trigger, give it a random chance to spawn, have that set a bool, and if that bool is true or false have the object spawn at one location or another lol
There is random functions yes
Theres more like random number generators etc.
the random-toolset of arma 3 is more than enough for any task you might have with a little creativity
If you want spawn positions for every position you can use any object and not just markers.
Houses have special points in then where ai can stand and move, its complicated
markers are good for 2d-locations, objects if 3d is necessary
you can also get the positions the AI stands in
or use https://community.bistudio.com/wiki/buildingPos to get the location of a specific one in AGL space
-1 will return ALL positions
for your task an array that stores all available spawn positions and a selectRandom would probably be ideal
So something dumb along the lines of CRT1 SetPos [4783.464,6112.624,3.453] or [4728.515,6154.601,4.023]; isn't going to work haha
no its exactly that
_allSpawnPos = [ [4783.464,6112.624,3.453],[4728.515,6154.601,4.023]]; //array that holds all available spawn pos
_randomPos = selectRandom _allSpawnPos; //select randomly from array
CRT1 setPos _randomPos; //teleport unit to selected pos
and now the pro gamer move is to automatically fill the _allSpawnPos wth cool locations instead of hand writing it


Ah nice
giving me the pro tech tips
_allSpawnPos is the array name right? so i could call that _Box1SpawnPos? or is it something held locally so i could use this exact same code (change the CRT1 of course and coordinates)
Yeah, variable names are (in sqf) marked with the _ prefix.
awesome
Pro move: replace it with your own var names by ctrl h > replace all
So you dont forget one and eff up the code
i'll put that in the brain bank thanks
has someone used the "https://community.bistudio.com/wiki/BIS_fnc_wpFastRope" waypoint function with success?
i once spend a whole day unsuccessfully trying to get units to fast rope out of a heli
i used the editor waypoint (iirc) and they would always rope to high and bc the rope was short fall off
Well, debugging and ide s are noob friendly bc it actually helps them
not my debugger and its IDE integration lol
Sqf-vm ftw
where do i find that file?
File A3\functions_f\Waypoints\fn_wpLand.sqf [BIS_fnc_wpLand]..., line 19
in A3\functions_f\Waypoints\fn_wpLand.sqfโฆ? ๐
@ironsight it's one of arma's pbo files, you can unpack them, they are in addons folder within game
functions_f.pbo
hey @winter rose i played around with the land bns fucntion: https://community.bistudio.com/wiki/BIS_fnc_wpLand_TKOH
and the docu on the biki is complete BS
bns?
have you tried https://community.bistudio.com/wiki/BIS_fnc_wpLand our lord and saviour?
params taken are
Author: Karel Moricky
Description:
Let group members land at the waypoint position
Parameters:
0: GROUP
1: ARRAY - waypoint position
2: OBJECT - target to which waypoint is attached to
Returns:
BOOL
and thats it. i went over the script, it only takes/uses 3 params (the ones above).
I tested with the above params, works well
uh
_TKOH means Take On Helicopters - a note is missing to state that
naaah, it's OK
j/k
I'll fix it when home
np, thanks for pointing the potential issues though @spark turret ๐
i found something else. here https://community.bistudio.com/wiki/BIS_fnc_wpArtillery
the magazine type is also optional. you can just input "" and it will use _vehMagazine = _vehArtilleryAmmo select 0 for ammotype.
i would comment but "Registraion of new accounts for the Community Wiki has been temporarily suspended. We apologize for the inconvenience."
hey guys I want to have a respawn point in a cave but the module is weird because it picks the highest terrain point
not sure if somehow I could place some code into an invisible helipad so that would be a respawn point?
i think so, im pretty sure the helipad registered z coords, so wherever u put it it should be a viable spawn point
u might need the right position script though
some examples should help u there
@coarse schooner thanks i did that
if you want wiki changes you can also just post in #community_wiki
anyone know how to use the debug console to see which mods are loaded? (i'm doing dedicated test server, so connecting via client as admin)
@signal raven
getDLCs 1 for DLCs,
getLoadedModsInfo for Modsโฆ available in the next patch
@winter rose ty! Can't wait for next patch ... I settled for dropping 4 folders of various depth into my thing & going to test that next
I'm basically counting on the fact it might be poorly explained
is there a way to damage anyone who is in a certain trigger area except people in a trigger area inside the first trigger
the overlapping triggers dont exactly "see" each other
so probably is not as simple as it sounds
why trigger areas?
would be simpler if you explain what is it you are trying to achieve
yeah
basically trying to damage anyone within a certain area
except people behind wall covers
the only example I can think of is that Mass effect mission were standing in sunlight damages you
is it a some sort of explosion thing or something?
radiations
is there a source for it?
like a bomb or device?
also radiation goes through most walls
or well depends on the type
its walls made exactly to shield from it
but its not exactly radiations its a sci fi beam
I'll make the science for it after I'm done with the scripting part
could just do a lineIntersects check if the players body is somehow exposed to it
I'm interested
wrote something for lambs danger which is used if the "view" is blocked to get valid cover/concealment positions
https://github.com/nk3nny/LambsDanger/blob/master/addons/main/functions/fnc_findCover.sqf#L75-L83
yes that was what I was coming to too
oh yeah was thinking about that exact function
pick direction you want the beam to come from and check if the characters can are visible
might need like check for head, hands and feet to be accurate
possible. this function only really goes for feet, torso, head area
I can settle for that
you can do select position the head, hands, etc if you wan more accurate results
@winter rose - did I mention that for now I fell back to using the *.rpt log - which lists all the mods & official or not for the time being?
i cant seem to remeber what the function for making ai run was.
someone help
aaaah speedMode.
was there a command for getting the addon that a config belongs to?

I don't think I can know which player is in contact with line intersect and damage that player specifically
I'll have to play with trigger areas I guess
why you think you can't?
how would that be possible syntax wise?
oh thats useful
whats the meaning of
configSourceMod (configFile >> "RscText");
``` returning an empty string?
usually means it came from the arma3/addons folder i thought.
according to the biki
configSourceMod (configFile >> "CfgVehicles" >> "Car");
``` should return `"A3"`
How do we decide what the mission template field should look like in the server.cfg?
https://community.bistudio.com/wiki/server.cfg#Example_Configuration_File > Mission rotation
class Missions
{
class TestMission01
{
template = MP_Marksmen_01.Altis; <-----------This line
...
I'm trying to load: AntistasiAltisCommunityVersion.altis (this is the folder) which holds the mission.pbo ... my cfg below:
class Missions
{
class Mission_1
{
template = "AntistasiAltisCommunityVersion.altis";
more of a #server_admins question, but you use the name of the pbo. so in your example the pbo should be called AntistasiAltisCommunityVersion.altis.pbo
Does anyone know what kind of position that eden uses? I'm trying to set position of objects in script
When I do
_obj setPosWorld (_house modelToWorldWorld _pos);
//_obj set3DENAttribute ["Position", getPosATL _obj];
The object is where it should be
But when I do
_obj setPosWorld (_house modelToWorldWorld _pos);
_obj set3DENAttribute ["Position", getPosATL _obj];
It is offset
modelToWorldWorld = ASL (sea level)
modelToWorld = AGL (ground level / sea level)
3DEN "Position" = ATL (ground level)
Yeah nevermind, turns out that I need to set the eden position and then the eden rotation
https://community.bistudio.com/wiki/inPolygon
Will inPolygon work for 3d volumes?
It accepts 3d positions, but I don't think that necessarily means it'd be able to determine a volume based on the polygon array
3d position means it's an XYZ position, not 3d as in volume
Yeah, ill probably end up just using inpolygon in addition to a fixed height value to determine if a point is within it
Don't know if there's a specific syntax for polygon vectors
[1,1,1] inPolygon [[0,0,0],[0,2,0],[2,2,0],[2,0,0],[0,0,2],[0,2,2],[2,2,2],[2,0,2]]```
Returns false, even though I would think it should be inside
[1,1,500] inPolygon [[0,0,0],[0,2,0],[2,2,0],[2,0,0]]```
Returns true
I believe the array has to be formatted in a counter clockwise or clockwise order
I couldnt figure out though if jt took height into account
My conclusion would be that it does not
you could try inArea (see syntax 3) to check if a position exists within an area
inArea would work but sometimes i'll have a shape I need to check that isn't rectangular or elliptical
With complex polygon shapes you'll need a custom function which does that.
Looking at how math solves it there are a lot of methods of doing exactly that, which can be translated to SQF
@tiny wadi here's an SQF version of pnpoly (Point Inclusion in Polygon Test):
/*
Author: Grezvany13
Description:
Checks if a 2D Position exists in a 2D Polygon shape
Parameter(s):
0: ARRAY - 2D Position of test point
1: ARRAY - Array with 2D Positions of polygon verticles.
Returns:
BOOL
*/
TAG_fnc_pointInPolygon = {
params ["_point", "_vs"];
_x = _point[0];
_y = _point[1];
_inside = false;
for [ { _i = 0; _j = ((count _vs) - 1) }, { _i < (count _vs) }, { _j = _i + 1 } ] do {
_xi = _vs select _i select 0;
_yi = _vs select _i select 1;
_xj = _vs select _j select 0;
_yj = _vs select _j select 1;
_intersect = ((_yi > _y) != (_yj > _y)) && (_x < (_xj - _xi) * (_y - _yi) / (_yj - _yi) + _xi);
if (_intersect) then {
_inside = !_inside;
}
};
_inside;
};
PS. not tested in-game, but should work.
PPS. if BI wants to include this, feel to implement ;) guess it's the same as inPolygon
source: https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html
inArea would work but sometimes i'll have a shape I need to check that isn't rectangular or elliptical
@tiny wadi Did you check https://community.bistudio.com/wiki/inPolygon properly?
he did, although it doesn't support 3D locations (XYZ), just like my script
Yeah ^^
I think the solution I am going to go for is to check first if it is within the 2d polygon, and then have an additional variable that determines the height to create a volume. So it won't support oddly shaped volumes, it'll just extend the 2d upwards whatever height I set
Yep
btw... you might be able to find some math solutions for Point Inclusion in Polyhedron ๐
that code does the same as inPolygon... also noticed that
Ahhh, yeah that would work @exotic flax. I forgot what the term would be to call it so I couldnt google anything relating to it:P
Ill see what I can find, but it might be a bit overkill
inPolygon + ZCheck
hmmm.... checking some search results on "Testing Point Inclusion in a Polyhedron", and they all go to scientific papers trying to explain the problem and possible solutions... but no real solution has been found (yet?)
Just keep in mind: Each following coord you add will be a "line". So example for a square: TopLeft,RopRight,BottomRight,BottomLeft
Otherwise it would be faulty
with a Polyhedron you would need a full matrix of points and vertexes... because each point can go to 1 or more other points...
which is most likely why there is no real solution for that problem
It's not always a rectangle, right?
meh, okay.
Yeps
for very little reward
gl
Thanks ๐
This is run by server, and I want to let clients set the variable "attackHeli" and values in their profilenamespace on each machine.
but nothing changed on client's machine. what am I doning wrong?
[profileNamespace, ["attackHeli", [obj_name, false]]] remoteExec ["setVariable", -2, true];
@brittle apex try boundingBox/boundingBoxReal
@quasi rover try to make a function and remote exec the function
Anyone know why it's not re-adding the goggles here? It does everything else right:
[player,"25thID"] call BIS_fnc_setUnitInsignia;
// Re-assign players identity which gets removed after user loads a loadout
player setIdentity str player;
// Re-set eye wear that's removed when setIdentity was re-assigned
Sleep 0.5;
_goggles = goggles player;
player addGoggles _goggles;
// Save player loadout
[player, [missionNamespace, "Var_SavedInventory"]] call BIS_fnc_saveInventory;
if setIdentity removes the goggles, then _goggles = goggles player; would just be an empty string wouldnt it? because by the time it execute the identity has already been set. try setting _goggles before setting the identity.
Hey i'm not sure it's possible, but i want to start a timer on a trigger, and then later when another one goes off stop the timer and print the time on screen.
Is there anyway to do the timer part of this? It's for a mission where my guys are competing to get the best time casually and there's a bit at the start where you can customize your loadout so i can't just use the final mission timer.
something like the shoot house time trail challenges.
time command to get the in-game time. You can use this command to save the start time, and calculate end time
Like:
startTime = time;```
```sqf
endTime = time - startTime;```
awesome, yeah i think i've got an idea of how to implement that with triggers, i'll post it if i get it working
excuse me, i need help. _a = [1.992e+006]; _a = _a select 0 ; _a = _a tofixed 0 ; _a = parseNumber _a ;hint str _a ; why the output is still 1.992e+006 instead of 1992000?
Why you do parseNumber _a? Shouldn't if you don't want to show e
what would be the most efficient way to go about taking an element out of an array as it is selected?
if (isServer) then {
params ["_box"];
private _count = [1,2,3,4,5];
private _items = ["rhs_acc_1p63","rhs_acc_1p29","rhs_acc_1p78","rhs_acc_ekp1","rhs_acc_ekp8_02","rhs_acc_okp7_dovetail","rhs_acc_pkas"];
_box addItemCargoGlobal [selectRandom _items,selectRandom _count];
_box addItemCargoGlobal [selectRandom _items,selectRandom _count];
_box addItemCargoGlobal [selectRandom _items,selectRandom _count];
_box addItemCargoGlobal [selectRandom _items,selectRandom _count];
_box addItemCargoGlobal [selectRandom _items,selectRandom _count];
};
@warm hedge I execute the sql statement select to get such a number, 1.992e+006. I need to convert it to a normal number (1992000), but what I get with tofixed is a string, I also need to convert it to a numeric value.
i dont think this is right but something like this @fair drum
_item = _items deleteAt floor random count _items;
1.992e+006 and 1992000 are equal to each other. So you only need to think when you prefer either way to output
_a = [1.992e+006];
_a = _a select 0; //1.992e+006
_a = _a tofixed 0; //"1992000"
_a = parseNumber _a; //1.992e+006
hint str _a; //"1.992e+006"```
So instead
```sqf
_a = [1.992e+006];
_a = _a select 0; //1.992e+006
hint (_a tofixed 0); //"1992000"```
or
```sqf
_a = [1.992e+006];
tofixed 0;
hint (_a select 0); //"1992000"```
@warm hedge tks,bro!
Hi! How to make a loop? I tried to use while and waituntil, but every try lead to some kind of nonsense. Will something like this work?
_fnc = {
if (condition) then {do stuff} else {exitwith {call _fnc}}
@robust hollow cfgidentity has glasses property
Will something like this work?
no.
while {condition} do {
do stuff;
}
@lilac kettle check wiki
https://community.bistudio.com/wiki/while itโs all there
CIY_fnc_resetHeli = {
profileNamespace setVariable ["attackHeli", [obj_name, false]];
};
remoteExec ["CIY_fnc_resetHeli"];
@unique sundial It works on hosted server, but not dedi-server.
@runic quest why do you need to convert it like this?
if you want to display it it will be string if you want it for calculations it makes no difference
@quasi rover because you need to saveProfileNamespace for it to stick?
It works on hosted server, but not dedi-server.
IF you posted your actual code, then yes of course because you only define that script function on one machine
What Dedmen said. You need to either A. Make that variable public, or B. Define the function on all clients through other means, such as cfgFunctions or by just a script that runs on all clients. Your best bet here is to not remoteExec the function but the code inside of it. Youre also going to possibly have some issues with other variables in your script, but i cant say because were not getting the full story. I recommend you take a look at this guide.
https://community.bistudio.com/wiki/Variables
The script was run by server machine, so I just thought remoteExec is enough to be executed on every connected client. but I need to study more. thanks, guys.
Due to how TFAR is currently built, you could do
_items = [player] call CBA_fnc_uniqueUnitItems; // If player has lots of items, this is faster and more efficient than simple items player; if (_items findIf {"TFAR_anprc152" in _x} == -1) then {add tfar radio}But that might break when TFAR updates
@still forum thus is dropping me a "missing ;" error, even after adding it
after the then{};
maybe, but otherwise I don't see it
thats exactly where Ive placed it, still the same error
paste your exact code if you need help with error and full error from .rpt
say I got a gigantic cfgSounds section in my description.ext. Is there a way I can write it somewhere else, then port that into the description.ext?
been trying to loop the EMP script from ALIAS but can't seem to make it work
it triggers only once
can't post the entirety of the EMP script because its several sqfs and it would be spam but this is what I'm using to loop the activation line
while {true} do {
sleep 20;
playMusic "Beam";
sleep 0.5;
Beam hideObject false;
[emp_me,2000,true,true,0.1] execvm "AL_emp\emp_starter.sqf";
sleep 3;
Beam hideObject true;
};```
anyone who has used it in the past knows what could prevent it from looping?
@fair drum you mean #include?
anyone who has used it in the past knows what could prevent it from looping?
script errors? but I don't know where, maybe undefined variable?
not getting any error log
and the rest of the stuff in the looping script works fine
I can post the content of emp_starter.sqf if thats ok
have you added logging into the loop
to check if the loop itself is running?
cuzz you're telling me the loop itself doesn't work, and now you say the rest of the looping stuff works.. so what now ๐
the looping works
the hideObject and the playMusic loop just fine
its the [emp_me,2000,true,true,0.1] execvm "AL_emp\emp_starter.sqf";
that doesnt
and if it does
it doesn't seem to work twice
if (!isServer) exitWith {};
_obj_emp = _this select 0;
_rang_emp = _this select 1;
_viz_eff = _this select 2;
_player_viz = _this select 3;
_dam_unit = _this select 4;
if (!isNil {_obj_emp getVariable "is_ON"}) exitwith {};
_obj_emp setVariable ["is_ON",true,true];
emp_dam =_dam_unit; publicVariable "emp_dam";
if (_viz_eff or _player_viz) then {[[_obj_emp,_viz_eff,_player_viz],"AL_emp\viz_eff_emp.sqf"] remoteExec ["execVM"]};
[_obj_emp,_rang_emp] execvm "AL_emp\config_obj.sqf";
waitUntil {!isNil "special_launchers_emp"};
waitUntil {!isNil "emp_dam"};
[] execvm "AL_emp\emp_effect.sqf";
it does call to 3 other scripts
maybe the problem could be in config_obj.sqf
oh nevermind that only marks the objects to jam with the emp
Well
if (!isNil {_obj_emp getVariable "is_ON"}) exitwith {};
_obj_emp setVariable ["is_ON",true,true];
not too sure I'm reading it right
looks like it stops the rest of the code from launching if _obj_emp has the is_ON variable?
something to prevent looping?
yes
I don't think I can just remove it but I'll try
_obj_emp setVariable ["is_ON",true,true];
which one do I turn false?
๐ the what?
you want to unset that variable, on that object
you remove a variable by setting it to nil
he mod uses !isNil to check whether it should exit, so make the variable nil, and it won't exit anymore
sorry if I sound dumb but
like this?
_obj_emp setVariable ["is_ON",true,Nil];
I'll try
I don't see why they do the broadcast, seems useless to me
so now it loops but it gives me an error on that line saying
error type any, expected bool, number, array
not sure if I should ignore but it may cause issues once in a server
don't ignore errors, ever
yeah
figured it may cause some memory leak or something
what should I do about it?
I guess it says that because it expects a bool instead of the Nil
What exactly did you add now?
_obj_emp setVariable ["is_ON",Nil,true];
where
on that same line of the previous one
or should have I added a new one somewhere?
add a new one in your script
oh at the end of the loop
still learning the basics but how would I identify _obj_emp in my script?
do I write _obj_emp = _this select 0; at the beginning of the loop where 0 is the same "slot" used in AL_emp\emp_starter.sqf?
not sure I understand
the arrow points at the object
you already have it in your script. You are passing it to execVM
just take it
but I'm getting an undefined variable in the expression error if I just add
_obj_emp setVariable ["is_ON",Nil,true]; to the loop
you're implying that I should rename emp_me to _obj_emp?
because otherwise I don't get what you mean
no, the opposite
I'm confused? whats your scripting knowledge? You've been here for years, I assumed you're on intermediate kinda level
haven't really been modding or scripting heavly
this is probably the first time I try something so complex
I've usually just found cheaty ways to do what I wanted and it worked for 2-3 years
but I'm trying to get more in depth recently with the little time I have
Guess I missjudged then, I thought just pointing a direction is sufficient to let you figure it out, here
while {true} do {
sleep 20;
playMusic "Beam";
sleep 0.5;
Beam hideObject false;
emp_me setVariable ["is_ON",nil];
[emp_me,2000,true,true,0.1] execvm "AL_emp\emp_starter.sqf";
sleep 3;
Beam hideObject true;
};
I noticed and appreciated that
dont like people making scripts for me
I did just learn a bit but Im still pretty noob on the subject
Been using some radio chat in my missions latelt and thought i would get all fancy and add some lip files.I used the a3 tool set to do it .I am mostly using radio based chat in vehicles so iam not at all using the say commands.I made up the files according to the instructions.Making sure no spaces etc were in the name or filepath.I have the audio files and lip files stored together in their folder.Tried in my sounds folder in my mission and also in a data pbo thats a loaded mod.But no lip moving is going on..Any ideas? I ve had a bit of a search here and didnt really find a solution to my application.
Any help appreciated.Thanks.
@smoky verge take a look at the wiki how call and execvm and such work and how you can pass variables tru parameters to the script
how to get ground altitude ASL of position?
[x,y] call altitudePosition
> z
im trying to check if [x,y] is on ground or on sea
anything that does that also works
thats great, thanks!
oh wow, just the other day I was complaining about == not working with booleans and now they're making it work
BI....good???
issue where?
fix where?
that's a issue known since OFP and reported in 2016... I doubt you made them change their mind ๐
I can dream that my comment reminded them about it. But I just thought it was a neat coincidence (and neat that they're making that change)
BI recently got some new people on board to do bug fixing in Arma 3, while BI themselves can work on Enfusion. So the FT is (finally) being looked at ๐
~~bool == bool is quite stupid code. I hope they won't add this.~~It's real changelog ๐
Foolproof!
if (true == false) then {
// TODO
};
I said the same
It's nothing big but it's just... stupid ๐
At least it will be easier for begginers 
easier for beginners to write stupid code that they themselves don't understand
has absoulutely no idea whats going on
And they'll now say "but it works fine, so that means there's nothing wrong with it and I will now use it in my tutorial videos to teach others"
it's such a minor thing that I personally think making == behave consistently is worth the possibility of people adding 5 unnecessary characters to their script
so does that mean we also get ===, !==, <=> and more? ๐คฏ
3 chars vs 9 ๐คทโโ๏ธ
Whats wrong with the != stuff? It makes imverting booleans for "button" functions a lot easier
inverting booleans?
!true
Ah whoops
See! Thats the point that beginners often miss. They only stumble upon it when they see that bool == bool doesn't work
So why is comparing booleans evil?
Its slower, and in most cases just stupid
So why is comparing booleans evil?
if (condition == true)
but condition is already a boolean, that does nothing

yes you always could with isEqualTo if you really needed to in the few rare cases where you need to
bool1 and bool2?
nope
Just a tought example.
false and false -> false
false == false -> true
Hmm
Ah I recognize my fault after the post
I needed to compare booleans once in the last 3 years
I see your point
That means out of maybe about 2k (I literally have no idea how much I wrote) lines of code written over that time, one single case where bool == bool would've made sense
Well but its comparing about 2 variables and less about the bool. I dont really see a problen other than it being a bit confusing for newbs
But on the other hand, a couple dozen beginners that thought
if (isPlayer player == true) then {..}
made sense
I just don't see the huge harm in letting people do that if they want to. Having the command behave in the way you would expect it to is important for accessibility, and commands having arcane, unpredictable limitations is half the problem with sqf in the first place.
Yeah true
Which then came here as they couldn't figure out why it didn't work, which were then educated about why it doesn't make sense to do that
But tbh if ppl dont know what they do its most often not the functions fault




