#arma3_scripting

1 messages ยท Page 113 of 1

granite sky
#

It won't prevent setDamage 1, so A3 revive's bleedout would probably still kill the unit.

limber thunder
#

Okay, I will try it again then

quasi sedge
#

Greetings everyone,
any good method
how to use some kind of static analyzer
for arma 3 mods
.sqf .sqm files?

granite sky
#

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.

limber thunder
#

How can I execute a script that runs only on the server?

quasi sedge
#

if (isServer) {

}
?

granite sky
#

well, that's if it runs everywhere and you don't want it to execute something elsewhere.

limber thunder
#

I want that the script is only run by the server.

granite sky
#

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.

limber thunder
granite sky
#

If you're dumping code into an editor init box, then isServer is also the way.

limber thunder
granite sky
#

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.

limber thunder
granite sky
#

"myScript.sqf" remoteExec ["execVM", 2];

#

but execVM is terrible and you should learn how to use CfgFunctions :P

limber thunder
granite sky
#

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.

limber thunder
limber thunder
granite sky
#

Yes, I don't trust your logic on "only once" though.

#

Mission ends on every machine.

limber thunder
#

I'll just give it a try with what you wrote. But thanks for your suggestions

dreamy kestrel
#

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]
vivid bridge
#

Is it possible to increase the spread of bullets for bots and humans with scripts?

limber thunder
granite sky
#

(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.

dreamy kestrel
mighty bronze
#

Hello, is there any way to re size items (or vehicles) and make it work on muliplayer? Thanks

vivid bridge
#

Can you tell me how to run three different animations one by one?

warm hedge
warm hedge
mighty bronze
warm hedge
#

That is the only way and it apparently has some limitations you can't really alter

mighty bronze
#

thanks

meager granite
#

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?
south swan
#

Sounds like in-engine BIS_fnc_sortBy

meager granite
#

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

south swan
#

I'd argue that for _array sort {...} select 0 usage the more useful thing would be _array selectMax {...}

meager granite
#

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

quasi sedge
#
any good method
how to use some kind of static analyzer
 for arma 3 mods 
.sqf .sqm files? 
meager granite
#
private _closest_tank = vehicles sort {if(_x isKindOf "Tank") then {_x distance player} else {nil}} select 0;
south swan
#

_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 notlikemeow

vivid bridge
#

does anyone know if this command stopped working?

are there any alternatives?

[s1, s2] join grpNull

warm hedge
#

Define stopped working

vivid bridge
warm hedge
#

Hence my question

#

There's only very few context in your question to tell any answer

#
  1. errors?
  2. are they (s1, s2) defined?
  3. any Mods?
  4. did it worked before?
vivid bridge
errant iron
#

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 };

meager granite
#

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
};
errant iron
#

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

meager granite
#

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

errant iron
#

well, i guess i know now notlikemeow

meager granite
#
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
meager granite
errant iron
errant patio
#

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).

meager granite
# errant patio Hi folks, I'm having an issue with following the tutorial on custom modules - I'...

https://forums.bohemia.net/forums/topic/184230-error-with-making-a-module/
Something-something CfgFunctions isn't setup right

errant patio
#

thanks, i'll have a read and hopefully can figure it out!

fair drum
errant patio
#

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
fair drum
#

are you currently just copy pasta what is on the wiki page currently?

errant patio
#

pretty much, yes

#

though clearly not doing a great job of it

fair drum
#

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?

errant patio
#

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

fair drum
#

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

errant patio
#

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?

fair drum
#

sure

errant patio
#

sent :)

fair drum
#

yooooo in 2.16, import can be used to easily bring in local variables to event handlers???

warm hedge
#

I don't think so, they're literally different script

fair drum
#

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;
}];
winter rose
#

from the parent scope

warm hedge
#

As I said they're different script, there should have no relation between them

fair drum
#

Ah poo

wind flax
#

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.

harsh oasis
#

how do i use unit capture for tanks ??

wind flax
#

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?

meager granite
wind flax
#

Yeah I'll just write it myself

meager granite
#
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

wind flax
#

That seems a lot more elegant then what I was going to do lol

granite sky
#

It will fail very occasionally due to the random problem though :/

#

random very occasionally rolls the input value due to bad rounding.

little raptor
#

random x returns value in range [0,x] (both inclusive)

hallow mortar
#

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

little raptor
#

engine doc says inclusive blobdoggoshruggoogly

hallow mortar
granite sky
#

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.

digital hollow
#

If I need to track ~50 numbers that update per frame on a vehicle which would be better for performance/network?

  1. setVariable as each is calculated x50
  2. setVariable ["allVars", [_v1, _v2..., _v50], true]
  3. setup animationSources for each, animateSource ["v1", _v1] and let then engine sync them >=D
