#arma3_scripting

1 messages ยท Page 37 of 1

proven charm
#

this is from the wiki: selectPlayer bob;

#

that's how to use it

#

bob could be unit named bob in the editor, for example

light nimbus
#

hmm yeah i tried that in drawdoown 2035 ir didn't work. i renamed my character with zeus enhanced too

#

any ideas?

#

there was a command called something like "no select player" and it just, it worked but it would select a random stationery NPC, and was unpredictable and uncontrollable

winter rose
#

selectPlayer
or selectPlayer, eventually
also selectPlayer.

light nimbus
#

uh, what's different between all those?

#

they all have the exact same text it seems

winter rose
#

none, that's the beauty of it
there is one command to switch player, and that's it

light nimbus
#

oooh you're joking ๐Ÿ˜†

warm hedge
#

Try not troll, Lou! angry_eyes

winter rose
#

yes POLPOX
you can point at a unit and use```sqf
selectPlayer cursorObject;

light nimbus
winter rose
spark turret
#

what is that supposed to mean?


    Move player into given unit. Some usage advices:

        Try avoiding selectPlayer on editor-placed units in multiplayer, as it may, on occasion, lead to some undefined behaviour.
        If you need to selectPlayer into another unit, consider creatingUnit dynamically.

does that say "just dont use it in MP at all"?

copper raven
#

no it says to not use it on editor placed units

light nimbus
#

you're not saying I can't use it on Zeus spawned units right?

copper raven
#

i'm not actually sure at which point its UB

#

i assume maybe if some other player joins and picks that playable unit one used selectPlayer on

#

very vague

nova skiff
#

working on a scenario, onPlayerRespawn.sqf is running on mission start instead of when a player respawns
is there any way to prevent this/why is this happening
respawn on start is disabled

#

(putting this here also, just in case)

hallow mortar
nova skiff
#

godsend

#

just adjusted to respawnOnStart = -1; and onPlayerRespawn.sqf is still firing at mission start

trail smelt
#

In search of a script for animations on a protesting crowd I came across Grumpy's post on bi forums where he publishes his script [Link: https://forums.bohemia.net/forums/topic/215768-scripting-a-group-of-protesting-civilians/?page=2] And when I tried to use this script only as an animation without an attack, this started happening to me on the dedicated server (I removed the part about the attack from init and initserver..)

Dedicated Server:
https://streamable.com/ohh6p1

Eden editor test as MP:
https://streamable.com/9psh9q

Any idea how to fix the animations so they don't make such a mess?

nocturne bluff
#

Anyone know how to disable the keydown serach in listboxes/trees?

versed drum
#

How do I check if a vehicle is alive or not?

#

I am trying to setup a mobile respawn that is dependent on whether or not the vehicle is destroyed or not

brazen lagoon
#

where is onPlayerKilled called?

#

is it only run local to the player or is it global

copper raven
#

and it's local

#

similar to killed eh

brazen lagoon
#

which is to say it will run local to the player that was killed

#

cool thx

copper raven
versed drum
brazen lagoon
#

just easier than dealing with the weirdness of attaching killed EH to a player and then it persisting or not

versed drum
#

if (alive _vehicle) then
    {
        while {true} do
        {
            "Respawn_east_1" setMarkerPos getPos Defender1;
            sleep 2;
        };
    
    }
    else
    {
        Hint "Respawn vehicle destroyed";
    };```
granite sky
#

Well, you have an infinite while loop there?

versed drum
#

I have changed the while loop to also be while {alive _vehicle} do but that doesn't seem to stop the while loop

#

to be fair it is my first time trying to script in arma

granite sky
#

It'll stop the loop, but then it still won't print the destruction message. You need to put the while on the outside.

#

Should work:

while {alive _vehicle} do {
    "Respawn_east_1" setMarkerPos getPosATL Defender1;
    sleep 2;
};
hint "Respawn vehicle destroyed";
versed drum
#

Worked perfectly thank you!
I assume that if I wanted to delete the marker I would simply just add
deleteMarker "respawn_east_1"

#

after the hint ofcourse

granite sky
#

Yes.

versed drum
#

Worked out well, thanks very much!

copper raven
#

huh?

median nimbus
#

prob setting the respawn on unit init and disabling it on kill

granite sky
#

Nah, the slow part is the periodic update anyway. EH is just complicating things there.

#

Assuming that Defender1 is an object that moves.

versed drum
#

I was wondering if it was possible to use an if statement to check if multiple were destroyed and output either a systemChat or a hint message

calm badger
#

id like to use a certain mod's mod.paa in a script

#

but since it's not in a specific pbo and it's just named mod.paa how would i reference it?

#

do i list the filepath as something like @[modname]/mod.paa?

copper raven
#

as your condition

copper raven
versed drum
calm badger
copper raven
#

try \mod.paa

#

with the prefix backslash

calm badger
#

the script is running from another mod and there are other mods loaded which i presume all have their own mod.paa s

copper raven
#

then you're out of luck i think

calm badger
#

alright

copper raven
#

you'd need filepatching for that

#

so you can specify the exact absolute path

copper raven
calm badger
#

the mod is the mod.paa is not

#

by mod.paa i mean the little png that goes next to all the assets that a mod adds to denote what addon its from

#

most seem to be called just mod.paa

fair drum
#

i would just copy the .paa to your mission folder and use it there

tough abyss
#

Not without permission...First.

tough abyss
#

How do CT_GROUPS work?

vapid frigate
#

Not sure, but have you tried setting an onKeyDown or onKeyPress event that returns false?

nocturne bluff
#

I think you mean true, but yes i have. :/

little raptor
#

Do you mean controls group?

tough abyss
#

Yeah

#

Is it basically a way to apply groups of settings to groups of controls?

#

Or does it also work like a container bit like how JFrames work in Java?

little raptor
#

Kinda. You can move, hide and disable a group of controls together, and anything that falls outside the group will not be rendered (you can enable scrolling)

little raptor
little raptor
tough abyss
#

Probably also similar to how a XAML file works too.

#

Container then manipulate the elements inside of the container.

little raptor
#

Yeah kinda

tough abyss
#

SQF uses cpp as a template structure gotcha.

#

Would using an array be a good quick and dirty way of creating typing text?

little raptor
#

Typing text?

tough abyss
#

And is there anything special I need to perform on a UI element to make it attach to the a position in 3D?

#

Go from UI coordinate space to world coordinate space

#

I don't want to use DrawIcon3D it's too limited

tough abyss
little raptor
#

I've never used that fnc. But anyway an array can be used to quickly build strings using joinString

tough abyss
#

Awesome.

#

BIS_fnc_typeText; is pretty useful unfortunately I want it centered.

#

Right at 0.5 0.5

little raptor
tough abyss
#

So maybe just use DrawIcon3D then?

#

I mean it works but lacks the flexibility I wanted.

#

And if I need to stack text below it I can just do pos vectorAdd [0,0,z];

#

or vectorDiff

little raptor
#

You can use ctrls but it has a few problems of its own:

  1. You have to control drawing manually (size, position, when not to render at all, etc.)
  2. You have to perform more calculations so it's slower
  3. The delay problem
tough abyss
#

Must be why Bennies CTI mainly used static targets.

#

Like town locations when drawing the Strategic HUD

#

That one

#

What I am doing is forwarding data from UAV drones to infantry based on how well the drone knows the data.

#

Any command that is good for that?

#

I've been using KnowsAbout too fairly good effort

#

or NearTargets

#

At least NearTargets doesn't update immediately and the drone takes time to map out the data.

nocturne bluff
#

Setting maxHistoryDelay to a really high number seems to keep it away decent enough

little raptor
little raptor
tough abyss
#

NearTargets works,

little raptor
#

There is also targetsQuery

tough abyss
#

What is faster?

little raptor
#

They don't do the same thing so their performance varies. It depends what you want to do.
Since you say you want to know how well it knows the target I'd say use targetsQuery

#

But it's slowish

tough abyss
#

Basically I am polling within limits targets in an "area"

#

Both friendly and enemy but applying drawIcon3D differences when the targets are different sides.

#

Type of targets I am looking for is statics, vehicles, infantry.

little raptor
#

Dunno hard to say which works best. You gotta try them out yourself

tough abyss
#

Yeah figured as much.

#

All good.

pulsar bluff
#

hmm, action menu is hidden when player in steerable parachute?

#

any way around this? like maybe attaching addaction to the parachute itself?

tough abyss
#

How do you flush the UI namespace .paa file cache?

#

SQL DB or NameSpace storage?

copper raven
#

there is no official support for it, so no

#

either make your own extension or use something like extDB3

little raptor
#

or using another name for you paa meowsweats

boreal parcel
#

why isnt this working properly? marker with variable name military_11 exists and is set to colorOPFOR through the eden editor yet the unit still gets hidden

if !(getMarkerColor "military_11" isEqualTo "colorOPFOR") then { 
    hideObjectGlobal this; 
}
winter rose
#

try using == perhaps?

boreal parcel
winter rose
# boreal parcel no change

try then copyToClipboard getMarkerColor "military_11";? this should copy the marker's color to your clipboard

#

if a (non-complicated) code does not work, check the values ๐Ÿ˜‰

boreal parcel
#

good idea lol

#

? its color east

granite sky
#

Where did you get "colorOPFOR" from?

boreal parcel
#

what the hell

#

my bad lol, colorOPFOR came from 2 places, the bohemia color wiki and because when you hover over the color in the editor you get a popup saying colorOPFOR

granite sky
#

but yeah, string matching

#

If you compared the color array it might actually return true :P

hallow mortar
#

If you don't want to guess which of those any given marker uses, you can account for both:

getMarkerColor "military_11" in ["ColorOPFOR","ColorEAST"]```
boreal parcel
#

ah good idea, thank you. I guess thatll teach me to trust the editor popups

warm swallow
#
markers = [];

{
    _marker = createMarker ["marker_" + str _x, getPos _x];
    _marker setMarkerType "o_inf";
    _marker setMarkerSize [1, 1];
    _marker setMarkerAlpha .8;
    _marker setMarkerColor "ColorOpfor";
    _marker setMarkerPos getPos _x;
} forEach vics;

I have this script to, when given an array vics, creates a marker on each of them. Is there a way to make this continuously update. I've tried several ways but it never works.

willow hound
#

Continuously update as in create and delete markers as vehicles are added and removed from vics or continuously update as in update the position of the marker to the current vehicle position?

warm swallow
#

Sorry, I should have been more specific. I mean, update the markers over a set interval for each element in the vics array.

#

So the array remains constant.

hallow mortar
#
while {true} do {
  sleep 1;
  {
    private _marker = ("marker_" + str _x);
    _marker setMarkerPos (getPos _x);
  } forEach vics;
};```
This will update the position of the existing markers once a second; place it after the existing code. It won't account for changes in the array or whether the vehicle is alive or not.
Replace `true` at the start with a bool variable if you want the ability to turn it off later.
warm swallow
#

