#arma3_scripting
1 messages ยท Page 113 of 1
Okay, I will try it again then
Greetings everyone,
any good method
how to use some kind of static analyzer
for arma 3 mods
.sqf .sqm files?
If these are chatGPT output (and they look like it), please remove them from the channel.
chatGPT just writes semi-plausible garbage for anything non-trivial in SQF.
How can I execute a script that runs only on the server?
if (isServer) {
}
?
well, that's if it runs everywhere and you don't want it to execute something elsewhere.
I want that the script is only run by the server.
Which may or may not be the correct answer in context. Depends on your starting point.
If you're writing a mod and using preInit or postInit CfgFunctions, then if (isServer) is what you need.
With this I can check if the script is executed correctly by the server?
If you're dumping code into an editor init box, then isServer is also the way.
I have a script that should execute another script, but only on the server
haha yes
In that case remoteExec(Call) with 2 as the target.
Unless that script is already running everywhere, in which case isServer again.
Context is key.
{"myScrit.sqf"} remoteExec ["call", 2];
like this?
"myScript.sqf" remoteExec ["execVM", 2];
but execVM is terrible and you should learn how to use CfgFunctions :P
okay thanks ๐
Also you never did explain the context. Let's say your previous script is running everywhere. Now you're execVMing myScript.sqf once per machine.
All on the server, but more than once.
The script should be executed only once at the end of the mission with an if function. Accordingly, it can actually be executed only once
But if I use 2 as the destination parameter, it will only run on the server and not on every machine, right?
I'll just give it a try with what you wrote. But thanks for your suggestions
apparently nil as a hashmap value is pretty sticky. unlike its getvariable analog, getordefault does not return the default when nil is the actual value.
_map = createhashmap;
_map set ['_key',nil];
_val = _map getordefault ['_key',false];
isNil '_val'; // true
by contrast:
_object setvariable ['_var',nil];
_val = _object getvariable ['_var', true];
[isNil '_val', _var]; // [false, true]
Is it possible to increase the spread of bullets for bots and humans with scripts?
You might want to try this. Maybe it is what you are looking for:
https://community.bistudio.com/wiki/setSkill
(for humans, yes but it's complicated and expensive)
Arma doesn't give you any direct script control over dispersion aside from changing the bullet path in a Fired EH.
could always try mission configuration, skill, accuracy settings
Hello, is there any way to re size items (or vehicles) and make it work on muliplayer? Thanks
Can you tell me how to run three different animations one by one?
I really don't know what do you mean by resize items or vehicles but most unlikely. A Mod is required
Look for commands like switchMove playMoveNow
Change de objects size. Like setObjectScale but that works on multiplayer
That is the only way and it apparently has some limitations you can't really alter
thanks
I wonder if we can improve sort, right now to have to write something like this:
private _sort = vehicles apply {[_x distance player, _x]};
_sort sort true;
private _nearest_vehicle = _sort select 0 select 1;
```which is pretty ugly. Maybe there can be `ARRAY sort CODE` which would work like this:
```sqf
private _nearest_vehicle = vehicles sort {_x distance player} select 0;
```and for desc sort you'd do:
```sqf
private _farthest_vehicle = vehicles sort {-(_x distance player)} select 0;
```Any thoughts?
Sounds like in-engine BIS_fnc_sortBy
That one also has "filter" but you can do that by adding select.
I hate building subarrays for current sort, in-engine sorting by code could be so much faster
I'd argue that for _array sort {...} select 0 usage the more useful thing would be _array selectMax {...}
You might want say 3 closests vehicles though
But I'd be okay if we also had ARRAY selectMin CODE and ARRAY selectMax CODE to avoid building and returning scripting array when you only need a single return
Probably more than half of my sorts are these kinds of sorts - find single item by some property
sort and sortFirst maybe
any good method
how to use some kind of static analyzer
for arma 3 mods
.sqf .sqm files?
https://i.imgur.com/U5UYIcD.png
Visual studio code + sqflint
maybe someone knows better method?
Perhaps filter can be added right into sort, if CODE return is not NUMBER or say nil
private _closest_tank = vehicles sort {if(_x isKindOf "Tank") then {_x distance player} else {nil}} select 0;
_array selectMax [{...}, 3]; ๐
except singular selectMax is a simple pass across the array in (seemingly) O(1) time. And expanding it to multiple would demand multiple passes or sort and brings extra complexity 
does anyone know if this command stopped working?
are there any alternatives?
[s1, s2] join grpNull
Define stopped working
Is there something else?
Hence my question
There's only very few context in your question to tell any answer
- errors?
- are they (s1, s2) defined?
- any Mods?
- did it worked before?
mod lambs danger b vcom ai.
the units have names.
Trigger
is it normal for a trigger condition to not activate when using exitWith {true}? below is a simple custom timer, but once the ticks reach to 0 it never completes: sqf _ticks = thisTrigger getVariable ["ticks",10]; if (!this) exitWith {thisTrigger setVariable ["ticks",nil]; false}; if (_ticks < 1) exitWith {systemChat "true"; true}; if (player in thisList) then {hintSilent format ["Time Left: %1",_ticks]}; _ticks = _ticks - 1; thisTrigger setVariable ["ticks",_ticks]; false systemChat "true" shows up, but the trigger isn't activated - if i write it using then {true} else {... false}, it works fine: sqf _ticks = thisTrigger getVariable ["ticks",10]; if (!this) exitWith {thisTrigger setVariable ["ticks",10]; false}; if (_ticks < 1) then {true} else { if (player in thisList) then {hintSilent format ["Time Left: %1",_ticks]}; _ticks = _ticks - 1; thisTrigger setVariable ["ticks",_ticks]; false };
You can't return with exitWith in top most scope
Code will execute, but its returned value won't be set as top most scope return value
Just wrap your whole thing in call {}
call {
_ticks = thisTrigger getVariable ["ticks",10];
if (!this) exitWith {thisTrigger setVariable ["ticks",nil]; false};
if (_ticks < 1) exitWith {systemChat "true"; true};
if (player in thisList) then {hintSilent format ["Time Left: %1",_ticks]};
_ticks = _ticks - 1;
thisTrigger setVariable ["ticks",_ticks];
false
};
huh, i would have assumed otherwise from the first example in the docs ```sqf
if (true) exitWith
{
systemChat "exiting the main scope = leaving the whole script";
};
systemChat "never shown - the script has already ended";```
i guess that was assuming the code would have been written in a function and called, so it wasn't literally the highest scope
The code runs fine, the problem is that top most scope doesn't get a return value from exitWith
This is an issue for event handlers and these trigger fields
well, i guess i know now 
player addEventHandler ["HandleDamage", {
if(true) exitWith {0};
}];
```Player will not be invincible, EH scope won't return 0 but instead return nothing and default engine behavior for damage will be used
Yeah its one of the quircks of the engine\sqf
oh that reminds me of an earlier handler i had written to prevent damage from AI HMG statics, this was exactly why it wasn't working (i also forgot to use _unit getHit _selection to avoid healing them)
Hi folks, I'm having an issue with following the tutorial on custom modules - I'm pretty sure it's a basic issue but I can't get my head around it.
https://community.bistudio.com/wiki/Modules
I've gotten as far as 'Writing the Module Function', but whenever I try to use the module in a mission this appears at the start:
[BIS_fnc_moduleExecute] Cannot Execute Module, error found in fn_moduleNuke
this seems to happen regardless of what I put in fn_moduleNuke.sqf, but I can't find details of what the error actually is anywhere - where should I look? I've been looking through the .rpt for my sessions and can find no mention (other than my addon being loaded).
https://forums.bohemia.net/forums/topic/184230-error-with-making-a-module/
Something-something CfgFunctions isn't setup right
Hello forum, I keep getting an error when I try to make an module. The error is: [bIS_fnc_moduleExecute] Cannot execute module, error found in a_function_name. Ive rebuild the module multiple times, I even copied everything from the Arma 3 Module Framework page and still get the error. Does anyon...
thanks, i'll have a read and hopefully can figure it out!
The module wiki is pretty outdated. R3VO and I will probably rewrite it here soonish when we have the time. In the mean time, post the goods and I'll help you through it.
Thanks for the offer :) not sure of the best way to share it here, can't seem to share files (had hoped to .zip it and post but alasโฆ)
Hope this is OK!
Pastebins:
Config.cpp: https://pastebin.com/KCbTavvv
fn_moduleNuke.sqf: https://pastebin.com/50FsDt2f
Directory Structure:
Directory: E:\Modding\ARMA 3\MyModule
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 27/06/2023 19:47 functions
-a---- 31/10/2023 22:03 4812 Config.cpp
Directory: E:\Modding\ARMA 3\MyModule\functions
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 31/10/2023 22:01 884 fn_moduleNuke.sqf
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
are you currently just copy pasta what is on the wiki page currently?
so I would show you an example how it works in "Modules Enhanced" but I write it for HEMTT and use lots of CBA macros so that would be something we could chat about and go through the code sometime if you are available later today to go really in depth. But for now, it looks like this might be your first mod as well? As your CfgPatches looks pretty place holder?
I would be totally up for learning some best practices etc. - but I'm australian, and it sounds like timezones may be an issue we'll have to work out (it's already 10:20pm here). Happy to try and find a time that suits though.
It's not my first mod but it is my first mod in quite a few years, and I lost all my working files etc. from last time sadly so I'm basically starting from scratch. I was planning to update the config properly once I at least had a Hello World example working.
My previous mod was Aiming Deadzone Fix:
https://steamcommunity.com/sharedfiles/filedetails/?id=1923461667
alright well its 730am here and I have a case at 8am for a couple of hours. so if you are still up after we could go through it. otherwise, I get off work at 5pm (your 8am) today and I can help anytime after
I think I probably won't be available until a similar time tomorrow (due to some Halloween events at work.. lol) - would it be OK if I added you as a friend and we figure out a time that suits for a little later this week?
sure
sent :)
yooooo in 2.16, import can be used to easily bring in local variables to event handlers???
I don't think so, they're literally different script
https://community.bistudio.com/wiki/import
I mean, at face value without messing with it, it looks like I possibly could do something like:
private _test = "Hello";
_object addEventHandler ["SomeEH", {
import "_test";
hint _test;
}];
from the parent scope
As I said they're different script, there should have no relation between them
Ah poo
Is there anyway to "live" update a texture? For example, if I have a paa on the server, and it's in the missions folder, can I upload a new version of that, and have all the clients redownload it mid-mission? My first thought would be to use file patching if that's possible.
how do i use unit capture for tanks ??
Not possible
Thanks. Also quick question, do you know of any pre-existing functions for selecting X amount of items randomly from an array?
So if I had an array of 10 objects, and I wanted it to select 5 randomly (and preferably unqiuely), is there something already inplace for that?
No idea about existing function but its very easy to script yourself
Yeah I'll just write it myself
private _random_items = [];
for "_i" from 1 to 5 do {_random_items pushBack (_array deleteAt floor random count _array)};
it will delete items from _array though so copy it if you want to keep it intact
That seems a lot more elegant then what I was going to do lol
It will fail very occasionally due to the random problem though :/
random very occasionally rolls the input value due to bad rounding.
random x returns value in range [0,x] (both inclusive)
Then why has it been documented that x is not included since 2006?
I swear there was a whole discussion about this thing not too long ago. Don't remember what the outcome was though
engine doc says inclusive 
If that's true then "Suma" has a lot to answer for, whoever that was https://community.bistudio.com/wiki?title=random&direction=prev&oldid=27807
It's not really inclusive. It's a bug that's been mislabelled as a feature rather than fixing it :P
Inclusive would imply equal probability.
floor random 1 will always return 0, I suspect.
floor random 1000 can (rarely) return 1000.
but 999 is far more likely.
If I need to track ~50 numbers that update per frame on a vehicle which would be better for performance/network?
setVariableas each is calculated x50setVariable ["allVars", [_v1, _v2..., _v50], true]- setup animationSources for each,
animateSource ["v1", _v1]and let then engine sync them >=D
Have each client interpolate it themselves
And only broadcast target values and time when the target has to be reached
If they change by some algorithm, then provide data for it so clients can calculate it themselves
ah, yes would be ideal. a lot is based on player input though. I suppose if a little visual lag is acceptable, could sync the inputs and again client-calculate.
further, if it's only the vehicle crew that needs to be kept up here, it's better to do a targeted sync anyway, so 3. is just silly in most cases.
at the time Lead dev and the other ล panฤl brother, Ondลej ๐
Isn't that correct for an inclusive generator that isn't limited to whole numbers?
With floor, everything from 999 to 999.999999 will round to 999, but if 1000 is the max, only exactly 1000 will result in floor returning 1000. That doesn't mean 1000 is any more or less likely to appear than any other number in the range, it's just an artefact of how floor works.
Yeah I mis-spoke. This is just why no-one would intentionally write that function as inclusive.
You can actually work around it by multiplying the input value by something like (1 - N/2^24) but that should be done on the library side.
all solutions are ugly as hell anyway, because the standard usage rolls floor random count _array into the same line.
...Is that the standard usage, or just the usage by people who've forgotten about selectRandom? :U
there was a time where such commands were mere fantasies in the mind of foolsโฆ
selectRandom's much less useful because you can't delete elements from the array with it.
Say you want to pick N elements out of a larger array.
but not the same element twice.
personally I would selectRandom and then - the selected element from the array, but I guess there could be various reasons why you might not want to do that
performance, mostly.
What I was mainly getting at though is that there are lots of things you can do with random that don't have anything to do with arrays. Is array selection really the most common, "standard", use for it?
And could you not avoid the issue by making the "standard" implementation round random ((count _array) - 1)?
No, that has half the probability of the first and last elements.
I wouldn't make any claims about standard use but it's a pretty common case.
I have a fnc call [arg1, arg2] call myFNC; But arg2 can be sometimes empty, what can I do to prevent errors? I just want to pass nil, and deal with it in the subsequent function, but it throws an error instead.
bruteforce it by shuffling the array then selecting the requested amount ๐
I don't think the BIS shuffle function is even reliable because it uses floor random :P
Handle it in the called function. For example, if say passing two strings but one can be nill simply do this: if !(params [ ["_arg1,"",[""]], "_arg2"]) exitwith {"error"}; _arg2 = [_arg2] param [0,nil,[""]]; which will st _arg2 as nil if not a string (or nil)
and _arg1 will be empty string (or whatever you want as default)
I can not handle it in the called function since I never get there. So you suggest to put there some dummy content inside instead of nil, in the calling function before I pass it?
I am not following. What is the error you get in the first fnc?
It says that I am trying to pass an undefined var in the call command. So the target function is not even executed.
ok, so in the first function if _arg2 is never defined you'll get an error. I thought it was defined by a params command or something and you were just simply passing it along. You can try to set it as dummy for example "false" and that would negate the error. You can also try private _arg2 = nil; but IIRC that would still generate the error.
I think ultimately the issue is you define _arg2 somewhere but only under certain conditions. You can try defining it at top of first function too as like private ["_arg2"];
The passed arguments are declared through params command in the first function.
oh, just remembered. You must be calling all this in scheduled enviro. Unscheduled you can call nil. Scheduled you'll have to pass a dummy value I think.
@ornate whale
The example I gave should set it back to nill if you want but if you dont, just handle a false value or something
How do I do that? ๐ I have all my fncs defined in CfgFunctions. And I start the cascade in init or similar. Also I don't think that switching to unscheduled is a good idea.
init is scheduled. only functions with preInit etc are unscheduled or if you call from an unscheduled place. I'd just avoid all that, set it as a dummy value using an isNil check _arg2 = if (isNil {_arg2}) then {false} else {_arg2};
You can even put the if-then inside the [] call myFnc as the second paramter
[_arg1, if (blah blha) then {false} else {_arg2}] call myFnc
Ha, ha, OK, I made my code as modular as possible, thinking that passing values from one to the other will work just fine, but now I see, this kind of refactoring might not be the best, even though it makes coding very easy for me.
The worst thing is that I have to basically do the input validation on every level now, since I aim for modularity. Or just fill all the params everywhere it is possible with default values.
Here's a hint: If you pass an array with a nil it will not throw an error. It's double wrapping the parameters but if your passing them around a lot it might be viable example:
_args = [_arg1,_arg2] ; [_args] call my_func; then in my_fnc: params [["_args",[],[[]]]]; _args params ["_args1","_args2"]; it's weird but if you have a constant set of parameters, sending them wrapped in an array inside an array might be helpful
Hmm, OK, this is would certainly help, but it is kinda weird design choice. ๐
Thanks alot for your tips.
yeah, I dont know the entire context so if you find better go for it
actually scratch that last wrapping an array as it still errors out trying to create the first array. You'll have to put in dummy values.
What about just passing a name of a variable, and then just use get to pick what is needed, even though it is not ideal either.
it still errors out when doing [_arg1, _arg2] call myFunc
You do that:
[_arg1, [_arg2, nil] select isNil "_arg2"] call myFunc
What does it do? It creates from nothing a little bit more than nothing? ๐
It's just an ugly way to dodge the scheduled code nil protection.
just tested doesnt work
I guess you could instead wrap the array declaration with isNil {}
I'll try that
ah yeah it doesn't due to the array
So you have to use if/then instead, which is even uglier.
nope. literally cannot put a nil in an array in scheduled.
And what about this [ [] ];
sure you can, as long as it's not a variable reference
I have to be doing something horribly wrong otherwise this should not happen in any language. ๐ Where are the infamous pointers, I would love to have them here.
true. yes then you have to explicitly check every value and build it which is the ugliest
until this moment I literally never encountered this error. Is this bug?
granted most of my stuff is unscheduled
I actually want a debug setting where undefined variables throw errors in unscheduled.
keeps tripping me up because I have underscore blindness
ok, I can understand that but it's a trade off and I prefer it as is unscheduled. Leave it to me to isNil check when needed. ๐คฃ
what would be awesome is if functions had signatures but that is not going to happen now
You could initiate the entire chain as unscheduled. So make another function aside from init.sqf and in init.sqf : isNil { [] call init2.sqf }; then everything is unscheduled from that point on. But be warned it can change how things are done dramatically and reduce perf if you don't know what you are doing.
Having some difficulty checking if a player is admin on mp server. This should be simple but isnt working
!(admin clientOwner isEqualTo 2)
when its related to locality its always best to check biki
well
always best to check biki regardless
Yeah true. Thanks!
in biki we trust
Is there a way to check in game if an object is editor placed?
AKA not terrain placed?
Not terrain placed, editor placed, but also not placed live in game (zeus or other means)
So createVehicle'd things?
Ah that's what you mean
I barely remember if it is possible or nuh ๐ค
What's your usecase if you don't mind me?
are all terrain objs 3den entities? 
Nu
nvm, idea over 
can possibly use get3DENLayerEntities along with getMissionLayers ๐ค
So my use case is persisting all objects in the mission if their classnames are predefined. My code base works fine but sometimes my devs add 3den objects in that list to their missions. So when those objects get persisted loaded on the next game session they collide with the 3den placed object.
There's other ways to approach the problem but one way is to simply not care about 3den placed objects
Single precision float granularity/precision something-something?
I wonder if anyone was able to get that inclusive upper limit in a real test
Yes ๐คฃ
How long did it take?
Wonder if floor random 1000 == 1000 will ever trigger? ๐ค
Perhaps we could use selectRandomIndex or deleteRandom then
I'd pick selectRandomIndex, more universal
in tonight's episode of "Nice-to-haves with Sa-Matra" 
Can't have a day without me wanting a new scripting command 
I found it because it hit in real code
Antistasi's roadblock generation routine would hit it occasionally.
code basically found all roads in an area and checked them in random order for valid places.
Not really. The reason for not comparing floats with == is that it can have unexpected behavour if you're feeding it with fractional values that don't have precise representations in FP. 1000 has a precise representation. Also >= 1000 would give the same result.
Is it possible to disable NVGs for players without taking away the item so it stays visible on the player model?
Shoulderpatches are my NVGs, but I dont want them to actually work.
you can set the vision modes available in the items config
ie. visionMode[] = {"Normal","Normal"};
I dont think you need to double it up like that just the single normal should work and then its an nvg item that does nothing
Yes, random is inclusive (or atleast always was and still is)
Meaning it can return the argument value.
Inclusive workaround is easy -0.0000001
Except when 0
mh
wouldnt I have to have access to the encrypted mod files?
ah if you dont - or dont want to make a mod that changes it
you'll probably have to use https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#VisionModeChanged
and then use the action to turn off the nvgs
So basically run an eventhandler on every player that disables nvg when they enable them
Yeah
unfortunately this is vehicles only:
https://community.bistudio.com/wiki/disableNVGEquipment
a somewhat theoretical question: I change the landing and taxi sequence on Nimitz to scripted event handlers. With that a mission maker can hook his own scripts to landing and taxi events. But for the control of the transition from one event to the next, how do I ensure the mission maker function is complete? For example, after landing and touchdown the plane sits on the flightdeck. Let's say my longest running function there folds the wings up. But a mission maker wants to make a visual inspection of the plane by some crew, that lasts longer. How can I allow for such a scenario?
You could have it wait for a variable flag, which is assumed to let it proceed if not set. For example,
waitUntil {!(missionNamespace getVariable ["TeTeT_var_carrierHoldAfterLanding",false])};```
With that code, if `TeTeT_var_carrierHoldAfterLanding` is either not set, or set to false, the sequence would proceed immediately. However, if it's set to true (by the missionmaker), the sequence would pause at that point until it becomes false again.
(You could also invert the true/false and remove the `!`, but I find "true means yes, do hold" to be more intuitive)
hmm, ok, but it cannot be a boolean, as I have no idea how many functions may be running by mission makers, and I want to be flexible with my own scripts as well. Maybe if I make the var an integer and every script can register itself by incrementing the int at start and decrement it when terminating, that might work.
wasn't this called a latch or so, OS studies been too long ago ๐
thanks for the idea of this variable, @hallow mortar !
It can be a bool. You just might need some clever engineering to make it work for multiple sequences at once - for example, by referencing a variable set on the landing aircraft rather than in the mission namespace.
sorry, I don't follow then. For example I have three functions, f1, f2, f3 associated with the landedTouchdown event. How can a single bool in the plane or carrier or mission contain this state, as the functions don't know of each other?
Oh I see, you want to have multiple functions be able to delay the sequence independently. Then yes, probably a number "queue". You'll have to provide clear documentation on how to increment it though, or possibly a function with simple inputs to register things into the queue.
You might still want to have it stored on the carrier object rather than mission namespace, in case of multiple carriers being in the mission.
that's sound advice to store in the carrier, the scripted ehs are tied to it as well.
_thisScriptedEventHandler might be useful there
ah, no, that's the number of eh's associated with the event it seems
you could just put a setvariable in the init box of anything editor placed. or collect at mission start all entities and give them variables or put them into an array of "spawned in editor" stuff
i guess https://community.bistudio.com/wiki/fromEditor only works for team members
now theres a command ive never used
Maybe fix it on engine level just for random commands? I guess single float comparison check shouldn't be that costly?
0 max (random - 0.0000001) or if(result == max) then {result = 0} or something
Hello,
Is there an easy way to select if the value is true or 1?
Seems module defaultValue = true, returns 1, without opening attributes in editor
_logic getVariable myAttributeName
//Return 1
But if I open attributes , without touching anything.
It return true
So if I want to get an array every value which is true or 1.
Currently I get error because
private _iedTypes = ["iedClass1", "iedClass2","iedClass3"] select {_logic getVariable _x};
```
Works if I open attributes in the editor and press ok.
But if I only attach the module without opening attributes I get an error because it's trying to get bool, not number.
14:17:34 "variable logic L Alpha 1-2:3 is: 1"
14:17:34 "variable logic openedModule is: true"
-0.0000001 wouldn't work as a general case. It's something like - N / 2^24.
1000 - 0.0000001 >= 1000 => true :P
Yeah we could do that.
We can just do a max -epsilon
_logic getVariable _x in [true, 1]
Thanks a lot ๐๐
Yeah it was just an approximate number, the same that dedmen posted
["_mode", "", [""]],
["_mode2", 0, [0]]
];
switch _mode do
{
case "First":
{
hint "Hello";
};
case "Second":
{
};
default {};
};``` When I spawn first with this - ["First"] spawn {"treasure.sqf"}; the hint doesnt display. I feel like Im missing something small
Not really, you're missing something large :P
I feel like _mode isn't being defined; your Params is an array of arrays and the first element may contain _mode but it isn't being passed like that.
If it even accepts arrays to being with, I believe it's just string.
Ah, string or array. Huh.
spawn can't be used to execute files directly. You'd need to either load & compile them (usually with CfgFunctions), or use execVM for quick and dirty stuff.
["First"] spawn {"treasure.sqf"} is simply spawning a code thread that returns the string value "treasure.sqf" into the void.
Just a quick one, is it possible to get the rotation value of a marker using script commands? Thanks in advance all
Ahh, thank you, sorry I should have known that
How do a custom multiplayer loadout, so when I change it it changes on every player of a team?
loop all the players and call https://community.bistudio.com/wiki/setUnitLoadout on them
I never quite understood this part of the debug console, what does the 'count' field refer to?
Random code playing
how many times the code was executed before it gave up
It'll run for a second or for 10k iterations. Whatever's faster.
ah gotcha, thanks!
is there a way to set the players map to a certain location. For example force the map open to one place on the map?
mapAnimAdd
Hey- so quick question
I'm trying to script a new Zeus module into the game to essentially change a variable on an object whenever my missionmakers need to
I've configged the Module into CfgVehicles, but I'm having trouble with figuring out how to reference the object the module is being used on in code
Please help, I've been at this for hours ๐ญ
Does anyone know if it's possible to detect when a player is talking through TFAR? I'm not sure if it'd be possible because TS is external, but apparently the beta version has AI detect the player when they're talking - so I'm assuming there's a function somewhere
I have just answered my own question. I'd been looking this up for 45 minutes and just now found the page.
For anyone curious, check here
https://github.com/michail-nikolaev/task-force-arma-3-radio/wiki/API%3A-Events
I'm tearing my hair out here- anybody know about Zeus Modules and is willing to help me?
do you use zeus enhanced in your modset
Yes
I'm working on making a custom module with the exact same functionality as Add Full Arsenal
Only difference being that the function is for a custom limited arsenal my unit uses
are you trying to use their api for modules
No
if not, please do. its much easier.
for example:
["yourfunnycategory", "yourwackymodulename", {call storey_fnc_insertdadjoke}] call zen_custom_modules_fnc_register;
//in fnc_insertdatajoke
params ["_pos", "_obj1"];
systemChat "What did the moose say to the moses?"
_obj1 setPosASL ((getPosASL _obj1) vectorAdd [0,0,500]);
systemChat "nothing, mooses cant talk"
_obj1 is passed to the function as whatever the module was dropped on
Huh...
Well, I'm just trying to add it in via config
run the first line on postinit and it'll register a zeus module
that will run storey_fnc_insertdadjoke
Hmm... okay
I'll consider it
What solution would I use if we deprecate Zeus Enhanced?
Yeah, been looking at that for a while now
_logic is just the thing you see in zeus interface when you drop it
thats passed to the function
and gets attached to the object you dropped it on
(it probably isnt but the analogy works)
wow thats actually simpler than i thought
Hmm... okay
I've been trying to do it, but for some reason my module has no attachedTo objects with it
stupid question,
are you actually dropping it on the object after its been added as editable?
i.e when you do it with full arsenal does it work then
if so, send the function you're using for the module
if not, you need to add it as editable prior to dropping the module on it
I don't understand the question
Yes
It's literally just any empty prop to put an arrsenal on
Identical to the Add Full Arsenal module included in ACE
does add full arsenal work on said object
Yes
then refer to this bit
One sec
params [
["_logic", objNull, [objNull]], // Argument 0 is module logic
["_units ", [], [[]]], // Argument 1 is a list of affected units (affected by value selected in the 'class Units' argument))
["_activated", true, [true]] // True when the module was activated, false when it is deactivated (i.e., synced triggers are no longer active)
];
if (!local _logic) exitWith {};
private _object = attachedTo _logic;
systemchat "begin...!";
systemchat str _this;
systemchat str _logic;
systemchat str _object;
systemchat str _units;
_object call f41_fnc_arsenal;
/*
switch (true) do {
case (isNull _object): {
[LSTRING(NothingSelected)] call FUNC(showMessage);
};
case (isPlayer _object): {
["str_a3_cfgvehicles_moduleremotecontrol_f_errorPlayer"] call FUNC(showMessage);
};
case (!alive _object): {
[LSTRING(OnlyAlive)] call FUNC(showMessage);
};
default {
TRACE_1("BIS_fnc_arsenal: AmmoboxInit",_object);
// Global Effects: "Action to access the Arsenal will be added automatically on all clients."
["AmmoboxInit", [_object, true]] call BIS_fnc_arsenal;
};
};
*/
deleteVehicle _logic;```
The systemchats are in there for debugging
Found a typo with params/units, correcting and testing
So- the _units variable returns as []
So nothing is found
I'm scouring the Biki page on modules for it
Like I just need to get the unit it's placed on
AAAARGH! Like...
["_units ", [], [[]]], // Argument 1 is a list of affected units (affected by value selected in the 'class Units' argument))```
This line is so unhelpful, like how does it work?
"Pre-defined sync preview entities can be: "
?????
What is "sync preview"?
what is _object returning? objNull?
what is curatorCanAttach set to on the config of your module
๐
1
HOOOOOLY F##K
it is right there after all
Oh my GOOOOOOD
WHY IS THIS NOT ON THE BIKIIIIII ๐ญ ๐ญ ๐ญ
You are a GODSEND
Thank you SOOOOO much
what biki page are you looking at
i shall ask for it to be added
๐ God BLESS you
can you tell god to get rid of my cold thanks
I unironically have a friend trying to become a priest, sooooo I meeeeean
If you wanted to
I could hit them up
bro got connections to god deadass
I gotchu fam ๐ค
heyo, I'm trying to figure out how to use BIS_fnc_showAANArticle to make an article appear on a laptop in game. https://community.bistudio.com/wiki/BIS_fnc_showAANArticle I don't understand how I'd get the example to appear on a laptop in game, do I put the example 1 text in a certain kind of file in the mission folder, in the init of the laptop item, or somewhere else? Thank you
Do you mean you want to add this into a texture (3D space/model)?
so, there's this mod im using, 'MGI advanced modules" right? there's a module in the mod called "Car traffic" i don't know how this sqf stuff works at all, but what i need to achieve is spawning a specific faction set of vehicles from CUP, there IS a CUP option in the "Car traffic" module, but i've found it spawns other factions vehicles from the CUP mod itself, instead i need to just use the takistan civ vehicles. nothing else, but what i need help with is an array of this sort of thing, which is what im completely confused about
Unless someone is also using that very mod, nobody here will be able to help you about it. That is functionality added by that very mod as you already figured, so trying to get help via the mods workshop page will lead to much more likely results than asking here (aka: the mod author probably has some documentation for this somewhere on that page)
Well, he did, but- unfortunately it's just the same thing stated their in that module
https://www.dropbox.com/s/n9v8ryoyh4k500w/MGI ADVANCED MODULES by Pierre MGI.pdf?dl=0
You can probably try to check the article
Yeap
I've looked..
Sadly
But maybe reaching out on the comments
Could work I guess?
I dunno, most guys that do this stuff have better time to waste years later in their time, hard to say you would get a response from my understanding.
_vehs = _this select {getText (configFile >> "CfgVehicles" >> _x >> "faction") == "CUP_C_TK"}; _vehs;```As far as I understand, use this
@nocturne bluff you do not want to know what bad things are prepared in the devil we all know as @grizzled cliff
Black Magic, wizardry and such stuff you know?
I do.
but indeed would be interesting what he wants to patch
how can i make this name: "ััฬััะบะธะน ะฐะปัะฐะฒะธฬั" work on map icons drawn with drawIcon? they return an empty string where as normal names like: Thomas, work fine
_m drawIcon [
_x call MRTM_fnc_iconType,
_x call MRTM_fnc_iconColor,
_x call MRTM_fnc_getPos,
_x call MRTM_fnc_iconSize,
_x call MRTM_fnc_iconSize,
_x call MRTM_fnc_getDir,
_x call MRTM_fnc_iconText,
1,
0.035,
"TahomaB",
"right"
];
It may because TahomaB does not support such characters
Anybody dealt with https://community.bistudio.com/wiki/addTorque ?
"A single application of torque would produce one impulse, which may not be enough. In this case consider applying a series of continuous impulses, for example to make a quad bike to roll forward"
I guess simply applying same force each frame for X seconds won't be the same for clients with different FPS, won't it?
it should be
isn't it local? afaik forces are applied locally
we do have setAngularVelocity too
Was going to apply it on vehicle owner of course. Tested this code at different FPS and it is indeed different depending on FPS:
till = diag_tickTime + 0.2;
onEachFrame {
quad addTorque (quad vectorModelToWorld [100,0,0]);
if(diag_tickTime > till) then {onEachFrame {}}
};
Now I wonder how I can apply approximately same amount of torque regardless of FPS, tried having 10000 * diag_deltaTime instead of 100 but it works better with low FPS and with high FPS
I guess I really need addForce here instead
change vector by diag_deltaTime
is there a way to tell when a road segment ends? I am wanding to get road length, and needa detect when a road is connected b/c it's a single road line, like the left of the orange to the right, or b/c it's a branch off like the dirt road on it.
but from experience, addtorque doesnt work very well
(addforce is also just addtorque in disguise, dont tell anyone ๐คซ)
ang velocity is much better and can be provided as an impulse too
only thing I can think of would be checking if road type changes, or if road end/start pos differ-
Did just that in my previous message, it doesn't work well
addForce worked much better though
The torque applied as impulse.
https://community.bistudio.com/wiki/addTorque
Each actor has an angular acceleration and an angular velocity change accumulator which are directly modified using the modes PxForceMode::eACCELERATION and PxForceMode::eVELOCITY_CHANGE respectively. The modes PxForceMode::eFORCE and PxForceMode::eIMPULSE also modify these same accumulators and are just short hand for multiplying the vector parameter by inverse inertia and then using PxForceMode::eACCELERATION and PxForceMode::eVELOCITY_CHANGE respectively.
https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxRigidBody.html#cb04ffc816d45afff2d04e93d7446e79
adding same torque adds the same amount of rotational velocity. More application = more changes
tbh, by the sound of it multiplying by the delta time should work 
I am trying to find a value of range of AA vehicle. Want to draw a circle of AA range that can spot vehicles, so pilots will avoid this radius. Is there some config I can search for ?
i had it working with any framerate for capital ships its just addtorque sucks ass for using instead of setangvel
Check the vehicle's and ammo's sensor >> AirTarget >> maxRange https://community.bistudio.com/wiki/Arma_3:_Sensors_config_reference#Example_Config_-_full_definition
except Patriot (or whatever they're called) launchers that don't have sensors and just shove LOAL rockets towards datalink-provided targets 
ammo should work, though
yes, I am looking at https://community.bistudio.com/wiki/Arma_3:_Sensors#Vehicles, and trying to find some configs. but also thinking about manual AA guns (flacks) without rockets
get weapons, get their firemodes, get max range of those 
Hi all, does anyone know if it is possible to change the helicopter flight model used by a player, using scripts? As in, from standard to advanced, and back again? I am building a training environment, and it would be awesome to be able to toggle the model on/off using code.
negative!
Roger ๐
I got kind of mixed results
_weapon: autocannon_35mm | _range: 500
_weapon: missiles_titan_AA | _range: 500
_weapon: SmokeLauncher | _range: 10000
maxRange=2500; in autocannon_35mm >> far in my config dump, though
SmokeLauncher can hopefully be sorted out by its simulation="cmlauncher";
configfile >> "CfgWeapons" >> "autocannon_35mm" >> "maxRange"
maxRange=6000; in missiles_titan_AA >> Player
get weapons, get their firemodes, get max range of those
maxRange on the weapon itself is only used when "this" firemode is present in modes[]= and selected, afaik
also, difference between detection vs engagement ranges, especially if you have datalinked AA.
and missile can have the aircraft detected but not locked (at least if we consider those comments in wiki examples to be true) ๐
TAG_fnc_getMaxRange = {
params ["_vehicle"];
private _max = 0;
private _allTurrets = [[-1]] + allTurrets [_vehicle, true];
private _weapons = [];
_allTurrets apply { _weapons append ( _vehicle weaponsTurret _x ); };
_weapons apply
{
private _weapon = _x;
private _modes = ( getArray ( configFile >> "cfgWeapons" >> _weapon >> "modes" ) ) select { _x isNotEqualTo "this" };
_modes apply
{
private _mode = _x;
private _range = getNumber ( configFile >> "cfgWeapons" >> _weapon >> _mode >> "maxRange" );
_max = selectMax [_max, _range];
};
};
_max;
};
[cursorObject] call TAG_fnc_getMaxRange;
Can someone tell me how to show a variable in the systemChat or hint with remoteExec?
I've already tried this, but I can't figure out the right syntax :/
[str, "DISP_scoreDataWest"] remoteExec ["systemChat", 0, true];
this: ```sqf
[str DISP_scoreDataWest] remoteExec ["systemChat", 0, true];
Okay that was easy haha
Yeah, thought so too but tests proved otherwise
and how did it work? I don't think i can decypher it works better with low FPS and with high FPS 
I suspect you'd need the delta time of the next frame. Which you can't get.
still should end up with 2 seconds (or however much) of torque accumulated 
Antistasi has some code using addTorque that adds some extra recoil to weapons you mount on a vehicle. What we found is that it looks fine normally, but when you're localhost it frequently explodes the vehicle on the first shot.
I suspect what happens is that you fire the mortar it triggers a ton of hearing/behaviour checks for AI, which causes a very long frame that then makes the vehicle rotate through the ground from the torque.
physx is goddamn trash :P
I'm not even sure if it's adding an impulse or a torque though.
It rotates the vehicle much more at lower FPS than at higher FPS
have you tried benchmarking how far it is rotating with each over a period of time
Not really but in my test it rotated several times less at high FPS than on low FPS
I already decided to use addForce instead
oh yeah you said i forgot
hello everyone!
im new-ish to arma 3, barely 8 months. newer to scripting, 2 months top.
Hi again folks.. back hoping for another steer. Iโm thinking about adjusting the first person view for pilots when they get into a chopper; I want to enable a better view of the dashboard for those who donโt have trackIR. Is there a command that would be suited for this type of thing? Cheers
There's already a modest amount of adjustment that players can do on their own with (iirc) Ctrl-Numpad/Pageup/Pagedn to shift their point of view around.
Ah ok thanks Iโll start there. I was curious if it could be scripted, but Iโll explore the default options for this .. thanks ๐
Fun fact: this is not an "always on" feature - the limits of motion are part of the specific vehicle's config, and if they aren't defined (cough CSLA cough) you can't do it at all.
Duly noted; only times Ive had trouble was with TFAR/ACRE taking over Ctrl-Num for radio switching, so I had to rebind.
Thoughts on the flicker effect of my lightning?
The instances of lightning, randomness, and area damage will be customizable. Just trying to narrow down the effect.
how do I take into account different players screen sizes when using BIS_fnc_dynamicText;
I'm trying to make text that enters from the top of the screen and leaves from the bottom but I'm unsure if the value that works for me doesn't work for other bigger monitors
["TEST",0.5,-0.3,22,4,2,789] spawn BIS_fnc_dynamicText; seems to work on a 1536x864
You can use the array input for x and y to change width, then you could probably use GRID macros to manipulate your values
#define GUI_GRID_X (0.5)
#define GUI_GRID_Y (0.5)
#define GUI_GRID_W (((safezoneW / safezoneH) min 1.2) / 40)
#define GUI_GRID_H ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)
#define GUI_GRID_WAbs (0)
#define GUI_GRID_HAbs (0)
damn thats a lot of funny letters
what would you say is a safe value for a 1080p screen?
The safezone values are relative to the screen edges, so start from those.
top of screen is safezoneY, bottom of screen is safezoneY+safeZoneH.
im finding the whole dedicated server thing to be nerve wrecking and im getting bald. would anyone here be oh so inclined to help me figure out some stuff? im at the "my mission works well on self hosted but blows up on dedicated" part of my arma 3 life.
yet another case hahaha
like this loop. it runs on the server, but since "player" is remote, it returns [] :
while {true} do {
RPR_ActiveTasksID = player call BIS_fnc_tasksUnit;
RPR_getStates = [];
{RPR_getStates pushBack (_x call BIS_fnc_taskCompleted);} forEach RPR_ActiveTasksID;
// Check if all elements in RPR_getStates are true
if ({_x != true} count RPR_getStates == 0) then {break;};
uiSleep 10;
};
don't think thats something i want running on every client for however long they are staying... but the server can't do it either.
What you mean the server can't? Do all the array work and iterations on the server, then remote execute it to the unit what you want to happen.
remoteExec player call bis_fnc_tasksUnit?
if !(isServer) exitWith {};
// build players
RPR_Players = allUnits select {isPlayer _x};
// JIP compat
addMissionEventHandler ["OnUserSelectedPlayer", {
params ["_networkID", "_playerObject"];
// wait for unit ownership transfer
_playerObject addEventHandler ["Local", {
params ["_player"];
removeEventHandler ["Local", _thisEventHandler];
RPR_Players pushbackUnique _player;
}];
}];
while {RPR_Players = RPR_Players select {!(isNull _x)}; RPR_Players isNotEqualTo []} do {
{
private _player = _x;
private _createdTasks = _player call BIS_fnc_tasksUnit;
private _allCompleted = _createdTasks findIf {!(_x call BIS_fnc_taskCompleted)} == -1;
if (_allCompleted) then {
// do something here - lets make a hint
["All tasks completed"] remoteExec ["hint", _player];
// remove player from array so they don't get rechecked
RPR_Players deleteAt _forEachIndex;
};
} forEachReversed RPR_Players;
sleep 10;
};
if you wanted JIP compatiblity, you just add the player to RPR_Player in the initPlayerLocal.sqf or by using onUserSelectedPlayer event handler since the players list in this would only execute once on its creation. Now you've offloaded all the calculations to the server instead of each client if that's what you wanted.
sorry im confused. what breakes the loop here? that "RPR_players" is not empty? the idea is that the loop holds the rest of the script until all tasks return succeeded, failed, or canceled. i guess i could use "break" where you put the hint?
the while breaks when all units are removed from the array making it []
so basically, when all players you have added to the array have all their tasks completed, the while ends and continues the rest of the script below it
Changing the array from inside the forEach over the same array? Cringe
Use forEachReversed, please
And use _array deleteAt _forEachIndex; please 
I thought using deleteAt and _forEachIndex were iffy due to _forEachIndex not keeping up with deletions
And how would _array = _array - [player]; be any better?
because I would think using the object itself instead of an index would be more consistent since the object wouldn't get mismatched like _forEachIndex in that particular instance
not saying it would, but someone must have broke it to make that wiki note
U wot
It still modifies the array that's being iterated over
It still moves the following elements at least one (possibly more) elements back
man am i biting more than i can chew or what. im clearly not ready for this lol
ah yes, i fail to remember that, the array movement itself. what if you made the element null instead, then exited when all are null
its not, you're fine
Would work. But forEachReversed was introduced specifically for this usecase 
modified above
im gonna have to digest all that. i did not get the initplayerlocal or the onuserselectedplayer part at all.
I have have no idea ๐
I'll get a picture of what I'm looking to achieve though
maybe im better off just playing with variables on every task script. like, set a completedtask=[] on the main script, a completedtask = true after each tasksetSate in each task script, and a waitUntil count completedtask == "i already have a variable that holds how many task scripts were executed") back on the main script.
unless there is another way to check tasks states that doesn't require the server to ask the clients.
if say a player joins 2min into the mission and this has already run, that player isn't going to be in RPR_Players so you need a way to add that joined player to it.
addMissionEventHandler ["OnUserSelectedPlayer", {
params ["_networkID", "_playerObject"];
// wait for unit ownership transfer
_playerObject addEventHandler ["Local", {
params ["_player"];
removeEventHandler ["Local", _thisEventHandler];
RPR_Players pushbackUnique _player;
}];
}];
see #arma3_scripting message for addition
ohh i see now.
ok ok, man i have so many questions its embarrassing.
if the task script is server executed, every "createvehicle" in the task script will be server owned, correct?
yes, until like say a driver enters a vehicle, then the ownership is moved to the driver's machine
hoping for some help making something like this from the link I put above
this one is from the contact campaign
is that a static image on the laptop?
I don't think so, but possibly. I've been able to do static images before with whiteboards
i would check to see if its a static image. if it is, then its probably just a photoshoped image and you do it just like a whiteboard
yeah i read about ownership when switching seats and all. but for regular objects, for example, an addaction to deleteVehicle.. since the obj is server owned, the client can't just delete it. correct? so it would have to be something like "[obj] remoteExec ["deleteVehicle", 0, true];" ??
deleteVehicle doesn't care if its local or not. Its toasted everywhere.
ahh great. the issue is somewhere else then. made a wreck task. get there, holdaction sets pos of a box on caller's feet. box has addaction deleteveh. holdaction is not showing. box is not deleting. both remeoteExec'd. f my life.
post it then
part in question:
WreckSelect = selectRandom ["B_Heli_Transport_01_F", "B_Heli_Light_01_F", "B_T_UAV_03_dynamicLoadout_F", "B_UAV_02_dynamicLoadout_F"];
crater = "CraterLong" createVehicle RPR_WreckLoc;
Wreck = WreckSelect createVehicle RPR_WreckLoc;
Wreck allowDamage false;
sleep 0.5;
Wreck attachTo [crater, [0,1,1.2]];
Wreck setDamage 0.7;
Wreck SetFuel 0;
Bbox = createVehicle ["Land_Computer_01_black_F", getPos crater, [], 0, "CAN_COLLIDE"];
[Bbox, ["Take Blacbox", {deleteVehicle Bbox}]] remoteExec ["addAction", 0, true];
[west, "taskWreck", ["Find the downed aircraft and retrieve the blackbox.", "Search and Retrieve"], Wreck, "CREATED", -1, true, "search"] call BIS_fnc_taskCreate;
_TaskMapLoc = RPR_WreckLoc getPos [Random 50, random 360];
["taskWreck", _TaskMapLoc] call BIS_fnc_taskSetDestination;
[
Wreck,
"Retrieve Black Box",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
"Wreck distance player < 3",
"_caller distance Wreck < 3",
{[[player, "Acts_CarFixingWheel"] remoteExec ["switchMove"]];},
{},
{Bbox setPos [getPosATL player select 0, getPosATL player select 1, getposATL player select 2];},
{},
[],
20,
10,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, Wreck];
great if the script is run by client. toasted if run by dedi.
and there is sooo much more lol
there might be some upssis from trying to make it work. like i have player on the hold action, then _caller.
didn't work : )
This is a texture that is basically photoshopped/screenshotted. You (basically) cannot turn a GUI into texture (you can actually but is complicated)
oof alrightly, thanks anyway
not like i know much but.. @tough abyss what is this meant to do?
[
Wreck,
"Retrieve Black Box",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
"_target distance _this < 3",
"_caller distance _target < 3",
{
params ["_target", "_caller", "_actionID", "_arguments"];
_caller switchMove "Acts_CarFixingWheel";
},
{},
{
params ["_target", "_caller", "_actionID", "_arguments"];
private _pos = getPosATL _caller;
Bbox setPosATL _pos;
},
{},
[],
20,
10,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, Wreck];
try that
also, try not to use long duration times, the ui goes away after a few seconds and players might not know to continue holding
made an edit
yeah so far the ui is lasting for these periods. it does go away if you dont look at the object constantly. comes back when you look at the object. the animation however is telling you its still ongoing, since its set at while holding or set to last for the duration of the animation. but will deff. keep that in mind.
its not while holding though. you need to end the animation in the interupted code block + in the completed code block
i think it depends on the animation? that one does cancel if you let go of the hold action. the loop ones do need an exit.
goes to prove how little i know about any of this lol. many of these things are not explained in the wiki or are burried under a thousand search results in the forum. late to the arma 3 scripting party for sure.
another one that baffles me. got a waitUntil (player inArea "markername") for a task. well, if the server runs the script, it apparently can't check if "player" inarea. like.. dude.
player is objNull on the server.
exactly.
So what's baffling?
No?
The server can get a list of players easily enough. allPlayers, playableUnits etc.
well ill just be honest and say that im so frustrated with it all, im just pissed at any single thing that makes me do extra steps for something i think should be much simpler. what can i say... waituntil {mood != pissedoff}. nature of the mp beast.
Nothing is easy in Arma, embrace and enjoy the pain
But seriously its not that hard, just takes MP-oriented mindset, wish locality and engine-driven syncronization of stuff was better documented so you don't have to setup tests to find it out yourself.
yeah. and testing on dedi makes it all so much harder. since you can't just edit the script and re run it... right? (secretly hopes there is a way)
does this make sense?
RPR_playerlist = call BIS_fnc_listPlayers;
waitUntil {(count RPR_playerlist inArea "a marker") > 0};
you need inAreaArray there rather than inArea.
And you need to fix the precedence because otherwise count (as a unary) goes before inArea(Array).
so waitUntil {sleep 1; count (RPR_playerlist inAreaArray "a marker") > 0};
(you always want a sleep in that sort of waitUntil, otherwise it's thrashing)
Note that this is only correct if the player list is established before the loop, which it probably isn't.
hmm. am i not creating the list on the variable?
Otherwise you'd need:
waitUntil {
sleep 1;
_players = call BIS_fnc_listPlayers;
count (_players inAreaArray "markerName") > 0;
};
It's creating the list when you run the code and only when you run the code.
Arma won't update the array for you.
well my guess was that there has to be players for there to be tasks.. and this waituntil is on a task. so creating the list .... oh... the one player on the list might leave and then there is chaos.. got it.
Also it's making a list of player objects. A player's object changes when they respawn, for example.
Or if they leave and rejoin.
oh arma. you certainly are a roller coaster of emotions. the more i know, the less i knew.
You can, with file patching, dedi and multiple clients all run on the same PC. A few steps to setup though
Also at last count the dedicated server locks the files (unlike the clients), so you have to restart that every time you change anything.
Dedmen was working on that recently but I'm not sure how far he got.
Heya all, does someone know how to prevent Civilian from using the ACE_Splint "Vanilla" Function?
Aka modding the condition of an existing item?
change the actions condition in config
I have waypoint for UAV. How to check if UAV is in position, loitering in circle, ready for another waypoint ?
private _waypoint = _group addWaypoint [_pos, _radius + 50];
_waypoint setWaypointPosition [_pos, -1];
_waypoint setWaypointType "LOITER";
_waypoint setWaypointLoiterType "CIRCLE_L";
_waypoint setWaypointLoiterAltitude _height;
_waypoint setWaypointLoiterRadius _radius;
_waypoint setWaypointSpeed "LIMITED";
_waypoint setWaypointStatements ["true", "diag_log format ['_leader: %1 | _units: %2', this, thisList];"];
_group setCurrentWaypoint _waypoint;
ps: unitReady is always true on _vehicle
probably the best way is to use https://community.bistudio.com/wiki/currentWaypoint to check in which waypoint the group is at
I am using one waypoint and changing position, _waypoint setWaypointPosition [_newPos, -1];, so will not see any change there
well check distance2D then
Trying to check if unit have AT Launcher then check for compatiblemagazines in ammobox and give them to the unit. But something goes wrong... ๐ฆ
params ["_unit", "_container"];
_unitRPG = secondaryWeapon _unit;
_weaponsConfig = configFile >> "CfgWeapons";
_UnitHaveRPG = {
_itemConfig = _weaponsConfig >> secondaryWeapon _unit};
((getText (_itemConfig >> "simulation")) == "Weapon") and { (getNumber (_itemConfig >> "type")) == 4 } and {
((getText (_itemConfig >> "nameSound")) == "atlauncher")
};
_RPGmags2 = if (_UnitHaveRPG) then { (magazineCargo _container) arrayIntersect (compatibleMagazines _unitRPG); } else { "" };
_RPGmag2 = if ((count _RPGmags2) > 0) then { selectrandom _RPGmags2 } else { "" };
if ((_UnitHaveRPG) and ((count _RPGmag2) >= 3) and (_unit canAdd [_RPGmag2, 2])) then {
_unit addWeaponItem [_unitRPG, _RPGmag2];
_unit addItem _RPGmag2;
_unit addItem _RPGmag2;
[_container, _RPGmag2, 3] call CBA_fnc_removeMagazineCargo;
} else {
};
Can someone help?
@serene sentinel _UnitHaveRPG is a code type variable and is therefore not executed in the if condition
How can check in cycle that units secondaryweapon is equal to the conditions in _UnitHaveRPG ?
๐ง call _UnitHaveRPG
also, extra } after secondaryWeapon _unit in line 6 is likely to break stuff
There's some more curly brackets in there that don't make sense but I can't tell which cause I'm on mobile
or don't have {...} around _UnitHaveRPG's condition at all 
Can you show where i need to put brackets or something else needed , please?
params ["_unit", "_container"];
_unitRPG = secondaryWeapon _unit;
_weaponsConfig = configFile >> "CfgWeapons";
_itemConfig = _weaponsConfig >> secondaryWeapon _unit;
_UnitHaveRPG = getText (_itemConfig >> "simulation") == "Weapon" &&
{ getNumber (_itemConfig >> "type") == 4 &&
{ getText (_itemConfig >> "nameSound") == "atlauncher"}};
_RPGmags2 = if (_UnitHaveRPG) then { (magazineCargo _container) arrayIntersect (compatibleMagazines _unitRPG); } else { "" };
_RPGmag2 = if ((count _RPGmags2) > 0) then { selectrandom _RPGmags2 } else { "" };
if (_UnitHaveRPG &&
{ count _RPGmag2 >= 3 &&
{ _unit canAdd [_RPGmag2, 2]}}) then {
_unit addWeaponItem [_unitRPG, _RPGmag2];
_unit addItem _RPGmag2;
_unit addItem _RPGmag2;
[_container, _RPGmag2, 3] call CBA_fnc_removeMagazineCargo;
} else {
};
count _RPGmag2 >= 3 in the last if doesn't really make sense, though
count _RPGmag2 >= 3
is never true?
it's a string. With a magazine classname. It's almost always true ๐คฃ
well then
oh, hey, https://community.bistudio.com/wiki/BIS_fnc_consolidateArray is a thing
@stable dune thanks, it works now
test = _RPGmags2 call BIS_fnc_consolidateArray;
But it doeenst return value from box, i assume we want count of current mags from container, right?
well, yes
something like ```sqf
private _RPGmags2 = magazineCargo _container;
_RPGmags2 sort true;
private _consolidatedRPGmags2 = _RPGmags2 call BIS_fnc_consolidateArray;
private _compatibleMags = compatibleMagazines _unitRPG;
private _filteredRPGmags2 = _consolidatedRPGmags2 select {_x#1 >= 3 && {_x#0 in _compatibleMags}};
[_container, _RPGmag2, 3] call CBA_fnc_removeMagazineCargo; can also be switched to _container addMagazineCargoGlobal [_RPGmag2, -3]; since 2.14. One less function to call, one less dependency to have.
That's nice
didn't know this, thanks
hello lads i need some help
so basically i want to make a tank shoot some rounds on an target so i can record it but idk how to use all the script i found
could anyone helo ?
Hello guys,
When a player becomes unconscious or enters the incapaciated state, he switches to the civilian side. Does anyone have an idea how to get around this or find out which side he was on before?
thanks I will try it
That worked. Thanks
@fair drum @granite sky @meager granite @digital hollow thanks for the help and support last night. i've managed to sort out i'd say all of the locality issues i HAD. of course, you touch this, that breaks... learning, dont you love it? ๐
also artemoz helped
but the locality stuff, once it clicks, it really clicks so you'll get there
guys, someone just told me (i.e. someone i ususally trust) he'd read somewhere on the BI forums that some future arma would support javascript for scripting.... strikes me as too-good-to-be-true. Unfortunately, on BIF the term "javascript" is disallowed for search
anybody heard anything or can confirm that it wont happen?
Does SQF support ElseIf statements?
Don't think so
already canned
an intern played around with it one summer iirc
never really got anywhere
I'm trying to figure an efficient way to do else-if stacking to test what KindOf thing it is
SQF does not have elseif
sad
switches or call + if exitWith
switch true do {
case (/* something */): {};
case (/* something */): {};
case (/* something */): {};
};
private _return = switch true do {
case (/* something */): {/* return */};
case (/* something */): {/* return */};
case (/* something */): {/* return */};
};
call {
if (/* something */) exitWith {};
if (/* something */) exitWith {};
if (/* something */) exitWith {};
};
private _return = call {
if (/* something */) exitWith {/* return */};
if (/* something */) exitWith {/* return */};
if (/* something */) exitWith {/* return */};
};
both can also get you a return if you wanted
so ExitWith flings you out of the current scope only? What's a scope according the SQF?
Is it just a layer of if/switch/while or is it the whole script
Indeed in the second case the exitWith will exit the call
if it was
call { if ( base condition ) then {
if (/* something */) exitWith {};
if (/* something */) exitWith {};
if (/* something */) exitWith {};
} else { something else }
};```
would this exit the call or just the top-level If
Huh
exits the if but youre returning it anyway
Literally Hypoxic said is the preferred syntax
I understand that, I'm trying to understand SQF scoping
It breaks out of the scope that the exitWith is in.
Okay, so if it was in the top layer, it'd go to the middle one, not the bottom one?
Yes, although you don't have anything else there so it's academic.
Right, but for other situations... I'd rather learn how to use this tool once and learn it right.
I have like 2 other places I could use a good exitWith
Thanks.
if (true) then {
if (true) then {
if (true) exitWith {};
systemChat "omg you cant see me";
};
systemChat "HELLO! YOU CAN SEE MEE!!!!";
if (true) exitWith {};
systemChat "I AM A HIDDEN SYSTEMCHAT OMG!!!!";
};
basically chances are if youve indented its a scope
though that does require proper indentation ๐
yuuup
further clarification: If I'm picking out which string is correct to use, how do I properly hand off that string to the _return = variable?
exitWith {"foo"};?
exitWith {_return = "foo"};?
private _return = call {
if (false) exitWith {"foo"};
if (true) exitWith {"man"};
if (true) exitWith {"choo"};
};
_return; // returns "man"
SQF has no classical "scopes" as SQF has no control structures like if, for, while, ...
SQF has operators, operating on code, which do similar things, but SQF in essence only knows variables/values and operators
Any code value ({...}) may spawn a scope
What that scope does and how it is connected to the previous ones however fully depends on the operator (eg. spawn will execute the code in the scheduler, not having the variable stack available you have at the moment of the value creation)
with a forEach eg. exitWith may exit the "operator", not the "scope"
which is an important distinguishing factor, as "exitWith" otherwise could be used to just "skip" an iteration but it actually does leave the operator, making it no longer execute any further rounds
More available in the biki: https://community.bistudio.com/wiki/exitWith
And regarding that magic scoping stuff:
https://community.bistudio.com/wiki/Variables#Local_Variables_Scope
Thanks for the in-depth! This is interesting.
thx. pity, though.
If you are able to read c++, this might be interesting to you too:
https://github.com/SQFvm/runtime
Works similar enough to get a hang of how things work with SQF
what are you talking about, of course it has control structures...
which to be clear, the scope in that case is the block on which the control structure is operating... so with:
{ ... } forEach [...];
// ^^^^^^^ that is your scope, anything encompassed by the curly braces
could be wrong, can you enlighten me otherwise?
in an if control structure...
if (...) then { ... };
// ^^^^^^^ technically, that is a scope
if is actually a unary command that takes a bool, while then is a binary command that takes an if-type and code.
So yeah, the apparent control structures in SQF are kinda fake.
I'm not honestly sure how relevant this is to the point about scopes though :P
can if really be considered unary though? it is at least binary, because you can never have just if (...); must always be followed by either then or exitWith, right? at minimum binary operator, sometimes ternary when you count else { ... }.
nope, its just useless if you dont follow it with anything
if (...) probably runs, I'd guess.
it does and you can assign it to a variable etc just like anything eelse
In theory you could write some goddamn horror like call { if (condition) } then { stuff };
then just takes an iftype and executes code afterwards
private _ifMyElephant = if (alive _unit);
private _iLoveArrays = [{systemChat "im livin the life"}, {systemChat "i am ded"}];
_ifMyElephant then _iLoveArrays;
its beautiful
john shouldnt you be asleep as well its nearly 5am
huh, would not have believed it...
if (true); // true
wait can you do true then {systemChat "hi"};
not sure how that's useful exactly... learn something new.
It probably just returns something that evaluates to true when you try to output it.
Although in theory if () could be completely redundant syntactical sugar.
rather than !alive _unit i shall herein be using if (alive _unit) else {systemChat "i am ded"};
lol
well sometimes you need the code block... mentioned this before, for instance, an ad hoc ternary statement:
[_alpha_case, _bravo_case] select _charlie_cond;
which would immediately evaluate both.
analog to C++ for instance:
_charlie_cond ? _bravo_case : _alpha_case
this works fine tho
if [...] seems to evaluate the condition and return that
typename returns if
but you can get creative with lazy eval and boolean conditions.
for instance, I am using that in places to prompt users, i.e.
_primerCond && { /* prompt user */ private _response = [...] call BIS_fnc_guiMessage; _response; }
as an if or sometimes switch case condition.
i think something along the lines of that is why lazy eval isnt made bwc
isn't made what? bwc?
backwards compat
with what?
playerside is good but it goes by config, so if you have a WEST player switch to EAST during sessions, he will still report playerside == west
not a bad thing, but just a note
(Typing out the question made me realise what I did wrong and so I figured it out and deleted the question)
No, then requires an if type (which is kinda stupid)
no js PLEASE
replacing SQF wouild only make sense if the new lang would have a benefit
JS
no
There was that script language from the other engine - enscript? - I wonder how much investigation has gone into putting that in the arma engine.
If any, I'd like to know what the investigation found out.
what is best way to wait until a player has spawned so i can run one-time code on them?
alive player seems to return true before spawn
Initial join? Engine-driven respawn? Scripted respawn?
alive player shouldn't return true for initial join from lobby or engine respawns
seems to return true on this screen. Doesnt return true on spawn selection screen
while {true} do {_state = (alive player); systemChat (str _state);};
So its scripted respawn, no idea how it works, you probably want to look into its code for useful global variables about its state
Wait, this is briefing phase?
You can check for it instead
getClientStateNumber >= 10
nice thanks
Or even getClientStateNumber == 10, depending on what you do
So stuff doesn't run when mission is in end screen
I'm not sure what you mean requires an if type, do you mean BOOLEAN true? as somewhat established the other evening...
Iftype is created from the if operator
It is, technically, the same we a bool but different type meaning, as it can be used with then or exitwith
it's a "hidden" type (not normally seen).
typeName if true // returns "IF"
sounds like some order of precedence shenanigans 
yeah. if is unary. then is binary. else is binary but with higher precedence than then
and booleans are dirt-low
if _something then {} else {} -> (if _something) then ({} else {}) ({} else {} translates to [{}, {}])
and i'm an official slowpoke{} else {} is glorified [{}, {}]. Man, those things get trippy at times
else has special precedence then?
oh, it's actually in the list :D
huh, that's wild, so [else, then] select (if something) is not far from the case, re: ternary expressions, excepting for the evaluation part.
you can't type binary/unary commands without their args
otherwise the game treats them as variables or nular commands, which results in error
calls, waitUntils and so on are the same. Unary call CODE, binary ARRAY call CODE, unary waitUntil CODE...
was it java or javascript?
I know it existed in TKOH (same engine) https://community.bistudio.com/wiki/Java_Scripting
Given that CfgPatches requiredVersion doesn't work, is there maybe a script check that can be done for the A3 version? Bit sick of dealing with pirates.
Would productVersion work?
ah yeah, probably
or even the script version of requiredVersion
Also slightly unrelated, but I made a script the other week to check if the mod is being used from the workshop or if its a ripped pbo as well, if you wanted to include that
Nah, no-one who edits a PBO ever manages to run the thing IME :P
requiredVersion is good though, thanks
My goal with it was to prevent people from just downloading your mod and throwing the pbo into a private pack and then reuploading it
Hello guys, I would like to play a sound when a player shoots another player unconscious. I have already looked at the various event handlers, but unfortunately I have not found one that triggers when a player is put into the incapacitated state. Does anyone have an idea how I can check if the player running the script has shot a unit unconscious?
check lifestate after hit eh
it won't be reliable unless your EH triggers later than the code that puts the unit into unconscious mode
you should probably check 1 frame later, using a per frame EH for example
Okay, but how do I know which player's lifeState I have to check? There are several players and it is important that only the player who killed the other player hears the sound
Good idea, but won't that cause performance problems?
if you check via EH no not really
Okay, thanks for the idea
this addEventHandler ["Hit", {
params ["_unit", "", "", "_instigator"];
if (isPlayer _instigator) then {
[{params ["_unit", "_instigator"]; if (lifeState _unit == "incapacitated") then {["sound"] remoteExec ["playSound", _instigator]};}, [_unit, _instigator]] call CBA_fnc_execNextFrame;
};
}];
CBA_fnc_execNextFrame does exist 
is there a function (edit: changed phrasing) for triggering a zeus ping?
I want to script a trigger to do a zeus ping.
ยฏ_(ใ)_/ยฏ
no because that would be bad
I said command. I meant function. Or is that still a no?
still no
imagine writing something like this: while {true} do {[player] call BIS_fnc_pingCurator}
or maybe a server only one time only trigger that pings to let me know when a player entered an area. Yes I know there are other ways of doing that. Im asking the most general form of what im looking to do.
If the player on the script hits another unit, the inner part is executed. I don't quite understand the part with _instigator. And does the variable _unit refer to the player on which the script is running or to the unit which is hit?
Shooting a player who's already unconscious would also trigger that.
inb4 checking the current lifeState before next-framing
There's a feedback tracker request somewhere for a lifestatechanged EH but I can't find it.
I'll try it out a bit. Thanks
maybe several because the one I did just find is from 2016
a simple way is just checking the animation state
AnimStateChanged EH
but it triggers too late
not as soon as the target is unconsious
although at that point it feels like straight-up running it in EachFrame MEH can be more effective (or at least more consistent) than "Hit" EH 
you wouldn't know who did that to you tho
you also wouldn't if multiple "Hit" EHs including non-player ones arrive at the same frame, tho
Then maybe it's better to do it with the hit EH after all
Even if the script runs locally on each client?
you at least know it was one of them
plus even if it wasn't really a player, at least that player did shoot. so for all you care he was the cause
Do you mean when a vehicle hits the other player?
ZEN has a key to (fake) ping other curators. You can use that function. The Space-to-view works though https://github.com/zen-mod/ZEN/blob/master/addons/editor/initKeybinds.sqf#L131
no
hello anyone here know howto hide the turret interior of a sog tank (trying too make a t-54b missile launcher contraption)
Would that really be that bad? We can already script things that are much more annoying
What's going on with these pirates? As in pirating Arma 3? Or just taking your work?
Curious to see what you came up with.
I can send it if youd like Hypoxic, it a sqf script that needs to be slightly edited for each mod. It checks the id of the workshop mod to make sure it matches. And then has some search protection as well so you have to know what you're doing to get rid of it
it utilizes addon/mod info script functions
yeah shoot it over
@fair drum Pirate Arma 3. The trouble is that we use stuff from 2.12 and the pirate versions tend to be older.
damn, thought i added him. thanks @south swan !
Good evening,
two things:
-
Is it possible to force a ffv thing to a passanger seat via a script? (For example for the drivers passangers seat in the offroader)
-
If not, is it possible to retain some sort of movement for a unit (like rotational) if it is attached to a object?
ffv?
fire from vehicle
Not really. Best you can do with only script is probably 1. attach a weapon model and spawn bullets on click, and 2. read mouse input and set rotation.
If you have an invisible helper vehicle with an FFV seat though... https://youtu.be/oDYWVe1x0cQ
that with the invisible helper vehicle looks interesting, but I guess I first need to create such a vehicle with the proper-ish config right? (Not sure if i want that though, as I planned it be just one scenario instead of a mod).
But thanks!
tkoh had java
javascript as a scripting syntax would be fine in my opinion, though id like a later version of the ecmascript standard than what JS is if they did
Java is NOT Javascript, you have to remember that
trying to push Java into the RV engine is seriously one of those "they are smoking crack" things
it made no sense.
Q: on getOrDefaultCall, are any magic variables furnished? i.e. the key being requested, for instance?
https://community.bistudio.com/wiki/getOrDefaultCall
Hey guys looking to see if I can get some help fixing my script right here. So I have made an if statement which checks a specific variable, if that variable is true then it will animate an object (which the code is attached to using ACE Actions) and also add magazines to the person executing the code, aka the player.
The code is being called like so:
[_this,_player] call TestAnim_fnc_AnimAddGear;
and is executing this script:
if (TestVariable) then
{
(_this select 0) animate ["TestAnim_hide", 1, true];
for "_i" from 1 to 2 do {(_this select 1) addItemToVest "ACE_tourniquet";
} else
{
(_this select 0) animate ["TestAnim_hide", 0, true];
for "_i" from 1 to 4 do {(_this select 1) addItemToVest "30rnd_556x45_M855A1_PMAG_Tan";
};
Anyone have any idea why it may not be working and is spitting out errors?
Obviously TestVariable is already set in another script
Whats the error first off
You dont have any ending }; for either of the for statements
True, changing it already and rerunning. Will update
Getting an error here sqf (_this select 0) animate ["TestAnim_hide", 1, true];
Type Array, expected Object
I'll assume that _this is an array in the script that calls [_this,_player] call TestAnim_fnc_AnimAddGear;
Needs to be an object
I understand that, but the action is being called on the config of the actual Object using ACE Actions like so:
class Test_Anim_Change
{
displayName = "Test Anim Change";
distance = 1;
condition = "true";
statement = "[_this,_player] call TestAnim_fnc_AnimAddGear;";
};
So wouldn't this theoretically work?
I can say that the below animate statement works without issues when executed alone from the statement part like so:
statement = "(_this select 0) animate ['TestAnim_hide', 1, true]";
Nope. You have to pass it as a local var.
_this will be an array. You COULD use statement = "[_this select 0,_player] call TestAnim_fnc_AnimAddGear;";
But as of current, you're passing the first index as an array
I'll try it out and get back to you
Working, thanks my guy
Is there a way to disable timestamps for 'diag_log' command? I dump some info into RPT and want timestamps to not be in a way for that
I do not think there even is a way. What's your usecase?
I dump some info into RPT and want timestamps to not be in a way for that
I meant what could be the benefit for you
The benefit is that I will not have to manually delete timestamps every time I want copy-paste dumped info into separate file.
Hmm
I think you have two options:
- Remove the timestamps via regex in your text editor
- Use
copyToClipboardcommand instead
I've found the setting
timeStampFormat = "none";
But it said to be for dedicated server config. I've tride putting it into description.ext, but nothing changed
Yeah, there are ways to overcome this issue, just hoped there is a setting to make life easier. Thanks for your suggestions.
Actually yeah, copyToClipboard is quite useful, thank you for that
I know the difference. I was just asking for clarification since as you said TKOH had java and they were talking about javascript in arma.
Hello :D
Is there a way to get a variable name as a string in a script? so from VAR = 123; I would be able to get "VAR"?
I... do not think there is. What's your usecase?
set/getVariable
Well it would work for some cases and not for some I thought the question is the opposite?
ie. missionNamespace getvariable "myStringVariable"
I assign vehicles variable names in the editor, such as HELI_1, HELI_2, etc...
I have a script that checks if the vehicle exists/is alive before attempting to teleport the players.
Only way I know to check whether something exists is to use isNil but that only accepts a string.
params ["_unit", "_listOfPlayers", "_vehicle", ["_altPos", false]];
if (_unit in _listOfPlayers) then {
if (!(isNil str(_vehicle))) then {
if (alive _vehicle && _vehicle emptyPositions "Cargo" > 0) then {
_unit moveInCargo _vehicle;
} else {
if (!(_altPos isEqualType false)) then {
if (_altPos isEqualType "") then {
_unit setPos (getMarkerPos _altPos);
};
if (_altPos isEqualType objNull) then {
_unit setPosATL (getPosATL _altPos);
};
};
};
} else {
if (!(_altPos isEqualType false)) then {
if (_altPos isEqualType "") then {
_unit setPos (getMarkerPos _altPos);
};
if (_altPos isEqualType objNull) then {
_unit setPosATL (getPosATL _altPos);
};
};
};
};
Currently not working as str(VAR) doesn't return what I need, which I should've known.
you can just use isNil "_vehicle"
Well in this case you can also use isNil {_vehicle}
or that
Would it work properly in a function?
Will try that as well.
Not even sure if it is possible to have nil _vehicle in your script, I maybe misremembered but it would throw undefined variable error upon you tried to pass HELI_1 or such and they're nil?
It seems like it will throw an error yes, however the function is still executed and the player is teleported to the altPos instead.
You may want to check isNil before use this function then
Will do, would there by any downside to keeping it within the function as well?
Only downside if you've made it sure it is not nil before you run the script
Oh potato, if I check if it is nil before I call the function, then it will not get called if it is nil and the player won't be tp'ed to the altPos, I need to make that a second function I guess and cal it if the vehicle is nil.
Ah welp, at least the main thing is figured out, thanks a lot for the help 
Hello all. I have seen a lot of issues getting my units to move around effectively. I use the โmoveโ command a lot (not waypoints). Could this be why some groups or single units simply refuse to move to their given destination?
Iโm not sure how much the terrain might influence the issue (hills do also seem to create problems for AI troop movements).
Has anyone experienced issues like this and is there a recommended way to deal with the โnon-moversโ apart from brute-forcing them to a different nearby location and hoping that resets their lack of enthusiasm?
(I also see some issues getting these same groups to obey Zeus move commands, if thatโs relevant).
use doMove command instead. also there maybe limit on how far they can move
Thanks @proven charm Iโll try that ๐
Have been having some troubles with railgun charging systems on single-seat planes recently, specifically it wasting the round and not firing off. Did some testing with helicopters as well, and it seems like when in driver seat, player simply can't get railgun charge up system working (tried with both adding railgun directly to driver + adding railgun to gunner and trying to use manual fire as driver). Works just fine when adding to gunner seat and using it as gunner, though. Not exactly sure what could be causing this issue, since it has worked just fine before.
Script I am using for adding railgun:
this addMagazineTurret ["RailGun_01_DummyMagazine",[-1]]; this addMagazineTurret ["60Rnd_75mm_RailGun_APFSDS_mag",[-1]]; this addWeaponTurret ["cannon_railgun_fake",[-1]]; this addWeaponTurret ["cannon_railgun",[-1]];
-1 in this case referring to the driver/pilot. Used in init box of Shikra, Blackwasp and Gryphon.
Tested in singleplayer and multiplayer, worked neither of times. Vanilla without any mods.
Can't say for sure, but I think this might be somehow connected to the hotfix on 19th September when one particular issue with T-100X was fixed, that being presence of driver/commander played on top of gunner player breaking functionality of railgun charge up system. Just tested it with commander seat in Kuma as well and it doesn't work either, so that is something to note too I guess.
How can i check if unit's AT launcher loaded? Something like this:
_rpgLoaded = (_unit weaponState (secondaryWeapon _unit) # 4) > 0;
who can suggest the right code?
After some research, looks it needs a gunner seat to shoot one while you're trying to shoot one from driver seat
Loaded as in? Magazine is there, ready to shoot or something else?
@warm hedge Magazine is in launcher's magazine slot
secondaryWeaponMagazine
PS. sqf this addMagazineTurret ["RailGun_01_DummyMagazine",[0]]; this addMagazineTurret ["60Rnd_75mm_RailGun_APFSDS_mag",[0]]; this addWeaponTurret ["cannon_railgun_fake",[0]]; this addWeaponTurret ["cannon_railgun",[0]];This does work for a Nyx tankette and shoot and could flip it
Not sure I am understanding, there isn't manual fire option for Nyx driver?
Railguns do work just fine when gunner uses them, yeah. Problem arises when driver/commander try to use them. In case of Nyx, commander acts as gunner so there is that.
Looks it actually wants gunner or commander to shoot - which basically is [0]
Yeah, I think that might have been added in this hotfix I mentioned in message above, because when I was testing it out with single-seat jets (which only have driver/pilot seat, tested on September 7th) before hotfix, it was working just fine.
Sometimes I wish we had getPosAGL ENTITY to save on one command from ASLtoAGL getPosASL ENTITY (getPos sucks)
Hey guys, i am trying to lock enemy corpse inventory, so that people can't pick up gear or anything from enemies (OPFOR/INDFOR deadbodies).
I took a look at https://community.bistudio.com/wiki/lockInventory
but i am having a hard time trying to get this to work.
Any suggestions on what i might look into?
player addEventHandler ["InventoryOpened",{
params ["_unit","_container"];
_override = false;
_allUnitBackpackContainers = ((allUnits) select {!alive _x && {(player distanceSqr _x) < 250}}) apply {backpackContainer _x};
if (_container in _allUnitBackpackContainers) then {
systemchat "Access denied!";
_override = true;
};
_override;
}];
keep in mind it's not tested
exec this on every client when they join
Should disable the opening of a dead unit's inventory
Oh, whao, ok
thanks
you could do this in init.sqf or initPlayerLocal.sqf
thank you so much
let me test this out and see if there are any problems
but regardless thank you!
is there a way to keep object above ground ( floating ) and keep simulation enabled ? for example, keep balloon above ground and able to pop it with gun
You could attach it to something (attachTo doesn't require the objects to be touching or even anywhere close), or you could reset its position every frame (setPosASL + EachFrame mission event handler)
if I disable simulation on "helper" object, and attach balloon on it, does balloon also extend properties of helper ? ( meaning balloon will have simulation disabled also ) ?
Probably yes, and it will also inherit the normal simulation properties of the object it's attached to, such as its update frequency. So choosing the right object to attach to is important. (Not difficult though, just pick something that has physics)
so.. there is no way?
not that I know of. might want to find a sog dev and ask them maybe check #sog_prairie_fire for one of them
if it has no hiddenselections then no it is not possible
Sometimes vehicles have animations for hiding the turret. I don't know if SOGPF tanks have that though.
Can someone help. I need to set a limit for pickable RPG mags from box. It' no going the right way unfortunately _countPicked
I need to stop cycle when unit will have 1 magazine loaded in RPG and maximum 2 in inventory.
_countPicked = 0;
while {
_RPGmags2 = (magazineCargo _container) arrayIntersect _compatibleMags;
_tryToPick && count _RPGmags2 > 0 && _countPicked <= 2
} do {
private _selectedRPGMag = selectrandom _RPGmags2;
if !(_unit canAdd [_selectedRPGMag, 1]) then {
_triedCounter = _triedCounter + 1;
if (_triedCounter > 3) exitWith {
_tryToPick = false;
};
continue;
};
while {
_unit canAdd [_selectedRPGMag, 1]
&& { _x == _selectedRPGMag } count (magazineCargo _container) > 0
} do {
if (!_rpgLoaded) then {
_unit addWeaponItem [_unitRPG, _selectedRPGMag];
_rpgLoaded = true;
} else {
_unit addItem _selectedRPGMag;
_countPicked = _countPicked + 1;
};
_container addMagazineCargoGlobal [_selectedRPGMag, -1];
};
}
What are the symptoms?
ah yeah, second while loop.
I'll simplify it.
_countPicked = 0;
while { _countPicked < 2 } do {
private _RPGmags2 = (magazineCargo _container) arrayIntersect _compatibleMags;
_RPGmags2 = _RPGmags2 select { _unit canAdd [_x, 1] };
if (count _RPGmags2 == 0) exitWith {};
private _selectedRPGMag = selectrandom _RPGmags2;
if (!_rpgLoaded) then {
_unit addWeaponItem [_unitRPG, _selectedRPGMag];
_rpgLoaded = true;
} else {
_unit addItem _selectedRPGMag;
_countPicked = _countPicked + 1;
};
_container addMagazineCargoGlobal [_selectedRPGMag, -1];
};
@south swan what? :P
eh, don't mind me
@granite sky looks like it works fine now. Thank you!
Hi. When using the ingame Screenshot function the screenshots somehow look very bright in comparision to screenshots taken with f12 for example. does someone know the reason?
well, that is bad news. Thank you anyway.
how bright? i can run them through lightroom if you want
For my project I need a lot of screenshots taken automatically by sqf. I am already researching if I can counter that gamma issue with python and opencv somehow. What value would you set in lightroom? That is adobe, correct?
The FT ticket has a split 50/50 picture. You could probably calibrate on that by getting the gamma'd half to match the normal one. (if possible)
I would like to have the Splendid Preset. So brightness with 101 is actually the gamma value!?
Yeah. Colors and all set settings aren't my friends. But maybe hypoxic will push me in the right range of values.
this is - 50 brightness, + 50 contrast
Love it. Thank you so much.
do you have photoshop?
no photoshop, but knowing which values are to change (brightness and contrast) will help me ๐
Actually I've same issue for ages and somehow and some say they don't. I still have no clue what it is
ah. I understood it is an issue everybode has
bruh, been wondering why my thing ewasn't working. I had a random spawn with no args >.>
oh no wait, it's because I was comparing the vehicle to it's self
That's certainly one way to avoid an apples-to-oranges comparison; just compare the same apple
my launcher keeps dying
can anyone help me with the script to have lights automatically turn on when night time hits?
map lights? or placed lights in the editor
Hello, How do I make this code to run only when a player has equipped a primary weapon and a handgun?
while {alive _this} do {
_pWeap = primaryWeapon player;
_hWeap = handgunWeapon player;
sleep 30;
player removeWeapon _pWeap;
sleep 45;
player removeWeapon _hWeap;
};
it's better to do it like this ```sqf
while {alive _this} do {
sleep 30;
_pWeap = primaryWeapon player;
if(_pWeap != "") then {
player removeWeapon _pWeap;
};
sleep 45;
_hWeap = handgunWeapon player;
if(_hWeap != "") then {
player removeWeapon _hWeap;
};
};
is there a way to create infinite loop with for ?
trying to have a loop where when I define number of cycles via input param, and if input param is -1, then loop should be infinite
from 0 to 10 step -1
is there a thing to check if something is a position or would I have to check if it's an array and has atleast 2 numbers?
I wanna make a script I use accept blank input, then tries to use what's on the clipboard, see
it removes like 1 second of work for me, but still xD
Doesn't appear to be any standard command or function for it. You could check if CBA has one, if you have a CBA dependency.
I don't necassarily, but I almost always use it so eh
Checking if it's an array with 2-3 numbers would be all such a function does, anyway, since that's all that qualifies something as a position (there is no specific Position data type)
oh yea, I know
_newPrimaryPosition = [];
if(count _newPrimaryPosition == 0)then{
// POSITION CHECK
private _inpStr = copyFromClipboard;
if(_inpStr select [0,1] == "[" and _inpStr select [count _inpStr - 1] == "]")then{
_inpStr = _inpStr select [1,count _inpStr - 2];
};
_strA=[_inpStr,","] call BIS_fnc_splitString;
_posOut = [0,0,0];
for "_i" from 0 to (2 min (count _strA-1)) do{
private _nC = parseNumber (_strA # _i);
_posOut set [_i,_nC];
};
_newPrimaryPosition = _posOut;
};
......
Horray!
lets add some privates :P
hmm- would it be worth it to make it also set rotation-
oh wait, that'd need new params format to be entered. xD
Well, this goes to a group position setting script. Get the position I want, select the "center" object of the group, select the rest of the group, then run the script. All selected objects will be moved with the "center" so that the "center" object's position matches what was inputted
_var isEqualTypeArray [0,0,0] || _var isEqualTypeArray [0,0]
ok- now I need to match direction-
How do I rotate something around a point :]
basically with sin & cos functions
[
x * cos angleRad - y * sin angleRad,
x * sin angleRad + y * cos angleRad,
0, // Y rotation - 2D only
]
```something like that (in Reforger at least ๐)
but I want it to be 3D xP
just attach everything to the centerObj, move it, then detach. No fun, I know.
Is there command that returns amount of primarywepon magazines of soldier ?
no, you'll need to count it yourself
doesnt https://community.bistudio.com/wiki/compatibleMagazines do that?
I think thatโs an array of all possible magazines the gun can use not necessarily ones a player has
private _compatible = compatibleMagazines currentWeapon player;
{_x in _compatible} count (magazines player + primaryWeaponMagazine player);
will count both inventory and loaded mags, for all muzzles
@meager granite great, thanks
hmmmm this code returns me 17 but I only got 5 mags in inventory
maybe it also counts grenades
yep it seems to work with rifleman but not with grenadier
i checked it, handgrenades and smokes not count
try grenadier guy
GL is part of primaryweapon , sot it's ok that it count it's ammo
alright then
Do compatibleMagazines [currentWeapon player, "this"] if you want only primary muzzle
I am tempted to make a 3den menu item or something that lets ya use my scripts easier- Some of these scripts I made, I feel are so useful and others might benefit, but idk how I'd share them xD
rn I just have the code in advanced debug's console and run it via pressing enter-
(I wanted to share the code but realized I probably shouldn't share it here, just to share it x3)
wtf is this nonsense?
https://sqfbin.com/lufoyeqafiwuhacojaqu
All of them work but two of them will spam the RPT and ScriptError EH. So the only reliable way to allow nillable types when you are not sure of the unscheduled/scheduled context is to do redundent checks? a la the last two?
Undefined Variable error in VM is horse doodoo. I can understand if it is a typo e.g. _myVan instead of _myVar where _myVan isn;t a local variable already on the stack and not being assigned. I get that. But allowing nillable parameters SHOULD be allowed.
Has allowCrewInImmobile stopped working since the latest updates?
Can you make it accept nil as a type?
oh wait
yeaaaaaah please use https://sqfbin.com/ to replace this wall of code by a nice link, thanks thanks!
Is that a thing? ["_myVar",nil,[nil]]? but it will still throw error on param command, no?
will do!
[1] spawn {
private _fnc = {if !(params [["_numA",0,[0,nil]],"_numB"]) exitwith {systemchat "FAILED"};
_numB = if (isNil {_numB}) then {1} else {_numB};
_numB = [_numB] param [0,1,[1]];
systemchat ("F WORKS " + str [_numA,_numB]);};
call _fnc;
};
why
params will give warning error msg. And I'm just trying to help em ;P
private _fnc = { params ["_var", 42, [0]]; hint str _var; };
[14] call _fnc; // hints 14
[nil] call _fnc; // hints 42
oh I'm reading their code wrong xD
(nil can be used to "jump" a function parameter)
I thought the params was for the spawn
[_numB,1] select (isNil "_numB") is wrong
you are using _numB in the created array before checking its existence
right.
also, can do parseNumber
that's just indicating it will throw an error if done the shorthand way instead of the long way
the example is just an example. issue is pasisng in nil but wanting to catch first parameter as being required
wait, catch why
oops I got that wrong
no can do AFAIK
edited comment
just don't really rely on the boolean result of params and let the function show an error when wrongly called, end of story - will save you headaches ๐
Wait, so, you want it so it stops if nil is provided, or it to fill in a nil with a default value?
want first parameter to be required (not nil, of specific type) but second can be nil and assigned default if nil or wrong type
Well, just make it so it doesn't have a check.
er-
params["_aaa",["_aab","default",[""]]];
if(isNil "_aaa" || {typeName _aaa == "STRING"})exitWith{...};
...
oh
oh again
isNil? Exit. Not Nil? Is it [valid type]? No? Exit. Otherwise, continue.
uhm ... to default assign just do:
params [
["_array", [], [[]]],
["_from", 0, [0]],
["_to", nil, [0]]
];
if isNil "_to" then { _to = count _array - 1; };
for "_i" from _from to _to do {
systemChat (_array select _i);
};