meager granite
#

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

digital hollow
#

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.

winter rose
hallow mortar
# granite sky but 999 is far more likely.

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.

granite sky
#

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.

hallow mortar
#

...Is that the standard usage, or just the usage by people who've forgotten about selectRandom? :U

winter rose
granite sky
#

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.

hallow mortar
#

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

granite sky
#

performance, mostly.

hallow mortar
#

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)?

granite sky
#

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.

ornate whale
#

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.

winter rose
granite sky
#

I don't think the BIS shuffle function is even reliable because it uses floor random :P

tender sable
#

and _arg1 will be empty string (or whatever you want as default)

ornate whale
tender sable
ornate whale
#

It says that I am trying to pass an undefined var in the call command. So the target function is not even executed.

tender sable
#

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"];

ornate whale
#

The passed arguments are declared through params command in the first function.

tender sable
#

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

ornate whale
tender sable
#

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

ornate whale
#

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.

tender sable
#

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

ornate whale
#

Hmm, OK, this is would certainly help, but it is kinda weird design choice. ๐Ÿ˜„

ornate whale
tender sable
#

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.

ornate whale
#

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.

granite sky
#

[_arg1, [_arg2, nil] select isNil "_arg2"] works, right

#

just horrible :P

tender sable
granite sky
#

You do that:
[_arg1, [_arg2, nil] select isNil "_arg2"] call myFunc

ornate whale
granite sky
#

It's just an ugly way to dodge the scheduled code nil protection.

tender sable
#

just tested doesnt work

granite sky
#

I guess you could instead wrap the array declaration with isNil {}

tender sable
#

I'll try that

granite sky
#

ah yeah it doesn't due to the array

#

So you have to use if/then instead, which is even uglier.

tender sable
#

nope. literally cannot put a nil in an array in scheduled.

ornate whale
granite sky
#

sure you can, as long as it's not a variable reference

ornate whale
#

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.

tender sable
#

until this moment I literally never encountered this error. Is this bug?

#

granted most of my stuff is unscheduled

granite sky
#

I actually want a debug setting where undefined variables throw errors in unscheduled.

#

keeps tripping me up because I have underscore blindness

tender sable
#

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

tender sable
manic kettle
#

Having some difficulty checking if a player is admin on mp server. This should be simple but isnt working
!(admin clientOwner isEqualTo 2)

sullen sigil
#

admin is server exec ๐Ÿ™‚

#

admin owner _unit is better

manic kettle
#

Ah...its a server exec

#

These are so rare i forget its a thing

sullen sigil
#

when its related to locality its always best to check biki

#

well
always best to check biki regardless

manic kettle
#

Yeah true. Thanks!

tough abyss
manic kettle
#

Is there a way to check in game if an object is editor placed?

warm hedge
#

AKA not terrain placed?

manic kettle
#

Not terrain placed, editor placed, but also not placed live in game (zeus or other means)

warm hedge
#

So createVehicle'd things?

manic kettle
#

Right

#

Uh no sorry

#

I mean in 3den

warm hedge
#

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?

sullen sigil
#

are all terrain objs 3den entities? thonk

warm hedge
#

Nu

sullen sigil
#

nvm, idea over meowsweats

#

can possibly use get3DENLayerEntities along with getMissionLayers ๐Ÿค”

manic kettle
#

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

meager granite
#

I wonder if anyone was able to get that inclusive upper limit in a real test

south swan
#

Yes ๐Ÿคฃ

meager granite
south swan
#

There

#

Got the answer of "don't compare floats with ==", which is totally reasonable

meager granite
#

Wonder if floor random 1000 == 1000 will ever trigger? ๐Ÿค”

#

Perhaps we could use selectRandomIndex or deleteRandom then

#

I'd pick selectRandomIndex, more universal

south swan
#

in tonight's episode of "Nice-to-haves with Sa-Matra" blobcloseenjoy

meager granite
#

Can't have a day without me wanting a new scripting command hmmyes

granite sky
#

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.

granite sky
wise grove
#

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.

ivory lake
#

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

still forum
#

Except when 0 notlikemeow mh

wise grove
ivory lake
#

ah if you dont - or dont want to make a mod that changes it

#

and then use the action to turn off the nvgs

wise grove
#

So basically run an eventhandler on every player that disables nvg when they enable them

ivory lake
#

Yeah

round scroll
#

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?

hallow mortar
#

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)
round scroll
#

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 !

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.

round scroll
#

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?

hallow mortar
#

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.

round scroll
#

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

pulsar bluff
proven charm
pulsar bluff
#

now theres a command ive never used

meager granite
#

0 max (random - 0.0000001) or if(result == max) then {result = 0} or something