I just had a thought. The code I've been testing up until now is in the init.sqf file. That wouldn't affect how the code runs, correct?

#

It works! I wonder what I was doing wrong lol, the code you provided was very similar to code I had already tried, hmm. Thanks!

hallow mortar
#

It won't break it, however:

  • You should use the local versions of the marker commands to avoid duplicate markers, since init.sqf runs on all machines
  • Anything you place after the while loop I posted [in init.sqf] won't run until after the loop exits, unless you use spawn to turn it into a separate thread, so watch out for that.
warm swallow
#

I thought the local version of marker would only create it on the machine that it was executed on, no?

hallow mortar
#

Yes, and init.sqf runs on all machines

warm swallow
#

Probably should've mentioned that.

#

Also, just to make sure, to ensure JIP compatibility, I should add an if (isServer) {} around it, right?

hallow mortar
#

That doesn't really have anything specific to do with JIP compatibility, it just makes sure the commands run only on the server. Sometimes that improves JIP handling (prevents global commands being run again later), sometimes it breaks it completely (local commands that need to run on clients won't work).
In this case you do want to only run on the server, since you're using global commands that will take effect on all clients; you can use an isServer check or you can move the code [or the calling of the code] to initServer.sqf

I checked the createMarker docs and it turns out you can't actually create duplicate markers, though you should still avoid using duplicate global commands.

warm swallow
#

yea. I'm going to add an ifServer because this will run after init. Thanks!

warm swallow
#
private txt5Layer = "txt5" call BIS_fnc_rscLayer;

I'm getting an error that this line doesn't have a semicolon for some reason...

granite sky
#

Check the previous line.

#

SQF parser is kinda bad at spotting error locations.

hallow mortar
#

You can't use private on global variables

granite sky
#

oh, lol

true frigate
#

Hey sorry, just a quick question, I'm trying to have a rocket spawn in and destroy a ground vehicle with lock on, like the Titan does, and this script usually works for anything flying, but doesn't appear to for ground vehicles.
Would anyone know why? Cheers ๐Ÿ™‚

_tgt1 = Tgt1;
_missile = createVehicle ["M_Titan_AT",[12702.8,6927.14,4],[],0,"CAN_COLLIDE"]; 
_azimuth = [12702.8,6927.14,4] getDir Tgt1;
_missile setDir _azimuth; 
[_missile,_tgt1] spawn { 
    params ["_missile","_tgt1"]; 
    sleep 0.1; 
    _missile setMissileTarget _tgt1; 
};```
granite sky
#

In what way doesn't it work?

#

I'd have been inclined to give the thing a bit of velocity.

true frigate
#

It doesn't appear to lock onto the vehicle, in the wiki, it says that the return value is true if successful, but mine always returns false on setMissileTarget

granite sky
#

Also if it's ACE the target might need a heat signature.

hallow mortar
#

Is the target warm and in line of sight? The Titan is IR-guided

true frigate
#

I didn't think that would effect the script, but it makes sense

true frigate
granite sky
#

Now curious whether vanilla Titan needs heat. I thought it didn't.

true frigate
#

If you don't mind me asking too, how would you recommend setting velocity for the missile?

hallow mortar
granite sky
#

setVectorDir with vectorFromTo + a bit of Z + vectorNormalized, then setVelocityModelSpace.

true frigate
#

This is gonna be a first for me, but I'll give it a go haha

granite sky
#

Vectors are pretty useful :P

#

hmm, I have this vague recollection that something was too slow for setVelocityModelSpace

hallow mortar
#

Missiles are usually pretty good at providing their own velocity tbh. It might help with the Titan since its acceleration curve is slow as balls, but if it's coming from a ways away it shouldn't make much difference

true frigate
#

It would be nice to know this so I can use it in future though, so if I can get it working now, would be really cool

#

So for my understanding, a vector doesn't follow the object by default if you use something like setDir, so just using something like this

if (!isServer)exitWith{};
_tgt1 = Tgt1;
_missile = createVehicle ["M_Titan_AT",[12702.8,6927.14,4],[],0,"CAN_COLLIDE"]; 

_azimuth = [12702.8,6927.14,2] getDir Tgt1;
_missile setDir _azimuth; 

_missile setVelocityModelSpace [0, 10, 0];

[_missile,_tgt1] spawn { 
    params ["_missile","_tgt1"]; 
    sleep 0.1; 
    _missile setMissileTarget _tgt1; 
};```
Wouldn't give it forward velocity. I need to set the vector first with setVectorDir and vectorFromTo. 
To be fair, I haven't tested this out, this is purely speculation from what I've read on the wiki haha
#

Actually got it right first try lets go.
Probably not a huge accomplishment for any of you, but I'm glad I managed to work that out ๐Ÿ˜„

tough abyss
warm hedge
#

Diagnosis exe lets you to do that

tough abyss
#

You could easily find the vector orientation by using drawLine3D

#

I did something similar to normals on geometry surfaces.

#

E.g the map geometry normals.

#

By converting screenspace to world then adding a vector to the point draw at the beginning of the 3D line

true frigate
tough abyss
#

All game programming is literally the same Model space is different to world coordinate space (Global Coordinate space). Another name for it is Local coordinate space.

#

That is what you'd call it in say blender 3d

true frigate
#

Now that's a software I'm familiar with ๐Ÿ˜„

tough abyss
#

Is it me or does arma 3 try really hard to encourage bad code?

fair drum
#

considering it's written for the lowest common user/unexperienced/casuals, I don't think that's a fair assumption

hallow mortar
#

It's easier to write bad code because good code often requires a deeper understanding of how Arma and SQF works. I wouldn't describe that as trying to encourage bad code, though - it's more of a symptom of the hacky, ancient, and convoluted nature of the engine and language. It's not on purpose, bad code is just the path of least resistance sometimes.

south swan
#

"write once, never touch again, if you need to change anything - rewrite the entire script" ๐Ÿ˜›

pulsar bluff
#

there is merit to writing something simply at first, especially in iterative game design

#

hacking something together in 3 hours, seeing if people like it... if not , then you've only wasted 3 hours ... if so, then yes, take more time to re-write it in a manner which takes into account more edge/corner cases etc

south swan
#

arguably, good code means good architecture. And good architecture either means that user needs to implement it (which takes way more effort than slapdashing a quick and dirty script) or a developer needs to implement it (which frequently leads to very restricting game logic)

pulsar bluff
#

anyone here done a "dynamic groups" system to manage player groups? is it better to create the group locally on the player, or create on server and manage all from server?

south swan
pulsar bluff
#

i use it now but its not a great fit, and has some annoying bugs. also it doesn't fit with my roles system

warm swallow
#

I'm trying to rewrite the following code using RemoteExec so it runs on all clients:

if (isServer) then {
    {
        _marker = createMarker ["marker_" + str _x, getPos _x];
        _marker setMarkerType "o_inf";
        _marker setMarkerSize [1, 1];
        _marker setMarkerAlpha .8;
        _marker setMarkerColor "ColorOpfor";
        _marker setMarkerPos getPos _x;
    } forEach caches;

    {
        [_x, -1] call ace_cargo_fnc_setSize;
    } forEach caches;
};

this is what I have:

if (isServer) then {
    {
        _marker = createMarker ["marker_" + str _x, getPos _x];
        [_marker, "o_inf"] remoteExec ["setMarkerType"];
        [_marker, [1,1]] remoteExec ["setMarkerSize"];
        [_marker, .8] remoteExec ["setMarkerAlpha"];
        [_marker, "ColorOpfor"] remoteExec ["setMarkerColor"];
        [_marker, getPos _x] remoteExec ["setMarkerPos"];
    } forEach caches;

    {
        [_x, -1] call ace_cargo_fnc_setSize;
    } forEach caches;
};

is this correct, and/or how would I use remote exec with call in the 2nd part?

south swan
#

o_O

#

all of the used marker commands are Global Effect ones, so they don't need any remoteExec

#

including the ace_cargo_fnc_setSize, it also has global effect

warm swallow
#

ahhhhhh. I see

#

according to this, should I set the marker as public?

south swan
#

that means "use createMarkerLocal, then setMarkerTypeLocal, then setMarkerSizeLocal, then... and in the end use one global command, say, setMarkerPos"

warm swallow
#

so change all commands to local except the last?

south swan
#

yes

warm swallow
#

gotcha

#
["<t font ='EtelkaMonospaceProBold' align = 'center' size='1.8' color='#8fa1c9'>" + "Phase 1"+"</t>", 0, -.3, 5, 1, 0,_txt5Layer] spawn BIS_fnc_dynamicText;
south swan
warm swallow
#

gotcha

#

I see

#

Hmmmm

#

There is this waning the forums...

#

So how would I execute this on all clients?

south swan
#

"<t font ='EtelkaMonospaceProBold' align = 'center' size='1.8' color='#8fa1c9'>" + "Phase 1"+"</t>" is not a Structured Text, it's a String ๐Ÿคทโ€โ™‚๏ธ

warm swallow
#

One more question, sorry. If I remote exec an entire function, then the contents of that function doesn't have to be remote Exec if it normally would, because it is running on the target machines, correct?

south swan
#

"contents" as in "code"? You only need to remoteExec the function itself, but make sure the function is present on client machines as well.
"contents" as in "arguments"? Arguments get computed on the calling machine and remoteExec sends the already calculated values

warm swallow
#

"contents" as in "code". I'm just not sure whether or not I need to use remoteExec on the function.

#

