#arma3_scripting
1 messages Β· Page 736 of 1
Brilliant, thanks π
When you use setVariable on an array with public set to true, does it properly sync array contents across the network?
Edit: Seems like it is
Does anyone know if it also properly syncs multidimensional arrays?
It syncs the value of that variable, whatever is in there, as long as it's serializable (controls, displays, local only objects are not)
Perfect, thanks!
Hi, so I'm trying to get all of the Archer Missle Systems on the mission so I can disable them instantly. But allUnits and allUnitsUAV does not contain the unit. Does anyone have an idea of how to get it "OPTRE"
find what kind of object they are, then use something like allMissionObjects or something
alright, what's the best way to find out what type of object they are?
typeOf
yeah thanks I got it working appreciated
while (true) do {
removeAllEventHandlers "_drops";
_zombies = [];
{if ((side _x) == east) then {_zombies pushBack _x}} forEach allUnits;
_drops = {_x addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
systemchat format ["%1 was killed by %2", _unit, _killer];
}];
} forEach _Zombies;
sleep 10;
};
what am i trying to do?
array all opfor and add an EH handler to them so i can then spawn something where they died, systemchat is there for debug just to see if the EH is working.
the array works just fine on a single fire without the EH but then when the EH is added, the EH still does nothing. any pointers on what im doing wrong
its on a loop to keep regathering the "_zombies" as they will be spawning constantly and a single fire wont catch those that spawned late to the party
It doesn't matter
while {true} do {```It should be this. `while` takes a code not a boolean
that is true
removeAllEventHandlers "_drops";
wat?
{if ((side _x) == east) then {_zombies pushBack _x}} forEach allUnits;
units east
also this is horribly inefficient
and will eventually cause many problems
hey thats my name
whats the better way?
don't keep adding and removing event handlers
but if i keep adding EH's wont they just stack up if im constantly adding an EH to the unit
don't you have one event handler?
i mean im trying to get all alive opfor, add an eh to them and keep detecting new spawned opfor
to control all the zombies?
only add the EH to new enemies
is there an easy way to do that?
yes
uh. how if i may ask?
keep an array of current enemies
get list of all enemies
subtract the two and you get new ones
add the EH to the new ones
update current enemies
i shall give it a go
an alternative way is loop through all enemies but add the EH to ones that you didn't add before (using setVariable and getVariable)
altho that's less efficient
alrighty, ill throw something together and repost it in here if i have troubles
ty for the help
_zombiedrops = true;
_loop = 0;
_zombies = [];
_zombiesnew = [];
{if ((side _x) == east) then {_zombies pushBack _x}} forEach allUnits;
sleep 10;
while (_zombiedrops) do { //this is line 8
{if ((side _x) == east) then {_zombiesnew pushBack _x}} forEach allUnits;
_zombiesupdate = [_zombiesnew] - [_zombies];
systemChat format ["%1", _zombiesnew];
_drops = {_x addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
systemchat format ["%1 was killed by %2", _unit, _killer];
}];
} forEach _zombiesupdate;
sleep 10;
_zombiesnew = _zombies;
_loop = _loop + 1;
systemChat format ["while loop running ,%1" ,_loop];
};
getting an error type bool, expected code
line 8
the systemchats are just me wanting to see what its throwing out in the loop for now
so ignore those even if i have screwed them up
Again, while takes CODE as input. Try while {_zombiedrops} do.
also what on earth? 
anyone good with pulling items from the config?
true
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
Also protip: you can just edit your post
|| (getText (_x >> 'cursor') isEqualTo 'smg'))
&& getNumber (_x >> 'scope') isEqualTo 2" configClasses (configFile >> "CfgWeapons");```
Sometimes this just returns an empty string of ""
yeah true
And what's your intention?
get the config names of all arifles, srifles and smg's
:/
Is it that bad? Seems relatively fine
Im still relatively new to sqf, first time i've needed to take from the config like this
actually I think it's correct (at least the syntax). I counted the parentheses wrong
you say it sometimes returns an empty string. when is sometimes?
Ah you meant that
not sure, I'll grab the rpt file
also isn't that thing supposed to return an array
yeah it does
True. Just tried on vanilla, it never returns "". More like just configs!
so you meant empty array and not empty string?
Full code please?
array looks something like this ["", "srifle_DMR_01_F", "", "" .... ]
ill paste into sqfbin
that's weird. i assume configClasses is not supposed to return empty strings for the classes not matched?
aha
but then again, all the weapons it takes from the config should have a baseClass no?
context does help. the problem was never in the code shown π
Oh so yeah, guess I understood what's your intention
what is baseWeapon ?
https://community.bistudio.com/wiki/BIS_fnc_baseWeapon
This should help to fetch the base weapon
ah no attachments
If configName _x != baseWeapon, won't show in Arsenal
So yeah, basically weapons with no attachments
_wepClass = configName _x;
_baseWeapon = getText (configFile >> "CfgWeapons" >> _wepClass
this is unnecessary. _wepClass is configFile >> "CfgWeapons" >> configName _wepClass
but i suppose you really want [configName _wepClass] call BIS_fnc_baseWeapon
True. The _x is already a config
ah ok
But yeah highly recommend to use the function
I'll try that, thanks
Good luck
also, pushBackUnique is idempotent: to do so twice is unnecessary π
yeah that was a mistake from debugging
Another question I had just quickly, couldn't find anything online about it. What exactly is scope referring to in a weapons config?
scope does βit is hidden or publicβ
ah it refers to that kinda scope
0 is private, meaning cannot be created
1 is protected, meaning can be created but is hidden in the editor
2 is public, meaning can be created and is shown in the editor
so you may actually want scope != 0 instead of scope == 2, but that's really for you to decide
ok
https://community.bistudio.com/wiki/CfgVehicles_Config_Reference#scope
https://community.bistudio.com/wiki/CfgWeapons_Config_Reference#scope.3D0
Seems like it's different for CfgVehicles and CfgWeapons - which also makes sense because you can't createVehicle things from CfgWeapons (nor place them in the Editor).
all works great, thanks guys π
im sorry i suck at sqf
you also made me spot a mistake id made
i would recommend using more indentation. it helps with spotting mistakes
well you have 3 mistakes:
- like I said before use
units east. it's faster than looping through all units and checking their side. - you never update the list of "zombies"
- your array subtraction is wrong.
also you shouldn't get the list of units before loop
everything should happen in the loop
_lastZombies = [];
while {true} do {
_zombies = units east;
_newZombies = _zombies - _lastZombies;
{
_x addEH...
} forEach _newZombies;
_lastZombies = _zombies;
sleep 10;
};
and here's the alternative approach I mentioned before:
while {true} do {
_zombies = units east;
{
if (_x getVariable ["AddedEH", false]) then {continue}; //if EH was already added skip
_x addEH...;
_x setVariable ["AddedEH", true];
} forEach _zombies;
sleep 10;
};
Trying to do a mission where we have 10 tasks within that mission. That are selected at random. So the mission has replayablility. Any ideas how
well firstly, for maintainability and your own sanity, separate each task into a different file or directory.
at startup on the server you have a list of the tasks and select one. you then call the initialisation code for the selected task and signal all clients to do the same.
the easiest way would be to add each task to one trigger and each trigger have with 50% of occurrence
@solar zenith
but there's a possibility that you get either all tasks or none 
do you want any limit of those tasks? if so, you could make an array with selectRandom(s) reducing the array everytime, up to the final number of tasks you want to have
do you want to select just one task, or do you want to select K tasks from a set of 10 tasks, or do you want to select 10 tasks from a set of more than 10 tasks?
ty for the help again, i now see what u mean by how inefficient my code is
just 1 task at a time at random from a bunch of like 10-20
than you can do what i detailed in my first message
okay.. well im pretty new to it all, i know basic scripting stuff. is there anychance you could explain further or step by step please?
i understand inits, and different sqfs and that
okay. you can run initialisation code on the server in init.sqf using isServer or in initServer.sqf.
the server should pick the task. that you can do by say holding a list of task names in an array, and using selectRandom to pick one.
once the task is selected you'll want to execute some initialisation code for that task on the server, and possibly on clients as well.
if you need to execute initialisation code on the clients, you will need to remote execute from the server to the clients.
yeah i wouldnt know how to do any of that... dammit... im just trying to replicate the extraction campaign from western sahara. but differently. so you start at the fob. go out and do the first random mission. then come back to the fob with intel. and then it pings the second random mission and so on
Q: I think I probably already have a sense for what's going on, but I wonder if I can get some clarification about which return value should be happening.
Scenario: I have a function in which the I have an if then else decision tree at the end with an embedded exitWith. I half expect exitWith to return the function, but it seems as though the trailing debug log is returning instead. i.e.
private _debug = true;
// ...
if (_true) then {
// where _retval is an [] (ARRAY)
if (_alsoTrue) exitWith {_retval};
};
if (_debug) then {
[...] call my_log; // returns BOOL
};
Logs of the calling context indicate I am receiving the BOOL back again, as well as messages hinting at the my_log invocation being part of that return path.
It seems like to me that exitWith is leaving the immediate if then CODE scope, not the overall function.
https://community.bistudio.com/wiki/if
https://community.bistudio.com/wiki/exitWith
exitWith is leaving the immediate if then CODE scope,
yes, that is correct.
I have a function
you don't have a function. sqf has no functions
the closest you can get to a return statement is probably something like ```SQF
function =
{
private "_return";
scopename "return";
call
{
if (...) then
{
if (...) then
{
_return = _retval;
breakTo "return";
};
};
if (_debug) then
{
diag_log "blah";
};
};
_return
};
I've head "sqf has no functions" before, but I've never understood what people mean by that. It has code which can be stored in a variable that can be called with parameters and produce an output. Is that not a function, for all intents and purposes?
yeah, it behaves kind of like what most languages call functions from the outside, though not exactly since you can break out through the caller and mutate the caller's locals. viewed from the inside you have the same weirdness but inverse, and also you lack any built-in concept of return
if sqf has functions, it is only by convention. we can say that the language has no functions but we the users have built functions on top of the language
Alright, makes sense. I'm not entirely convinced that what we have shouldn't be classified as functions, but I see your point that they act sufficiently differently from functions as defined in other languages as to make the distinction worthwhile.
It's more functional I think than having functions, per se. Yes there is CODE, that is what I consider function, but definitely also functional as suggested above for those reasons, you can inject code, callbacks, etc. Functions can be ad hoc, i.e. {"this is a function"} or compiled, from config, etc.
you also have to consider that there is no functional difference between the code you assign to a variable, calling it a function by convention, and the code you pass to if (...) then
really we should be talking about subroutines though. it's kind of a shame how computer science has overloaded the term function
well, true enough. you have to understand the sort of language that it is, data types. it is not a structured Pascal, that's for sure.
I think I'm understanding now. Even in other languages where code is assigned to variables (javascript for instance), the idea of functions are still widely talked about and used. The distinction that people are trying to make is that there is nothing fundamentally special about a function like there is in C for instance. However, even though there being nothing special about "functions" in a language like sqf, we still follow (and are able to follow) the functional programming paradigm.
yeah, except i wouldn't call functional programming since that has a very specific meaning
if you want to assign a tag to the paradigms used in sqf, i would instead probably call it imperative structured programming
we are not renaming CfgFunctions!
okay, thanks for the clarification. that's what it seemed like was happening, the log was indicating along the same lines.
Imperative fair enough point.
cfgCodes
π
Hey so I'm having troubles getting PlaySound3D working in multiplayer, it works fine in singleplayer but only PlaySound works in multi for some reason π€
usage plz?
"music1" remoteExec ["playSound"];```
I assumed I could replace playSound with playSound3D. Although I suppose thats not the case
apologies, very new to this still π
Otherwise for now I've just been using a trigger with
playSound3D [getMissionPath "Rise.ogg", player];
no worries, we're here to help
see
https://community.bistudio.com/wiki/playSound
https://community.bistudio.com/wiki/playSound3D
playSound3D has a global effect, so no need to remoteExec it
Thats what I was thinking, this works on dedicated too?
it should
I'll give it a go and let you know what happens, hopefully my friend can hear it too π
Thanks Lou π
What's the recommended way to find and preview assets such as pictures, textures, models, music, etc? In particular, I'm looking for the file paths of the hold action icons in the game to preview them and use then in a hold action script.
object textures can be "seen" by viewing the object through config viewer. HoldAction icons are available in BIKI, click on the "Show text" button https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
@jade acorn Thanks a bunch, I didn't see the "Show text" button on the wiki. I'll have to keep an eye out for that next time.
Speaking of the config viewer though, aside from obvious configs like vehicles, weapons, magazines, etc, how do you actually find stuff? Search via script maybe?
https://community.bistudio.com/wiki/Arma_3:_Splendid_Config_Viewer here's some, let's say boilerplate, for using the default viewer, but if you're like me and hate the rought vanilla interface then try out Advanced Developer Tools by Leopard20 or Polpox Base Functions that has some kind of advanced config viewer inside
Awesome, thanks a bunch!
There's also 7erra's =) https://steamcommunity.com/sharedfiles/filedetails/?id=1387934106
the holy trinity 
How do I miss optional parameters in a script?
For example, I need to access volume in playSound3D but it comes after soundPosition in the parameters, I don't want SP to override my positioning from an object
then provide objNull
you cannot skip a command parameter (a function's yes, with nil)
Like this?
playSound3D [getMissionPath "sounds\Fail.ogg", FailSource, false, objNull, 100, objNull, 1000];
Ahh alright
maybe [0,0,0], but I don't guarantee it
So just log position of object and use that instead? π
I know for some scripts _x works doesnt it?
or getPosASL FailSource yeah
no
What am I thinking of for that then lol
Ahhhhh right
Would there happen to be a way to smoothly transition weather, even when manual weather is not enabled in the mission config? I was hoping to make a weather script for public zeus that could do smooth transitions.
hi, can we get the real "WorldtoModel" position ? because actually i'm trying the "truck WordToModel (ASLtoAGL getposasl _obj1)" but when i use the "attachto" command the relative postion is not "100%" i have a space between the truck and my obj on the "Z" axis so the "Altitude"
setOvercast server-side?
try worldToModelVisual?
i will try but i need to use this "command" with "(ASLtoAGL getposasl _obj1)" or i need to use it with a "getposvisual" ?
try a getPosASLVisual or a getPosWorldVisual perhaps
ok thx i will try then
I jumped onto a public zeus server with scripts enabled and tried a 10 setOvercast 1 that I remoteExec'd and it didn't seem to work. The only way I could change the weather was to subsequently run a forceWeatherChange. As a workaround, I was hoping that multiple small incremental forceWeatherChange's could approximate a smooth transition, but even with small changes it hangs the client for a second or two. So now I'm hoping that I either did something wrong, or that there's a workaround.
you can't change overcast that fast due to weather simulation
it's over 30 minutes iirc, not 10s
_veh worldToModelVisual ASLToAGL (getPosWorldVisual _obj) seems to work pefectly thx
So it should work, but the system (with weather simulation enabled) can't go any faster than x weather change per minute and inputting a faster transition time than what it can handle will just make it transition as fast as it can?
in multiplayer sessions the weather change would desync
so you can either force it instantly or wait the 30 minutes to be sure every player sees the same weather
yes
it's synced quite regularly afaik (well, not every 30s I think, but still)

It's certainly worth testing! If the limiting speed factor is the weather simulation, that'll make it easier to test in SP. I'll whip up a quick script to periodically log weather parameters to a csv string and pop it into excel for graphing after an hour or so.
Thanks again for the help!
see https://community.bistudio.com/wiki/Multiplayer_Scripting#JIP_Synchronisation (works for other than JIP)
PlaySound3D is only working on my client, not serverside
Trigger
remoteExec ['LouisTag_fnc_SFX1',2];
Description.ext
{
class LouisTag
{
class SpawnUnits
{
class SFX1 {file = "SFX.sqf";};
};
};
};
SFX.sqf
playSound3D [getMissionPath "sounds\Fail.ogg", FailSource, false, [10444.7,2613.57,17.1143], 100, 1, 0, 0, false];
I know you dont NEED to use remoteExec to execute it for playSound3D, but doing it shouldn't break the multiplayer should it?
so what? this doesn't work?
Not for all players, just me
what's FailSource?
An object with variablename FailSource
is your trigger server only?
I'm using the host server feature
and? what about the clients?
So my friend is helping me test as of now
He can hear audio if i use "music1" remoteExec ["playSound"]; but it isnt directional
if you use say3D it will be
but I don't really see what could be wrong with your playSound3D
it should work as far as I see 
Thats what's confusing me π
It could be a mod to be fair, are there many that mess with that audio?
I don't think it's a mod issue
but in any case using say3D is better
playSound3D has so many limitations
for say3D you need to define the sound in description.ext (direct path won't work)
also it does need remoteExec, because it has local effect
class CfgSounds
{
sounds[] = {Fail, Scream};
class Fail
{
name = "Fail";
sound[] = {"Fail.ogg", db-40, 1};
titles[] = {0,""};
};
};```
Like this right?
For description.ext
Alright I'll try say3d. Ill keep a backup of this current script in case it turns out i was just being stupid
Im trying to teleport a player, but I want it to be like they close there eyes, so a quick fade to black and then teleport and then bam they are in a new place. This is the code I have
cuttext ["", "BLACK IN", 3];
player setPosATL getposATL teleport;
cuttext ["", "BLACK OUT", 3];```
this code instantly teleports the player and then fades to black
also if you decide to use say3D be sure to set JIP to false in remoteExec (I don't think you'd want that to be heard every time someone joins)
Mind if I ask how you do that?
titles tootitles[], you mean?
it's not empty on the wiki
Β―_(γ)_/Β―
... remoteExec ["...", 0, false];
Cheers π
that false flag is for JIP
false is the default, no need to set it
@warm swallow You'll need to use sleep 3 or sleep 4 or something after you first cuttext.
I thought it was true 
remoteExec ["..."] is enough π
@true frigate ^
Alright π
i got it thanks!
Is remoteExec ["...", 2] not better as it only executes on the server?
Or does it not matter
for say3D it must be for everyone
because it has local effect
i.e only the client where it executes hears the sound
@true frigate
Makes sense. Thank you!
Just want to check then (first time using Say3D), this is the correct format?
FailSource say3D ["Fail", 0, 1, false, 0];```
I assume 0 distance means infinite, but I could be wrong
Alright I'll just set it to 2000 because thats within range of the players
there isnt a downside to setting it high right?
that's just the max distance
Alright π
I think the game uses some kind of attenuation, so it'll never be heard that far 
but if you want it to be heard everywhere why not just use playSound?
Because i'd like it to be directional π
It isnt working as of now, I tried in debug menu and I'm getting NOID <No Shape>
that means you didn't define the sound properly
Uh I may have been stupid. If my .ogg files are in a folder, I need to do folder\fail.ogg right....
ofc
Oops
Surprisingly enough, it works now π
Thanks for pointing out what the error meant
so im trying to control how many shots i need to take a player down with a shotgun, to be 2 shots needed. I have this code
{_x addMPEventHandler
["MPHit",
{
params ["_unit", "_source", "_damage", "_instigator"];
_x setDamage damage + 0.5;
}
];
} forEach [p1, p2, p3, p4, p5 ,p6]```
but how would I check to see if they were hit before, because for each player, i want it to increment from 0.5, to 1. But if I add 0.5 to what they've already been hit with they will just die
this code is wrong
how would I check to see if they were hit before
setVariable/getVariable
ah
how would I do that considering its a forEach, like how do I still make a variable that changes with each player?
I already told you. setVariable and getVariable. read the wiki for those commands
@little raptor this is what I have
{_x addMPEventHandler
["MPHit",
{
params ["_unit", "_source", "_damage", "_instigator"];
_x getVariable ["timesHit", 0]
_x setVariable ["timesHit", timesHit + 0.5]
_x setDamage timesHit * 0.5;
}
];
} forEach [p1, p2, p3, p4, p5 ,p6];```
_x means nothing in the event handler code block
_unit is what you want to refer to
ah
will that still work with forEach?
{_x addMPEventHandler
["MPHit",
{
params ["_unit", "_source", "_damage", "_instigator"];
_unit getVariable ["timesHit", 0];
_unit setVariable ["timesHit", timesHit + 0.5];
_unit setDamage timesHit * 0.5;
}
];
} forEach [p1, p2, p3, p4, p5 ,p6];```
your forEach is iterating over p1...p5, giving them the name _x each in turn, and while doing so assigning an event handler to that _x
so yes
if that is what you want to do
why do you add 0.5 to the timesHit and then set damage to be half of timesHit
im trying to make it so that each person has to take 2 shots to go down
{
params ["_unit", "_source", "_damage", "_instigator"];
_unitTimesHit = _unit getVariable ["timesHit", 0]; // get the value
_unitTimesHit = _unitTimesHit + 1; // increment the value
_unit setVariable ["timesHit", _unitTimesHit]; // store the value
if (_unitTimesHit >= 2) then {
_unit setDamage 1; // kill the unit;
};
0; // ???
}
try that
no dont try that
hm
ok well
the guy i tested it on died in one shot
i didnt get any script errors though so
im just trying to not make the shotgun i use in my mission op
if you shot them with a shotgun then that triggered probably twice
since a shotgun launches multiple projectiles

im getting an error type object expected task in this code
if (g1 getVariable ["repaired", false] == true) then
{
tg1 setTaskState "Failed";
};```
the task is tg1, how do i make it usable for setTaskState
well no it isn't, it's an object as the error message says
also you should be using the task framework https://community.bistudio.com/wiki/Arma_3:_Task_Framework
i have a question, are there any good mods with diving gear? with stuff like rebreathers, drysuits, wetsuits, dive computers, stuff like that?
@warm swallow
_this addEventHandler ["HitPart", {
(_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];
_hits = _target getVariable ["TAG_fnc_hits",0];
_hits = _hits + 1;
_target setVariable ["TAG_fnc_hits",_hits];
hint format ["%1 has been hit %2 times",name _target,_hits];
if (_hits > 10) then { _target setdamage 1} else {
_target call ACE_medical_treatment_fnc_fullHealLocal;
};
}];
i use this, albeit its integrated into ace heal but you can remove that, and change (_hits > 10) to whatever number you wish. the hint is for debug and can be removed safely
it sounds like what your looking for
curtesy of grumpy old man on Bi forums years ago
Thanks!!!!!
When creating objects relative to a main object. What the best way to get the height at the relative position? Height being the height of the first walk able surface, either ground or an object.
I was thinking of just using lineIntersect and finding it with that, but I'd say someone probably more experienced with positions has solved this before.
Hello! It's been a little bit. You guys are the only ones I know that know a good bit about coding, so I figured I would get quality help. I'm trying to configure a radio in game to play music I've added. Here's my code:
`
Description.ext
class playRadio
{
sounds[] = {};
class FBRHFF
{
name = "FBRHFF";
sound[] = { "FBRHFF", 10, 1};
titles[] = {};
};
};
initPlayerLocal.sqf
radio addAction ["Play Song",[execVM "playRadio.sqf"]];
playRadio.sqf
_sounds = selectRandom ["FBRHFF"];
{radio, ["FBRHFF", 100, 1]} remoteExec ["say3D"]; `
I'm not entirely sure why I keep getting this error:
Error position: <addAction ["Play Song",[execVM "playRadi>
23:22:45 Error Type Array, expected String,code
23:22:45 File C:\Users\Levi\Documents\Arma 3 - Other Profiles\TemplarBOMSF\mpmissions\Fighting_Bengals_Training.Malden\initPlayerLocal.sqf..., line 1
execVM should be in {} brackets instead of []. Going by the error.
[] makes in an array. it needs {} code or "" for string.
so it would be
radio addAction ["Play Song",{execVM "playRadio.sqf"}];
instead of the latter?
Alright, I'll give that a shot
Okay, now everything works, it just won't play the song I've selected
Granted there's only one song in there
how is the radio object defined? Is it available on the remoteExec target?
I'm not sure, I just put this in the Variable Name in the Object: Init section of the asset I'm using
Variable Name: radio
I'm also not sure if that's what you're asking
Alright. Does say3D work in the debug console with player as the from object? Just to see if the Cfgsounds works?
Ah, yeah it won't.
class playRadio -> NEEDS to be class CfgSounds
{
sounds[] = {};
class FBRHFF
{
name = "FBRHFF";
sound[] = { "FBRHFF", 10, 1};
titles[] = {};
};
};
It's named playRadio because that's what I have that .sqf named
I apologize in advance, because I am quite new to this
Standby
So when I call on CfgSounds it'll go to that .sqf, yeah?
I guess I'm confused, as there's no CfgSounds in my mission folder
class CfgSounds is defined in the description.ext
CfgSounds is a class, it is not a file.
As long as it is defined somewhere where the game looks for configClasses, config.cpp for addons. Or the description.ext for missions. Arma will find it.
So Arma will essentially find the song I want to be played THROUGH the Description.ext?
The song class, FBRHFF will be looked at. It should have a property that will point it to the file that is the song.
as per https://community.bistudio.com/wiki/Description.ext#CfgSounds
sound[] = { "FBRHFF", 10, 1}; FBRHFF will be used as the name of the file that is the song.
I have missed an essential part of this..
sound[] = { "FBRHFF", 10, 1}; should be
sound[] = { "FBRHFF.ogg", 10, 1};
Yep.
Okay, it's fixed in the Description.ext, I'm going to see if I can't find out why it isn't playing still.
All I get is a popup saying ["say3D]
what is the code?
`_sounds = selectRandom ["FBRHFF"];
{radio, ["FBRHFF", 100, 1]}; ["say3D"];`
Again I apologize for this
I emplore you to look up the commands on the wiki.
https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands
remoteExec can't just be removed. you need to adapt the code accordingly
radio say3D ["FBRHFF", 100, 1];
``` should work.
but _sounds = selectRandom ["FBRHFF"]; doesn't do anything in your code.
NOID <no shape>
Does it play the sound?
Negative
Did you reload the mission after changing the description.ext?
if you did, post the them again, with the code you put in the console.
You know, I may be a bit daft. I didn't think to reload the mission
Still the same error, NOID <no shape>
No audio either
NOID <no shape> that is not an error.
https://community.bistudio.com/wiki/say3D
it returns the sound source. that means the command runs correctly
but are you testing in SP or in MP still?
SP at the moment, should I be in MP?
not until you want to test the remoteExec
can you post the description.ext and the code you run in the console?
Sure, one sec
` class CfgSounds
{
sounds[] = {};
class FBRHFF
{
name = "FBRHFF";
sound[] = { "FBRHFF.ogg", 10, 1};
titles[] = {};
};
}; `
aswell as, the folder structure in the mission? what is the path to the FBRHPP.ogg as seen from the description.ext file?
I have FBRHPP.ogg set in a folder titled "sounds" in the mpmissions>Fighting_Bengals_Training.Malden
Just to be organized
https://community.bistudio.com/wiki/Description.ext#CfgSounds and tell me what is wrong in your setup.
yep
Let me reload everything real fast.
Triple check my code.
Okay, still no sound from the radio
with the debug console or the whole code?
which one?
radio say3D ["FBRHFF", 100, 1];
[radio, ["FBRHFF", 100, 1]] remoteExec ["say3D"]; Not tested but that should be the syntax. You can test it in the debugConsole, even in SP it would work.
swap it into your code and test the whole.
Thank you for your help, by the way. Dealing with beginners must be a headache
Aslong as they don't take it for granted and read the wiki more and more. its worth it. Having a big ass steamworkshop is defo worth it, imho.
Honestly almost diverted to just downloading a mod that would do the same thing, but figured this would be more with it
thank you
'..._success} do {
_res = (call _findPlace) |#|findEmptyPosition [0, 2, _vehicleName];...'
Error findemptyposition: .( : )
Error ] .
File... blabla line 15
params ["_taskLoca", "_vehicleName"];
_findPlace =
{
_radius = random [100, 140, 200];
_angle = random 360;
_rdPos = _taskLoca getPos [_radius, _angle];
nearestBuilding _rdPos
};
_finalPos = [0,0,0];
_success = false;
while {!_success} do {
_res = (call _findPlace) findEmptyPosition [0, 2, _vehicleName];
if (!(_res isEqualTo [])) then {
_finalPos = _res;
_success = true;
};
};
_finalPos```
how to fix this error?
findEmptyPosition got an object instead of a position in your code it seems
sounds more like you've put a hidden character there
that's a parsing error
but yeah you also need position
well i just used Enter and Space
But better to make sure
call _findPlace is not a position?
but you should still see if you've actually put any hidden characters there
if it was a syntax error you'd see type object, expected array
it says another errors, whatever it passed
thank you for help!
Is there a quick way of determining if a script has been run through execVM?
scriptDone
π
am I getting the syntax wrong with any of the BIS_fnc_randomPoss?
//INITIALIZE ZONE POSITION ARRAY
_zonePosArray = [
[0,0,0], 2,
[0,0,0], 2
];
//GET ZONE POSITIONS
_zonePos5 = if (random 10 > 5) then {
[["pathZone"], ["water"]] call BIS_fnc_randomPos;
} else {
selectRandomWeighted _zonePosArray;
};
_zonePos4 = [[_zonePos5, 10], ["water"]] call BIS_fnc_randomPos;
_zonePos3 = [[_zonePos4, 100], ["water"]] call BIS_fnc_randomPos;
_zonePos2 = [[_zonePos3, 500], ["water"]] call BIS_fnc_randomPos;
_zonePos1 = [[_zonePos2, 3000], ["water"]] call BIS_fnc_randomPos;
Syntax:
[whitelist, blacklist, code] call BIS_fnc_randomPos
Parameters:
[whitelist, blacklist, code]: Array
whitelist (Optional): Array - whitelisted areas. If not given, whole map is used. Areas could be:
Object - trigger
String - marker
Array - in format [center, radius] or [center, [a, b, angle, rect]]
Location - location.
blacklist (Optional): Array - blacklisted areas. If not given, water is blacklisted. Areas could be:
Object - trigger
String - marker name or special tags names: "water" - exclude water, "ground" - exclude land
Array - in format [center, radius] or [center, [a, b, angle, rect]]
Location - location.
I am trying to use the [center, radius] format in most of these cases
your first BIS_fnc_randomPos is wrong
yo bros is there a way to open a pilotcamera with script?
context: giving pilot a user action to open targeting pod (the one you normally open with ctrl+right click)
does execVM run the script on whichever client called it? or does it run it on the server?
local
as can almost everything yeah
cool, thanks
is there any alternative to BIS_fnc_countdown? maybe i'm using it incorrectly, but my game says there is a script error in the function
why do you even want to use that?
I wanna have a timer in my mission so that after the timer (eg 40 mins) runs out the script terminates
I haven't added the termination part yet
Me go to sleep now for 40 minutes
just use sleep ... 
but in sleep how can you access the time remaining?
actually i guess you wouldnt need to
If you donβt need to donβt bother
If you do iterate though sleep with a delay of a second until you reach 0
yeah that would be way easier
Hey, merry Christmas everyone. Can someone help me with this small problem: I want to spawn many markers with the same code, but i donΒ΄t know how to make it working since there needs to be a different variable everytime. This is my code: ```sqf
private _markerName = createMarker ["_USER_DEFINED", getPos player];
_markerName setMarkerType "hd_dot";
_markerName setMarkerColor "ColorGreen";
the code should be executed multiple times to set markers on different locations. But therefore i need different variables every time. How can i do this?
use a counter
but how should i implement it? it needs to be a different Variavle neme if iΒ΄m not wrong
_markerID = missionNamespace getVariable ["my_markerCnt", 0];
_markerName = createMarker [format ["_USER_DEFINED%1", _markerID ], getPosASL player];
my_markerCnt = _markerID + 1;
thank you very much π
Where does activatedAddons get the addons from to list, as in what files/file does it search in order to know what addon files to count in.
I just noticed while testing out stuff with ACE - No medical that even though the mod has all ace_medical addons removed from the addons folder, it still says that stuff like ace_medical_engine is still active when I run the command in game.
What I'm trying to get done is use Improved Melee System alongside ACE - No medical due to an addon incompatibility using ACE Medical, but IMS thinks that ace medical is on so it fails to render damage. Might have to tinker around and make a local version of the mod but it'd be nice to know for future.
How do you transition from an animation like "Surrender" to something else? the only thing that seems to work is switchMove, which is undesirable since it immediately snaps into the new animation.
if the animation has no connectTo/interpolateTo in the config it can't link to other animations in the anim graph
the only way is switchMove
Got it, thanks!
if you want to you can just make a mod and make it possible to interpolate to other anims
e.g.:
connectFrom[] = {"AmovPercMstpSnonWnonDnon", 0.01};
InterpolateTo[] = {"AmovPercMstpSnonWnonDnon", 0.01};
It's a good idea, but I'm making tools for use in public zeus lobbies, so I'm pretty much restricted to vanilla behaviors, so I'll just have to accept having an instantaneous transition from a surrendered to captured state.
altho you might want to remove interpolateTo
Too bad there is no interpolateMove to complement switchMove
otherwise AI can snap out of it easily 
Such a command should be very easy to add actually
yeah
It wouldn't be perfect of course, many direct interpolations produce suboptimal results, but might be better than switchMove
do I absolutely have to create a separate file for a single function?
how do I call it from that file? I mean, I hope I don't have to write compile for every function
depends what you mean by "function"
you can just write "inline functions"
_fnc_doBla = {
...
};
call _fnc_doBla
that's what I needed, thanks
Is there a command that is to code as compileFinal is to string?
I do A2 and write all functions as shown, but i imagine in A3 you want to make the variables read-only
no. that's still the way
It doesn't seem very amenable to defining multiple functions in a single file then
yeah. which is why I wrote it as a local var 
I guess y'all just use that cfgfunctions thing, but i always found the practice of single function per file terribly unergonomic
you can just include those "inline functions" 
or mimic an object with switch
//blablas.h
_fnc_bla = {};
_fnc_blabla{};
#include "blablas.h"
In A2 it makes no difference because there is no compileFinal so i just write
my_global = 0;
my_fn_doSomething =
{
my_global = my_global + 1;
};
params [
["_mode", "", [""]]
];
switch (toLowerANSI _mode) do
{
case "create": {};
case "read": {};
case "update": {};
case "delete": {};
default { ["case %1 does not exist", _mode] call BIS_fnc_error };
};
I'd say this is the best way (if not using compileFinal) 
I mean in terms of MP safety
Heh i would never do that. If the action is known statically then it better be bound statically too
What are we guarding against?
What is the attack vector?
some attacker changing the global var to a different var
But that is not in itself a viable attack vector
How do you achieve that in the first place? Overwriting a global
fnc_heal = {
player setDamage 0;
};
hacker changes it to:
fnc_heal = {
player setDamage 1;
};
```π€£
there were some loopholes to execute code in MP. some were posted in some hacker forums. not sure if any of those loopholes still work
there is an error (screenshot: https://imgur.com/a/iND0kov) and I can't quite understand what's wrong
the code is something like this:
FNC_angleToCenter =
{
//... something something
_rotation;
};
addMissionEventHandler ["EntityRespawned", // <-- line 16
{
params ["_entity", "_corpse"];
//...
}];
maybe you have a missing ; before line 16
Β―_(γ)_/Β―
there's nothing wrong with what you wrote above
also
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
I believe there's an error specifically for missing semicolons, so that's not it
besides, it shouldn't have a ; there anyway
oh you also posted the error
my bad
didn't see it
I think you have a hidden character before [
if you want post the full code somewhere
like here (if short) or sqfbin.com
I rewrote it and the error still remains
here's the full code:
https://sqfbin.com/deliwunopemuyekexafo
missing ;
or should I say extra variable 
why does it think there should be a ;?
ah got it, it's meant to be driver instead of _entity
because you've put two variables next to each other without an operator in between
SQF is an operator based language
how do you compile it?
compile what?
how do I see the errors like in your screenshot?
cool, thanks
Ok so I'm making a mission that is set above 100 meters in the air.
So the players will be walking up there on a platform. The problem is that whenever I jump or whenever the character hits a lower plane below him, he goes into a freefall animation.
He can still walk but it gets annoying having to constantly wait for the freefall animation to end.
Now I've seen Leopard20's theory on how this could be fixed, in which he posted on the bottom of this page: https://feedback.bistudio.com/T75547. However even then, the problem hasn't been officially fixed yet.
If anyone happens to have any potential solutions to this problem, please feel free to share it. And if not, it's fine. I'll just deal with it and have the players walk on a much lower altitude.
MERRY CHRISTMAS (in korea)
https://sqfbin.com/duverufuzajebikecoca
This is my script and it doesn't work.
if i run the game, it stucks at loading screen and nothing happens.
I'm trying to fix this but I can't even know error. so please someone fix this as christmas present. 
what do we get? π
hmmm..
Korean Cookies pls
ok i'll send it with fedex
Also if anyone is willing you can take a look at this
It's a problem that's been bugging me for a while now
Eventually I just gave up and went to do other kinds of missions, but I wanted to see if there could be a fix to this
well you have several errors
I'll list them for you
okay..
ooh i forgot this one
findPlaceBuilding.sqf
params ["_taskLoca", "_vehicleName"];
_findPlace =
{
_radius = random [40, 100, 200];
_angle = random 360;
_rdPos = _taskLoca getPos [_radius, _angle];
nearestBuilding _rdPos
};
_finalPos = [0,0,0];
_success = false;
_resultPos = [];
while {!_success} do {
_res = (getPos call _findPlace) findEmptyPosition [0,2,_vehicleName];
if (!(_res isEqualTo [])) then {
_finalPos = _res;
_success = true;
};
};
if (!_finalPos isEqualTo [0, 0, 0]) then {_resultPos = getPos _finalPos;} else { };
_resultPos```
this too has an error π€£
it's my first sqf work
- publicVariable: you're broadcasting local vars in your code (e.g.
publicVariable "_point";). they must be global. for [{_i = 1},{_i<=(count _rdMissions - 1)},{_i=_i+1}] do {: your _i starts at 1. it should start at 0. also use the otherforsyntax (for "_i" from...)
_intel addAction ["μ κ΅° μ 보", {
[name _task, "SUCCEEDED"] call BIS_fnc_taskSetState;
deleteVehicle _intel;
}];
_intel addEventHandler ["Killed", {
[name _task, "FAILED"] call BIS_fnc_taskSetState;
deleteVehicle _intel;
}];
_task and _intel are not defined in those scopes
4. if (!_finalPos isEqualTo [0, 0, 0]): ! is a unary command. it has higher precedence than isEqualTo (binary command) so it executes first, but it acts on _finalPos -> error
either wrap the isEqualTo statement in parentheses !(_bla isEqualTo _blabla) or just use isNotEqualTo
There may not be any way to prevent this. It seems the engine detects the altitude and forces the action
Someone else was recently asking about the same thing
yeah I tried but couldn't find any workaround
the engine keeps playing the animation
alright then i have to replace _intel to this?
@buoyant abyss you still might be able to snap the players out of it using switchMove
but the "halo animation" still triggers for a brief period
no. this is only defined in object init fields
you should use the addAction args
_intel addAction ["μ κ΅° μ 보", {
params ["_intel", "", "", "_task"];
[name _task, "FAILED"] call BIS_fnc_taskSetState;
deleteVehicle _intel;
}, _task];
something like that
can arguments be array?
there's the same problem at addAction
oh so Im not blind π€£
lol
yeah so that covers the addAction
for the event handler I need to know what _task is
yes
as in is it a global thing?
can it change?
does it depend on intel?
ok so you associate the "task" with the intel
yeah I know
also isn't _task a string? 
why do you do name _task?
yeah that's wrong
private _task = [
BLUFOR,
format ["task%1", str _taskNumber],
[format ["%1 κ·Όμ²μ μ μ μ λ³΄κ° λ΄κΈ΄ μ»΄ν¨ν°κ° μλ€. μμ ν ν보νλΌ.", name _loca], "μ κ΅° μ 보 μμ", "asdf"],
getPos _intel,
"CREATED",
-1,
true
] call BIS_fnc_taskCreate;
_task is just a bool
you need the taskID
which is this format ["task%1", str _taskNumber],
private _task = format ["task%1", str _taskNumber];
that will be "correct"
anyway:
_intel setVariable ["associatedTask", _task];
_intel addMPEventHandler ["MPKilled", {
if (!isServer) exitWith {};
params ["_intel"];
_task = _intel getVariable ["associatedTask", ""];
[_task, "FAILED"] call BIS_fnc_taskSetState;
deleteVehicle _intel;
}];
fix the other problems I said too
the publicVariable ones in particular
also this loop:
while {!_success} do {
_res = (getPos call _findPlace) findEmptyPosition [0,2,_vehicleName];
if (!(_res isEqualTo [])) then {
_finalPos = _res;
_success = true;
};
};
```is terrible
it can loop forever
but you run it in execVM so I don't think that's why the game gets stuck
hmm... or just my computer sucks? π
no, but your code has several errors, so ...
Hello, I have a question regarding "find" and 2D arrays. Can it be used to find elements in it without having to loop through each cell
and then using "find"?
e.g _array = [[10,"Bob"], [35, "John"], [24,"Nick"]];
Reason is, I want to find the index of a unit in my array after a death has occured and I'm trying to avoid having a foreach loop(for array cells) inside
an event handler that itself is inside a foreach loop(for units)
no, instead of foreach you can use https://community.bistudio.com/wiki/findIf, or better - use a hashmap
also I just noticed that this loop probably will never exit if it fails the first time
you're just running the same thing all over again
I'd like to use a hashmap but I'm using an array as it containts enemy units i want to target,the array is sorted to my liking and I'm using an index to target them in order. (To my amateur knowledge) You can't use an integer as an index for a hashmap. e.g doTarget hashmap index 0
it will exit (my opinion). because it calls _findPlace and returns pos randomly, so it's not gonna repeat same thing.
no, it only has a small chance of exiting
it might succeed if you increase the search radius every iteration
i can't increase radius because i'll hide it in a building
if I increase it, it will be spawned outside
if you want to put something in a building use buildingPosition
not findEmptyPosition
findEmptyPosition never returns a pos inside other objects afaik
did you even test it before using it? 
i said it. it's my first work lol..
well you should always test before using something
the debug console is intended for that very purpose. you write snippets and test how they behave
buildingPos will work. but I think intel might spawn inside something like bed and desk
then it cannot be found forever
buildingPos is where AI can walk
oh
it almost never is inside a "bed or desk"
wdym "almost"?
also arma very rarely has beds and desks 
I mean it shouldn't be
like I said, the AI should walk there (tho AI has no collision so they can pass thru them). and the player should be able to go there too
your bigger concern should be placing the object on the floor in the center of the room π
that can happen
no problem. i'll try buildingPos
well.. i have some problem.
_intel addEventHandler ["Killed", {
[_task, "FAILED"] call BIS_fnc_taskSetState;
deleteVehicle this;
}];```
i want to use `_task`, but I can't add arguments unlike `addAction`.
I already showed you
here
this one?
oh
this language is so confusing..
it's probably the easiest language I've ever seen 
i think the easiest and best language is kotlin
is there java library for arma 3? lol
no
to both statements
what have you got now?
oh i thought wrong
i played multiplayer
i'll try it again
omg it happened again
game stucks
code
i think i can fix it
hmm it's still not working..
findPlaceBuilding.sqf
params ["_taskLoca", "_vehicleName"]; //_taskLoca position must be Pos2D
_findPlace =
{
_radius = random [40, 100, 200];
_angle = random 360;
_rdPos = _taskLoca getPos [_radius, _angle];
nearestBuilding _rdPos
};
_finalPos = [0,0,0];
_success = false;
_resultPos = [];
while {!_success} do {
_res = call _findPlace buildingPos -1;
if (_res isNotEqualTo [0, 0, 0]) then {
_finalPos = _res;
_success = true;
};
};
_finalPos```
makeIntelTask.sqf
```sqf
params ["_taskNumber", "_loca"];
private _pos3d = getPos _loca;
private _pos2d = [_pos3d select 0, _pos3d select 1];
private _objLocation = [];
while {_objLocation isEqualTo []} do {
objLocation = [_pos2d, "Laptop_EP1"] execVM "Functions\findPlaceBuilding.sqf";
};
private _intel = "Laptop_EP1" createVehicle _objLocation;
[
BLUFOR,
format ["task%1", str _taskNumber],
[format ["%1 KOREAN", name _loca], "KOREAN", "asdf"],
getPos _intel,
"CREATED",
-1,
true
] call BIS_fnc_taskCreate;
private _task = format ["task%1", str _taskNumber];
textLog format ["Created Task: find Intel case. Pos: %1", _objLocation];
_intel addAction ["KOREAN", {
_arguments = _this select 0;
[_arguments select 0, "SUCCEEDED"] call BIS_fnc_taskSetState;
deleteVehicle _arguments # 1;
}, [_task, _intel]];
_intel setVariable ["asdfTask", _task];
_intel addMPEventHandler ["Killed", {
params ["_intel"];
[_intel getVariable "asdfTask", "FAILED"] call BIS_fnc_taskSetState;
deleteVehicle _this # 0;
}];```
_res = call _findPlace buildingPos -1;
if (_res isNotEqualTo [0, 0, 0]) then {
wrong. it's always true
while {_objLocation isEqualTo []} do {
objLocation = [_pos2d, "Laptop_EP1"] execVM "Functions\findPlaceBuilding.sqf";
};
wat?
how?
buildingPos -1 returns an array of positions
or empty array
so _res isNotEqualTo [0, 0, 0] is always true
also keep in mind that not all buildings have positions
as for this, this is completely wrong
it could be what's crashing the game for you
you're creating millions of scheduler threads
first of all, forget execVM
you're using it way too much
and wrongly
first of all, if you're not familiar with the scheduler read this:
https://community.bistudio.com/wiki/Scheduler
as for what's wrong with execVM:
- it recompiles the script every time you run it
- you can't return something from it (what you were doing by mistake there). instead it returns the handle to the created scheduler thread
- it creates a new scheduler thread (but keep in mind that "thread" doesn't mean multithreaded. SQF is single-threaded). you should avoid creating new scheduler threads as much as possible
i can't remove paused script from scheduler?
you can. using its handle
now what are the alternatives?
- using
CfgFunctions. it compiles the scripts only once. - using
compile preprocessFileLineNumbers "file.sqf", and storing the result into a variable as a function (but making sure you only do this once)
you cancallorspawnthose functions like before
ofc if you're only running execVM once and you want a new thread it's ok to use
which one do you recommend?
CfgFunctions when you want to run a code many times. you can call or spawn the function as many times as you want
for one time scripts, call compile preprocessFileLineNumbers "file.sqf" when you don't want to create a new thread and you want to return a result from a script.
and execVM for one time scripts with new thread
also as I pointed out before this loop is very bad too:
while {!_success} do {
_res = call _findPlace buildingPos -1;
if (_res isNotEqualTo [0, 0, 0]) then {
_finalPos = _res;
_success = true;
};
};
instead use grid search and nearestObjects
like this?
class CfgFunctions
{
class TAAG
{
class Category
{
class findPlaceBuilding {};
};
};
};```
yeah but use your own tag 
also make sure the script is in functions\fn_findPlaceBuilding.sqf
not nearestTerrainObjects?
that doesn't return editor placed buildings
if you care ofc
It's crashing again.. and I'm very tireeeed..
in my country it's 3am
thank you leopard and have good night.. or good day..
okay thanks. I'm confused about what is wrong, though. Isn't it supposed to be [whitelistArray, blacklistArray] call BIS_fnc_randomPos? don't they both need to be arrays?
yep lmao. Apparently I'm doing BIS_fnc_randomPos wrong tho. getting an error and I don't know why
I just said that according to the function description
whitelist (Optional): Array - whitelisted areas. If not given, whole map is used. Areas could be:
Object - trigger
String - marker
Array - in format [center, radius] or [center, [a, b, angle, rect]]
[["pathZone"], ["water"]] call BIS_fnc_randomPos;
doesn't match any
Array
or does it mean arrays of those?
oh right 
then I guess it's correct
Β―_(γ)_/Β―
the rest are wrong
I got it backwards 
only the first one is correct
Is there a solution for getting selection-space coordinates and vectors in sqf? I tried to do the vector coordinate-space-switching math, unsuccessfully
ie for something attached to "righthand", finding what vectorDirAndUp it needs to be to point a specific model- or world- orientation.
https://imgur.com/a/qXHPit2
The alternative would be to attach a helper object
if I have a global variable, that variable will always be accessible anywhere in the mission, right?
For example:
zoneDamage = 0.02;
[] spawn {
while { true } do {
sleep 1;
if (player inArea "restrictedZone") then {
player setDamage (damage player + zoneDamage);
};
};
};
sleep 30;
zoneDamage = 0.05
```Will the spawned code start damaging the player by `0.5` after 30 seconds?
That's a global variable
Except for some very specific stuff, yes it's accessible in all scripts on that client
okay, so my code will work as I expect it to?
Uhh probably not
There is no guarantee of timely execution for scheduled scripts. In simple terms players with lower framerate may survive longer
Can you clarify what exactly it is you're looking to achieve
As you can se in the pictures, attaching the laptop to the hand selection result in it pointing up along the arm. I want to calculate what vectorDirAndUp is needed to have it point, for example, toward the left of the player.
can I not call a pre-compiled function from another pre-compiled function?
they appear to be working just fine in init.sqf, but it throws "unknown variable" or something like that when I try to use them from another pre-compiled function
how do I go around this?
You want the laptop to face model right but still follow the hand rotation?
no, just face model right at that pose
Right, in a particular pose, of course
There is some selectionVectorDirAndUp command i think that probably gives you the rotation matrix for the hand
So you invert that and multiply it with the model space rotation matrix
Right, that's the vector math part that I failed at xD
my bad, they don't work in init.sqf either
Well you have commands for multiply and transpose. Transposing a rotation matrix inverts it
A 3x3 rotation matrix is just three perpendicular unit vectors. You already get the Z and Y unit vectors as dir and up. You just need aside which is their cross product
say I have a zone marker on the map, and I want it to slowly move onto a random position. If I have the position, how would I constantly set it's position to be closer to it's final position until it gets there? Is there a command to make it move in a certain direction?
WHY does it look for SB folder? https://imgur.com/a/x0vd2m4
why does it have to be so painful?
There is no command to get a selection direction. I've had some luck getting the direction from one selection to the next though.
For example, the direction from the elbow to the hand is forearm direction
There is, and Leopard already gave me the code I just wasn't using it correctly xD
#arma3_scripting message
hi, there is a way to "SetDir" an object attached to a vehicle with the "simulation = false" ?
when i mean "SetDir" i mean already this command
it doesn't work anymore. If the simulation is disabled you can't "SetDir" or "SetVectorDirAndUp"
yes you can
if you have "enabled" the simulation on your "object" and this object is attached to a vehicle with "simulation disabled" you can't. I have tried you can try too.
but i will try to disable the simulation on the object too
I just tested setting the dir of an object that has its simulation disabled, and you can
not sure about attachements
yeah but i don't mean an "object with simulation disabled" i mean an "object with simulation enabled but attached to a vehicle with simulation disabled" sorry for my english
ok
Hello, is there a way to remove the magazine of a player's weapon
I know i could remove the weapon and then add it again, but i was wondering if there is an easier way
removePrimaryWeaponItem should do
works! Thanks :)
Is there any point in using removeMagazine instead of removeMagazineGlobal for MP missions?
i think removeMagazine is local effect
so if you want to remove a magazine only for that specific unit on its machine, you can use that
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?
anyone know why https://sqfbin.com/wipikajebotesefavada <- returns a script error saying "undefined variable in expression: thisTrigger"? the code is directly in the onActivation of a trigger
you need to pass it to the spawn
i mean
you need to define it inside the spawn
you passed it, now you need to define it. you could do params ["_thisTrigger"] or _thisTrigger = _this select 1;
also, line 3 has an error with the string @wind cairn
what is the error? @past wagon
thisTrigger setTriggerStatements ["this", "titleText ['text', 'BLACK'];
^ HERE
see how the entire rest of the line is blue, meaning its part of the string?
you never closed it
it continues on, that is a piece of code that goes to the onAct of the trigger
titleFadeOut 2;", ""];};
ended there
yeah
sorry, lemme check the syntax for that
oh then you are correct, my bad
didn't know the code was in the format of a string
I added the params ["_thisTrigger"]; but it's run into the same issue as before I put it into the spawn, where I get generic expression with the sleep command
oh
you cant have sleep there
if that's the execution for a trigger, then it is an unscheduled environment, meaning there is no sleep/waitUntil/while allowed
Does putting spawn infront not schedule it?
I guess not
well, I would think so, but if it's giving you "Generic Error in expression" for the sleep, then that might be the case
hmm, ill try find a workaround
null = [thisTrigger] spawn {
params["_thisTrigger"];
_thisTrigger triggerAttachVehicle [player];
_thisTrigger setTriggerActivation [ "VEHICLE", "NOT PRESENT", true ];
_thisTrigger setTriggerStatements ["this", "
[] spawn {
titleText ['text', 'BLACK'];
sleep 5;
forceRespawn (triggerAttachedVehicle thisTrigger);
sleep 2;
titleFadeOut 2;
}
", ""];
};
@wind cairn try this
the issue is that you're using sleep in your trigger statement w/o spawn, trigger statements are not executed in a scheduled environment
I thought I was already using spawn, i must've been using it incorrectly
no problem
why do some commands use code inside a string, anyway? Why not just {}?
hi, this is my code https://sqfbin.com/bacegogekagekerecebu and I have some problem.
- When I play the game,
call TAAG_fnc_startMission;is not working insideinit.sqf. But if i run this code in debug console, it works. - If I spawn Laptop and Ammo box, error occurs.
'...laceBuilding;
};
private _destroyObj = |#|createVehicle ["BWA3_Box_Ammo", _objLoca..."
Error 0 ( ) .( : 3)
blabla (path) fn_makeSmallDestroy.sqf ..., line 10```
while {_objLocation isEqualTo []} do { objLocation = [_pos2d, "FIR_MP_Laptop"] call TAAG_fnc_findPlaceBuilding; };
again, wrong.
deleteVehicle _arguments # 1; deleteVehicle _this # 0;
wrong.#is binary and has lower precedence
publicVariable "_point";
I told you before. DONT PUBLISH LOCAL VARIABLES
while {!_success} do { _res = call _findPlace; if (count _res isNotEqualTo 0) then { _success = true; _finalPos = _res; }; }; _finalPos
why do you keep using a while loop? use grid search
If I spawn Laptop and Ammo box, error occurs.
you didn't share that code
is there an equivalent to exit for sqf?
exit what?
a script
use breakOut or if you're in the main scope, exitWith
will exitWith stop the script?
if you're in the main scope
ok
Because internally, in the engine, the code is stored as string, from what i know it's a leftover thing from SQS, as SQS was not compiled. This does mean recompile on execution, e.g., event handler code, that's why people suggest doing seperate functions for event handlers that do a lot of work.
https://community.bistudio.com/wiki/a_hash_b document says hash has higher precedence
higher than select
not a unary command
Isn't it Hash-select operator?
yes
who's talking about select?
wait i'm confused now
deleteVehicle _this # 0;
wrong. # is binary and has lower precedence
I'm talking about unary commands
in this case deleteVehicle
all binary commands have lower precedence than unary commands
is binary and has lower precedence
you said # has lower precedence

deleteVehicle is unary
# is binary
O(deleteVehicle) > O(#)
get it now? 
oh
i got it
sooo I should code like
_asdf = _this # 0;
deleteVehicle _asdf;```
this?
divide the map into grids
no, you have to do it manually
you can divide the map into squares of a certain size
and search in these grids
there's no way to use position 3d?
I mean search for the building in the grids
what you wrote may have a 0 chance of success right now
nearestBuilding returns only 1 object
and that object may not even have building positions
you have to try new objects
if you don't care about performance you can pick a large radius (not too large tho) and get all objects in there
then iterate thru all of them
_objs = nearestObjects [_pos, ["house", "building"], 1000, true];
//get a few objects to randomize
_buildings = [];
{
if (_x buildingPos -1 isNotEqualTo [] && {
_buildings pushBack _x >= 4
}) then {
break; //collect up to 5 buildings
};
} forEach _objs;
_building = selectRandom _buildings;
it's easier and performance wise it's ok
alright i'll try that
is it possible to disable a trigger locally for each player
enableSimulation
does that do more than just its animation and physics?
since when a trigger has animation and physics? 
thats why im confused, what exactly does it disable?
ok
_nearObjects = nearestObjects [_pos, [], 400];
_buildings = [];
{
if (_x buildingPos -1 isNotEqualTo [] && {_buildings pushBack _x >= 4}) then {break;};
} forEach _nearObjects;
_building = selectRandom _buildings;
getPos _building```
is this right?
i think getPos is incorrect
don't use empty type [] 
do you have any idea how many objects there could be?!
and no, don't use getPos
don't ever use getPos
read the wiki as to why
also didn't you want a buildingPos?
just return selectRandom (_building buildingPos -1)
oh I forgot to write type
hmm
another error occurs
'...ndPlaceBuilding;
private _destroyObj = |#|createVehicle ["BWA3_Box_Ammo", _objLoca...'
Error 0 ( ) .( : 3)
File (path) fn_makeSmallDestroy.sqf
and i have question
how to read that error?
it gives a little information
and wth is Error 0 ( ) .( : 3)
Is there any way to terminate a script from inside a loop?
would 'stacking' exitWith statements work?
e.g
{
if (!(alive player)) exitWith
{
exitWith{};
};
};
!rpt
Arma generates a .rpt log file each time it's run, which contains a lot of information like the loaded mods, or any errors that appear, this log file can be very useful for troubleshooting problems.
To get to your RPT files press Windows+R and enter %localappdata%/Arma 3
Additionally see the wiki page for more info: https://community.bistudio.com/wiki/Crash_Files
To share an rpt log here, please use a website like https://sqfbin.com/ to upload the full log, that way the people helping you can take a look at it and try to figure out the problem you're having together with you.
Note: RPT logs can hold personal information relevant to your system, the game or others.
post the full code
use breakOut like I said before
that doesn't include that file
it's the same code
textLog format ["Created Task: find Intel case. Pos: %1", _objLocation];
that's wrong
textLog doesn't exist
well it exists, but it does nothing
always use the wiki
that extension is outdated
but anyway that is not the source of the error
and I don't see anything else wrong
This command is non-functional in the retail version
bruh
params ["_taskNumber", "_loca"];
private _pos3d = getPos _loca;
private _pos2d = [_pos3d select 0, _pos3d select 1];
private _objLocation = [_pos2d, "BWA3_Box_Ammo"] call TAAG_fnc_findPlaceBuilding;
private _destroyObj = createVehicle ["BWA3_Box_Ammo", _objLocation, [], 2, "NONE"];
private _task = format ["task%1", str _taskNumber];
[
BLUFOR,
format ["task%1", str _taskNumber],
[format ["%1 κ·Όμ²μ μ μ νμ½ μμκ° μλ€. λ°κ²¬ μ¦μ νκ΄΄νλΌ.", name _loca], "μ κ΅° νμ½μμ μμ", "asdf"],
getPos _destroyObj,
"CREATED",
_taskNumber,
true
] call BIS_fnc_taskCreate;
_destroyObj setVariable ["asdfTask", _task];
_destroyObj addMPEventHandler ["Killed", {
params ["_destroyObj"];
[_destroyObj getVariable "asdfTask", "SUCCEEDED"] call BIS_fnc_taskSetState;
(deleteVehicle _this # 0);
}];```
here
this is fn_makeSmallDestroy.sqf
error occurs line 7
private _destroyObj = createVehicle ["BWA3_Box_Ammo", _objLocation, [], 2, "NONE"];
something went wrong here
hmmm
also _this # 0 is _destroyObj
do you need .rpt file?
no. what is TAAG_fnc_findPlaceBuilding now?
_pos not defined
jejus
alright
that error is gone
21:00:17 Error in expression <_intel setVariable ["asdfTask", _task];
_intel addMPEventHandler ["Killed", {
pa>
21:00:17 Error position: <_intel addMPEventHandler ["Killed", {
pa>
21:00:17 Error ?μμ½?μΉλΏ ?λΊ€μ½?μ? ?λ? θΉΒ??_intel)εͺΒ ?λλΏ?λλ. (crashed. I can't read it)
21:00:17 File path..., line 20```
crashed. I can't read it
like I said read the rpt
yeah that was in rpt
?μμ½?μΉλΏ ?λΊ€μ½?μ? ?λ? θΉΒ??_intel)εͺΒ ?λλΏ?λλ
I don't understand korean. what is that saying?
yeah but the rest are korean 
anyway...
maybe change the game language to English?
{
if (!alive player) then
{
"appTriggerInner" enableSimulation false;
"appTriggerOuter" enableSimulation false;
titleText ["You Have Been Killed.", "BLACK"];
sleep 2;
titleFadeOut 2;
breakOut "main";
};
};```
Any idea why its not taking the if path when the player dies?
also don't use loops for that
we have event handlers
lol game & launcher crashed
and more importantly never use while loops without sleep
don't buy iMac..
without? why not?
a while loop without sleep will run multiple times in a single frame
a player cannot "die" in that frame, no matter how many times you check 
ok
but anyway for something like dying we have event handlers
does it matter where the event handler is in the code?
no. it should be only used once. after you add it it'll fire every time that event happens
cool
finally
it makes normal error message
Error Foreign error: Unknown enum value: "Killed"
is it MPKilled?
yes. why did you change it?
{
params ["_unit", "_killer", "_instigator", "_useEffects"];
"appTriggerInner" enableSimulation false;
"appTriggerOuter" enableSimulation false;
titleText ["You Have Been Killed.", "BLACK"];
sleep 2;
titleFadeOut 2;
breakOut "main";
}];```
still doesn't seem to work
you can't put sleep in EH code
ah ok
"appTriggerInner" enableSimulation false;
wrong
breakOut "main";
wrong
class CfgFunctions {
class SB {
class SomeCat {
file = "my/folder";
class blabla {
//will look for "my/folder/fn_blabla.sqf"
};
};
}
}
how do you access the triggers?
yeah, I have figured things out already
using their var name
but not wrapping them in ""
that forms a string
it's not a variable anymore
doesn't seem to pick it up even though its in mission.sqm
_HVTobj addMPEventHandler ["MPKilled", {
params >
21:30:33 Error position: <addMPEventHandler ["MPKilled", {
params >
21:30:33 Error Generic error in expression
21:30:33 File path ..., line 20```
pick up what?
21:30:42 Cannot create non-ai vehicle FIR_MP_Laptop,
nvm bug on my end i think
what is FIR_MP_Laptop anyway?
are you sure it even exists?
where did you even get that name in the first place?
so do you have any ideas to solve this?
what's _HVTobj ?
params ["_taskNumber", "_loca"];
private _pos3d = getPos _loca;
private _pos2d = [_pos3d select 0, _pos3d select 1];
private _objLocation = [_pos2d, "O_Officer_Parade_Veteran_F"] call TAAG_fnc_findPlaceBuilding;
private _HVTobj = [_objLocation, east, ["O_Officer_Parade_Veteran_F"]] call BIS_fnc_spawnGroup;
leader _HVTobj disableAI "all";
private _task = format ["task%1", str _taskNumber];
[
BLUFOR,
format ["task%1", str _taskNumber],
[format ["%1 κ·Όμ²μ HVT (κ³ κ°μΉ νμ )μ΄ μλ€κ³ νλ€. μν¬νμ¬ κΈ°μ§λ‘ 볡κ·νλΌ. λͺ©νλ μ΄λ³μ μ볡(μ°Έμ μ©μ¬, CSAT) 볡μ₯μ μ
κ³ μλ€.", name _loca], "μ κ΅° HVT μν¬", "asdf"],
getPos leader _HVTobj,
"CREATED",
_taskNumber,
true] call BIS_fnc_taskCreate;
_HVTobj setVariable ["asdfTask", _task];
_HVTobj addMPEventHandler ["MPKilled", {
params ["_intel"];
[_HVTobj getVariable "asdfTask", "FAILED"] call BIS_fnc_taskSetState;
deleteVehicle (_this # 0);
}];```
finally
no error now
but there's problem
_point = 400;
_pointMarker = createMarker [format ["Point: %1", _point], position wherePoint];
_pointMarker setMarkerType "loc_help";
_pointMarker setMarkerText format ["Point: %1", _point];
sleep 10;
call TAAG_fnc_startMission;```
this is `init.sqf`
but call TAAG_fnc_startMission; does nothing
but if i run that code in debug console, it works
don't put sleep in init.sqf 
and what's TAAG_fnc_startMission?
_rdMissionCount = random [4, 6, 8];
_rdMissions = [];
// _missionTypes = ["hvt", "kill", "destroysmall", "destroy", "terminal", "hostage", "intel"];
_missionTypes = ["hvt", "destroysmall", "intel"];
_missionAreas = [
benio,
corazon,
drassen,
elvillon,
fernando,
lospeligron,
manteria,
maruko,
sanarulco,
victorin
];
_rdMissionArea = selectRandom _missionAreas;
for "_i" from 0 to (_rdMissionCount - 1) do {
_rdMissions set [_i, selectRandom _missionTypes];
};
for [{_i = 0},{_i<=(count _rdMissions - 1)},{_i=_i+1}] do {
switch (_rdMissions select _i) do {
case "hvt": {[_i, _rdMissionArea] call TAAG_fnc_makeHVTtask};
//case "kill": {[_i, _rdMissionArea] execVM "TaskFunctions\makeKilltask.sqf"};
case "destroysmall": {[_i, _rdMissionArea] call TAAG_fnc_makeSmallDestroy};
//case "destroy": {[_i, _rdMissionArea] execVM "TaskFunctions\makeDestroytask.sqf"};
//case "terminal": {[_i, _rdMissionArea] execVM "TaskFunctions\makeTerminaltask.sqf"};
//case "hostage": {[_i, _rdMissionArea] execVM "TaskFunctions\makeHostagetask.sqf"}; TODO
case "intel": {[_i, _rdMissionArea] call TAAG_fnc_makeInteltask};
default { };
};
};```
for [{_i = 0},{_i<=(count _rdMissions - 1)},{_i=_i+1}]
ditch that for syntax
you don't even need for
ever heard of forEach? 
well..
i didn't know about forEach when I make that code
whatever it works
sooo
call TAAG_fnc_startMission; why this code is not working in init.sqf
leopard is there a way to exit the script when the event handler is executed?
sorry for interuppting
I see no reason
uh
exit what script?
handler's argument
the script the event handler is in like initPlayerLocal.sqf -> script.sqf (where event handler is) exit that script and go back to initPlayerLocal.sqf
you can't