stable dune
#

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"

granite sky
#

1000 - 0.0000001 >= 1000 => true :P

still forum
little raptor
stable dune
#

Thanks a lot ๐Ÿ‘Œ๐Ÿ‘

meager granite
storm arch
#
    ["_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
granite sky
#

Not really, you're missing something large :P

manic sigil
#

If it even accepts arrays to being with, I believe it's just string.

Ah, string or array. Huh.

granite sky
#

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.

storm arch
#

I just realized that

#

that really was a big missing part xD

#

thanks for the help

rough dagger
#

Just a quick one, is it possible to get the rotation value of a marker using script commands? Thanks in advance all

hallow mortar
#

markerDir

#

And of course its corresponding setMarkerDir/Local

rough dagger
#

Ahh, thank you, sorry I should have known that

weak isle
#

How do a custom multiplayer loadout, so when I change it it changes on every player of a team?

manic kettle
#

I never quite understood this part of the debug console, what does the 'count' field refer to?
Random code playing

sullen sigil
#

how many times the code was executed before it gave up

granite sky
#

It'll run for a second or for 10k iterations. Whatever's faster.

manic kettle
#

ah gotcha, thanks!

storm arch
#

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?

granite sky
#

Not with scripting.

tidal ferry
#

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

tidal ferry
#

Please help, I've been at this for hours ๐Ÿ˜ญ

true frigate
#

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

tidal ferry
#

I'm tearing my hair out here- anybody know about Zeus Modules and is willing to help me?

sullen sigil
#

do you use zeus enhanced in your modset

tidal ferry
#

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

sullen sigil
#

are you trying to use their api for modules

tidal ferry
#

No

sullen sigil
#

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

tidal ferry
#

Well, I'm just trying to add it in via config

sullen sigil
#

run the first line on postinit and it'll register a zeus module

#

that will run storey_fnc_insertdadjoke

tidal ferry
#

Hmm... okay

#

I'll consider it

#

What solution would I use if we deprecate Zeus Enhanced?

sullen sigil
#

pain and suffering of an untold scale

#

(i dont know)

tidal ferry
#

aaaaaaaaa

#

Okay- thanks

sullen sigil
tidal ferry
#

Yeah, been looking at that for a while now

sullen sigil
#

_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

tidal ferry
#

Hmm... okay

#

I've been trying to do it, but for some reason my module has no attachedTo objects with it

sullen sigil
#

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

tidal ferry
sullen sigil
#

can you move the object before you are trying to use the module on it

#

in zeus

tidal ferry
#

Yes

#

It's literally just any empty prop to put an arrsenal on

#

Identical to the Add Full Arsenal module included in ACE

sullen sigil
#

does add full arsenal work on said object

tidal ferry
#

Yes

tidal ferry
#

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"?

sullen sigil
#

i have no idea

#

however it should be _logic

#

have you tried testing typeOf _logic

tidal ferry
#

Yeah

#

It returns to the logic object fine

#

Just not the object I place it on

sullen sigil
#

what is _object returning? objNull?

tidal ferry
#

Yeah

#

ObjNull

#

I think it may have something to do with config, but idfk

sullen sigil
#

what is curatorCanAttach set to on the config of your module

tidal ferry
#

CuratorCanAttach?

#

Oh

#

OHHH

#

Lemme try thast

sullen sigil
#

๐Ÿ™ƒ

tidal ferry
#

It's not mentioned on Biki page though

#

Whaat should I set it as? True?

sullen sigil
#

1

tidal ferry
#

Got it

#

Trying now

#

YES

#

YES YES YES YES YES

#

THAT WORKED

#

THANK YOU

#

SO MUCH

sullen sigil
tidal ferry
#

HOOOOOLY F##K

sullen sigil
#

it is right there after all

tidal ferry
#

Oh my GOOOOOOD

#

WHY IS THIS NOT ON THE BIKIIIIII ๐Ÿ˜ญ ๐Ÿ˜ญ ๐Ÿ˜ญ

#

You are a GODSEND

#

Thank you SOOOOO much

sullen sigil
#

what biki page are you looking at

sullen sigil
#

i shall ask for it to be added

tidal ferry
#

๐Ÿ™ God BLESS you

sullen sigil
#

can you tell god to get rid of my cold thanks

tidal ferry
#

If you wanted to

#

I could hit them up

sullen sigil
#

bro got connections to god deadass

tidal ferry
#

I gotchu fam ๐Ÿค™

tough abyss
#

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

warm hedge
#

Do you mean you want to add this into a texture (3D space/model)?

glossy trench
#

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

queen cargo
#

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)

glossy trench
#

Well, he did, but- unfortunately it's just the same thing stated their in that module