||```sqf
timer = {
if (isServer) then {
[_this select 0] spawn
{
ELAPSED_TIME = 0;
_duration = (_this select 0) * 60;
START_TIME = diag_tickTime;
while {ELAPSED_TIME < _duration} do
{
ELAPSED_TIME = diag_tickTime - START_TIME;
publicVariable "ELAPSED_TIME";
sleep 1;
};
};
};

if !(isDedicated) then
{
[_this select 0, _this select 1] spawn 
{
    _duration = (_this select 0) * 60;
    while {ELAPSED_TIME < _duration } do
    {
        _time = _duration - ELAPSED_TIME;
        _finish_time_minutes = floor(_time / 60);
        _finish_time_seconds = floor(_time) - (60 * _finish_time_minutes);
        if(_finish_time_seconds < 10) then
        {
            _finish_time_seconds = format ["0%1", _finish_time_seconds];
        };
        if(_finish_time_minutes < 10) then
        {
            _finish_time_minutes = format ["0%1", _finish_time_minutes];
        };
        _formatted_time = format ["%1:%2", _finish_time_minutes, _finish_time_seconds];

        private _h = format ["%2 %1", _formatted_time, _this select 1];
        private _textc = "<t font ='EtelkaMonospaceProBold' align = 'center' size='.5' color='#Ffffff'>" + _h +"</t>"; 
        private _txt4Layer = "txt4" call BIS_fnc_rscLayer;

        [_textc, .95, -.25, 1, 0, 0, _txt4Layer] spawn BIS_fnc_dynamicText;
        sleep 1;
    };
};
}; 

};

#

sorry for the code deump

south swan
warm swallow
#

ah

#

It's been a while since I've used that , thanks for the reminder

south swan
#

if you define the code yourself - it all depends on how and where it's defined. If you define it in, say, init.sqf (or some other script that gets executed everywhere, or in mission's CfgFunctions) - every client and server has the code. If you define it in, say, initServer.sqf (or inside if (isServer) then { block) - it is only defined wherever the code is run and you need to send the function over the network first (i.e. with publicVariable)

warm swallow
#

It's defined in a script that is called with execVM after server init. I'm guessing that, I can just call the function, and broadcast the result by remoteExec the BIS_fnc_dynamicText

#

So I wouldn't need to get rid of the isServer and isDedicated statements

#

Does anyone know what would cause this hint to show up while scripting? I'm not sure if it's something I did or the game.

manic kettle
#

everytime i open this channel i learn something new

manic kettle
warm swallow
#

its unprompted

manic kettle
# warm swallow its unprompted

No clue honestly. Does it persist if you remove calling either BIS_fnc_rscLayer or dynamic text? That would tell you if it originates from something wrong you did for either. If it does persist then it occurs before then

warm swallow
#

hmmm

ripe sapphire
#

yo bros is there an EH for when player remote controls a unit?

ripe sapphire
#

if player remote controls a soldier unit (thru zues not teamswitch) is it considered as new unit or uav in the EH?

winter rose
#

@icy warren wrong channel ๐Ÿ™‚ see below

wicked roostBOT
#

Are you looking to play with people?
pick one channel:
#looking_for_game to tell others you want to play
#looking_for_unit to tell others you are looking for a group
#communities_arma3 to browse through advertised groups

Note: Please follow the templates in those channels (if applicable), and don't use them for discussions.

ripe sapphire
#

damn

winter rose
#

try and thou shalt see?

ripe sapphire
#

ok ill try

#

thanks

drowsy geyser
#

trying to get a few AI's to switch to random animation but right now they all choose the same animation from the array,
How would I get them to choose a different animation from the array?

_randomAnimation = selectRandom [
"Acts_A_M03_briefing",
"Acts_Abuse_Akhanteros",
"Acts_A_M01_briefing",
"Acts_Arrival_Response",
"Acts_BoatAttacked01",
"Acts_Dance_01",
"Acts_Explaining_EW_Idle03",
"Acts_Gallery_Visitor_01",
"Acts_Grieving"];
{_x switchMove _randomAnimation;}forEach (allUnits select {side _x isEqualTo resistance});
finite sundial
copper raven
sharp skiff
#

can someone give me an addaction line that i can add a UAV terminal (nato) to the players Terminal item? im somehow cant get it to work (0 scripting knowledge)

warm swallow
#

Are you talking about the UAV terminal that goes into the player's inventory?

sharp skiff
#

yes

copper raven
#

i don't know the classname though

warm swallow
sharp skiff
#

classname should be easy to look up in the editor it will be added to an object to give the player the uav terminal if he doesnt have one just need to figure out the full line ๐Ÿคฃ thx

drowsy geyser
warm swallow
#

Oh! Well in that case you wouldn't need to add it on the actual UAV item then lol. It can be wherever, it just matters what the logic is.

copper raven
warm swallow
#
{
_randomAnimation = selectRandom [
"Acts_A_M03_briefing",
"Acts_Abuse_Akhanteros",
"Acts_A_M01_briefing",
"Acts_Arrival_Response",
"Acts_BoatAttacked01",
"Acts_Dance_01",
"Acts_Explaining_EW_Idle03",
"Acts_Gallery_Visitor_01",
"Acts_Grieving"];
_x switchMove _randomAnimation;
} forEach (allUnits select side resistance);
copper raven
#

no

warm swallow
#

no?

copper raven
#

you slow down the code for no reason by doing that

warm swallow
#

what's the better solution then

copper raven
#

array literals are expensive

sharp skiff
warm swallow
#

you can just spawn it in the palyer's inventory.? show the code you have so far

sharp skiff
#

sofar nothing as the idea is just there and im currently doing another thing i get to it later

tepid vigil
warm swallow
#

ah.

sharp skiff
#

just needed a hint in the direction as additem was the wrong one

warm swallow
#

so you're good now?

tepid vigil
#

I've been looking to optimize some old config code in the project I am working on, but this is the best I could do, can it be optimized further? Currently running this takes like ~25ms (with RHS loaded)

// Filter the scope only once
private _filteredWeaponConfigs = "
    (getNumber (_x >> 'scope') == 2)
" configClasses (_cfgWeapons);

private _allWeapons = _filteredWeaponConfigs select {getText ( _x >> "simulation" ) == "weapon"};
private _allDetonators = _filteredWeaponConfigs select {getNumber ( _x >> "ace_explosives_Detonator" ) == 1};
private _allAttachments = _filteredWeaponConfigs select {_t = getNumber ( _x >> "ItemInfo" >> "type" ); _t == 301 || _t == 302 || _t == 101};
private _allUniforms = _filteredWeaponConfigs select {getNumber ( _x >> "ItemInfo" >> "type" ) == 801};
private _allHelmets = _filteredWeaponConfigs select {getNumber ( _x >> "ItemInfo" >> "type" ) == 605};
sharp skiff
granite sky
#

Yeah, forEach with cases in commonality order is probably better.

tepid vigil
#

The _allAttachments code would need to be rewritten for that though, I tried adapting it to a forEach loop but I had some difficulty rewriting that particular condition as if statements don't accept variable assignments in the condition

copper raven
#

you can use a hashmap for the last 3

#

as they all check the same thing

granite sky
#

Something like this:

private _typeHM = createHashMapFromArray [
[101, _allAttachments],
[301, _allAttachments],
[302, _allAttachments],
[605, _allHelmets],
[801, _allUniforms]];

{
   if (getText (_x >> "simulation") == "weapon") then { _allWeapons pushBack _x; continue };
   private _t = getNumber (_x >> "ItemInfo" >> "type");
   if (_t in _typeHM) then { (_typeHM get _t) pushBack _x; continue };
   if (getNumber ( _x >> "ace_explosives_Detonator" ) == 1) then { _allDetonators pushBack _x; continue };
} forEach _filteredWeaponConfigs;
tepid vigil
# granite sky Something like this: ```sqf private _typeHM = createHashMapFromArray [ [101, _al...

With this method, it is 2x faster but all the arrays from the hashmap are empty when checked

// Filter the scope only once
private _filteredWeaponConfigs = "
    (getNumber (_x >> 'scope') == 2)
" configClasses (configFile >> "cfgWeapons");

private _allWeapons = [];
private _allDetonators = [];
private _allAttachments = [];
private _allUniforms = [];
private _allHelmets = [];

private _typeHM = createHashMapFromArray [
[101, _allAttachments],
[301, _allAttachments],
[302, _allAttachments],
[605, _allHelmets],
[801, _allUniforms]];

{
   if (getText (_x >> "simulation") == "weapon") then { _allWeapons pushBack _x; continue };
   private _t = getNumber (_x >> "ItemInfo" >> "type");
   if (_t in _typeHM) then { (_typeHM get _t) pushBack _x; continue };
   if (getNumber ( _x >> "ace_explosives_Detonator" ) == 1) then { _allDetonators pushBack _x; continue };
} forEach _filteredWeaponConfigs;

// Verify the sums
[count _allWeapons, count _allDetonators, count _allAttachments, count _allUniforms, count _allHelmets]
copper raven
#

๐Ÿค”

#

thats weird that it copies the values

tepid vigil
#

Appending doesn't work either notlikemeow

_allAttachments append (_typeHM get 101);
_allAttachments append (_typeHM get 301);
_allAttachments append (_typeHM get 302);
_allUniforms append (_typeHM get 605);
_allHelmets append (_typeHM get 801);
copper raven
#

ehh wut, that should work

south swan
#

just for the context: initial configClasses is half of the runtime already. Just {getNumber (_x >> "scope")} forEach _filteredWeaponConfigs would be half of the remainder (quarter of the initial runtime)

granite sky
#

The arrays in the hashmap are stored by reference. Probably something else wrong.

#

hmm, what exactly has simulation == "weapon"?

tepid vigil
#

...weapons? I am not really familiar with the configs actually being looped here, this is from a fork of Overthrow that I am contributing to, and the code is like 4 years old at this point. The config related code has always been messy and buggy

south swan
#

first helmet i've checked has that as well

#

removing continue in the simulation type check gives the sane counts in the end, but doubles the execution time

#

checking for getNumber (_x >> "type") in [1,2,4] for primaries/secondaries/handguns reduces the (long) runtime by roughly 25% ๐Ÿคทโ€โ™‚๏ธ

#

giving (on my machine) 10 ms just for initial configClasses, 15 ms for that + {getNumber (_x >> "scope")} forEach..., 30-32 ms for configClasses + check config type + check for ace detonator + check ItemInfo type

copper raven
#

you should be running this once anyway

#

and caching the result

south swan
#

economy of scale at work. With 2.5k+ classes in the array no matter what you do it'd be slow anyways ๐Ÿคฃ

#

inb4 "run it once during mission creation, cache the result into a separate array in .sqf file, include that with the mission"

tepid vigil
#

And yes, it only runs once and caches

south swan
#

so get whatever is more readable for your eyes and be done with it, i guess ๐Ÿ˜‰

tepid vigil
#

The initialization function where this runs takes like 20 seconds to execute though, and I think it's really absurd and no function should take that long to execute. So I am picking off some low hanging fruits in optimization to try to cut down on that time

south swan
#

20 seconds measured how? Something like logging the timestamps in the beginning and the end?

proven charm
#

run in unscheduled and it will be faster

tepid vigil
#

Just starting the mission and waiting for it to load, there aren't that many functions to execute during initialization so this one must be taking a bulk of the time. 20 seconds is a rough estimate

#

A directCall would certainly be faster, gonna have to try that out

proven charm
#

we should have directCall command ๐Ÿ˜„

#

to run unscheduled

south swan
#

well, there is a isNil {} hack

proven charm
#

yea I know ๐Ÿ™‚

copper raven
#

#define directCall isNil ๐Ÿ˜„

granite sky
#

This is where you implement your own scheduler + isNil to grind config :P

tepid vigil
#

~~Apparently this isn't even getting all uniforms, due to RHS for example using their own types. RHS uniforms are apparently of type = 131072 ~~ Edit: I am dumb (once again) and I wasn't looking at ItemInfo

radiant siren
#

need help with this? wasn't sure to replace first 'player' with _this and then second 'player' with _target? i tried these

if (player distance player < 5) then { 
 hintSilent "Hello there!";  
};
if (_this distance obj1 < 5) then { 
 hintSilent "Hello there!";  
};
if (_this distance player < 5) then { 
 hintSilent "Hello there!";  
};
hallow mortar
#

Need a bit of context here. Where is this code being run?

radiant siren
#

i've tried the init of a player but want to try initpLocal

just tried initplocal, nothing happened. preferably wanting it to with a hint for when a player get's certain distance of another friendly player

hallow mortar
#

An if is a single check at the time the code is executed. If it's not true at the time of that check, it does nothing (or the else code if present) and then continues, it doesn't wait for the condition to become true. For that, you need a waitUntil, or a loop to repeatedly check.

radiant siren
#

it worked but only worked once.

[] spawn {   
 waitUntil {(player distance obj1 < 5)};  
    if (player distance obj1 < 5) then { 
    hint "Hello there!"; 
    sleep 5;
    hintSilent "";
 };  
};

UPDATE:
this works, just dont know if it's bad to do XD

_0 = [] spawn { 
 while { true } do { 
  waitUntil {(player distance obj1 < 5)};  
    if (player distance obj1 < 5) then { 
    hint "Hello there!"; 
    sleep 5;
    hintSilent "";
    };
  }; 
};
little raptor
#
[] spawn {   
 waitUntil {  
   if (player distance obj1 < 5) then { 
      hint "Hello there!"; 
      sleep 5;
      hintSilent "";
   };
   false;  
  };
};
radiant siren
little raptor
#

you mean all other players or just a particular one?

radiant siren
#

all players, preferably friendly players to friendly players?

#

side west & east

little raptor
#

you could do something like:

[] spawn {
    private _removehintTime = time + 5;
    waitUntil {
        {
            if (player != _x && player distance _x < 5 && {
                [side _x, side player] call BIS_fnc_sideIsFriendly
            }) then {
                hint "Hello there!";
                _removehintTime = time + 5;
            };
        } forEach allPlayers;
        if (time > _removehintTime) then {
            hintSilent "";
        };
        false;
    }
}
#

oh and I forgot to add one thing

#

@radiant siren fixed

#

(it would trigger when player was near himself which ofc is always true!)

little raptor
radiant siren
little raptor
# radiant siren awesome! appreciate it as always! ๐Ÿ‘‘ โค๏ธ

no problem. also this should work a bit faster

[] spawn {
    private _removehintTime = time + 5;
    private _fnc_getSides = {
        [east, west, civilian, independent] select {
            [_x, side player] call BIS_fnc_sideIsFriendly
        }
    };
    private _lastSide = side player;
    private _friendlySides = call _fnc_getSides;
    waitUntil {
        if (_lastSide != side player) then {
            _lastSide = side player;
            _friendlySides = call _fnc_getSides;
        };
        {
            if (player != _x && player distance _x < 5 && {
                side _x in _friendlySides
            }) then {
                hint "Hello there!";
                _removehintTime = time + 5;
            };
        } forEach allPlayers;
        if (time > _removehintTime) then {
            hintSilent "";
        };
        false;
    }
}
#

it might be better to use side group player instead of side player tho

#

e.g. when a unit is a captive he changes side to civ

#

so he becomes friendly with other sides (including enemy)

#

but side group player doesn't change

radiant siren
#

ill give it go. ๐Ÿ™‚ ill try all of those options! thank you again! ๐Ÿ™‚

real tartan
#

guys, do you have some ideas to check if light (lamp, gun light, ... ) is pointed at object?

#

e.g. if object is lit by light ( can be partially )

tepid vigil
#

Also, kind of a engine question but why is == often faster than isEqualTo in the evaluation field of configClasses? At least in my tests it is, even though it really shouldn't be

sharp skiff
#

less letters? ๐Ÿคฃ

hallow mortar
little raptor
#

I mean for one things isEqualTo can compare between types

#

so internally it does have a type check

#

while == has overloads for different types

#

but at best it should only be <10-20% faster

#

(which is probably 0.0001-0.0002ms per check)

sharp skiff
#

this addAction ["Give Nightvision googles","[_player linkItem "NVGoggles"]]

#

gives me missing ] what did i miss? (it is set on an object)

little raptor
#

many things...

sharp skiff
#

thought so ... :-I

little raptor
#

your ] is outside the ""

#

and even if it was inside the syntax is wrong anyway

#
this addAction ["Give Nightvision googles", {player linkItem "NVGoggles"}]
sharp skiff
#

hm ok i try that im not good at arma 3 scripting

#

and "not good" is a Hard Understatement!

tepid vigil
sharp skiff
#

now for the next magic trick how to remove a addaction added by the game to an item for pickup neverendingstory

#

OR make the item Respawn after it was taken by the player fml

little raptor
sharp skiff
#

@little raptor that didnt solve the problem as far as i could find out there is no solution to it! (Engine hard coded) if i place a Nvgoogle item on the map it will get the addaction to pick it up no matter what special states the item has suck to be honest but i couldnt find a workaround

#

adding the code in the init just gives it a second addaction!

little raptor
#

I misunderstood your question

sharp skiff
#

yeah my english is not the best

little raptor
#

I thought you wanted that action to disappear

sharp skiff
#

yes sort of BUT the action from the game/engine itself not the user addaction but after reading a bit around this is undoable

#

and i dont know how to respawn items

little raptor
#

well for your question, iirc you can do what you want either by using enableSimulation on the container item or using lockInventory

#

and if that doesn't work you can just remove the actual item and add a prop instead

#
this addEventHandler ["Put", {
    params ["_unit", "_container", "_item"];
        if (_item == "NVGoggles") then {
          _container enableSimulation false
        }
}];
#

try that first

sharp skiff
#

it isnt a container but an item (nv googles) set to pretty much ONLY to show the item (disabled simulation etc. etc.) but it still has the Standard Pickup option

#

will do!

#

1 sec

little raptor
#

and when you put them in your inventory they're placed in your backpack, vest, etc. containers

sharp skiff
#

hm well ok but were do i get a prob then ? there is only the item in the EDEN editor @little raptor ?

little raptor
#
this addEventHandler ["Put", {
    params ["_unit", "_container", "_item"];
        if (_item == "NVGoggles") then {
          _fakeItem = createSimpleObject [getText (configFile >> "CfgWeapons" >> _item >> "model"), getPosWorld _container];
          deleteVehicle _container;
        }
}];
#

this code is not fully done tho because it deletes the whole container (even if it isn't virtual)

#

but give it a try nonetheless

little raptor
sharp skiff
#

welp did nothin uhm ok maybe the item name is wrong 1sec

little raptor
#

how do you test it exactly?

sharp skiff
#

running the mission

little raptor
#

you should drop your own NVG and see if it shows the pickup action for it
it doesn't work with NVG items you've put on the map yourself

sharp skiff
#

uff okay i give up just the addaction with a bright and bigger text let the player find it out

#

@little raptor But thanks for your help!

warm swallow
#

How would I convert setParticleParams to a global command? I've tried this code, but it showed up as invisible when I ran the script with it.

#
[_ps1, [
            ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
            1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
            [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
            [0.25], 1, 0, "", "", _ps1]] remoteExec ["setParticleParams", 0, true];
warm hedge
#

You should remoteExec entire particle commands

warm swallow
#

do you mean remote exec the creation as well?

#

also @warm hedge are there any examples of using remoteExec with particle commands online. I was looking for some reference for it but I couldn't find any.

warm hedge
#

Yes, a particleSource is a local object so

warm swallow
#

ah

deft lotus
#

Quick Question, Maybe someone knows how to do it.

Long story short, Goal is to Disable the Arty computer on specific vehicles (Static Artillery/Static Mortars) but leave it on for Vehicles that would have an artillery computer (Paladin, Himars, MLRS, ect).

Did some digging and found this----> enableEngineArtillery false;

However that just disables it for everything, and if i change the value to true it enables it for everything.

Any possible way to enable it just on specific vehicles?

warm swallow
# warm hedge Yes, a particleSource is a local object so

When I was texting it originally, I had everything at local, and it worked. I changed everything except for the particle creation to use remoteExec, and now they won't show up at all. Shouldn't the changes still be made, if the particle is created on my machine, and then remoteExec executes the params on my machine?

deft lotus
#

MP

#

However doing Testing in SP

warm swallow
#

hmm, It's not possible to remove default actions, so your best bet might be to add an EH for Activate to see if the _activated object was one of the weapons you mentioned

deft lotus
#

Gotcha Thanks ๐Ÿ˜„

warm swallow
#

Yea. Since enableEngineArtillery is local you can set it for each player in MP,.

manic kettle
#

enableEngineArtillery is a local command. So you can use a typeOf to remove it from the ones you don't want it on probably

#

If player is in _whitelistedartillery then enableEngineArtillery true
Else enableEngineArtillery false

manic kettle
#

We gave the same answer tho

warm swallow
#

Nvm sorry, I just meant the naming convention

#

@warm hedge When I create the particle with remoteExec I get an error In my other particle settings saying that it received a string instead of an object.
Here is the relevant code:

private _ps1 = ["#particlesource", _posATL] remoteExec ["createVehicleLocal", 0, true];
        [_ps1, [
            ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
            1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
            [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
            [0.25], 1, 0, "", "", _ps1]] remoteExec ["setParticleParams", 0, true];
        [_ps1, [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0]] remoteExec ["setParticleRandom", 0, true];
        [_ps1, .1] remoteExec ["setDropInterval", 0 ,true];
warm hedge
#

No I meant execute every codes regarded to particle in ONE remoteExec(Call)

warm swallow
#

ah. So I would make the creation into the function and then remoteExec that?

warm hedge
#

No need to make a fnc, you can just pass {} code into a remoteExecCall and ask it to execute a call command on everyone's end

warm swallow
#
{
            private _ps1 = "#particlesource" createVehicleLocal _posATL;
            _ps1 setParticleParams [
                ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
                1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
                [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
                [0.25], 1, 0, "", "", _ps1];
            _ps1 setParticleRandom [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0];
            _ps1 setDropInterval 0.1;
        } remoteExecCall ["call", 0, true];
#

I wrapped the function like you said, but am not getting any result now. @warm hedge

warm swallow
#
private _posATL = (_this select 0) modelToWorld [0,0,-1];
        particle1 = {
            _pos1 = _this select 0;
            private _ps1 = "#particlesource" createVehicleLocal _pos1;
            _ps1 setParticleParams [
                ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
                1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
                [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
                [0.25], 1, 0, "", "", _ps1];
            _ps1 setParticleRandom [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0];
            _ps1 setDropInterval 0.1;
        }; 
        [_posATL, particle1] remoteExecCall ["call", 0, true];

I have since modified it to this, but without getting it to work. The error is stating that _pos1 is an object, not an array, so _ps1 is not defined.

tough abyss
#

what is _this select 0 meant to be?

manic kettle
warm swallow
#

Which _this?

tough abyss
#

Top of the code _this select 0

warm swallow
#

for the line ```sqf
private _posATL = (_this select 0) modelToWorld [0,0,-1];

tough abyss
#

Include the addAction code

#

It's generally better not to use _this select 0 if you can help it.

#

instead unpack it with params

warm swallow
#

Here is the top to where I am, it's pretty big:

{    
    _x addAction ["<t font ='EtelkaMonospaceProBold' align = 'center' size='1' color='#c73c20'>" + "Destroy Cache"+"</t>", {
        caches_destroyed pushBack _this;
        publicVariable "caches_destroyed"; // Updates value

        //(_this select 0) removeAction 1;
        [(_this select 0), 1] remoteExec ["removeAction", 0, true];
        //vehicle (_this select 0) lockInventory true;
        [vehicle (_this select 0), true] remoteExec ["lockInventory", 0, true];
        _txt5Layer = "txt5" call BIS_fnc_rscLayer;
        _txt5aLayer = "txt5a" call BIS_fnc_rscLayer;

        ["<t font ='EtelkaMonospaceProBold' align = 'center' size='1.8' color='#c73c20'>" + "Cache Destroyed"+"</t>", 0, -.3, 5, 1, 0, _txt5Layer] remoteExec ["BIS_fnc_dynamicText", 0, true];
        ["<t font ='EtelkaMonospaceProBold' align = 'center' size='.8' color='#Ffffff'>" + str count caches_destroyed + "/" + str count caches + "</t>", 0, -.15, 5, 1, 0,_txt5aLayer] remoteExec ["BIS_fnc_dynamicText", 0, true];

        private _posATL = (_this select 0) modelToWorld [0,0,-1];
        particle1 = {
            _pos1 = _this select 0;
            private _ps1 = "#particlesource" createVehicleLocal _pos1;
            _ps1 setParticleParams [
                ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
                1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
                [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
                [0.25], 1, 0, "", "", _ps1];
            _ps1 setParticleRandom [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0];
            _ps1 setDropInterval 0.1;
        }; 
        [_posATL, particle1] remoteExecCall ["call", 0, true];
tough abyss
#

Yeah definitely use params

manic kettle
#

params ["_target", "_caller", "_actionId", "_arguments"];

tough abyss
#

^

#

Makes keep track of the variables much easier.

warm swallow
warm swallow
manic kettle
#

I can't tell you why but it also is less fucky with params

#

Yes

tough abyss
warm swallow
#

_this and _target in this context are the same, right?

manic kettle
#

Not exactly, but for your case yes

tough abyss
#
 [(_this select 0),(_this select 1),(_this select 2),(_this select 3)] params ["_target","_caller","_actionId","_arguments"]; 
#

Is essentially what happens behind the scenes

warm swallow
#

I'm still getting the error, hmm

#
{    
    _x addAction ["<t font ='EtelkaMonospaceProBold' align = 'center' size='1' color='#c73c20'>" + "Destroy Cache"+"</t>", {
        params ["_target", "_caller", "_actionId", "_arguments"];
        caches_destroyed pushBack _target;
        publicVariable "caches_destroyed"; // Updates value

        //(_this select 0) removeAction 1;
        [_target, 1] remoteExec ["removeAction", 0, true];
        //vehicle (_this select 0) lockInventory true;
        [vehicle _target, true] remoteExec ["lockInventory", 0, true];
        _txt5Layer = "txt5" call BIS_fnc_rscLayer;
        _txt5aLayer = "txt5a" call BIS_fnc_rscLayer;

        ["<t font ='EtelkaMonospaceProBold' align = 'center' size='1.8' color='#c73c20'>" + "Cache Destroyed"+"</t>", 0, -.3, 5, 1, 0, _txt5Layer] remoteExec ["BIS_fnc_dynamicText", 0, true];
        ["<t font ='EtelkaMonospaceProBold' align = 'center' size='.8' color='#Ffffff'>" + str count caches_destroyed + "/" + str count caches + "</t>", 0, -.15, 5, 1, 0,_txt5aLayer] remoteExec ["BIS_fnc_dynamicText", 0, true];

        private _posATL = _target modelToWorld [0,0,-1];
        particle1 = {
            _pos1 = _this select 0;
            private _ps1 = "#particlesource" createVehicleLocal _pos1;
            _ps1 setParticleParams [
                ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
                1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
                [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
                [0.25], 1, 0, "", "", _ps1];
            _ps1 setParticleRandom [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0];
            _ps1 setDropInterval 0.1;
        }; 
        [_posATL, particle1] remoteExecCall ["call", 0, true];
#

updated code to this point

tough abyss
#
systemChat format ["%1",_target];
``` See what comes back
warm swallow
#

?

tough abyss
#

It's a script debugging technique

warm swallow
#

oh ok

tough abyss
#

hint format ["%1"_somevar];

warm swallow
#

any

tough abyss
#

systemChat format ["%1",_somevar];

#

any?

warm swallow
#

yes

tough abyss
#

Theres your problem no data type.

#

Now find out why there is no datatype

manic kettle
#

It's not getting passed correctly for some reason

warm swallow
#

wait, this might be, but I'm going to restart the mission to make sure somethings not being fucky

#

so tiny bruh

#

Type Number Expected Array

tough abyss
#

Type number expected array

#

Says it all

#

it's getting a number when it should be getting an array

warm swallow
#

so Im probably selecting an element within the pos array

#

yep, just one set of brackets lol

#

I appreciate the help debugging

warm swallow
#

One more question:

Can I combine this code:

particle1 = {
            _pos1 = _this select 0;
            private _ps1 = "#particlesource" createVehicleLocal _pos1;
            _ps1 setParticleParams [
                ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
                1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
                [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
                [0.25], 1, 0, "", "", _ps1];
            _ps1 setParticleRandom [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0];
            _ps1 setDropInterval 0.1;
        }; 
        [[_posATL], particle1] remoteExecCall ["call", 0, true];

to where I call remoteExecCall and have the params in the same line?

tough abyss
#

Yep you can use params to unpack function vars as well

#

Also

#

Avoid complex inline functions you can't debug them.

warm swallow
#

what does that mean?

tough abyss
#

particle = {} is an inline function

#

You can't easily debug it.

warm swallow
#

oh

tough abyss
#

Functions generally make your life easier.

#

Overall.

sinful kayak
#

Does anyone here know how I can set a trigger to an IED that activates when a certain item is picked up?

tough abyss
#

But more complex an inline function the more difficult it is to debug.

warm swallow
sinful kayak
warm swallow
#
particle1 = {
            _pos1 = _this select 0;
            private _ps1 = "#particlesource" createVehicleLocal _pos1;
            _ps1 setParticleParams [
                ["\A3\Data_F\ParticleEffects\Universal\Universal", 16, 7, 16, 1], "", "Billboard",
                1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6],
                [[0.2, 0.2, 0.2, 0], [0.2, 0.2, 0.2, 0.45], [0.2, 0.2, 0.2, 0.45], [0.35, 0.35, 0.35, 0.225], [0.5, 0.5, 0.5, 0]],
                [0.25], 1, 0, "", "", _ps1];
            _ps1 setParticleRandom [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0];
            _ps1 setDropInterval 0.1;
        } [[_posATL], particle1] remoteExecCall ["call", 0, true];
tough abyss
#

Event handler that listens for Get

warm swallow
#

Not a valid combination of expressions?

tough abyss
#
[] spawn {
_container addEventHandler ["Take", {

      params ["_unit", "_container", "_item"];
      // Evil surprise delay by random amount between 1 and 30 seconds
      sleep round((1 + (random 30)));
      _IED setDamage 1;
    }    
}];
};
#

Then put in the code setDaamge on "Mine or IED whatever"

#

If you want to delay it just wrap it in a [] spawn {} call so you can use suspending / delaying

sinful kayak
tough abyss
#

On the container?

sinful kayak
#

Alright

tough abyss
#

If you put something on the ground ArmA 3 creates something called a groundweaponhold

#

Which is literally a container invisible though

#

When you "take" the EH registers a player took it from the "container"

#

Then runs the random sleep timer

sinful kayak
#

Ah that makes sense

tough abyss
#

Going kaboom at a random interval between 1 and 30 seconds

warm swallow
tough abyss
#

Everyone loves the element of surprise I actually wrote something interesting a script that was designed to place IEDs in the most scary way possible terrorism style

#

I made the code look for bushes, rubbish piles, etc

#

And then shove the IED under the bushes.

#

Players hated it.

#

Probably one of my most hated scripts, I said but realism?

#

Don't you want realism?

#

๐Ÿ˜ฆ

warm swallow
sinful kayak
#

I'm hosting a Vietnam OP with my friends and I know one of them likes AKs so I want to rig it ๐Ÿ˜ญ

#

I just hope he picks it up and gets absolutely vaporized

sinful kayak
tough abyss
#

With the random timer might scare the crap out of him.

#

Especially after he picks it up

#

Also

#

You could leverage a grenade pin pulling sound from the game

#

then using playSound3D

#

On the AK I know I am evil.

warm swallow
#

โ€œArma scripting sent me to the ERโ€

#

Hey Chief, since you seem to know a fair bit about locality, I was wondering.

if (isServer) then {
    [] spawn {
        while {true} do {
            sleep 1;
            {
                _marker = ("marker_" + str _x);
                _marker setMarkerPos (getPos _x);
            } forEach vehicle;
        };
    };
};
#

will this update the position for each vehicle (it is being called on the server)

tough abyss
#

Found it.


playSound3D ["a3\sounds_f\weapons\grenades\grenade_pullpin.wss", getPosATL _IEDThing, false getPosATL _IEDThing,1,1,0];
tough abyss
#

Which means any operations will be broadcast across all clients

warm swallow
#

Yep! I thought so just wanted to make sure

sinful kayak
granite sky
#

@warm swallow vehicles rather than vehicle there btw

sinful kayak
#

It gave an error

tough abyss
#

When you do [] spawn {} the scope of variables change

#

same with [] call {}

#

Any local variable outside those commands become undefined unless explicitly passed

sinful kayak
sinful kayak
#

Man i'm so lost

tough abyss
#

You have to define IED

#

Can't use a variable you don't have defined

sinful kayak
tough abyss
#

It has to be an object name

#

In the init field when you "place an object"

#

that is the objects name

#

"IED" means a string if you do this

#
_IED = "IED" // Not an object 
blazing zodiac
#

Hey all, I'm trying to figure out how to reference FSMs registered in the functions library with execFSM?

sinful kayak
tough abyss
#

Did you use the FSM editor to make it?

tough abyss
#

a variable name

#

Then use that.

warm swallow
#

@tough abyss Can I send you some code in private DMs? I'm trying to figure out if execVM is necessary on it.

tough abyss
#

No sorry I have math work to do.

warm swallow
#

no problem, thanks for your help

blazing zodiac
blazing zodiac
tough abyss
#

Not sure.

#

I've never worked with FSMs personally.

granite sky
#

I'm not even sure that you can register them in the functions library.

#

All the FSM commands take a filename.

tough abyss
#

If you use the addons creator

#

It will unpack all the A3 .pbo data files

#

Inside there is a missions_f look at the FSM code in that

#

for one of the missions

blazing zodiac
#

but there's no example

tough abyss
#

Is there any particular reason you are using an FSM instead of a script?

blazing zodiac
#

I'm using it for the high level "brain" for helicopter based reinforcements on an area. Just using to to clean it up instead of having a mess of conditionals for that piece. Each state and condition just call a function dedicated to them so the code is all still well separated and the high level logic is extremely easy to understand and adjust

tough abyss
#

Huh. I just realised i could build a tool using powershell for looping through all my directories and building a cfgFunctions.hpp automatically...

#

powershell or python

#

Wonder if thats how the CBA_A3 guys did it. hmmm.

#

Yep looks like it is

open fractal
#

this is the way

tough abyss
#

System Agnostic.

#

So I might go that route unless Ruby is better.

open fractal
#

easy script either way if we're just talking cfgfunctions

tough abyss
open fractal
#

I got deja vu and looked it up

#

we already talked about this lmao I used a batch script and you said use powershell

tough abyss
#

Yeah powershell is far far more flexible.

#

More expressive too.

#

And allows things like parallel work jobs etc.

#

As I said Python and Ruby are more OS Agnostic.

open fractal
#

unless you're the type of maniac to install powershell on Mac and Linux

tough abyss
#

Powershell is uniquely OOP based from the core.

#

.... Going off topic.

open fractal
#

i concur

tough abyss
#

Hmm I just worked out how to get the gradient of a terrain element. Get the position using ScreenToWorld [0.5,0.5] convert that to a point add a vector to the tip after obtaining the normal.

#

Then take the vectorCross product. of the point

#

Giving the normal end.

#

Then the gradient perpendicular to the normalSurface. which you can then take the vector Diff of the cross product to reverse the vector arrow, giving you a tangent line to the surfaceNormal

tough abyss
#

And then you just find the gradient using the end points of the vector.

wanton swallow
#

Is it possible to exclude vehicle from targets list or prevent target detection?

tough abyss
#
group forgetTarget target 
#

Don't people ever check the wiki?

#

:S

warm swallow
#

Hello! I was doing some bug testing with a friend for the script I wrote, and for some reason the text, that appeared on his screen was cut off from the top, while on my screen it appeared as normal. Here is the relevant code below:

#
["<t font ='EtelkaMonospaceProBold' align = 'center' size='1.8' color='#8fa1c9'>" + "Mission 1"+"</t>", 0, -.3, 5, 1, 0,_txt5Layer] remoteExec ["BIS_fnc_dynamicText", 0, true];
["<t font ='EtelkaMonospaceProBold' align = 'center' size='.8' color='#Ffffff'>" + "Sabotage the Boats"+"</t>", 0, -.15, 5, 1, 0,_txt5aLayer] remoteExec ["BIS_fnc_dynamicText", 0, true];
novel delta
#

Does anyone have suggestions for how i could modify this script to only allow certain entity names use it?
so for example Player1 and Player2 could use it but Player3 and so on couldnt?

this addAction ["Teleport", {player setPos (getPos TP1)}];
pulsar bluff
#

any way to get the cloud height (distance from ground to cloudbase) for a terrain?

manic kettle
novel delta
manic kettle
#

Right
Tpaccessbase1
Tpaccessbase2

novel delta
#

Thanks a bunch

warm hedge
#

A true is not equal to a "true"

tough abyss
#

"true" == "true" is true but true is a boolean value

warm hedge
#

Also an addAction is a local command, you can if ing to execute addAction

#

Or... yeah addAction's condition would work

manic kettle
#

Yeah agreed. If statement to add teleport addictions is obviously better, just a step more complicated. Not by much

warm hedge
#

If your teleport ability can be enabled or disabled mid mission, condition solution is the goto

manic kettle
#

Good point. Say a base is overrun and you want to disable that tp or something

novel delta
#

the intent for this was just so that I can restrict arsenals to specific roles by having them spawn in a different location and teleport to/from the main base
i.e so a regular soldier isnt grabbing a sniper kit

manic kettle
robust crystal
#

in my mission there is this script with intro and music at the beginning of the music, however it only works when the mission has respawn, because I want to do the same thing with the intro but only with a mission that does not have respawn (one life mission), is it possible and does anyone know what changes need to be made

#

this is the script, working with respawn

hallow mortar
#

Move it from onPlayerRespawn.sqf to init.sqf

robust crystal
#

but in init.sqf

#

this is in file

#

do i need this thing?

#

playmusic "intro";

hallow mortar
#

I don't know, do you want to play the music track "intro" at the start of the mission?

#

If you do, then leave that in there and just add the other script as well. If you don't, then remove it.

robust crystal
#

actually it is not necessary because the music is triggered by another script

hallow mortar
#

Also I'm concerned about your file names. I'm worried that because you have file extensions turned off, your init.sqf may actually be "init.sqf.txt" or something like that. I really recommend turning on "show file extensions" in Explorer.

winter rose
#

ooooooh yes.

arctic haven
#

Whats the best way to countdown a trigger from deactivating? I am running a scenario where the players will only get shot at while holding weapons. so ive set a trigger Condition: currentWeapon player != "" Activation: player setCaptive false Deactivation: player setCaptive true . i want to add like a 30 second timer so that if a player puts up his weapon mid combat he will still be shot at. any ideas?

winter rose
#

scripts

warm swallow
#

@winter rose if the x or y position or BIS dynamic text is greater than 1, will it show clipped off of the screen. I have a script using it and on my screen it shows as normal near the top while for the other person is shows clipped at the top? Any ideas how this inconsistency could happen.

winter rose
warm swallow
#

Appreciate it!

tough abyss
#

We can now check that with params instead.

warm swallow
#

Is there a better alternative to dynamic text now? I donโ€™t need the text to be dynamic lol

tough abyss
#

What do you want it to do?

#

there is BIS_fnc_typeText1 and BIS_fnc_typeText2

#

If that is your goal.

warm swallow
#

It just matters about the text positioning

hallow mortar
#

You can always ctrlCreate your own rscStructuredText element

winter rose
royal bramble
#

I'm having issues with running this script in a object init on a dedicated server as it works in singleplayer.

nul = [this] spawn { params ["_unit"]; sleep 1;
private _myArray = missionNamespace getVariable "TFI_Arsenals"; 
_myArray append [_unit];};

This perfectly appends the object in an array in singleplayer however it gives this error on the server.

copper raven
royal bramble
#

In initPlayerLocal

copper raven
#

server doesn't run that init script (dedicated), thus it's undefined there

royal bramble
#

Why does the object not get append on the client?

copper raven
#

actually you probably have a race condition

#

what's that sleep 1 for?

#

you just try to play waiting games with the init script?

#

best thing to do would be to ensure that it's defined in the initbox

royal bramble
copper raven
#
private _myArray = missionNamespace getVariable ["TFI_Arsenals", []];
_myArray pushBack this;
missionNamespace setVariable ["TFI_Arsenals", _myArray];
next kraken
#

hi @ all. im searching for a solution for making my script start only if the loading screen in a MP session is finished. the sound is allready there, but still my loading screen, (takes about 10 secounds) and then the script is allready running. also, is there a good function to snycronize missions scripts till all players are loaded in and the mission loading screen is gone ? thx !

royal bramble
copper raven
#

this isn't replacing anything

royal bramble
gritty garnet
#

How can i script a SA-20 using pook mod pack. Just trying to learn here

shut reef
#

How does a change of locality affect event handlers?
Like, when I add a Killed EH to a vehicle and several different players hop in the driver seat?
Cause that should change the locality of the vehicle to the driver, right?
Does the EH have to be added on all clients then, or how does that work?

little raptor
#

Does the EH have to be added on all clients then,
yes

#

or use MPKilled

shut reef
#

Right, thanks, I forgot that existed

little raptor
shut reef
#

what would that look like?

#

In this case I think MPKilled is best, cause I really only need to know about it on the server

little raptor
#

it's arg local

#

you should do it via Local EH if you wanted to go that way

little raptor
shut reef
#

But that would necessitate code to check if locality changed, would it not?

#

Cause it's local here now, then someone else becomes driver, whoops, locality changed and the EH is useless

#

So instead of tracking locality, MPKilled is easier, is it not? Then I only need to check if I'm the sever and I'm done

hallow mortar
#

The Local event handler fires when locality changes

shut reef
#

oh! Right, I read that wrong, I thought it was the keyword local

#

But still, if I just want to make sure that the server learn of the vic being killed MPKilled is easier, or not?

#

Cause otherwise I would have to manage the EH on the client that loses locality, otherwise I run the risk of adding it twice if locality changes back to that client

south swan
#

just add it everywhere, it will only fire where locality is at that point ๐Ÿคฃ

shut reef
#

Code path starts on the server, 0 benefit to doing that xD

little raptor
#

even if you add it to one PC

shut reef
#

Which is fine, cause it will ensure that the server also knows about it.

hallow mortar
#

It looks like the name of the action includes a number, presumably the index of the throttle you want to adjust which can be 1, 2, or 3 (aircraft can, in theory, have multiple engines with separate throttles). So e.g. planeOne action ["ThrottleFull1",planeOne]; to adjust engine 1's throttle.
However, because this action isn't fully documented, and there are several similar actions related to things that aren't simulated in Arma 3, like the APU and engine starters, it's very possible that it's a Take On Helicopters action that isn't fully implemented in Arma 3. I would not count on it working.

cedar cape
#

how would i do FOB creation

#

placing down objects/vehicles isnt an issue, i can do this with a mod

#

but how would i make it so players can turn it into a spawn point

cedar cape
#

no but

#

like

#

in game

#

without stopping

#

like the players can place down a respawn

cedar cape
hallow mortar
#

You have to configure respawn in Eden (or description.ext) in order to use it at all in the mission.
Once it's configured, you can use the script commands and functions (mostly functions) linked on that page to control it.

stable dune
#

In EH, you cannot change the local var, there must be a global var that is used

#

Yeh,

hallow mortar
manic kettle
little raptor
#

removeallMissionEventHandlers "Draw3D";
plz don't...

#

if it's for test it's fine

finite lion
#

Anyone ever thought about making a script that somehow detects the hill markers on the map?

#

I've been wondering if that's even possible

manic kettle
finite lion
#

thank you very much

#

You're an angel

#

๐Ÿ™

#

I've got a quite big list of information to gather before mixing and writing of scripts to accomplish my goals.

#

:) I decided to go back to arma 3 scripting and mission editing after a big while (2 years? I don't even know anymore XD)

tough abyss
#

Getting enemies into buildings is a little bit harder but not very, I've written a drawIcon3D before to loop through all the buildings mount points.

#

Dynamic spawn script eh also not too difficult might be a good idea to leverage the dynamic simulation system to improve mission performance

pulsar bluff
sharp tusk
#

So, I want to create a Huron box that spawns a vehicle, and then deletes the box, but I want to avoid calling on the object variable, so that I can place down a large number of these without changing the variables throughout the script for every single one

#

But when I call on this within the addAction script, it doesn't understand

#

suggestions?

warm hedge
#

Always post what exactly you've done, sir

sharp tusk
#

Sorry

#
call{ 
 this addAction["Warthog FAV",    
  {    
   _position1 = getPosATL creator_1; 
   _rotate = getDir creator_1;  
   _hog1 = createVehicle ["OPTRE_M12_FAV", _position1, [], 0, "CAN_COLLIDE"]; 
   _hog1 setDir _rotate; 
   deleteVehicle creator_1
  }  
 ]; 
};
#

This works

#

creator_1 is the variable name of the Huron Container

#

But I need to not have a variable name that needs changing

#

Because I want to copy/paste like, 30 of these

#

into a mission

tough abyss
#

Loop through the object containers "huon containers"

hallow mortar
#

https://community.bistudio.com/wiki/addAction
In the code field of the addAction, you can place this:

params ["_target", "_caller", "_actionId", "_arguments"];```
This will allow you to reference `_target` instead of a fixed variable name
tough abyss
#

then decide which side you want to spawn them on

tough abyss
#

Might be a good idea to make the box non-colliding.

#

Spawn a Warthog on the box without disabling collision bad things will happen.

#

You should add a contingency check to see if the box is intersecting with the vehicle

sharp tusk
hallow mortar
#

Just change the order of the lines so the box is deleted before the vehicle is spawned. You've already saved its position so you don't need it any more, and it's a simple way to avoid any problems.

sharp tusk
#

Thanks, I went and did that after thinking about it

cedar cape
#

how do i make it so players can place down a respawn

#

to make a fob

strange spade
#

if (isServer) then {
[respawn_vehicle, "respawn_west"] spawn {
params ["_veh", "_mk"];
while {sleep 10; true} do {
_mk setMarkerPos (getPos _veh);
};
};
};

cedar cape
#

i want it so its like the fob creation in KP liberation

#

problem with a vehicle respawn is they would spawn in the vehicle

#

and if it gets exploded it ruins it

#

i want it so the FOB will always stay as a respawn

strange spade
#

Wrong, my way you spawn outside and you can set the vehicle to be invulnerable

cedar cape
#

i see, could you make the vehicle something tiny or invisible

#

like the zeus mechanic

#

blufor respawn

#

is it possible to make it so players can place one of these

#

well only certian people

#

but yeah

strange spade
#

I've only done it with a vehicle but I suppose you could do the same with something like a road cone

cedar cape
#

could i make it like the blufor respawn object

#

or somebody in zeus could do it

#

however

#

if it was done in zeus how do i make it carry into restarts

#

i have alive which is for the asymetric mission and its all persistent

#

but as far as im aware it only saves markers and objects placed by players, not a respawn placed by zeus

strange spade
#

That's why I have it linked to a vehicle. If you move things with zues it won't save the new position. With a vehicle you can move it with zues, get in and out and it will save the new position

cedar cape
#

when it restarts

strange spade
#

Have not tested that.

cedar cape
#

alr

#

i will ask on the alive discord then

strange spade
#

Tested it quickly. Alive did NOT save the zues placed respawn

finite lion
south swan
#

what's a "memPoints texture"?

manic kettle
cedar cape
#

along with other thins, but the persistence feature saves things placed by players when the server restarts

#

like if use the R3F Logistics mod (alive compat version) and place down objects with that, if you have alive and persistence enabled it all saves when the server restarts

manic kettle
#

Yes I'm aware how r3f works. I'm taking about tying the respawn point adding to one of those objects. So if it's created, it's also a spawn

cedar cape
#

i was hoping i could get it to work with the zeus respawn though

#

since it may be bugged if its an object

#

the easiest option might be to make it a tent actually

#

one of those dome tents from combat patrol and then just make it a respawn

#

or something else like that

#

how would i make this spawnable in the r3f factory though?

little raptor
#

yes iirc

#

actually no I was thinking of PIP meowsweats

#

if I recall correctly

#

like I said I confused it with PiP

#

like mirrors

#

not sure about MFD

manic kettle
# cedar cape so how do i do it?

Well again there's a few ways.
You could make a script that searches for all items of a classname and then applies the spawn at that position. This could run every 1to5 minutes or so. That's probably the easiest way

hallow mortar
cedar cape
dusk shadow
#

Sanity check needed about trigger locality and deleting editor placed triggers:
So afaik an editor-placed trigger is a "global" in the sense that each machine (server/client) maintains a local copy of it which can be changed at will with setTriggerActivation etc without out affecting the copies of the trigger on other machines.
And deleteVehicle is an AG EG command, so what happens when a client calls deleteVehicle on their local copy of the trigger? Is the trigger deleted for all or only for the client executing the deleteVehicle?

winter rose
heavy lily
#

Missing some nuanced thing here, trying to get a custom sound file to play. Script looks like this:

speaker_1 say3d ["gametime", 50];

Desc.ext looks like this

{
    tracks[]={};
    class track01
    {
        name = "gametime"; // Name for mission editor
        sound[] = {"\gametime.wav", 1, 1.0};
        titles[] = {0, ""};
    
    };
};```

Getting a sound not found error. Sound file is in the mission folder
dusk shadow
heavy lily
#

same folder

dusk shadow
# heavy lily same folder

couple of things to try, first double check your spelling (assume you've done that), try removing the first , confirm that wav is supported (tbh i've been using ogg and wss so long i dont remember which are supported...)

heavy lily
#

yeah, tripple checked spelling, and I used wav like a week ago

dusk shadow
#

first *backslash

heavy lily
#

ah ok

#

still no dice after removing the \

dusk shadow
#

when changing mission config remember to go to editor and save. that usually updates it

#

before previewing again*

heavy lily
#

Aight running again, one sec

#

Negative

#

I think I'm just gonna change over to playsound3d

#

It'll let me define the damned file path

hallow mortar
#

say3D uses the config class name, not the display name

#

In that case, track01

kindred zephyr
manic kettle
#

I have a question on something that's been bothering me for a while. Let's say I'm making a local variable
_myvar = 1
Why do people define it instead by
private _myvar=1 ?

Wouldn't it already be local to whatever you're working in?

warm hedge
#

If you don't private it, it exists in every scope of the script. If you do, it only exists in the innermost (and its children) scopes. It is nice to have if you want to include a call in the script so it won't confuse variables

manic kettle
#

So if I don't private it and do
Call someotherscript.sqf
That script can access _myvar without passing arguments?

warm hedge
#

I... do think that is false, variables in outer scope can be accessed whatsoever, it is rather the way not to bring inner var into outer

manic kettle
#

Let's assume I'm executing this code on some object, a vehicle. What is an example of an outer scope?

copper raven
copper raven
copper raven
# manic kettle That makes sense, thanks.

_var = 4; // introduces a new _var
this is assuming that we're in the top level scope, if for example this script was called from some upper scope that had _var defined, it would instead assign to it

#

always private your variables, this way you ensure you don't fall into some debugging headaches ๐Ÿ˜„

manic kettle
#

Will do

winter rose
#

and have a giggle by yourself when you write private _parts;

heavy lily
#

[0, "BLACK", 5, 1] spawn BIS_fnc_fadeEffect; isn't fading to black, vision is just getting blurry...what'd i get wrong

tough abyss
#

is setOvercast a humidity variable?

peak pond
#

Hi, I want to add a Hold Action at a certain position. Is there some invisible dummy object I can use to register the action on to simulate this?

tough abyss
#

BIS_fnc_holdAction is the function name

peak pond
#

Yes, I"m wondering what dummy object I can use.

tough abyss
#

What sort of thing is it meant to do?

peak pond
#

In this mission there is a gigantic alien turret (OPTRE Tyrant) big enough to walk inside. I want the player to approach "the core" inside it and execute a hold action.

tough abyss
#

You can use any object.

#

Then disableSimulation to freeze it.

#

then hideObject true

#

Then you should still be able to interact with it via holdAction

peak pond
#

Does the hold action still work if disableSimulation and hideObject?

#

testing...

tough abyss
#

Yeah test it.

pulsar bluff
#

What is the standard way to do a display when opens on a key press and closes when the key is released? the issue arises when the display is opened "key down", the key events stop functioning so the "key up" is not detected.

#

i have tried adding the "key up" in new display but result is not great

tough abyss
#

onKeyUp onKeyDown

#

?

#

Key events shouldn't stop functioning for no reason.

peak pond
# tough abyss Yeah test it.

Just tested it, hideObject breaks the hold action. I assume it's because the object cannot be the player's cursorTarget if hidden.

tough abyss
#

Hmmmm.

peak pond
#

That's why I'm wondering if there is a good dummy object that can be used without being hidden. Like something that is big enough to be a cursorTarget, but transparent or invisible.

tough abyss
#

Grass cutter?

#

Thats invisible

#

But an object it just cuts grass away

peak pond
#

Nope, just tested

#

hmmm

tough abyss
#

Wonder if createSimpleObject allows init fields

peak pond
#

I added the hold action to the grass cutter, but I think it doesn't work since it can't be the player's cursorTarget.

tough abyss
#

Don't use cursorTarget to trigger

#

it use the params _caller

#

_caller is the object the holdAction is attached to

peak pond
#

I'm not using cursorTarget directly... I assumed that's what BIS_fnc_holdAction uses internally.

tough abyss
#

I have the source code for it I'll have a look

peak pond
#

I'm just doing a basic BIS_fnc_holdAction with "true" as the show condition.

tough abyss
#

Nope no CursorTarget

peak pond
#
my_objective_hold = {
    params ["_target"];
    [
        _target, "Set Tactical Nuke", "", "", "true", "true",
        {}, {}, {systemChat "Hold Action triggered"}, {}
    ] call BIS_fnc_holdActionAdd;
    hideObject _target;
};
#

Ok, well regardless of cursorTarget it doesn't work with a grass cutter, but does work with "visible" objects like a balloon or basketball. It also doesn't work if the target object is hidden.

tough abyss
#

6: CODE - code executed on start; arguments passed into it are [target, caller, ID, arguments]
0: OBJECT - target (_this select 0) - the object which the action is assigned to
1: OBJECT - caller (_this select 1) - the unit that activated the action
2: NUMBER - ID (_this select 2) - ID of the activated action (same as ID returned by addAction)
3: ARRAY - arguments (_this select 3) - arguments given to the script if you are using the extended syntax

#

_this select 1 is what you want.

#

That is the "caller" or the object performing the action.

#

cursorTarget is a horrible way to addActions without adding some checks.

#

Use in the condition section how close the player has to be to the object

peak pond
#

Sorry if I wasn't clear. I'm not using cursorTarget, and I know how to use BIS_fnc_holdAction, I use it all the time. The issue is that I need to use it on an object that is not visible to the player.

tough abyss
#

(_this select 1) distance2D (_this select 0) <= 60;

#

You should still be able to get the object.

#

Give it a variable name then hide it

#

See if the object exists.

peak pond
#

Yes, I hid the object. Problem is, once the object is hidden, the player cannot look at it and get the UI to start the hold action. I edited my above code snippet for clarity.

hallow mortar
#

There is an Invisible Wall object that you can use as a dummy for actions. It does have collision, but it's not too big so it's reasonably easy to disguise.

peak pond
#

Perfect. The invisible wall works. Thank you.

agile cargo
#

is there a knowsAbout that target a side?
I need to know if a specific group sees a side

warm hedge
#

In theory one cannot see a side. If you mean if one sees an unit from a certain side, you can probably iterate units

agile cargo
#

Yeah, any unit from a certain side

#

The idea is group X from opfor will fire flares if they see any indfor

warm hedge
#

Then units Independent findIf {OPFOR knowsAbout _x > 1} != -1 is a good way to do I think. Not tested, I'm on the phone

agile cargo
#

that could work, but what about I just loop this in a pfh:
combatBehaviour scout_group == "COMBAT"

#

the group would start on SAFE

#

if they switched to combat, I can assume they saw some shit

pulsar bluff
#

reposting a question that got buried ๐Ÿ˜„

#

What is the standard way to do a display when opens on a key press and closes when the key is released? the issue arises when the display is opened "key down", the key events stop functioning so the "key up" is not detected.
i have tried adding the "key up" in new display but result is not great

warm hedge
#

You can use a EH to detect change behavior

foggy hedge
#

Is there any command to get compatible ammo for a underbarrel grenade launcher (without knowing the muzzle name beforehand)? For main muzzle I can use CBA_fnc_compatibleMagazines or vanilla equivalents, but I'm unsure of how to apply this to UGL muzzles since the UGL muzzle config name changes depending on the mod author's naming conventions.

warm hedge
#

without knowing the muzzle name beforehand
Why? You can just fetch it from config

gusty path
#

Hmm this seems nice

copper raven
patent yarrow
#

Not particularly a major question. But does someone have the helmet randomizer script handy? Im at work rn and i wanted to look at it on my down time and i dont have access to my main pc

hallow mortar
#

I'm not sure there is a "the" helmet randomiser script. There are essentially two basic ways to do it and neither requires more than a couple of lines of code.
You can use https://community.bistudio.com/wiki/BIS_fnc_unitHeadgear to randomise headgear and facewear, or you can just make an array of helmet classes, use selectRandom to pick one, and use addHeadgear to apply it.

meager granite
#

Is there an addon\mod that lets you edit terrain live and then export your changes as setTerrainHeight array(s)?

cosmic lichen
#

Didn't @split coral did that?

split coral
#

Yeah. No proper exporting function in the mod yet though. But the changed heightmap can be copied fairly easily from 3den

pulsar bluff
#

found an ammo type id like to use for artillery but cant find a way to use it (compatible magazine)

#

"M_Mo_230mm_AT_LG"

#

and "R_230mm_LG"

#

"12Rnd_230mm_rockets" only seems to fire unguided "R_230mm_HE"

proven charm
#

or compatibleMagazines [weapon, muzzle] ?

pulsar bluff
#

yep, all i have is the cfgammo i want .. cant find the cfgweapon or cfgmagazine for it tho

#

looking for laser guided MLRS

meager granite
queen cargo
#

"@Cheaters"?

#

what is that strange role?

split coral
#

I'm away from my Arma at the moment, so I won't try to remember the specifics, but the heightmap in the mod is handled in two formats. The other is a simple hashmap with 2D positions as keys and altered/original Z as values. The other format is a bit more complex array with a rudimentary compression and is stored as a scenario attribute. The hashmap will be easier to convert to usable array.

gusty path
#

XD

#

Douggem going to be in their soon :D

copper raven
foggy hedge
# warm hedge > without knowing the muzzle name beforehand Why? You can just fetch it from con...

Could you please tell me how I could pull it from config? I've looked through some cfgWeapons for various mods and many UGLs are named differently ("EGLM","UGL", "gp34", etc) and most of the examples I've seen online assume that you know the muzzle config name beforehand. I've done some stuff with fetching names from config before but I'm not versed enough in it to figure this out unfortunately.

Example from CBA (how can I find the proper _glMuzzle for any given _rifle?):

_mags = [configFile >> "CfgWeapons" >> _rifle >> _glMuzzle] call CBA_fnc_compatibleMagazines
warm hedge
#

configFile >> "CfgWeapons" >> _rifle >> "muzzles" defines what it is as an array, if it has multiple muzzles it should return like ["this","EGLM"]

lavish ocean
queen cargo
#

still dont rly got why ... anyway

lavish ocean
#

cause i can always ban them later ;)

fallen locust
#

i guess you were not in skype @a2EOL chat @queen cargo

hollow stirrup
#

Whats fonz classed as a cheater for?

#

Other than obvious, or is it so?

lavish ocean
#

wonders why someone ask why well known Cheater is marked as Cheater in @cheaters rights group

queen cargo
#

nope @fallen locust

fallen locust
#

it was... interesting

lavish ocean
queen cargo
#

well dwarden :P because he is not well known to me ^^

spark turret
#

is there a way to make arma accept comments in editor-init fields?

#

if not, i would like to talk to a manager

#

whats a proper way to check in sqf if ACE is present?
apart from sth along isNil "ace_function"

sullen sigil
#

hit EH doesn't fire when hit by FFV from unit inside of vehicle but does when same unit is outside -- anyone else having a similar issue?

foggy hedge
foggy hedge
foggy hedge
sullen sigil
#

nvm, hit eh doesnt work from ffv if AI is on careless for some reason

winter rose
sullen sigil
hollow stirrup
#

I thought this was general misclick, no idea who he was and thought it may have been a joke

#

My bad <3

sullen sigil
#

cant find any steps to reproduce even with modded, seems super inconsistent but its definitely happening thonk

winter rose
#

"Hit" does not always trigger, too

sullen sigil
#

seems to be much more common when used with ffv
however i was testing with a blackhawk so rotary cannons probably trigger it enough lol

copper raven
spark turret
#

is there a function to get the first x elements of an array as a new array?

#

_myArray[0:10] ?

spark turret
#

aah thanks

lavish ocean
#

if it was joke, i served him as deterrent example ;)

pale glacier
#

Hello!
Need an advice..
I got this script, basically meant to loop an animation and to break the loop (and the animation) if shots are fired near the AI.
It works BUT the AI will keep doing his animation till the while loop ends and only then he'll stop it.

How do I make him stop the animation instantly once the shots are fired?

keepup = true;
0 = dude4 spawn {
    waitUntil {time > 0};  
    dude4 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";  
    while {keepup} do { 
        waitUntil {animationState dude4 != "AmovPercMstpSnonWnonDnon_exercisePushup"};  
        [dude4,"AmovPercMstpSnonWnonDnon_exercisePushup"] remoteExec ["playMove",0,True];} 
    };

this addEventHandler ["FiredNear", { keepup=false; dude4 switchMove ""; dude4 removeEventHandler ["FiredNear", _thisEventHandler]}];
open fractal
manic kettle
#

Oh so if I have an active script going with a while loop or waituntil going you can end it with terminate?

open fractal
#

alternatively you can add a check like

waitUntil {animationState dude4 != "..."};
if !keepup exitWith {};
``` to prevent the script from continuing
open fractal
#

animation can be confusing so you might get other suggestions for best practice

copper raven
#

just replace waitUntil {animationState dude4 != "AmovPercMstpSnonWnonDnon_exercisePushup"}; with if (animationState dude4 == "AmovPercMstpSnonWnonDnon_exercisePushup") then { continue; };

#

also add a small sleep

open fractal
#

if I recall correctly playMove does not need to be executed on all clients, just the object's owner. There may be weird behavior if you execute on all machines

copper raven
#

it'd be better if you used anim event handlers instead

pale glacier
#

Thanks lads, I'll try

pale glacier
pulsar bluff
meager granite
# split coral Yeah. No proper exporting function in the mod yet though. But the changed height...

Wrote a small function to turn your 3DEN attribute's GF_deformString made by DEFORMER into setTerrainHeight array and apply it:

// Params: String
// Returns: Nothing
fnc_applyDEFORMER = {
    private _array = call compile (_this select [1,1e6]);
    private _grid = getTerrainInfo # 2;

    private _sets = [];
    {
        private _grid_x = _x # 0;
        for "_i" from 1 to count _x - 1 do {
            private _y = _x # _i;
            private _grid_y = _y # 0;
            for "_j" from 1 to count _y - 1 do {
                _sets pushBack [
                     _grid * _grid_x
                    ,_grid * (_grid_y + _j - 1)
                    ,_y # _j
                ];
            };
        };
    } forEach _array;

    setTerrainHeight [_sets];
};
```posting in case somebody finds it through search:
- Call with "x[..." string from `mission.sqm`'s `GF_deformString` attribute
- Does NOT support `adjustObjects` flag as I personally didn't need it
#

Usage in another mission without addon enabled

#

Again, thanks for the great addon.

split coral