#arma3_scripting

1 messages Β· Page 125 of 1

west portal
#

ok thanks

stable dune
#

Well Lou explained better how to use it.

proven charm
#

can you somehow get pointer to the debris left from destroyed building?

#

I mean debris that belongs to the destroyed building

granite sky
#

@proven charm Yes, using the BuildingChanged mission event handler.

#

Bear in mind that it won't work with BIS_fnc_createRuin.

hushed tendon
#

Is there a way to use setObjectTexture on objects that do not have hiddenSelections? or some other way to color the object?

grizzled cliff
#

and got the memory leak fixed

grizzled cliff
#

Sweet, I'd consider this to be low level complete. You can call sqf functions, get values, get data out of values, and free memory.

#

It is also thread safe

round scroll
#

what are you doing?

grizzled cliff
#
    void threaded_invoke_demo() {
        while (true) {
            
            game_value player = invoker::get().invoke_raw("player");
            
            game_value pos_val = invoker::get().invoke_raw("getpos", &player);
            game_data_array *pos = (game_data_array *)pos_val.data;



            float x = ((game_data_number *)pos->data[0].data)->number;
            float y = ((game_data_number *)pos->data[1].data)->number;
            float z = ((game_data_number *)pos->data[2].data)->number;
            
            invoker::get().release_value(&player);
            invoker::get().release_value(&pos_val);

            LOG(DEBUG) << "Thread ID " << std::this_thread::get_id() << " Player Pos: [" << x << "," << y << "," << z << "]";
            Sleep(10);
        }
    }
#

^ that is what i am doing :D

cosmic lichen
#

You can attach a user texture object and set the texture on that.blobcloseenjoy

meager granite
#

How come you can have Explosion event handler but not HitPart with _isDirect=false? πŸ€”

#

Just noticed this for a first time

#

First shot: Explosion only
Second shot: HitPart (both for _isDirect being true and false), then Explosion

fleet sand
#

Quick question does anybody know how to extend turret of a ED drone ? via script ?

hallow mortar
meager granite
#
17:55:13 ---------------------------------------------------------
17:55:13 "Frame 214804: HandleDamageVehicle: C_Hatchback_01_sport_F (ALIVE=true)"
17:55:13 ["13ddaf30080# 1782913: hatchback_01_f.p3d (C_Hatchback_01_sport_F)","wheel_2_2_steering",0.00864477,"B Alpha 1-2:1 (Sa-Matra) (B_MBT_01_cannon_F)","Sh_120mm_APFSDS_Tracer_Red",3,"B Alpha 1-2:1 (Sa-Matra) (B_Soldier_F)","hitrf2wheel",false]
17:55:13 ---------------------------------------------------------
17:55:13 "Frame 214804: Explosion: C_Hatchback_01_sport_F"
17:55:13 ["13ddaf30080# 1782913: hatchback_01_f.p3d (C_Hatchback_01_sport_F)",0,"1782915: shell_tracer_red.p3d (Sh_120mm_APFSDS_Tracer_Red)"]
#

0.008 damage to wheels

#

Damn this sucks, gonna have to account for this edge case now

#

Damage only happens to wheels (and 0 total), maybe its some hardcoded behavior to destroy car wheels, thus skip of HitPart?

#

Bigger explosion properly triggers all event handlers

#

Guess this 0 damage of Explosion makes the engine skip HitPart? Yet this 0 does a tiny bit of damage to wheels.

#

I wonder what this 0 in Explosion even means then

meager granite
little raptor
#

I was just double checking if it's related to my changes

meager granite
#

How I tested it:

  1. Hatchback and Slammer
  2. Add all 3 EHs to Hatchback (HitPart, Explosion, HandleDamage)
  3. Shoot AP round close to Hatchback into the ground
sullen marsh
#

@grizzled cliff i'd love that

#

Even just to see how it's done

velvet merlin
#

whats the most simple/reliable way to make something from a mod to be executed clientside once a mission starts/once the player is in the mission?

#

postInit via cfgFunctions?

grizzled cliff
#

whats your github

sullen marsh
#

Verox-

grizzled cliff
#

with a -

sullen marsh
#

wiith the tac at the ne

#

dyeah

#

Someone from germany stole Verox : <

#

He never even commits

granite sky
#

Only reasonable way really?

grizzled cliff
#

lol

#

added

little raptor
#

I was thinking KK added a new EH for that in 2.16

#

But looks like not

sullen marsh
#

Awesome, thanks nou : D

grizzled cliff
#

i think ima spend the rest of the night commenting

drowsy geyser
#

does the command ctrlSetAngle not work for a progress bar using RscProgress ?

#

Syntax: control ctrlSetAngle [angle, centerX, centerY, now] Parameters: control: Control - picture control
ah so guess it does only work for pictures?

warm hedge
#

Yes, it should work only for pictures

hallow mortar
#

Be pretty cool if there was rotation support for other control types though

proper sigil
#

Could someone advise how to go about a following problem?

I want a script that attaches an action to vehicles to be executed on both vehicles placed in editor and on those placed in zeus session. For no I tried to go around it this way:

        if(typeOf _x in tinyCargoSize) then {
        
            [ _x, 2] call ace_cargo_fnc_setSpace;
            
            [_x, "vehicle", 0, 0] execVM "DNT_supplies\DNT_createSupplies.sqf"; //Claim is only available at the beggining but it dissapears after aborting and joining again
            
            _x addMPEventHandler ["MPKilled",{
                params ["_unit", "_killer", "_instigator", "_useEffects"];
                
                [0,_x]remoteExec ["removeAllActions"];
                [_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf"; 
                _unit removeMPEventHandler ["MPKilled", 0];
                
                 
            }
            ];
        };
... more lines similar to those above
}forEach vehicles; //This part is responsible for executing code on vehicles placed in Editor