warm hedge
glossy trench
#

Yeap

glossy trench
#

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.

warm hedge
#
_vehs = _this select {getText (configFile >> "CfgVehicles" >> _x >> "faction") == "CUP_C_TK"}; _vehs;```As far as I understand, use this
queen cargo
#

@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?

nocturne bluff
#

I do.

queen cargo
#

but indeed would be interesting what he wants to patch

granite haven
#

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"
    ];
warm hedge
#

It may because TahomaB does not support such characters

granite haven
#

will try out diff fonts

#

works, thank you

meager granite
#

"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?

little raptor
#

it should be

#

isn't it local? afaik forces are applied locally

#

we do have setAngularVelocity too

winter rose
#

now

#

(devBranch, 2.16)

meager granite
# little raptor isn't it local? afaik forces are applied locally

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

sullen sigil
#

change vector by diag_deltaTime

astral bone
#

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.

sullen sigil
#

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

astral bone
meager granite
#

addForce worked much better though

sullen sigil
#

how peculiar

#

i suppose addtorque probably doesnt touch forces or something

#

๐Ÿคท

south swan
#

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 meowsweats

#

tbh, by the sound of it multiplying by the delta time should work tanking

real tartan
#

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 ?

sullen sigil
south swan
#

except Patriot (or whatever they're called) launchers that don't have sensors and just shove LOAL rockets towards datalink-provided targets notlikemeow

#

ammo should work, though

real tartan
south swan
#

get weapons, get their firemodes, get max range of those blobdoggoshruggoogly

rough dagger
#

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.

rough dagger
#

Roger ๐Ÿ™‚

real tartan
south swan
#

maxRange=2500; in autocannon_35mm >> far in my config dump, though

#

SmokeLauncher can hopefully be sorted out by its simulation="cmlauncher";

real tartan
south swan
#

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

digital hollow
#

also, difference between detection vs engagement ranges, especially if you have datalinked AA.

south swan
#

and missile can have the aircraft detected but not locked (at least if we consider those comments in wiki examples to be true) ๐Ÿ™ƒ

real tartan
#
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;

limber thunder
#

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];
proven charm
#

this: ```sqf
[str DISP_scoreDataWest] remoteExec ["systemChat", 0, true];

meager granite
south swan
#

and how did it work? I don't think i can decypher it works better with low FPS and with high FPS meowsweats

granite sky
#

I suspect you'd need the delta time of the next frame. Which you can't get.

south swan
#

still should end up with 2 seconds (or however much) of torque accumulated tanking

granite sky
#

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.

meager granite
sullen sigil
#

have you tried benchmarking how far it is rotating with each over a period of time

meager granite
#

I already decided to use addForce instead

sullen sigil
#

oh yeah you said i forgot

half sapphire
#

hello everyone!

#

im new-ish to arma 3, barely 8 months. newer to scripting, 2 months top.

rough dagger
#

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

manic sigil
rough dagger
#

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 ๐Ÿ™‚

hallow mortar
manic sigil
#

Duly noted; only times Ive had trouble was with TFAR/ACRE taking over Ctrl-Num for radio switching, so I had to rebind.

fair drum
smoky verge
#

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

fair drum
#

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)
smoky verge
granite sky
#

The safezone values are relative to the screen edges, so start from those.

#

top of screen is safezoneY, bottom of screen is safezoneY+safeZoneH.

half sapphire
#

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

half sapphire
#

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.

fair drum
half sapphire
#

remoteExec player call bis_fnc_tasksUnit?

fair drum
#

Nope, you use the unit itself instead of player

#

I'll put up an example in a sec

fair drum
# half sapphire like this loop. it runs on the server, but since "player" is remote, it returns ...
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.

half sapphire
#

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?

fair drum
#

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

south swan
#

Changing the array from inside the forEach over the same array? Cringe

#

Use forEachReversed, please

#

And use _array deleteAt _forEachIndex; please derpWolf

fair drum
#

I thought using deleteAt and _forEachIndex were iffy due to _forEachIndex not keeping up with deletions

south swan
#

And how would _array = _array - [player]; be any better?

fair drum
#

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

south swan
#

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

half sapphire
#

man am i biting more than i can chew or what. im clearly not ready for this lol

fair drum
#

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

south swan
#

Would work. But forEachReversed was introduced specifically for this usecase blobdoggoshruggoogly

fair drum
#

modified above

half sapphire
#

im gonna have to digest all that. i did not get the initplayerlocal or the onuserselectedplayer part at all.

tough abyss
#

I'll get a picture of what I'm looking to achieve though

half sapphire
#

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.

fair drum
# half sapphire im gonna have to digest all that. i did not get the initplayerlocal or the onuse...

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

half sapphire
#

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?

fair drum
tough abyss
#

hoping for some help making something like this from the link I put above

#

this one is from the contact campaign

fair drum
tough abyss
#

I don't think so, but possibly. I've been able to do static images before with whiteboards

fair drum
#

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

half sapphire
fair drum
half sapphire
#

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.

half sapphire
#

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.

warm hedge
tough abyss
#

oof alrightly, thanks anyway

half sapphire
#

not like i know much but.. @tough abyss what is this meant to do?

fair drum
# half sapphire part in question: ``` WreckSelect = selectRandom ["B_Heli_Transport_01_F", "B_H...
[  
    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

half sapphire
#

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.

fair drum
half sapphire
#

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.

granite sky
#

player is objNull on the server.

half sapphire
#

exactly.

granite sky
#

So what's baffling?

half sapphire
#

that you have to run that waitUntil on players.

#

clients}

granite sky
#

No?

#

The server can get a list of players easily enough. allPlayers, playableUnits etc.

half sapphire
#

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.

meager granite
#

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.

half sapphire
#

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};
granite sky
#

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)

half sapphire
#

i like that sleep there.

#

yes

granite sky
#

Note that this is only correct if the player list is established before the loop, which it probably isn't.

half sapphire
#

hmm. am i not creating the list on the variable?

granite sky
#

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.

half sapphire
#

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.

granite sky
#

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.

half sapphire
#

oh arma. you certainly are a roller coaster of emotions. the more i know, the less i knew.

granite sky
#

The starting point for connected players is allUsers

#

but you don't need that here.

digital hollow
granite sky
#

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.

faint trout
#

Heya all, does someone know how to prevent Civilian from using the ACE_Splint "Vanilla" Function?
Aka modding the condition of an existing item?

sullen sigil
#

change the actions condition in config

real tartan
#

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

proven charm
real tartan
serene sentinel
#

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?

quiet gazelle
#

@serene sentinel _UnitHaveRPG is a code type variable and is therefore not executed in the if condition

serene sentinel
#

How can check in cycle that units secondaryweapon is equal to the conditions in _UnitHaveRPG ?

south swan
#

๐Ÿง  call _UnitHaveRPG

#

also, extra } after secondaryWeapon _unit in line 6 is likely to break stuff

quiet gazelle
#

There's some more curly brackets in there that don't make sense but I can't tell which cause I'm on mobile

south swan
#

or don't have {...} around _UnitHaveRPG's condition at all blobdoggoshruggoogly

serene sentinel
#

Can you show where i need to put brackets or something else needed , please?

stable dune
# serene sentinel 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 { 
};
south swan
#

count _RPGmag2 >= 3 in the last if doesn't really make sense, though

stable dune
#

count _RPGmag2 >= 3
is never true?

south swan
#

it's a string. With a magazine classname. It's almost always true ๐Ÿคฃ

stable dune
#

well then

south swan
serene sentinel
#

@stable dune thanks, it works now

stable dune
south swan
#

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.

stable dune
#

That's nice

still raft
#

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 ?

limber thunder
#

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?

south swan
#

side group player

#

or playerSide

limber thunder
#

thanks I will try it

limber thunder
half sapphire
#

@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? ๐Ÿ˜„

fair drum
#

also artemoz helped

#

but the locality stuff, once it clicks, it really clicks so you'll get there

jaunty zephyr
#

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?

molten yacht
#

Does SQF support ElseIf statements?

peak pond
#

Don't think so

indigo snow
#

already canned

#

an intern played around with it one summer iirc

#

never really got anywhere

molten yacht
#

I'm trying to figure an efficient way to do else-if stacking to test what KindOf thing it is

warm hedge
#

SQF does not have elseif

molten yacht
#

sad

fair drum
#

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

molten yacht
#

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

warm hedge
#

Indeed in the second case the exitWith will exit the call

molten yacht
#

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

warm hedge
#

Huh

sullen sigil
#

exits the if but youre returning it anyway

warm hedge
#

Literally Hypoxic said is the preferred syntax

molten yacht
#

I understand that, I'm trying to understand SQF scoping

granite sky
#

It breaks out of the scope that the exitWith is in.

molten yacht
#

Okay, so if it was in the top layer, it'd go to the middle one, not the bottom one?

granite sky
#

Yes, although you don't have anything else there so it's academic.

molten yacht
#

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.

sullen sigil
#
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!!!!";
};
molten yacht
#

9.999/10 one of those !s should have been a 1

#

thanks a bunch, everyone

sullen sigil
#

basically chances are if youve indented its a scope

#

though that does require proper indentation ๐Ÿ™ƒ

molten yacht
#

yuuup

molten yacht
#