{
    _x addEventHandler ["CuratorObjectPlaced",{
        
        params ["_curator", "_entity"];
        private _targetType = typeOf _entity;
        
        
            
        if(_targetType in tinyCargoSize) then {
            [[_entity, "vehicle", 0, 0],"DNT_supplies\DNT_createSupplies.sqf"] remoteExec ["execVM"]; 
            [_entity, 2] call ace_cargo_fnc_setSpace;        
            _entity addMPEventHandler ["MPKilled",{params ["_unit", "_killer", "_instigator", "_useEffects"]; 
            
                [0,_unit]remoteExec ["removeAllActions"];
                [_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf"; 
                _unit removeMPEventHandler ["MPKilled", 0];
                }
            ];
        };
... more lines similar to those abov

}forEach allCurators; //This part is responsible for executing code on vehicles placed by zeus```
#

Problem with this is I'm getting weird behavior in MP like for example actions are only seen by first player joining and then after respawn they dissapear and so on. Ones that are in MPKilled eventhanlder works fine though so I wonder whether it would be possible to achieve similar goal using some different event handler?

#

I noticed there is an EH "Init" but I'm not sure how to use it as it's limited to use in config files only according to Biki?

open hollow
#

its quite slow, but probably _vehicles = [worldsize/2, worldsize/2] nearobjects worldsize will work better

sharp grotto
#

That's faster i think

{
        
} forEach entities [["Car","Helicopter","Truck_F","Ship","Tank"], []];
proven charm
#

vehicles returns more than just driveable vehicles, it also returns static objects

proper sigil
#

Yeah ik, but later I filter the vics I want anyway, I have desired vics divided into arrays like here if(_targetType in tinyCargoSize) then {...

tame coral
#

Does anyone know how to return a number from a script?
I've made a script that gets a players role description and then sets a variable to a number based on the result. I just need to somehow get that result into the trigger that calls it.

this is the basic script I used just for testing:

myNumberFunction = {
    // Your logic to calculate the number
    // For example, let's say you want to return the result of adding two numbers
    _result = 5 + 3;

    // Use the return statement to return the result
    _result
};

so in the trigger that calls this script we want to get "_result"

hint format["Result: %1", call myNumberFunction];

meager granite
#

ChatGPT bad

#
private _result = call myNumberFunction;
maiden garnet
#

hey everyone, i remember finding a script that made it so all curator spawned units would be disabled from fleeing, but i lost it on my old hard drive and can no longer find it

tame coral
meager granite
#

Excessive amount of comments for each line points at script being generated by ChatGPT

tame coral
#

I don't know what chatgpt is

dreamy kestrel
#

Q: this morning about HashMapObjects, and in particular about #Flags, what are they, and are they enumerated, documented, apart from createHashMapObject wiki page? thanks...

little raptor
tame coral
#

a friend who has poor internet connection he might have gone to the wiki maybe?

dreamy kestrel
heavy iris
#

Hello. Why does this code endlessly create a Speed ON action and not disable acceleration by Speed OFF?

_uid = getPlayerUID player;
_name = name player;
_ULTRA_UID = ["Deleted","Deleted"];

if (((_name find "TO" != -1 or name player find "TOS" !=-1) || (_uid in _ULTRA_UID)) && (alive player)) then {
    
    removeMissionEventHandler ["EachFrame",SKX_speedster];
    SKX_SpeedyON = player addAction ["<t color='#f4e541'>Speed ON</t>", 
    {
        params["_Speedy"];
        //["Speedy"] call ace_advanced_fatigue_fnc_removeDutyFactor;
        ["Speedy",0.48] call ace_advanced_fatigue_fnc_addDutyFactor;    
        SKX_speedster = addMissionEventHandler ["EachFrame", 
        {
            player setAnimSpeedCoef 1.5;
        }];
        _speedy removeAction SKX_SpeedyON;
        
        SKX_SpeedyOFF = _Speedy addAction ["<t color='#f44167'>Speed OFF</t>",    
        {
            params["_Speedy"];

            ["Speedy"] call ace_advanced_fatigue_fnc_removeDutyFactor;
            ["Speedy",1] call ace_advanced_fatigue_fnc_addDutyFactor;

            _speedy removeAction SKX_SpeedyOFF;
            removeMissionEventHandler ["EachFrame",SKX_speedster];
            sleep 2;
            ["Speedy"] call ace_advanced_fatigue_fnc_removeDutyFactor;    
            _speedy execVM "scripts\arf\moveSpeed.sqf";
            
        },[1],10,false,true,""];

    },[1],10,false,true,""];
};
drifting dome
#

I'm making a mission and want a trigger to check if two players are present before playing a music track.

The current code I have looks like this (image 1), the stuff between the red lines is what I'm concerned with, everything else works. It allows me to input this without throwing an error, but upon triggering it in the mission I get this error (image 2), any tips?

Sorry I can't type in the code like you, not currently at my PC, Thank you :)

hallow mortar
#
if (this && Z && ...```
Your issue is here. `Z` is an object (I assume, since you're doing setCaptive on it). `&&` requires the code on both sides of it to evaluate to either `true` or `false` (Boolean data type). You're providing it with something that evaluates to an Object data type.
little raptor
#

the issue is that this is not defined

hallow mortar
#

There are two issues 🀷

little raptor
hallow mortar
#

Well, you can just remove the reference to this (in On Activation) entirely - you don't need to worry about whether the trigger's condition is satisfied, because the trigger wouldn't have activated if it wasn't

eternal spruce
#

is it possible to have multiple on activation in a trigger, for example i have four objects (cargo 1-4) and i want each of them to be teleported using setPos, how do I set up the condition for each object to be teleported individually when it is entered in the trigger area

drifting dome
#

I'm booting the game now so I'll see soon if removing this works

hallow mortar
# eternal spruce is it possible to have multiple on activation in a trigger, for example i have f...

You can't have multiple On Activations.
You can set up the trigger so that it doesn't actually matter which object activates it.

// Condition
([box1, box2, ...] findIf {_x in thisList}) > -1

// On Activation
{
  // if they each have a separate specific target pos, this is a little more complicated, but it can be done
  _x setPosASL destinationPosHere;
} forEach ([box1, box2, ...] inAreaArray thisTrigger]);```
hallow mortar
drifting dome
#

yes I want to only play it once both players are present in the area

#

I will try this in a moment, thank you so much

#

So my code now looks like this (btw how do you do those fancy text boxes?), and no longer throws an error, however it still doesn't play the music?

UndercoverZ enableSimulation disable;
Z setcaptive false;
if (Z in thisList && Infil1 in thisList) then {
playMusic AmbientTrack01a_F_Tacops;
};

hallow mortar
#

playMusic requires a "string" for the track classname

#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
↓

// your code here
hint "good!";
drifting dome
#

oh I just gotta put it in parentheses?

#

the music I mean

hallow mortar
#

"quotes", not (parentheses)

drifting dome
#

oh yeah sorry I misremembered the name pikachusurprised

dreamy kestrel
#

Q: on HashMapObject, how would I facilitate calling a #base method from the context of the same derived method?

drifting dome
#

So my trigger code now looks like this, again no errors, but also no music, I've tried directing the playMusic function to the tracks actual file placement /A3/Music etc but that didn't work either.

UndercoverZ enableSimulation disable;
Z setcaptive false;
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
};
#

my music volume is on, just in case jazzskull

hallow mortar
#

Add some systemChat at various places to indicate which bits are being executed and which aren't

#

Oh hold on

#

enableSimulation, you can't use literally the word disable unless you saved a bool to a variable with that name

#

It has to be a Boolean value, true or false

drifting dome
#

oh I saw somewhere that disable was usable but yeah that makes sense

#

I'm very much new to this so stuff like that I have no clue of πŸ˜…

#

systemchat is just this right

systemChat "Message"
hallow mortar
#

Yes, but don't forget ; for end of line

drifting dome
#

where does systemchat show messages?

#

cause I didn't see any at all

#

nvm I was editing the wrong trigger nootnoot

#

It now looks like this, however the music is still not playing... On the plus side, the trigger and enemy script weren't actually working before, I just kinda assumed they were without testing it really, but now they are! so thank you very much! actualjakeLove

UndercoverZ enableSimulation false;
systemChat "Trigger deactivated";
Z setcaptive false;
systemchat "Enemy set";
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
};
systemchat "Music playing";
#

all the systemChat messages are shown

stable dune
#

put in if

hallow mortar
#

Move the "music playing" systemChat inside the then { };.
At the moment, if the if condition fails, the playMusic will be skipped but the systemChat will still be sent

#

Based on the systemChats that are being seen, I think the if condition is probably failing

drifting dome
#

yeah ok I low-key assumed that would be the case, but I just tried to make it as simple as possible for my pea brain

true frigate
#

Hey! Quick one here that I'm struggling with. Is there a way to select a random number between 2 numbers that isn't weighted? I'm looking between -90 and 90, but adding 0 to mid makes most results come out around that value (obviously πŸ˜„ )

drifting dome
#
UndercoverZ enableSimulation false;
systemChat "Trigger deactivated";
Z setcaptive false;
systemchat "Enemy set";
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
systemchat "Music playing";
};

This good?

hallow mortar
#

yes

drifting dome
#

yeah the music playing systemchat is not being shown now

hallow mortar
true frigate
#

It doesn't have to be ridiculously optimised, it's just for a little thing. Thanks! πŸ™‚

granite sky
#

(random 180) - 90

little raptor
#

what's wrong with random [-90, 0, 90]?

hallow mortar
granite sky
#

It's gaussian according to the description.

hallow mortar
#

also Zeus modules don't move when the Zeus camera does so be sure you're checking the right thing

drifting dome
eternal spruce
#

I'm the OP asking weather a trigger can have multiple on Activations. Regarding the objects having multiple destination you said i could be done, could you please elaborate on that for me

stable dune
drifting dome
#

wait I'm confused what does this do?

stable dune
#

i will systemChat conditions of Z in thisList, Infil1 in this and another way check is your object in area of trigger, is inArea.
Like Nikko said, if you have other side that actives, it wont show up in thisList. But inArea it will.

drifting dome
#

wait so I should change from thisList to inArea?

stable dune
#
UndercoverZ enableSimulation false;
systemChat "Trigger deactivated";
Z setcaptive false;
systemchat "Enemy set";
systemChat format ["Z in thisList: %1, Infil1 in thisList: %2", Z in thisList, Infil1 in thisList];
systemChat format ["Z in inArea: %1, Infil1 inArea: %2", Z inArea thisTrigger, Infil1 inArea thisTrigger];
if (Z in thisList && Infil1 in thisList) then {
  playMusic "AmbientTrack01a_F_Tacops";
  systemchat "Music playing";
};
if (Z inArea thisTrigger && Infil1 inArea thisTrigger) then {
  playMusic "AmbientTrack01a_F_Tacops";
  systemchat "Units inArea - Music playing";
};
drifting dome
#

wait isn't thisList and inArea doing the same thing here? wouldn't I only need one?

stable dune
drifting dome
#

aight thank you :)

#

So the trigger now looks like this (i decided to separate them and have one trigger for the music and one for the undercover script, just to make it a bit simpler)

//Activation = Anybody

//Condition
Z in thisList && Infil1 in thisList

//On Activation
systemchat "Trigger fired";
systemChat format ["Z in thisList: %1, Infil1 in thisList: %2", Z in thisList, Infil1 in thisList]; 
systemChat format ["Z in inArea: %1, Infil1 inArea: %2", Z inArea thisTrigger, Infil1 inArea thisTrigger]; 
if (Z in thisList && Infil1 in thisList) then { 
  playMusic "AmbientTrack01a_F_Tacops"; 
  systemchat "Music playing"; 
}; 
if (Z inArea thisTrigger && Infil1 inArea thisTrigger) then { 
  playMusic "AmbientTrack01a_F_Tacops"; 
  systemchat "Units inArea - Music playing"; 
};
drifting dome
#

ok so even thisList works now??? I removed the entire section of inArea just to see and it's still playing? what kinda wizardry did you do???

drifting dome
#

how would I go about making this a continuous evaluation? as in the rest of the script will execute without this until both players are in the area, and without the trigger being reactivated this will activate?

if (Z inArea thisTrigger && Infil1 inArea thisTrigger) then {   
  playMusic "AmbientTrack01a_F_Tacops";   
  systemchat "Units inArea - Music playing";   
}; 
#

if it's even possible

granite fog
#

is someone know how to get size of object in X and Y coordinates ?

real tartan
#

what class should I use to filter anything that can't assign loadout ( objects, vehicles, bunnies, snakes, ... ) ?
for now I have

if ( not ( _unit isKindOf "CaManBase" ) ) exitWith {};

what class should I use to eliminate rabbits or any units, that I can't use loadout on ?

real tartan
granite fog
#

it returns not correct dimensions. I need a size of marker like this one in 3den

hallow mortar
granite fog
eternal spruce
#

Does anyone see what's wrong here

{
_x setPos [4727.579,1853.876,0.067];
} forEach ([cargo_1, cargo_2,cargo_3, cargo_4, cargo_5, cargo_6] inAreaArray thisTrigger]);

I'm getting an error saying i'm missing a ")"

hallow mortar
#

It's actually an extra ] after thisTrigger

eternal spruce
#

sorry its still saying error

drifting dome
eternal spruce
#

That didn't work either now i'm missing a ;

winter rose
#
{
  _x setVehiclePosition [4727.579, 1853.876, 0.067]; // might I add
} forEach ([cargo_1, cargo_2,cargo_3, cargo_4, cargo_5, cargo_6] inAreaArray thisTrigger);
hallow mortar
#

Lou described the problem accurately
* and so did I :U

eternal spruce
#

@hallow mortar & @winter rose thank you, yes you were both correct there was an error on my end and i didn't noticed

raw meteor
#

as far as i can tell by looking at everything on the web this should work but the addCuratorEditableObjects gives an any type error.
what am i doing wrong here?

there are units in the group

_infantryGroup = createGroup [east, true];
{
_unitsAray = units _infantryGroup;
_x addCuratorEditableObjects [_unitsAray select _forEachIndex, false];
} forEach allCurators;
warm hedge
#

Which line throws the error?

raw meteor
#