exitWith {"foo"};?
exitWith {_return = "foo"};?

fair drum
queen cargo
# molten yacht Okay, so if it was in the top layer, it'd go to the middle one, not the bottom o...

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

molten yacht
#

Thanks for the in-depth! This is interesting.

jaunty zephyr
#

thx. pity, though.

queen cargo
#

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

dreamy kestrel
dreamy kestrel
#

in an if control structure...

if (...) then { ... };
//            ^^^^^^^ technically, that is a scope
granite sky
#

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

dreamy kestrel
#

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 { ... }.

sullen sigil
#

nope, its just useless if you dont follow it with anything

granite sky
#

if (...) probably runs, I'd guess.

sullen sigil
#

it does and you can assign it to a variable etc just like anything eelse

granite sky
#

In theory you could write some goddamn horror like call { if (condition) } then { stuff };

sullen sigil
#

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

dreamy kestrel
#

huh, would not have believed it...

if (true); // true
sullen sigil
#

wait can you do true then {systemChat "hi"};

dreamy kestrel
#

not sure how that's useful exactly... learn something new.

sullen sigil
#

it shouldnt return true i dont think

#

unless then can take a bool too

granite sky
#

It probably just returns something that evaluates to true when you try to output it.

sullen sigil
#

possibly

#

you dont even need then do you

granite sky
#

Although in theory if () could be completely redundant syntactical sugar.

sullen sigil
#

rather than !alive _unit i shall herein be using if (alive _unit) else {systemChat "i am ded"};

granite sky
#

lol

dreamy kestrel
#

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.

sullen sigil
#

else seems to require code on the left side

#

how peculiar

dreamy kestrel
#

analog to C++ for instance:

_charlie_cond ? _bravo_case : _alpha_case
sullen sigil
#

if [...] seems to evaluate the condition and return that

#

typename returns if

dreamy kestrel
#

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.

sullen sigil
#

i think something along the lines of that is why lazy eval isnt made bwc

dreamy kestrel
#

isn't made what? bwc?

sullen sigil
#

backwards compat

dreamy kestrel
#

with what?

sullen sigil
#

as in its the default

#

its 5am i need sleep

dreamy kestrel
#

fair enough will parse it later

#

love the discussion tho

pulsar bluff
# south swan or `playerSide`

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

meager granite
#

(Typing out the question made me realise what I did wrong and so I figured it out and deleted the question)

queen cargo
#

no js PLEASE

#

replacing SQF wouild only make sense if the new lang would have a benefit

#

JS

#

no

gray bramble
#

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.

manic kettle
#

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

meager granite
#

Initial join? Engine-driven respawn? Scripted respawn?

#

alive player shouldn't return true for initial join from lobby or engine respawns

manic kettle
#

seems to return true on this screen. Doesnt return true on spawn selection screen

#

while {true} do {_state = (alive player); systemChat (str _state);};

meager granite
#

So its scripted respawn, no idea how it works, you probably want to look into its code for useful global variables about its state

meager granite
#

You can check for it instead

#

getClientStateNumber >= 10

manic kettle
#

nice thanks

meager granite
#

Or even getClientStateNumber == 10, depending on what you do

#

So stuff doesn't run when mission is in end screen

dreamy kestrel
queen cargo
#

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

little raptor
south swan
#

sounds like some order of precedence shenanigans blobcloseenjoy

little raptor
#

yeah. if is unary. then is binary. else is binary but with higher precedence than then

south swan
#

and booleans are dirt-low

little raptor
#

if _something then {} else {} -> (if _something) then ({} else {}) ({} else {} translates to [{}, {}])

south swan
#

and {} else {} is glorified [{}, {}]. Man, those things get trippy at times i'm an official slowpoke

granite sky
#

else has special precedence then?

south swan
granite sky
#

oh, it's actually in the list :D

dreamy kestrel
little raptor
#

you can't type binary/unary commands without their args

#

otherwise the game treats them as variables or nular commands, which results in error

south swan
#

calls, waitUntils and so on are the same. Unary call CODE, binary ARRAY call CODE, unary waitUntil CODE...

vocal mantle
#

was it java or javascript?

granite sky
#

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.

opal zephyr
#

Would productVersion work?

granite sky
#

ah yeah, probably

opal zephyr
#

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

granite sky
#

Nah, no-one who edits a PBO ever manages to run the thing IME :P

#

requiredVersion is good though, thanks

opal zephyr
real cape
#

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?

sullen sigil
#

check lifestate after hit eh

little raptor
#

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

real cape
#

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

real cape
little raptor
#

if you check via EH no not really

real cape
little raptor
# real cape 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;
        };
}];
sullen sigil
#

CBA_fnc_execNextFrame does exist notlikemeowcry

vapid scarab
#

is there a function (edit: changed phrasing) for triggering a zeus ping?
I want to script a trigger to do a zeus ping.

little raptor
#

ยฏ_(ใƒ„)_/ยฏ

vapid scarab
#

I said command. I meant function. Or is that still a no?

little raptor
#

still no

#

imagine writing something like this: while {true} do {[player] call BIS_fnc_pingCurator}

vapid scarab
#

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.

real cape
granite sky
#

Shooting a player who's already unconscious would also trigger that.

south swan
#

inb4 checking the current lifeState before next-framing

granite sky
#

There's a feedback tracker request somewhere for a lifestatechanged EH but I can't find it.

granite sky
#

maybe several because the one I did just find is from 2016

little raptor
#

a simple way is just checking the animation state

#

AnimStateChanged EH

#

but it triggers too late

#

not as soon as the target is unconsious

south swan
#

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 blobcloseenjoy

little raptor
#

you wouldn't know who did that to you tho

south swan
#

you also wouldn't if multiple "Hit" EHs including non-player ones arrive at the same frame, tho

real cape
real cape
little raptor
#

plus even if it wasn't really a player, at least that player did shoot. so for all you care he was the cause

real cape
digital hollow
terse pulsar
#

hello anyone here know howto hide the turret interior of a sog tank (trying too make a t-54b missile launcher contraption)

hallow mortar
fair drum
fair drum
opal zephyr
#

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

fair drum
#

yeah shoot it over

granite sky
#

@fair drum Pirate Arma 3. The trouble is that we use stuff from 2.12 and the pirate versions tend to be older.

half sapphire
low zodiac
#

Good evening,
two things:

  1. 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)

  2. If not, is it possible to retain some sort of movement for a unit (like rotational) if it is attached to a object?

fair drum
#

ffv?

low zodiac
#

fire from vehicle

digital hollow
#

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

low zodiac
#

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!

grizzled cliff
#

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.

dreamy kestrel
wise frigate
#

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

dusk gust
wise frigate
#

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

dusk gust
#

Needs to be an object

wise frigate
#

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]";
granite sky
dusk gust
wise frigate
#

I'll try it out and get back to you

cyan dust
#

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

warm hedge
#

I do not think there even is a way. What's your usecase?

cyan dust
warm hedge
#

I meant what could be the benefit for you

cyan dust
#

The benefit is that I will not have to manually delete timestamps every time I want copy-paste dumped info into separate file.

warm hedge
#

Hmm

#

I think you have two options:

  1. Remove the timestamps via regex in your text editor
  2. Use copyToClipboard command instead
cyan dust
#

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

cyan dust
cyan dust
vocal mantle
#

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.

versed belfry
#

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"?

warm hedge
#

I... do not think there is. What's your usecase?

ivory lake
#

set/getVariable

warm hedge
#

Well it would work for some cases and not for some I thought the question is the opposite?

ivory lake
#

ie. missionNamespace getvariable "myStringVariable"

versed belfry
# warm hedge I... do not think there is. What's your usecase?

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.

ivory lake
#

you can just use isNil "_vehicle"

warm hedge
#

Well in this case you can also use isNil {_vehicle}

ivory lake
#

or that

versed belfry
versed belfry
warm hedge
#

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?

versed belfry
warm hedge
#

You may want to check isNil before use this function then

versed belfry
warm hedge
#

Only downside if you've made it sure it is not nil before you run the script

versed belfry
#

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 Salute

rough dagger
#

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).

proven charm
rough dagger
#

Thanks @proven charm Iโ€™ll try that ๐Ÿ‘Œ

unreal heath
#

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.

serene sentinel
#

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?

warm hedge
warm hedge
serene sentinel
#

@warm hedge Magazine is in launcher's magazine slot

warm hedge
#

secondaryWeaponMagazine

serene sentinel
#

so easy... ok ๐Ÿ™‚

#

thanks

warm hedge
unreal heath
#

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.

warm hedge
#

Looks it actually wants gunner or commander to shoot - which basically is [0]

unreal heath
#

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.

meager granite
#

Sometimes I wish we had getPosAGL ENTITY to save on one command from ASLtoAGL getPosASL ENTITY (getPos sucks)

frail vault
#

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?

granite haven
#

exec this on every client when they join

#

Should disable the opening of a dead unit's inventory

frail vault
#

Oh, whao, ok
thanks

granite haven
#

you could do this in init.sqf or initPlayerLocal.sqf

frail vault
#

thank you so much
let me test this out and see if there are any problems
but regardless thank you!

real tartan
#

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

hallow mortar
#

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)

real tartan
#

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 ) ?

hallow mortar
#

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)