23:18:56 Error in expression <{
_unitsAray = units _infantryGroup;
_x addCuratorEditableObjects [_unitsAray se>
23:18:56 Error position: <addCuratorEditableObjects [_unitsAray se>
23:18:56 Error Type Object, expected Array
23:18:56 File new_3.sqf..., line 29

warm hedge
#

Ah well I see. addCuratorEditableObjects does not take an object but an array, so no need to use select there, if your intention is to make the entire units of _infantryGroup editable

#

Your idea of the code is actually broken, though. Even if it does throw no error, it is going to add nothing to curators

raw meteor
#

i see that fixed it thanks

meager granite
#

Anybody likes the idea of OBJECT = OBJECT || OBJECT?

private _unit_or_vehicle = if(isNull _from_unit) then {_from_vehicle} else {_from_unit};
```=>
```sqf
private _unit_or_vehicle = _from_unit || _from_vehicle;
#

More complex example:

private _unit_or_vehicle_or_player = _from_unit || _from_vehicle || player;
warm hedge
#

So if X is null, X || Y should return Y, otherwise X?

meager granite
#

Yes

#

Or null if both are null

warm hedge
#

Not sure if there is a reason to limit this functionality for OBJECTs if we have one

meager granite
#

Yeah, it could work with other null-able types

#

|| might be a bit confusing since people could expect it return boolean

#

Maybe ifNull is a better name to disassociate from booleans

warm hedge
#

Honestly I don't think an operator should be used in this idea

meager granite
#
private _entity = _unit ifNull player;
warm hedge
#

Not a hard job for a SQF function, though

meager granite
#
private _unit_or_vehicle_or_player = _from_unit ifNull _from_vehicle ifNull player;
warm hedge
#
notNull [X, Y, Z]``` or... dunno, whatever the name is
meager granite
#

selectNotNull?

#

I like it being binary command though, trying to avoid creating arrays as much as possible

#

muh microseconds

warm hedge
#

findIf + select functionality is something good to have actually

meager granite
#

Otherwise you have to put the array and index into variables to then do select

warm hedge
#

I mean combine two commands into one. Instead of returning the index, return the value there instead

meager granite
#

Yep

#

ANY = ARRAY selectFindIf CODE

warm hedge
#

I think that is a better way to implement your idea

meager granite
#

Had a need for opposite for selectMax/selectMin few times too

#

but not in performance critical part

warm hedge
#

Of course I'm not a coder nor Bohemian so yeah, just throw a ticket and pray

meager granite
#
[_from_unit, _from_vehicle, player] selectFindIf {!isNull _x}
#

Wonder if it will be faster than say

_from_unit ifNull _from_vehicle ifNull player
meager granite
warm hedge
#

I actually just realized I really don't know what is Simple VM is, I guess

meager granite
#

It supposed to optimise single command iterators to run without creating script context for each iteration

#

I'm still not sure if it works and how well it works, waiting for docs from dedmen to explain it exactly

#

selectFindIf won't return null if all are null though

#

gonna have to check for isNil later for default value

formal stirrup
#

There an eventhandler to handle when a prop gets hit?

meager granite
#

EPEContactStart?

formal stirrup
#

Would bullets trigger that?

sullen sigil
#

hitpart should work

#

can put it on the projectile if need be

formal stirrup
#

Did indeed work, thanks kj

proven charm
#

how do you make guy sit on correct direction when sitting on char? I have this: ```sqf
[_off,"SIT"] call BIS_fnc_ambientAnim;

_off attachTo [_chair, [0, 0, 0]];

_off setdir (getdir _chair);

warm hedge
#

attachTo'd setDir is relative to the attached object here

proven charm
#

ok

#

i thought it might be but dont know how to fix

sullen sigil
#

vectorModelToWorld

#

will need vdir tho

proven charm
#

that's bit over my head but thx

hallow mortar
#

For a simple direction like facing the right way on a chair, you just need to know that 0 is now whichever way the chair model considers to be forward

#

So depending on whether the chair is oriented forwards, backwards, or sideways in its model space, you'll need either 0, 90, 180, or 270; objects aren't usually oriented at odd angles.

heavy iris
warm hedge
#

By using some dlls, I guess

little raptor
#

Technically yes. But it's not easy

#

You can't show it in A3 itself. But you can show it as an overlay

meager granite
#

Weren't some life mods rendering a browser into a texture so it displayed youtube videos or something?

#

Probably can be done the same way

little raptor
#

Well you can render it to a texture but you can't display it directly

#

If they were rendering to a texture they probably used a temp file to load it into Arma

#

You can't really do that with a game

sullen sigil
#

if you can change the engine rate for doom you can probably slow it down enough

#

bonus points if you put it onto one of the mfd for a blackhawk

still forum
still forum
meager granite
#

I still like binary command that returns null if both operands are null

#

selectFirst would return nil

#
private _unit_or_vehicle = if(isNull _from_unit) then {_from_vehicle} else {_from_unit};
```vs
```sqf
private _unit_or_vehicle = _from_unit ifNull _from_vehicle;
```vs
```sqf
private _unit_or_vehicle = [_from_unit, _from_vehicle] selectFirst {!isNull _x};
if(isNil"_unit_or_vehicle") then {_unit_or_vehicle = objNull};
little raptor
meager granite
#

ifNull could accept any types, check if both operands are of same type and of null-able types

meager granite
little raptor
#

Ofc it is

meager granite
#

NULLABLE ifNull NULLABLE would still be faster though

#

for two items at least

little raptor
#

Stupid name

meager granite
#

Yeah, I don't like it that much either

#

orIf?

#

orIfNull?

little raptor
#

Β―_(ツ)_/Β―

#

Still not much better

meager granite
#

or, || could be confusing when reading the code and thinking if these are bools or not

#

|ifNull|

meager granite
#
private _unit_or_vehicle = _from_unit Β―\_(ツ)_/Β― _from_vehicle;
little raptor
#

Well it's still a good method name for hashmap objs

little raptor
#

So it won't work anyway

meager granite
#

left operand or if null, then right operand

#

if both are null then result will be null

tribal creek
#

hello

#

i currently have a script here thats tied to a trigger

#

i was told that it will not run on a dedicated server can anyone help he convert it ?

#
_screen = "Monitor_1" createVehicle (player modelToWorld [0, 10, 0]); 
_screen setObjectTextureGlobal [0, _video]; 
[_video, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false]; ```
#

fyi my coding skills are non existent

meager granite
#

trigger's activation field?

#
// Only do stuff on server to ensure stuff only runs once
if(isServer) then {
    // Abandon script if monitor already exists
    if(alive(thisTrigger getVariable ["screen", objNull])) exitWith {};

    // Get players from list of entities that triggered the trigger
    private _players = thisList select {isPlayer _x};
    if(count _players > 0) then {
        // If there are any players in the trigger, use first one to spawn the monitor near them
        private _player = _players select 0;

        // Spawn monitor and save it into trigger so it knows there is already one
        private _screen = createVehicle ["Monitor_1", _player modelToWorld [0,10,0], [], 0, ""];
        thisTrigger setVariable ["screen", _screen];

        // Setup the video
        private _video = "imgs\Uav_Intel.ogv";
        _screen setObjectTextureGlobal [0, _video];
        [_video, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false]; 
    };
};
#

Wrote this, didn't test

#

might work

tribal creek
# meager granite trigger's activation field?

whoops sorry this is whats in the triggers activaion field

Monitor_1 setObjectTextureGlobal [0,_video];;  
_screen setObjectTexture [0, _video];  
[_video, [10, 10]] call BIS_fnc_playVideo;```
meager granite
#

this code won't work, first one might in SP

#

anyway try my attempt

tribal creek
#

hm ok

tribal creek
meager granite
#

Sort of

#

I don't know how activation field triggers exactly to tell

tribal creek
#

ok so i modified your script a bit so it playes on a monitor that is already spawned in

private _video = "imgs\Uav_Intel.ogv";
_screen = Monitor_1 setObjectTextureGlobal [0,_video];
        
_screen setObjectTextureGlobal [0, _video]; 
        [_video, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false];  
    }; ```
#

it plays fine

still forum
tribal creek
#

iam guessing this will work in a dedicated server now ?

#

and 1 last thing is the addaction commands on the laptop that is tied to the trigger

#
this addACtion ["Stop Video", "Intel_Trigger = false"];  
 
 
[missionNamespace, "BIS_fnc_playVideo_stopped", {  
 Intel_Trigger = false;  
}] call BIS_fnc_addScriptedEventHandler; ```
#

how do i convert this so it runs on a dedicated server

#

i keep trying and seem to get nowhere

granite sky
#

It doesn't look like it should be running on the server.

errant jay
#

can i make a "call fn_functionnameexample", happen only if a player is certain side?

winter rose
#

yes

#

you have my permission.

proven charm
still forum
#

if (_playerSide == west) then fn_functionnameexample;
:pog:

vocal mantle
#

@grizzled cliff is that a private repo?

proven charm
#

weird way of calling function πŸ˜„ can u pass args to that?

grizzled cliff
#

yah

vocal mantle
#

:(

little raptor
#

i.e. it will see the parent scope _this

vocal mantle
#

I would also love a peek

sullen marsh
#

peek

grizzled cliff
#

argh i wish i could add non read/write users

#

just read users

proven charm
sullen marsh
#

If you set it to an org I think you can fiddle with the groups enough to make it non-write

vocal mantle
#

Don't you have to approve push requests though?

errant iron
#

What's a reliable way to run a function on each player, including those that respawn and that join-in-progress? I'm trying to let people share their money via ACE actions, so I've written a function to add those actions to a given player. Here are the ideas I've thought of:

  1. Looping through players in initPlayerLocal.sqf
    JIP players won't be available so that won't do
  2. remoteExec the function globally in initPlayerLocal.sqf
    Given that the player object changes during respawn, and therefore their netId does too, I assume this would eventually stop working for JIP clients
  3. remoteExec the function globally in onPlayerRespawn.sqf (where respawnOnStart = 0)
    This is what I'm going with, but I'm a bit concerned about causing excessive network traffic. This would be called multiple times for the same player so I'm setting a local variable on each player in the function to make sure the actions aren't added more than once.
sullen marsh
#

Not with private repos, you can only add people as contributors which have write access

meager granite
#

remoteExecCall with jip flag from server, in that function also add Respawn EH

grizzled cliff
#

yah

granite sky
#

Or don't remoteExec at all and just run it from both onPlayerRespawn and initPlayerLocal.

sullen marsh
#

ALTHOUGH you could use the new protected branch thing

#

I'm not sure how that works fully though

grizzled cliff
#

just wait until its public, which should be soon :P only want to add people i almost entirely trust, verox happens to just barely be one of them :D

errant iron
#

Hmm, I might have misworded my initial question as I'm not sure how either approach would handle my situation correctly. Because adding actions is local, I need my function to run locally, on each client, against every other player, and preferably once.

sullen marsh
#

: D

#

Certainly worth the wait by the looks of it

errant iron
#

so with a single remoteExecCall + Respawn EH, JIP players would still need a way to register their player actions, and for calling directly in onPlayerRespawn/initPlayerLocal, I would need to broadcast that to JIP players as well

vocal mantle
#

well, whatever you want to do, I have no interest in fiddling with it. I have enough experience with git to not screw it up accidentally either.

granite sky
#

Then you'll need to JIP remoteExec the action in both onPlayerRespawn and initPlayerLocal.

drowsy geyser
#

is it possible to display allPlayers even if they are not grouped using this [] call BIS_fnc_groupIndicator;

errant iron
granite sky
#

I wouldn't worry about having one JIP queue entry per player. Just make sure that you're not passing a load of duplicated data in the call.

#

Hence remoteExecing an addAction directly is bad, remoteExecing a simple function that then calls addAction is good. That function can also do an existence check on the target unit and clear the JIP entry if it's gone.

tribal creek
#

umm how does one add remoteExec to this :

this addAction["Pick up Classified_Documents", "deleteVehicle Classified_Documents;"]

granite sky
#

You wouldn't, because it's in an editor init box and so it runs everywhere.

sullen sigil
#

or rather, you shouldn't

#

you can
but be prepared for 20 trillion billion million actions

tribal creek
#

oh ok ight

#

ig its fine as it is

tribal creek
fleet sand
# tribal creek i didn't quite get you. I have it in the init box of the object "Classified_Docu...

You dont have to and shudnt remote execute code in init of a object that you placed in eden editor because it would duplicated per player and you dont want that. And why you dont need to do that is becouse everyplayer will have that code localy on their machine.
You can watch this video it goes a bit in detail on locality of code:
https://www.youtube.com/watch?time_continue=718&v=-hz0SoS95VY&embeds_euri=https%3A%2F%2Fdiscord.com%2F&feature=emb_logo&ab_channel=Vestarr

Join the discord!
https://discord.gg/wCUqFxs

Consider supporting me as a modder/creator
Paypal: thevestarr@gmail.com

This video is just an introduction to multiplayer scripting in ARMA 3.
It's a huge topic and it's barely scratching the surface.

Resources:
https://community.bistudio.com/wiki/Multiplayer_Scripting
https://community.bistudio.co...

β–Ά Play video
errant iron
granite sky
#

It would, but you can only do that once.

#

You can do it in a mission as long as you know you're not going to use that object as a JIP ID for any other JIP.

errant iron
#

ah i didnt think of that

granite sky
#

In a mod you have to make custom JIP IDs, otherwise you'll break stuff.

#

And then you don't get the automatic cleanup.

errant iron
#

kind of inconvenient, but I guess it's not too hard to future-proof: sqf // onPlayerRespawn.sqf [_newUnit] remoteExec [ "SHZ_fnc_initMoneyShareActions", SHZ_globalPlayerTarget, (_newUnit call BIS_fnc_netId) + ":SHZ_moneyShare" ]; sqf // onPlayerKilled.sqf remoteExec ["", (_oldUnit call BIS_fnc_netId) + ":SHZ_moneyShare"]; (also added a HandleDisconnect handler on server)

drifting dome
#

I don't understand why this trigger doesn't execute the reveal command at all, as I don't see the systemChat nor the AI show the desired behaviour

systemChat "Trigger activated";
{
  //EnemyS is variable name of enemy group I want to see the players Spot, Snip and Odin (also variable names)
  _EnemyS reveal [_Spot, 4];
  _EnemyS reveal [_Snip, 4];
  _EnemyS reveal [_Odin, 4];
  systemChat "Players spotted by AI";
};
hallow mortar
#
  • Putting code inside a Code data type (denoted by { } ) is meant for "saving it for later" - not executing it right now, just putting it in a container that you can then do stuff with, like passing it to a command for the command to use. You don't need to do that if you just want to have code that's executed normally.
  • All the variables you're trying to reference are local scope variables (prefixed with _ ). If they aren't defined in the trigger code, then they won't exist in this scope. Editor object variable names are global scope variables (no _ ); local scope variables defined in other scripts need special handling to pass them to other scopes.
drifting dome
#

See I thought { } meant it would be executed at once but together when an if condition isn't given.

hallow mortar
#

Code is already executed as fast as possible.

drifting dome
#

thank you once again! I'll check if it runs now

#

thank you that worked! now I have an issue with one of the units in the group (only two AI) not firing at the players but I doubt that has anything to do with the script 😁

hollow lava
#

hey im looking for a command for my debug console to end load screen. Ive got players joining the server and getting load screen

molten yacht
#

This is so weird. A while loop works if its condition is true when initially executed but won't work if it's started and then the condition becomes true later....

#
private _radWarn = "<t color='#ff0000' size='3' font='EtelkaMonospaceProBold'>RADIATION WARNING</t><br/>
<t color='#ff0000' size='1.5' font='EtelkaMonospaceProBold'>LEAVE THE AFFECTED AREA IMMEDIATELY</t><br/>";
private _rwning = "f";

while {player getVariable ["HUD_RadWarning",false]; } do {
_rwning = "radWarn" cutText [_radWarn, "PLAIN NOFADE", -1, true, true];
UIsleep 0.7;
_rwning = "radWarn" cutText ["", "PLAIN NOFADE", -1, true, true];
UIsleep 0.7;
};```
alpine mountain
#

Where {} is code block

warm hedge
#

A while will not run anything if the while does see the condition is false in the first iteration

molten yacht
#

It won't keep checking?

warm hedge
#

No

molten yacht
#

Is there any way to get a while that WILL keep checking?

warm hedge
#

What is the goal anyways?

alpine mountain
#
while {true} do { if (player getVariable ["HUD_RadWarning", false]) then {} }
molten yacht
#

No

#

while {true} do {code}

#

if (true) do {code}

#

they work differently

molten yacht
warm hedge
#

Note that, while requires to re-evaluate the boolean again and again so just a boolean will not work for it, thus a code is required

warm hedge
molten yacht
#

It's a flashing cutText

#

and as is if you step into the trigger it flips the Variable

warm hedge
#

Mhm

#

Then just do while {true}?

warm hedge
#

With waitUntil I guess

meager granite
#

Depends on how you have stuff setup though

formal stirrup
#

Anyway to detect if a projectile is a rocket/missile?

fleet sand
formal stirrup
#

Based

sullen sigil
#

== is already case insensitive

warm hedge
#

You can just use configOf to get which is the projectile class

formal stirrup
#

Using fired and hitPart for this so i do have the projectile class, just a matter of checking if it was a missile that was the problem, Backup plan was to just add a hitPart handler to the missile launched with IncomingMissile

meager granite
#

There is also shotRocket

#

Bombs are also shotMissile

meager granite
#

Hashmaps are perfect for this

edgy dune
#

I am reading the handleDamage eventhandlers description and I eventually get to this linked page
https://forums.bohemia.net/forums/topic/205515-handledamage-event-handler-explained/

I dont quite understand the part that says

The "" part is the reason why consecutive leg hits are fatal.
casue how would just shooting the leg cause the unit to die if?
"legs": Unit doesn't die with damage to this part

meager granite
#

He means that even if you shoot already destroyed (damage >= 1) legs, you will still get overall damage increasing until you die.

#

This is true for any vehicle really, if you shoot already destroyed hit point enough, some damage is still applied to total damage which will eventually kill the vehicle

#

unless its configured to never get overall damage under normal circumstances (lots of RHS vehicles)

#
if (_hitSelection isEqualTo "") then {damage _unit} else {_unit getHit _hitSelection};ο»Ώ
```This example in the post is wrong way of doing it
#

getHitIndex been a thing since 2015

#

Next example is not ideal either, operating selection names is unreliable way of doing it

#

Unless you know selection names exactly

#

Back in the day some vanilla Arma 3 uniforms had slighting different selection names for same hit point

#

This was fixed but you have to account for mods where they might not follow same naming

#

hit part index and hit point name are most reliable ways of dealing with damage

#

Many hit point names are hardcoded in the engine so you can always expect them to be called exactly that

#

I probably should do a write up on all this as I've been super deep into it all recently

#

But I probably wont

edgy dune
edgy dune
meager granite
meager granite
#

I think this also applies to characters

#

I'm not sure there is an exact formula somewhere, but the idea is that if you hit some part, some of the damage is added to overall damage

#

Even if you keep shooting completely destroyed part, overall damage will keep increasing

meager granite
#

Just realized what a dummy I am and simply using find was almost twice faster:

s = "#crash"; a = [0,1]; [diag_codePerformance [{s select a == "#"}], diag_codePerformance [{s select [0,1] == "#"}], diag_codePerformance [{s find "#" == 0}]]
```=> `[[0.000520693,100000],[0.000600811,100000],[0.000385165,100000]]`
```sqf
s = "ATMine_Range_Ammo"; a = [0,1]; [diag_codePerformance [{s select a == "#"}], diag_codePerformance [{s select [0,1] == "#"}], diag_codePerformance [{s find "#" == 0}]]    
```=> `[[0.00051952,100000],[0.000595196,100000],[0.000385103,100000]]`
#

*1/3 times faster than inline array select

ivory lake
#

armorStructural is a big one for reducing global damage

graceful dew
#

Do the TurnIn/TurnOut event handlers supersede their actions or do they fire before?

sullen sigil
#

are the proxies on vestContainer supposed to change with different vests? they seem to be the same for all regardless of if they have a holster or not etc meowsweats

graceful dew
#

Would then canHideGunner = -1 enable full script handling of those actions?

meager granite
#

Try it?

nocturne bluff
#

@grizzled cliff sweeet

finite bone
#

Do the texts in AddAction support non-english characters?

warm hedge
#

addAction is not a concern but how a font in A3 works in generally. Usually Latin Alphabet + Kyrilic + some multiple accent alphabets + CJKs

keen rain
#

How would I make so that whenever a specific vehicle is destroyed the mission obj turns to "completed" ?

stable dune
keen rain
stable dune
#

Okay, so you want to create a task , and when object x is destroyed it will be completed?

keen rain
#

yes

#

basically story short:
My guys are progressing and recently captured an airbase, and got intel on possibly some PMC group arriving, they want to take down the heli, but there's 3 and they need to take down the cargo one. Problem, the three helis are similar.
So they can either take the right one or destroy the right one, for it to be complete.

sullen sigil
#

endMission

keen rain
#

... Not a mission end.

stable dune
keen rain
#

Appreciate it

#

also can you like modify a script mid-game like for example "pickup.sqf" and execute it from the extended debug console ?

sullen sigil
#

no

keen rain
#

appreciate it

sullen sigil
#

not unless youre creating the function by preprocessfilenumbers or whatever the command is

graceful dew
drowsy geyser
#

is it possible to display allPlayers/allUnits even if they are not grouped to the player using this [] call BIS_fnc_groupIndicator;?

#

i want to display all units but it only displays the units grouped to the player

hallow mortar
#

It's called groupIndicator, so I'm guessing that's how it's supposed to be

drowsy geyser
#

yes i tried to change the function but could not get it work

little raptor
drowsy geyser
#

weird i tried yesterday exactly this and it didn't work, trying again

little raptor
#

does it work without modification?

_this = _this param [1,[]];

switch _mode do {

    case "Init": {
        disableserialization;
        _display = _this select 0;
        _map = _display displayctrl 116601;

you're not providing a display to this

drowsy geyser
#

hmm sry i dident understand what you mean πŸ€”

little raptor
#

Read the part I showed

#

It expects you to pass a display.
idk which display it is tho

#

But it should have a map control with idc 116601

drowsy geyser
#

me neither xD, nevermind i guess it's not the effort worth

little raptor
#

what do you want to show it on?

#

main map?

drowsy geyser
#

the unit icons, it displays my icon but not the other units icon

little raptor
#

I mean where does it show them?

drowsy geyser
#

the other units icon only display if i group them to me

little raptor
#

how do you call the function?

drowsy geyser
#

[] call PARADOX_fnc_indicator;

#

from a sqf file

little raptor
#

that doesn't mean it'll use your function. see:

#

when you pass an empty array it just exits, and uses the onLoad event of RscGroupIndicator to call the function (which calls the BIS function)

#

so if you want to get it to work you should also create your own RscTitle

drowsy geyser
#

ah okay, i understand, sounds complicated but thank you for explaining it to me

little raptor
#

not really

#

are you making a mission or mod?

drowsy geyser
#

mission

little raptor
# drowsy geyser mission
import RscGroupIndicator from RscTitles;

class RscTitles
{
  class ParadoxGroupIndicator : RscGroupIndicator
  {
    onLoad = "['Init',_this] call (uinamespace getvariable 'PARADOX_fnc_indicator')";
    onUnload = "['Exit',_this] call (uinamespace getvariable 'PARADOX_fnc_indicator')";
  };
};
#

use this in description.ext

#

then change the first line of the function:

if (count _this == 0) exitwith {([] call bis_fnc_rscLayer) cutrsc ["ParadoxGroupIndicator","plain",0,false];};
#

and line 32:

_map ctrladdeventhandler ["draw","with uinamespace do {['Draw',_this] call PARADOX_fnc_indicator;};"];
drowsy geyser
#

this is very kind of you, thank you very much for the help meowheart

faint oasis
#

Hi, i have a question, i tried this addEventHandler ["HandleDamage", {0}]; inside a singleplayer mission, the event get called but the unit still die when i shoot it, is that normal ? I thought "0" will prevent it to be damaged but for me it's not working

little raptor
#

do you use mods?

kindred zephyr
faint oasis
#

I will try without mods to see if that was the problem but probably

little raptor
#

does the unit die / take damage any time you shoot it?

#

if so yes, it's because of a mod

faint oasis
kindred zephyr
#

execution location will also affect your unit, as "this" is context sensitive afterall

little raptor
#

I assumed by:

the event get called
you mean you did try a systemChat or something in the EH code?

faint oasis
#

because i wanted to see what was the _damage argument value

#

btw i tried without some mods and yeah now it's working so thank you

heavy iris
#

Hello. Does anyone have a script (or function) that allows you to enable crosshair when it is disabled in the difficulty settings?

little raptor
#

it's not possible

heavy iris
sage marsh
#

Hey. Anyone know how to enable/disable ai simulation for a whole group through script?

sage marsh
#

Thank youu

molten yacht
#

Is there any way to get OR set a helicopter gunner's turret direction

molten yacht
warm hedge
#

Pilot cam can be set in a different way

molten yacht
#

I said "like on the pilot cam" i.e. "as if this were a pilot cam, which has the command I want"

#

apologies for any musunderstanding

#

I'm wishing there was a way to set a turret's position to 0,0

#

(as in, perfectly straight out in front)

hallow mortar
#

Attach an invisible object in front of the vehicle and lockCameraTo it? It's not a great solution but we don't have a great deal of direct control over turrets.
https://community.bistudio.com/wiki/setTurretLimits could also potentially help, but because of how its arc definitions work, it may not be possible to get what you want.

tribal lark
#

I'm messing around with subtitles and wanted to test BIS_fnc_showSubtitle, so I put ```sqf
["CROSSROAD", "Mission is a go, I repeat, mission is a go, Crossroad, out."] spawn BIS_fnc_showSubtitle;

 in a blufor present trigger. It's right from the wiki page of the function but it didn't work, and I didn't get any error messages. I'm assuming I'm doing something really stupid but I could use some help πŸ˜…
tribal lark
#

Putting in the debug console gives me this

    private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'BIS_fnc_showSubtitle'} else {_```
#

Which I don't know what to make of

meager granite
meager granite
#

add something like diag_log and see if it prints into RPT

royal bramble
#

Is there a way to execute server commands such as changing a mission with scripts?

tough abyss
royal bramble
royal bramble
#

No like mission file

tough abyss
#

i believe its possible but do you own or have tcadmin etc access to the server and have .ext/.cfg setup?

meager granite
#
"password" serverCommand "#mission file.Altis Custom"
#

your script is gonna need your server.cfg password though

tough abyss
meager granite
tough abyss
#

how he is describing it coming from an addaction

meager granite
#

Anyway, maybe object's init is too early for whatever command you're trying to execute

#

As long as you supply right password and command, source doesn't matter

#

addAction is client-side so you'll have to query the server to do it

#

exposing password to clients is a no-no

#

so you'll need to have it hidden somehow

#

Through server-side only addon

tough abyss
#

this reminds me of people in pub zeus using hold action bi functions and one of the options instead of bothering to remotexec addactions

real tartan
#

I am trying to calculate velocity for flare going down to ground based on time and distance. Problem is that flare getting way too fast to the ground.

private _time = 30; // 30 seconds in air
private _height = 100;
private _pos = [0, 0, _height];
private _distance = _height - 50; // flare should fly from from 100m to 50m and then delete
private _velocity = _distance / _time; // CALCULATION
private _flare = createVehicle ["F_20mm_Red_Infinite", _pos, [], 0, "NONE"];
_flare setPosATL _pos;
_flare setVelocity [0, 0, -_velocity]; // SET VELOCITY

sleep _time;
deleteVehicle _flare;
tough abyss
#

it sorta looks like you're trying to set its velocity and position not calculate it

real tartan
#

I am calculating velocity so I can set it for time and distance flare needed to be in air

meager granite
#

you'll probably need to set velocity each frame

real tartan
#

in order to set it you need to calculate it

meager granite
#

as gravity\whatever rules there are for flares accelerate it

#

which probably still won't be precise

#

because engine probably adds gravity and then moves the entity on the same frame, not sure

real tartan
#

should I just setPosATL each frame ( or sleep 0.05 ) ?

#

no need for velocity in that case

meager granite
#

sleep wont produce smooth movement

#

You can try sleep with setVelocity

#

Won't be precise but at least smooth as engine handles the position

meager granite
#

Lazy solution of running a scheduled thread also works, just tested it:

private _time = 30; 
private _height = 100; 
private _pos = player modelToWorld [0, 0, _height]; 
private _distance = _height - 50; 
private _velocity = [0, 0, -_distance / _time]; 
private _flare = createVehicle ["F_20mm_Red_Infinite", _pos, [], 0, "CAN_COLLIDE"]; 
_flare setPosATL _pos; 
_flare setVelocity _velocity; 
 
[_flare, _velocity, diag_tickTime + _time] spawn { 
    params ["_flare", "_velocity", "_time"]; 
    waitUntil { 
        _flare setVelocity _velocity; 
        systemChat str (getPosATL _flare select 2); 
        diag_tickTime > _time; 
    }; 
    deleteVehicle _flare; 
};
#

ends close to target height

#

will be less accurate with clogged scheduler

#

turn that into each frame and it will be good enough

#

the issue here is overriding engine behavior

real tartan
#

trying to do it in vanilla if possible

hallow mortar
#

Given that the projectile is affected by gravity, could setMass change its rate of descent, or is that purely controlled by other properties?

real tartan
meager granite
#

good point about locality actually, flare will appear jumping up and down if you correct its position only on the server

#

To expand on this lazy solution just broadcast same thread arguments

#

except with serverTIme instead of diag_tickTime

#

no need to continously update it

#
[[_flare, _velocity, serverTime + _time], { 
    params ["_flare", "_velocity", "_time"]; 
    waitUntil { 
        _flare setVelocity _velocity; 
        systemChat str (getPosATL _flare select 2); 
        serverTime > _time; 
    }; 
    deleteVehicle _flare; 
}] remoteExecCall ["spawn", 0, _flare];
real tartan
#

I am familiar with CBA, but that will create additional mod dependencies to mission, where I want to avoid that

#

why re-invent the wheel ?

meager granite
#

CBA is definitely an overkill for something this basic

#

It will be smooth with setVelocity

#

Just not precise

#

CT_OBJECT

#

but it is very limited

hallow mortar
#

You could probably RTT it on a local-only user texture object, attached to the player's face. I wouldn't describe that as a great idea though

meager granite
#

Oh you meant into world space

#

then RTT and ui2texture

#

You can render something onto CT_OBJECT so that it separate from world space

#

but I remember it being very limited, there are lighting issues, etc.

real tartan
#

or better yet

private _serverTime = [time, serverTime] select isMultiplayer;
meager granite
#

Yeah, use time for SP

real tartan
#

how can I format numbers in logs to be readable ? example: 1e+010 to 10000000000. using diag_log and format for some big vales

#

BIS_fnc_numberText comes in mind, but does not work with floating point numbers.

real tartan
winter rose
#
[[_flare, _velocity, _time], { 
    params ["_flare", "_velocity", "_time"]; 
    _time = time + _time; // define it server-side for better accuracy
    waitUntil { 
        sleep 0.01;
        _flare setVelocity _velocity; 
        // systemChat str (getPosATL _flare select 2); 
        time > _time; 
    }; 
    deleteVehicle _flare; 
}] remoteExecCall ["spawn", 2, _flare];
meager granite
meager granite
#

The idea is to have each client do their own setVelocity for maximal smoothness

#

I guess that sleep won't hurt

winter rose
#

ah, if each client does that then… it would require some if (isServer) here and there
ooor a Function πŸ˜„

meager granite
#

deleteVehicle should be wrappen in if(local _flare) too btw

winter rose
#

or this script remoteExec'ing setVelocity…

indigo wolf
#

I have an array like this:
[vehicle1 [unit1, unit2], vehicle2 [unit1, unit2] ... vehicle14 [unit1, unit2]]

What I am trying to do is have 2 AI units (unit1, and unit2) to get inside their corresponding vehicle (vehicle 1, vehicle 2, vehicle 3...) using a for condition. I have no idea if this is correct or how to setup the for loop for this action.

I've added them on the array like this:```sqf
// Vehicle Array
vehicle_Land = [];
// Have empty vehicles be pushed into this stack
vehicle_Land pushBack this;
// Have AI assigned to these vehicles
(vehicle_Land select 1) pushBack this;

// repeate the steps for other vehicles and units assigned

meager granite
winter rose
#

hence the italics, it wouldn't be nice πŸ˜„

meager granite
#

init field?

#

what do you mean by "for condition"?

indigo wolf
#

The vehicle_Land = [] array is put in the mission init field.
The vehicle_Land pushBack this are done in the respective vehicle's init field.
The (vehicle_Land select 1) pushBack this; are done in the respective unit's init field.

The idea is have 20 AI located in a building run up to their designated vehicles and mount up to go to a waypoint.

#

Once a variable (callfor_Reinforcement) is returned true, these AI units will mount up and go to that waypoint.

#

I thought of using the for condition to recursively make individual AIs of each assigned vehicle to get inside them.

meager granite
#

πŸ€”

winter rose
#
for "_i" from 0 to (count _array) step 2 do
{
  private _vehicle = _array select _i;
  private _soldiers = _array select (_i + 1);
};
```😬
meager granite
#

Can you get sync links that you setup in editor through scripts?

indigo wolf
#

I looked at the addVehicle and orderGetIn commands, but couldn't find an example in the wiki as to how they actually work in this scenario.

winter rose
#

but if they are groups, I would recommend using groups

meager granite
#

How do you even want to define which units belong to which vehicle in the editor?

indigo wolf
meager granite
#

the issue with init fields is unpredictable order

indigo wolf
#

If there is a better way, I'm all ears.
Objective: Have AI mount vehicle and go to a position
Objects at hand: 20 AI and 10 Empty Vehicles

winter rose
#

waypoints?

meager granite
#

are they all in same group or you group 2 units together?

indigo wolf
#

Each 2 Units are of 1 group. There are 10 AI groups.

indigo wolf
# winter rose waypoints?

I tried to do waypoints from script perspective but couldn't figure out how (the wiki only explains the syntax).

meager granite
#

I thought you could like CTRL+drag a vehicle to be synced with a group or something but apparently its not a thing thonk

winter rose
#

anyway both are valid ways to get to what you want

meager granite
#

My scripting brain breaks when I try to think of doing something in the editor notlikemeow

#

No way to easily point one thing at another, no way to ensure execution order

indigo wolf
meager granite
#

Here is how I think it can be done the easiest way:

  1. Name vehicles something (like reinforcement_vehicle_1, reinforcement_vehicle_2, ...)
  2. Name a single unit in each group something (like reinforcement_group_1, reinforcement_group_2, etc.)
  3. In init.sqf have the following:
reinforcementSetup1 = [
     [reinforcement_vehicle_1, reinforcement_group_1]
    ,[reinforcement_vehicle_2, reinforcement_group_2]
    ,...
];

startReinforcements = {
    params ["_setup", "_move_to"];
    {
        _x params ["_vehicle", "_unit"];
        private _group = group _unit;
        _group addVehicle _vehicle;
        _group move _move_to;
    } forEach _setup;
};

and then when you'll want to alert your group execute:

[reinforcementSetup1, getPos player] call startReinforcements;
winter rose
#

getPosATL*

meager granite
#

ASLtoAGL getPosASL player πŸ€“

indigo wolf
#

Thanks I'll try it out and wok on this.

tame bison
#

Hello, help a beginner)
my code...

_vehicleObject = _type createVehicle (_pos);
while {player getVariable ["myVariable", false]} do {
my code...
sleep 1;
};
deleteVehicle _vehicleObject;```
everything works as it should here

I need to add a check _type
something like that
```if !(_type isEqualTo "") then
{
_vehicleObject = _type createVehicle (_pos);
};```
but as soon as I do this, the car is not deleted, I understand that I need to display the car name, but I don’t understand how to do it
winter rose
#
private _vehicleObject = objNull;
if (_type isNotEqualTo "") then
{
  _vehicleObject = _type createVehicle _pos;
};
// ...
deleteVehicle _vehicleObject;
```see https://community.bistudio.com/wiki/Variables#Local_Variables_Scope
tame bison
finite bone
#

I have the following addAction to mark few hostiles as traitors and start in-fighting within the OPFOR units. This works when I already fill the turnedunits stack with AI but I want to have this run dynamically within the radius defined and it should count vehicles as 1 unit instead of individual units inside it. Any idea how?sqf Satscreen1 addAction[ "Mark Hostiles as Traitors", { commsintercept = false; publicVariable "commsintercept"; params ["_target", "_caller", "_id", "_args"]; turnedunits call BIS_fnc_arrayShuffle; publicVariable "turnedunits"; private _halfcap = floor (count turnedunits) / 10; for "_i" from 0 to _halfcap do { (turnedunits select _i) join grpNull; uiSleep 2; (turnedunits select _i) addRating -8000; }; }, nil, 1.5, true, true, "", "commsintercept", 5, false, "", "" ];

zenith beacon
#

does anybody know the scripts to put up images on billboards in the eden editor? I'm kinda stuck of what to do

finite bone
zenith beacon
# winter rose +\"

this setObjectTexture [+"0, \a3\missions_f_aow\data\img\artwork\landscape\showcase_aow_picture_108_co.paa"];

zenith beacon
winter rose
zenith beacon
#

this setObjectTexture [0, "\a3\missions_f_aow\data\img\artwork\landscape\showcase_aow_picture_108_co.paa"];

zenith beacon
finite bone
#

oh yea forgot the quotes Kappa

finite bone
# finite bone I have the following addAction to mark few hostiles as traitors and start in-fig...

Figured a possible solution - sqf Satscreen1 addAction[ "Mark Hostiles as Traitors", { commsintercept = false; publicVariable "commsintercept"; params ["_target", "_caller", "_id", "_args"]; { _unit = _x; _grp = group _x; if ([10543.655, 4104.327, 0] distance _x < 1504) then { if (side _x == east) then { turnedunits pushBack _x; }; }; } forEach allUnits; turnedunits call BIS_fnc_arrayShuffle; publicVariable "turnedunits"; private _halfcap = floor (count turnedunits) / 10; for "_i" from 0 to _halfcap do { _unit = (turnedunits select _i); _grp = group (turnedunits select _i); if (_unit == vehicle _unit) then { { _x addRating -8000; } forEach units _grp; } else { _unit addRating -8000; } uiSleep 2; }; }, nil, 1.5, true, true, "", "commsintercept", 5, false, "", "" ];

round scroll
#

anyone knows of a way to check if a player is in water and swimming?

tribal lark
feral owl
#

Hello guys
On my modded server
Is it normal that getUnitLoadout command returns something different when executed server-side xor client-side?
For instance, items in my backpack (_loadout#5) got duplicated on server perspective whereas everything works fine when executed locally

Client (_unit = player):

    {
        "B_Carryall_blk",
        {
            {
                "ACE_rope6",
                1
            }
        }
    }

Server (_unit = player call BIS_fnc_objectFromNetId):

    {
        "B_Carryall_blk",
        {
            {
                "ACE_rope6",
                2
            }
        }
    }
open hollow
#

somewhere in a mod there is a copytoclipboard str diag_activeSqfScripts on something like a oneach frame... its the worst torture ive seen to an Editor

open hollow
feral owl
feral owl
open hollow
#

it can be a locality issue, setitem and other stuff are local, so for some reason you ccan have a magazine, that the other ppl or server dont "have"

open hollow
feral owl
feral owl
open hollow
#

well... funfact if you use developer tools, the stuff you have on the vanilla console still executes πŸ™‚

real tartan
#

I have 2 objects with known dimensions. I want to have _object2 attach to _object1 and rotate _object1 to right ( do a full circle ). How to attachTo _object2 to _object1 so it follows _object1 axis ?

private _dir = getDir _object1;
_object2 attachTo [_object1, [0, 0, 0]];
_object2 setDir _angle;

private _angle = 0;
while { alive _object1 } do 
{
    _dir = _dir + 1; // not worry about full rotation yet
    _object2 setDir _dir;
    sleep 1;
};
mystic scarab
#

Hello, how can I make a specific AI take damage and become unconscious but not die with ACE Medical?

little raptor
real tartan
#

like cone, but center of object2 is not on base of the cone, but in middle, and when setting dir to objec2, it is just rotating, but not facing out

little raptor
#

can you show an in game screenshot? I don't think I follow

#

you mean you want to rotate the up vector?

#

ah nvm I get what you mean now

#

I don't recommend attaching the object for this

#

because you have to detach and reattach (iirc setting position doesn't work on attached objects)

tidal ferry
little raptor
tribal lark
little raptor
#

yeah the code I posted should fix it

#

but it'll probably look bad (due to detaching and reattaching)

real tartan
tidal ferry
#

Any help with ACE Actions config? My guys are depending on me to get a fix out for some of our vehicles 😭

little raptor
# real tartan probably offset is off

try with:

private _dir = 0;
private _offset = 25;
while { alive _object1 } do 
{
    _dir = _dir + 1; // not worry about full rotation yet
    _object2 attachTo [_object1, [_offset * sin _dir, _offset * cos _dir, 0]];
    _object2 setDir (_dir - 90);
    sleep 1;
};
little raptor
#

actually it says string

tidal ferry
#

"External Base Actions Only, Code to return a position in model cords (priority over selection)"

little raptor
#

so position = "[x,y,z]"

tidal ferry
#

Maybe? But idk if it has to be calculated based on eyePos location

#

The usual entry for most vics is this:

#
position = "[_target, ace_interact_menu_cameraPosASL] call ace_interaction_fnc_getVehiclePosComplex";```
little raptor
#

well what I wrote gives a fixed position

tidal ferry
#

Yeah

#

I'll try that first and see if it works

little raptor
#

if you want a dynamic position you need a function (or just type the whole code in there...)

tidal ferry
#

Yeah- I'm not sure how to go about that, or if ACE already has a function for it

little raptor
#

you can also try this: "_target worldToModel unitAimPosition _target" (or unitAimPositionVisual)

tidal ferry
#

Loading the game now, will see if the base fix of just putting model coords in will work

#

Didn't work- let me try it

little raptor
#

what is the problem exactly?

tidal ferry
#

I put the coords in as like position = "[198487,13984874,4871871`]" (numbers random, actual was based off model coords) and it didn't show up where I needed it to

little raptor
#

your coords are wrong

tidal ferry
#

I know, those coords are junk

little raptor
#

also there's a `

tidal ferry
#

THe actual ones I used were different

#

It's just pseudocode

little raptor
#

are you sure you test it correctly?

#

where does the action appear right now?

tidal ferry
#

It doesn't

tidal ferry
little raptor
#

what is it following exactly? what is _object1?

real tartan
#

_object2 setDir (_dir - 0);

little raptor
#

- 0?

real tartan
hallow mortar
#

Subtracting zero from a number is unlikely to do anything useful

real tartan
little raptor
tidal ferry
#

Wait! I got some results

#

I think it's because I had another entry, 'selection', set the wrong way

little raptor
#

selection should be empty

#

the wiki page said it takes precedence over position iirc

#

position String (of code) External Base Actions Only, Code to return a position in model cords (priority over selection)
looks like it was the opposite

tidal ferry
#

Yeah, this may be an 'I'm stupid' moment if this works the way I think it will

indigo snow
#

surfaceIsWater, ASL z == 0, vehicle player == player?

tribal lark
#

Is there any reason why this wouldn't work? It's not for me rn and I'm lost as to why

tidal ferry
#

Alright, think I got it mostly working

#

I overestimated the complexity of it, it's just model coords and not anything else fancy

#

Wish I could get just- selections figured out, but ah well

round scroll
#

thanks cptnnick, ASL z < 1 and vehicle player == player is good enough for the check I think

tidal ferry
#

Well... almost got it

#

It only shows up when I'm backwards from the front of the vehicle? Which is weird

#

It works when I look backwards and down in the vehicle, but...

#

Nowhere to be found when I look at it normally

#

Current code is this (I know it's janky, looking for suggestions)

#
    position = "_d = _target selectionPosition ['pos driver','memory','AveragePoint']; _d set [2,_d#2+2]; _d";
#

@little raptor Any advice? πŸ˜…

granite sky
#

position's a keyword, isn't it?

#

I assume you mean something like _position = call { that stuff in the quotes };

#

If you want a single statement that does the +2 z then there's _target selectionPosition [whatever] vectorAdd [0,0,2]

hallow mortar
#

Yeah, you can't use position as a variable name because it's already a command name

#

Oh, no, I see, this is config stuff, you're not using it as a variable name

#

That's not the issue then

granite sky
#

oh, config. Ugh.

tidal ferry
#

But yeah- like

granite sky
#

Should work then assuming that _target exists?

tidal ferry
#

This is what I have so far:

#


class ACE_Actions: ACE_Actions
{

class Test_Action_1
{
    condition = "true";
    displayName = "Get in Pilot's Seat";
    icon = "\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_getin_ca.paa";
    statement = "_player moveInDriver _target; hint 'Worked!';";

    distance = 5;
    //position = "[_target, ace_interact_menu_cameraPosASL] call ace_interaction_fnc_getVehiclePosComplex";
    
    //position = "_d = _target selectionPosition ['pos driver','memory','AveragePoint']; _d set [2,_d#2+2]; _d";
    //position = "[0,11.3,-1.9]"; //"[-0.46,11.2,-1.8]";
    selection = "pos driver";

};
#

Based off of this framework:

#

I'm ripping my hair out trying to figure it out

#

It works somewhat, insofar as the ACE interact point shows up SOMETIMES

#

But only when I look at it at weird angles

granite sky
#

Does it work as expected with selection = "pos driver" instead of the position?

tidal ferry
#

Basically, as per framework, position overrides selection

#

But is required?

#

I've tried like a dozen permutations of position = X and selection = X

#

What I've narrowed it down to is the ACE interact showing up, but ONLY when looking backwards towards the tail of the vehicle

#

Which isn't very helpful for boarding a vehicle in a hurry

tidal ferry
granite sky
#

well, I don't know where you want it to be or where it is.

tidal ferry
#

Well

#

It's where I want it to be- I can only ACE interact with it when I face it at certain angles

#

Which is not at all what I want

#

I'd post pics in here, but uh, copypaste doesn't seem to be enabled

hallow mortar
tidal ferry
#

Oh!

#

Sick!

#

One sec

#

So basically- you can kind of juuuuust see it on the edge of the screen

#

However, it doesn't appear when I look at it straight on

#

Only when I look at it when facing +90 or -90 degrees from the vehicle's axis

granite sky
#

Aren't you trying to put it 2m above the pilot?

meager granite
#

Does CfgRemoteExec's server means any server or dedicated server only?

    /*
    Allowed targets:
        0 - can target all machines (default)
        1 - can only target clients, execution on the server is denied
        2 - can only target the server, execution on clients is denied
        Any other value will be treated as 0.
    */
    allowedTargets = 0;
errant jay
#

Any server

terse tinsel
#

Hi, I need help. I want to ensure that all units within the trigger's range are destroyed except buildings and vegetation. when I type this, nothing happens "{_x Setdammage 0} Foreach thislist;"

fleet sand
terse tinsel
#

i have this 😦

terse tinsel
fleet sand
finite bone
#

Nvm fixed the typo in the syntax Before:sqf _unit join grpNull; After: sqf [_unit] join grpNull;

terse tinsel
fleet sand
#

for testing you could just try this:

private _allUnitsInTriggerArea = allUnits apply {_x inArea thisTrigger};

{
    if(alive _x) then {
        _x setDamage 1;
    };
}foreach _allUnitsInTriggerArea;

This will kill every alive unit even players.

terse tinsel
#

unfortunately it still doesn't work :*, can you help me rearrange this script because I don't know how to write it to destroy people, cars, tanks, etc. "{_x setdamage 1; } foreach nearestObjects [getMarkerPos "yourmakername", [],500];" ???

tender fossil
terse tinsel
tender fossil
#

I remember having an issue with allUnits or allPlayers until I realized that the command starts working only about 30 seconds after mission start, don't know if that's the case still

fleet sand
# terse tinsel yes , when unit enter in trigger

I found it here:

private _allUnitsInTriggerArea = allUnits inAreaArray thisTrigger;

{
    if(alive _x && !(isPlayer _x)) then {
        _x setDamage 1;
    };
}foreach _allUnitsInTriggerArea;

InArea returns bool so it would return array of bools.

terse tinsel
#

And can it somehow be added to it so that it also destroys vehicles? Because now he only kills people I know I'm complaining and I'm sorry ;p

fleet sand
#

Btw if you want to kill players as well remove !(isplayer _x) in the if and it will kill everybody players and AI.

terse tinsel
finite bone
#

I've got bunch of units in an array and I want to delete the specific units from the array if they satisfy a condition. Any ideas how?

for "_i" from 0 to _halfcap do 
            {
                _unit = (turnedunits select _i);
                _grp = group (turnedunits select _i);
                if (_unit == vehicle _unit) then 
                {
                    _newgroup = createGroup [independent, true];
                    {
                        _x joinSilent _newgroup;
                        _x addRating -8000;
                        turnedunits = turnedunits - _x; // Basically, remove the entire group from the 'turnedunits' array if they exist
                    } forEach units _grp;
                } else 
                {
                    _newgroup = createGroup [independent, true];
                    [_unit] join _newgroup;
                    _unit addRating -8000;
                };
                uiSleep 0.5;
            };```
little raptor
#

select?

sullen sigil
#

_arr select {str _x isEqualTo "kjwisawesome"}

finite bone
#

I completely forgot about that πŸ˜“

finite bone
#

Ye after unplugging my mind for a minute I concluded to this:

turnedunits deleteAt (turnedunits find _x);```
little raptor
#

you should either use select or save everything you want to delete in an array and use - (turnedunits = turnedunits - _toDelete where _toDelete is an array)

finite bone
#

Yea I setup two arrays, one raw to perform the slice an dice and other to store the results as turnedunits

little raptor
#

I mean you're iterating forward. let's say you delete something at index 0. now everything in the array get shifted backwards
in the next iteration you want to do turnedunits select 1 but you will have skipped the item that was previously here (it got moved to index 0)

#

deleteAt returns the index?
deleteAt returns the item that was deleted

little raptor
meager granite
#

forEachReversed to the rescue

real tartan
#

is there a way to check if player standing in light ? ( not sun, but source of light: flashlight, floodlights, lamp, ... )

finite bone
#

You could check if the nearestObject to the player is a lightsource

real tartan
#

can stand behind it

#

can be 2nd closest object

finite bone
#

Maybe crosschecking the position of the player with the Vector3D of light direction? getLighting. Alternatively, you could check if if a position is in a shadow (Check the comment in the same wiki)

real tartan
#

maybe if that help, light souce is directional, not radial

pure sapphire
#

In arma3 how can use http request?

real tartan
#

checking posibility of using lineIntersects or checkVisibility

finite bone
#

An unoptimized solution would be to get nearestobjects around a player (say 25m) and then get its lighting values from getLighting and then cross checking its vector direction to that of the player.

real tartan
finite bone
#

If you have a list of lightsources you want to cross check on, then get its lighting direction via getLighting and then compare it with player pos

#

Actually, the getLightingAt is what you need through and through.

#

Ref - Example 1: getLightingAt player and compare the _ambientLightBrightness and _dynamicLightBrightness to check if the player is standing in a light.

#

No need for complex mathematics BlobSweat

real tartan
#

can I track back, from which light source is player standing in ?

finite bone
#

With just getLightingAt - dont think so.

fleet sand
#

You can make triggers in those light areas

hollow lake
#

Hi guys,

I am trying to figure out how to create a script that will force player into a first person after they leave main base, they can have 3d person at base but not outside

I have placed a trigger that if not present, it will start the script forcing the player to be in first person

while {(true)} do
    {
       if (alive player && cameraView == "External")
            then
            {
             player switchCamera "Internal";
            };
            sleep 1;
    };

I find arma 3 scripting hard lol, any help with this simple script? :(

little raptor
#

what you want is usually done using an each frame loop

#
if (missionNamespace getVariable ["Joki_eachFrame", -1] >= 0) exitWith {};
Joki_eachFrame = addMissionEventHandler ["EachFrame", {
   if (cameraView != "Internal") then
   {
       vehicle player switchCamera "Internal";
   };
}];
indigo wolf
meager granite
#

can't help you with waypoints, I'm bad with AIs

indigo wolf
#

Oh yea, not an issue at all - just an observation

#

Ill look into this more

fleet sand
#

With exitwith you exit the current scope you are in plus you can run aditional code if needed. With break to you need to name scopes and to exit you need to refrence specific scope with no aditional code to add in case you exit the scope.

little raptor
#

it won't see your scope name, so it won't work
also why write so much code when there's a simpler way?!

#

exitWith{} just gives me goto instruction vibes.
what you wrote gives me goto vibes
exitWith looks like return (but not the same thing ofc)

meager granite
#

Its breakWith

little raptor
meager granite
#

oh wait, its just for iterators

little raptor
#

because there's no such thing as "function" in Arma

meager granite
#

breakOut has binary version with left operand being return value

little raptor
#

i.e. no way to tell where you return to

#

that is the definition of a function yes, but in SQF "functions" don't have any distinction from "scopes" (aka "CODE" type)

#

a scope {} creates a code

#

when you assign it to a var you just call it a "function"

#

no. spawn creates a new context

#

that's a different thing

#

what I mean is that {} creates a new "variable" of type "code"

#
if _something then {}

you can just write

_code = {};
if _something then _code
#

so as you can see, it makes no sense to have return in SQF

#
fnc = 
{
  _code = { return true;  }; // return to where?!
  if _something then _code
};
#

you can probably implement return using preprocessor macros tho:

#define return(x) (x) breakOut "fnc"
#define BEGIN_FNC scopeName "fnc"

fnc = 
{
  BEGIN_FNC;
  _code = { return(true);  }; 
  if _something then _code
};

looks weird tho meowsweats

still forum
#

wrap it into a do while and breakWith πŸ˜„
(Actually I think we don't have do while do we?)
Maybe just foreach with one element? πŸ€”

sullen sigil
#

we indeed do not have breakwith in a3

#

i think it exists in vbs tho

hallow mortar
sullen sigil
#

uhhhhhhhhhhh

little raptor
#
#define return(x) (x) breakOut "fnc"
#define func(x) x = { scopeName "fnc";
#define endf };

func(myFunction)
  _code = { return(true);  }; 
  if _something then _code
endf

meowsweats

sullen sigil
#

interesting

tame bison
#

@winter rose
Tell me please again if it’s not difficult
there is a code (client):

etc...
    while {(!isNil {missionNamespace getVariable "MyVariable"})} do {};
deleteVehicle _vehicleObject;```
the car is removed immediately, but if I wrap all the code in [] spawn  , then everything works.
there is a code (server):
```params ["_sessionID"];
private _player = _sessionID call ExileServer_system_session_getPlayerObject;
my code...
_vehicleObject = [_veh, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
while {(!isNil {missionNamespace getVariable "MyVariable"})} do {};
deleteVehicle _vehicleObject;```
how to use [] spawn  here?

I want to achieve this:
spawned the car, then wait until the missionNamespace getVariableis = isNil and delete the car
little raptor
#

don't use while without sleep. or just use waitUntil

tame bison
# little raptor don't use `while` without `sleep`. or just use `waitUntil`

okay

[] spawn {
_vehicleObject = _type createVehicle (_pos);
etc...
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;
};

everything is working
but how should I use [] spawn {
code (server):

[] spawn {
params ["_sessionID"];
private _player = _sessionID call ExileServer_system_session_getPlayerObject;
my code...
_vehicleObject = [_veh, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;
};

Error Undefined variable in expression

little raptor
#

post the whole code. where did you define _type and _pos?

tame bison
# little raptor post the whole code. where did you define `_type` and `_pos`?
params ["_sessionID"];

private _player = _sessionID call ExileServer_system_session_getPlayerObject;
_vehclass = "Exile_Car_Volha_Blue";
_pos = (getPos _player) findEmptyPosition [10, 50, _vehclass];
_vehicleObject = [_vehclass, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;

if you remove the line deleteVehicle car appears

little raptor
#

where do you run it from tho?
if it worked without the waitUntil then this should work too

_this spawn {
params ["_sessionID"];
private _player = _sessionID call ExileServer_system_session_getPlayerObject;
_vehclass = "Exile_Car_Volha_Blue";
_pos = (getPos _player) findEmptyPosition [10, 50, _vehclass];
_vehicleObject = [_vehclass, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;
};
pure sapphire
#

How i can post the api in arma3 script ?

real tartan
#

Is there an alternative for addPublicVariableEventHandler since is deprecated since introduction of remoteExec ?
I usually do missionNamespace setVariable ["TAG_variable", "value", true] on server. Is there some way to listen for change of TAG_variable value? ( other than loop )

tribal lark
#

So I have a script that applies an addAction to all civilians on a server. My community uses ALiVE so it has to be run whenever new civs spawn in. However, there's a possibility that the addAction can be applied to a unit that already has it, which makes it have a duplicate one. I'm curious if there's a way to check and see if a unit already has the addAction applied so I can prevent that from happening. The best idea I have is to assign a variable to each unit and filter out the units that have that variable? Not sure how to do that when there's 20-30 civs spawned at a time tho

real tartan
tribal lark
#

Wow that was quick!

#

Thank you sm

hallow mortar
#

You can shorten that a little:

if (_unit getVariable ["TAG_actionAdded",false]) exitWith {};```
still forum
hallow mortar
#

Depending on how this is done, for example if you're using a forEach to go through all the units, you might not want to use exitWith.

tribal lark
#

I am using forEach

#

oof

hallow mortar
#
{
  if (_x getVariable ["TAG_actionAdded",false]) then {continue};
  _x setVariable ["TAG_actionAdded",true,true];
  // now add the action. If the script is running only on the server, then remember to remoteExec the action.
} forEach _yourListOfCivilians;```
tribal lark
#

Awesome :) I'm extremely new to scripting so I appreciate ya'll

knotty gyro
#

code

hallow mortar
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
↓

// your code here
hint "good!";
knotty gyro
#

Ok, I need a simple script to check wether a player is in a vehicle, and then make him captive, but remove captive status as soon as he exits the vehicle (basically make the opfor not fire at the car while the player is inside.

Something along the lines of

waituntil {sleep 2; player in (crew rescar1)};
player setcaptive 1; 
hint "Player captive";
waituntil {sleep 2; player not in (crew rescar1)};
player setcaptive 0; 
hint "Player not captive";

But I can't get it to work properly.

I need a snippet so I can paste it in the init of any vehicle of my choice.
Any guidance?

granite sky
#

You can't use waitUntil in editor init scope.

granite haven
#

id change the waituntil to this:

waituntil {sleep 2; vehicle player != player};
granite sky
#

So you'd either have to spawn that, or better, use GetIn/GetOut event handlers.

#

Best method depends on whether it's supposed to be vehicle-specific or not.

knotty gyro
#

I just need a generic code to paste to any init, like quick and dirty style

granite haven
#
0 spaw {
  waituntil {sleep 2; vehicle player != player};
  player setcaptive 1; 
  hint "Player captive";
  waituntil {sleep 2; vehicle player == player};
  player setcaptive 0; 
  hint "Player not captive";
};
#

try this

knotty gyro
granite haven
#
0 spaw {
while {true} do {
  waituntil {sleep 2; vehicle player != player};
  player setcaptive 1; 
  hint "Player captive";
  waituntil {sleep 2; vehicle player == player};
  player setcaptive 0; 
  hint "Player not captive";
sleep 1;
};
};
hallow mortar
#

spawn

granite haven
#

oops

knotty gyro
#

That's fine, I spotted it already

#

But you Sir, MrThomasM, I owe you a beer! ^^

granite sky
#

Just don't use it in a real MP mission :P

knotty gyro
#

Nah, I'm mostly making SP missions for my own amusement

#

I tend to branch out exponentially when making MP missions lol

#

They grow out of proportion in a hurry

#

Also, I remember from the early arma 1 days, a script that sort of did the same thing, but with a pistol. The script set player captive when he consealed the gun (which where then removed from inventory), and removed captive when the gun (stored in a variable) was replaced with the player.
Anyone know of any surviving caches of old scripts?

pure sapphire
#

In arma3 don’t have https request? How I can make discord log or send webhook to discord?

lone glade
#

Git is love git is life, best version control tool ever.

thin pine
#

svn is bae

lone glade
#

No repo corruption in git and the repos are lighter huehuehue.

nocturne bluff
#

ASLW maybe

tribal creek
#

could someone help me with something

#

i want to add ace's defuse function to a an object

little raptor
tribal lark
#

I'm getting an error saying _unit is undefined for _unitName = name _unit;.

_this doesn't work, I've tried putting it in other places, but Im just lost. Could use some help :)

["Civilian", "init",
{
_civs = allUnits select {side _x == civilian && side _x != playerSide && incapacitatedState _x != "UNCONSCIOUS" && captive _x != true };

{
private _unit = _x; 
   if (_unit getVariable ["TAG_actionAdded",false]) then {continue};
   _unit setVariable ["TAG_actionAdded",true,true]; 
 
    _unit addAction [
    "Have you seen any enemies nearby?",
    {
      private _enemyDetected = [_this select 0] call BIS_fnc_enemyDetected; private _unitName = name _unit;
        if (_enemyDetected) 
            then {
    titleText [format ["<t align = 'center' shadow = '2' color='#FFC0CB' size='1.5' font='PuristaBold' >%1</t>", _unitName],"PLAIN DOWN", -1, true, true]; 
    titleText ["<t align = 'center' shadow = '2' valign = 'bottom' color='#ffffff' size='1.5' font='PuristaBold' shadow = '2' >Yeah I seen them fucks, what's it to you?</t>", "PLAIN DOWN", -1, true, true];}
            else {
    titleText [format ["<t align = 'center' shadow = '2' color='#FFC0CB' size='1.5' font='PuristaBold' >%1</t>", _unitName],"PLAIN DOWN", -1, true, true];        
     titleText ["<t align = 'center' shadow = '2' valign = 'bottom' color='#ffffff' size='1.5' font='PuristaBold' shadow = '2' >Bad guys? Fuck man I'm just minding my own damn business I ain't no rat.</t>", "PLAIN DOWN", -1, true, true];}
    },
        nil,        
        1.5,        
        true,        
        true,        
        "",            
        "true",        
        5,            
        false,        
        "",            
        ""            
                     ];
} forEach _civs; 
}, true, [], true
] call CBA_fnc_addClassEventHandler;
#

The goal is to have the civ's name pop up as the first titleText

tribal lark
#

Ok I’ll try that

#

_this select 0 didn't work

#

uhh.. I won't

tribal lark
#

@tough abyss The error message said it was expecting a location or object and got an array for _this select 0

hallow mortar
#

Order of operations, it's doing (name _this) select 0

tribal lark
#

welp it got rid of the error but the name didn't show up :(

granite sky
tribal lark
#

Turns out the problem was having two titleText instead of just combining them

#

sigh

round scroll
#

@still forum thanks!

pure sapphire
indigo snow
#

underwater is only used for objects

#

isSwimming is mentioned on that page tho

#

forgot about that one :P

still forum
#

there is no isSwimming command... the underwater command just returns if the unit is in swimming state not wether its underwater

bold comet
#

if you wanted your mission to send information to a remote web server (kills/deaths happening in the mission for example), how would you do that ?

#

exploiting htmlLoad might be a solution but maybe there's a more straightforward answer ?

still forum
#

htmlLoad or making your own Extension...

meager granite
#

You can try checking if player animation has "SwimmingActions" in "actions" in config

#

@round scroll

lone glade
#

Or simply check if the unit's head is underwater ?

meager granite
#

Well unit might not be in swimming animation under water for whatever reason (animation transition, forced animation, glitch, etc.)

#

getText(configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "actions") find "SwimmingActions" >= 0

#

here is animation check anyway

polar belfry
#

hello I think I have an issue with some script code. the code I'll post is made to be executed from an init of an object like a oil spill and the thing I saw is that it was only working for the zeus and not the players.
Eg the players weren't hunted by the AA missiles that came raining but the zeus if he tried it himself would be hunted by them

#

I'll post pastebin soon when arma opens

tender fossil
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
↓

// your code here
hint "good!";
polar belfry
#

so I want it to read where any player is and act accordingly

#

but so far it only worked for zeus who put them down

polar belfry
#

by that I mean the zeus was hunted by the AA missiles but the rest weren't

hallow mortar
#

There is a difference between how init field code works for Editor-placed objects and for Zeus-placed objects.
When an object that was placed in the Editor runs its init field, the code is executed on all machines when the mission starts or when they JIP.
When an object is placed by Zeus (via saved composition), its init field code is executed only on the machine that placed it. If you need it to run on other machines too, you need to remoteExec it - or redesign the code so it doesn't need to run on every machine.

polar belfry
#

the code needs to is the issue

polar belfry
hallow mortar
#

If you choose remoteExec, don't remoteExec each command individually. Make a function and remoteExec the function.
Redesigning the code to work from one machine is complex and I'm not going to do it for you, but it should be possible. forEach playableUnits comes to mind as a starting point - stop referencing player and start referencing _x

polar belfry
#

so could I do the

{"Whole function"}foreach units player```
and all player checks could go as _x
#

instead of player eg:

if((vehicle _x iskindof "Plane") && (side _x == west))then{ ```
hallow mortar
polar belfry
#

True

#

But I meant as a concept with what I saw in the foreach page

polar belfry
#

When I get back home I'll have another question

queen cargo
lone glade
#

That's skrubs using git

warm hedge
#

No. I guess it's called scripted light, not config defined one

#

It is. And you cannot through script

#

No config values can be overwritten on the fly, as you already know

neat bloom
#

Hello people, i have a question about hint function in multiplayer.

hint "123";

it will be send only to one player, but how to define, who is that player?

lone glade
#

now git gud

stable dune
polar belfry
#

Just to make sure with foreach command
The zeus/server calls the function and gets data for each user

#

in my case I have let's say 3 players

queen cargo
#

"cool. How do we use it?" "No idea. Just memorize these shell comands and type them to sync up."

polar belfry
#

It will do the function for me, then for my second and third player

#

cause I tell the server to get data for each playable unit

queen cargo
#

q.e.d.

obtuse crypt
#

Hello,

Question regarding simple issue. I wanted players which spawn on specific position, to be teleported to specific vehicles as soon as mission start. In order to do that I placed next code in each of players init.

this moveInCargo V1;

When tested in SP and MP from editor it worked properly.

When I tested it on dedicated server with 2-3 players it also worked.

When mission started with 40 players on server, no one was teleported to their vehicles.

Does anyone know what is issue and what can I do to solve it?

bold comet
#

unless you got a neat client or ide plugin doing all the work

obtuse crypt
meager granite
#

Init field is a pretty bad place to have your scripts, its global executing including for JIP players

#

Thought moveInCargo requires unit to be local πŸ€”

obtuse crypt
meager granite
#

These are player units you choose in lobby, right?

obtuse crypt
#

So we pick slots, we enter map for briefing and then go inside game.

meager granite
#

Tweaked it a little

#

Hm

#

More tweaks

#
  1. If client is not a dedicated server (will have a player unit)
  2. Spawn a thread and wait until player loads (player == player) and locality arrives from the server (local player)
  3. Then if this particular editor unit is the player, do move in cargo.
#

Potential issue: If player joins later in the game into that unit and it was AI, they'll teleport into the vehicle

#

If your mission supports players turning into AI when they leave and JIP, I can account for that too

#
if(!isDedicated) then {this spawn {waitUntil{local player}; if(player == _this) then {_this moveInCargo V1}}};
#

Removed player == player as local player should cover both already

obtuse crypt
meager granite
obtuse crypt
# meager granite Yes, that. I guess it should be fine then.

Ok, thank you again, I will test this one.

While we are on topic, another question. On same mission I have a trigger with Server Only option checked, activated by anyPlayer and next code inside onActivation field:

AIV_1 setFuel 1;

Again, it worked normally in SP/MP but on dedicated it didnt, so I needed to uncheck Server Only option. Is this a correct way to do this, or I did something wrong.

meager granite
#

Why was it server only?

obtuse crypt
# meager granite Why was it server only?

I try to use server only to avoid unnecessary executions on other clients, basicly I understood that is correct way to do for playing on dedicated server with larger number of players.

meager granite
#

So the idea of trigger that some player unit enters it and it refuels some vehicle? Or do you have another condition to check if that vehicle is also in the trigger?

#

As for optimization concerns, I don't think its a big deal unless you have 1000 of these triggers or very complex condition in them.

obtuse crypt
meager granite
#

having that trigger global should be fine, its a drop in the ocean performance-wise

obtuse crypt
# meager granite having that trigger global should be fine, its a drop in the ocean performance-w...

Thanks one more time.

I have one last, as it concerns me in a same way as the first question with moveInCargo. I use LAMBS AI mod and HC on my server. Due to that if I want AI to stay static, I need to turn off LAMBS for it and execute command for DisableAI. For that purpose I made a small script so I dont need to write whole code for each AI unit separatly.

This is code:

Private _Target = _this select 0;
if ( local _Target ) then {

    waitUntil { time > 0; };
    _Target setVariable ["lambs_danger_disableAI", true, true];
    _Target disableAI "PATH";
    _Target setunitpos "UP";
    _Target forceSpeed 0;
};```

Is it ok if I call this script from AI unit init using only this code?

```sqf
this call {[_this] execVM "Disable_Move.sqf";};
meager granite
#

Looks fine

obtuse crypt
meager granite
#

isDedicated check in case of units is done to never reach local player waitUntil, becuse it will never resolve on dedicated server as it never has a player unit

obtuse crypt
neon plaza
#

Trying to get this as a line of code that players can use on an Item...


this addAction ["Its just a weather balloon agent Mulder, {  
params ["0 setFog [0,0,0];  

winter rose
#

who wrote that…

neon plaza
#

lol me

#

I am not a coder my friend.

hallow mortar
#

Any time you open a thing, be it starting a string with ", starting a code block with {, or starting an array with [, there must be an equivalent close - another ", a }, or a ] as appropriate

#

Also you've got a random params [ hanging out that doesn't seem necessary in the context of what you're doing, even if it was done properly

neon plaza
#

Yea If anyone knows how to write that line of code that would make It useful.

hallow mortar
#

Please don't DM me. This is the channel to discuss scripting problems. Posting here allows everyone to help.

winter rose
#
this addAction ["Its just a weather balloon agent Mulder", {
  0 setFog [0,0,0];
}];
```should be enough.
neon plaza
winter rose
#

yes

#

see https://community.bistudio.com/wiki/addAction:

this addAction
[
    "title",    // title
    {
        params ["_target", "_caller", "_actionId", "_arguments"]; // script
    },
    nil,      // arguments
    1.5,      // priority
    true,     // showWindow
    true,     // hideOnUse
    "",       // shortcut
    "true",   // condition
    50,       // radius
    false,    // unconscious
    "",       // selection
    ""        // memoryPoint
];
winter rose
#

so basically,

this addAction
[
    "It's just a weather balloon, agent Mulder",    // title
    {
        0 setFog [0, 0, 0];
    },
    nil,      // arguments
    1.5,      // priority
    true,     // showWindow
    true,     // hideOnUse
    "",       // shortcut
    "true",   // condition
    3         // radius
];
neon plaza