fair drum
#

not that I know of. might want to find a sog dev and ask them maybe check #sog_prairie_fire for one of them

sullen sigil
#

if it has no hiddenselections then no it is not possible

hallow mortar
#

Sometimes vehicles have animations for hiding the turret. I don't know if SOGPF tanks have that though.

serene sentinel
#

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];
    };
    
}
granite sky
#

What are the symptoms?

serene sentinel
#

he taking more

#

if _countPicked <= 3 he takes 4

granite sky
#

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

south swan
#

eh, don't mind me

serene sentinel
#

@granite sky looks like it works fine now. Thank you!

winged ice
#

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?

hallow mortar
#

Yes, it's because it's broken :D

winged ice
fair drum
#

how bright? i can run them through lightroom if you want

winged ice
fair drum
#

yes, would have to have a trial one to mess with it

#

to get a value

hallow mortar
#

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)

winged ice
winged ice
fair drum
#

this is - 50 brightness, + 50 contrast

winged ice
fair drum
winged ice
warm hedge
#

Actually I've same issue for ages and somehow and some say they don't. I still have no clue what it is

winged ice
astral bone
#

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

hallow mortar
#

That's certainly one way to avoid an apples-to-oranges comparison; just compare the same apple

astral bone
#

my launcher keeps dying

tardy remnant
#

can anyone help me with the script to have lights automatically turn on when night time hits?

fair drum
hidden finch
#

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;
};
proven charm
real tartan
#

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

digital hollow
#

from 0 to 10 step -1

astral bone
#

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

hallow mortar
#

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.

astral bone
#

I don't necassarily, but I almost always use it so eh

hallow mortar
#

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)

astral bone
#

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

little raptor
astral bone
#

ok- now I need to match direction-
How do I rotate something around a point :]

proven charm
winter rose
#
[
  x * cos angleRad - y * sin angleRad,
  x * sin angleRad + y * cos angleRad,
  0, // Y rotation - 2D only
]
```something like that (in Reforger at least ๐Ÿ˜›)
astral bone
#

but I want it to be 3D xP

winter rose
#

then Maths

#

if you just want a 180, multiply the vector by -1

digital hollow
#

just attach everything to the centerObj, move it, then detach. No fun, I know.

serene sentinel
#

Is there command that returns amount of primarywepon magazines of soldier ?

meager granite
flint topaz
#

I think thatโ€™s an array of all possible magazines the gun can use not necessarily ones a player has

meager granite
#
private _compatible = compatibleMagazines currentWeapon player;
{_x in _compatible} count (magazines player + primaryWeaponMagazine player);
#

will count both inventory and loaded mags, for all muzzles

serene sentinel
#

@meager granite great, thanks

proven charm
#

maybe it also counts grenades

#

yep it seems to work with rifleman but not with grenadier

serene sentinel
#

i checked it, handgrenades and smokes not count

proven charm
#

try grenadier guy

serene sentinel
#

GL is part of primaryweapon , sot it's ok that it count it's ammo

proven charm
#

alright then

meager granite
#

Do compatibleMagazines [currentWeapon player, "this"] if you want only primary muzzle

astral bone
#

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)

tender sable
#

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.

analog cargo
#

Has allowCrewInImmobile stopped working since the latest updates?

astral bone
#

oh wait

winter rose
tender sable
astral bone
#
[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;
};
winter rose
astral bone
#

params will give warning error msg. And I'm just trying to help em ;P

winter rose
#
private _fnc = { params ["_var", 42, [0]]; hint str _var; };
[14] call _fnc;   // hints 14
[nil] call _fnc;  // hints 42
astral bone
#

oh I'm reading their code wrong xD

winter rose
#

(nil can be used to "jump" a function parameter)

astral bone
#

I thought the params was for the spawn

winter rose
#

you are using _numB in the created array before checking its existence

tender sable
#

right.

astral bone
#

also, can do parseNumber

tender sable
#

that's just indicating it will throw an error if done the shorthand way instead of the long way

astral bone
#

I think?

#

oh nvm, it doesn't work x3

tender sable
#

the example is just an example. issue is pasisng in nil but wanting to catch first parameter as being required

astral bone
#

wait, catch why

tender sable
#

oops I got that wrong

tender sable
#

edited comment

winter rose
#

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 ๐Ÿ™‚

astral bone
#

Wait, so, you want it so it stops if nil is provided, or it to fill in a nil with a default value?

tender sable
#

want first parameter to be required (not nil, of specific type) but second can be nil and assigned default if nil or wrong type

astral bone
#

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.

queen cargo
#

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);
};
astral bone
#

unless I'm missing something.

#

wait, wrong thing

#

typeName

#

I always confuse typeName and typeOf xD