#arma3_scripting

1 messages ยท Page 737 of 1

wind cairn
#

ok

little raptor
#

an event handler is executed somewhere else

south viper
#

hi i have a problem with "playsound" without the gas mask the sound start again. so the problem (i think) it's the execution of the sound (with cba_fnc_waitandexecute)

player addEventHandler ["InventoryClosed", 
{
    if ("G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)) then 
    {
        
        if (!(gas_mask_effect_sound_playing)) then 
        {
            no_gas_mask = false;
            call BIS_fnc_VRFadeIn;
            gas_mask_sound_put_on = playSound "gas_mask_put_on";
            "RscCompass" cutrsc ["RscCompass","plain"]; // Show digital compass
            "gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
            _function = 
            { 

                gas_mask_effect_sound = playSound "gas_mask_effect";
                [_this, _this, 19] call CBA_fnc_waitAndExecute;
            };

            [_function, _function, 20] call CBA_fnc_waitAndExecute;

            //gas_mask_effect_sound_playing = true;

            if ((backpack player) == "B_CombinationUnitRespirator_01_F") then 
            {
                (backpackContainer player) setObjectTexture [2, "a3\supplies_f_enoch\bags\data\b_cur_01_co.paa"]; // Show hose segment
            };
        };
    } else 
    {
        no_gas_mask = true;
        deleteVehicle gas_mask_effect_sound;
        //gas_mask_effect_sound_playing = false;
        "RscCompass" cuttext ["","plain"]; // Hide digital compass
        "gas_mask" cutText ["", "PLAIN"]; //Overlay off
        if ((backpack player) == "B_CombinationUnitRespirator_01_F") then 
        {
            (backpackContainer player) setObjectTexture [1, ""]; // Hide hose segment
        };
    };
}];
wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
โ†“

// your code here
hint "good!";
south viper
#

woah

#

player addEventHandler ["InventoryClosed", 
{
    if ("G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)) then 
    {
        
        if (!(gas_mask_effect_sound_playing)) then 
        {
            no_gas_mask = false;
            call BIS_fnc_VRFadeIn;
            gas_mask_sound_put_on = playSound "gas_mask_put_on";
            "RscCompass" cutrsc ["RscCompass","plain"]; // Show digital compass
            "gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
            _function = 
            { 

                gas_mask_effect_sound = playSound "gas_mask_effect";
                [_this, _this, 19] call CBA_fnc_waitAndExecute;
            };

            [_function, _function, 20] call CBA_fnc_waitAndExecute;

            //gas_mask_effect_sound_playing = true;

            if ((backpack player) == "B_CombinationUnitRespirator_01_F") then 
            {
                (backpackContainer player) setObjectTexture [2, "a3\supplies_f_enoch\bags\data\b_cur_01_co.paa"]; // Show hose segment
            };
        };
    } else 
    {
        no_gas_mask = true;
        deleteVehicle gas_mask_effect_sound;
        //gas_mask_effect_sound_playing = false;
        "RscCompass" cuttext ["","plain"]; // Hide digital compass
        "gas_mask" cutText ["", "PLAIN"]; //Overlay off
        if ((backpack player) == "B_CombinationUnitRespirator_01_F") then 
        {
            (backpackContainer player) setObjectTexture [1, ""]; // Hide hose segment
        };
    };
}];

#

beautiful ! thanks

quasi condor
#

so.. you can't solve this?

little raptor
south viper
#

how can i fix it

little raptor
quasi condor
#

bruh

#

I have nitro

#

goodbye spam

#

whatever

#

what should i do...

little raptor
#

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

south viper
#

with CBA_fnc_waitUntilAndExecute ?

little raptor
#

in CBA_fnc_waitAndExecute before looping again.

#

but didn't it have a condition already? thonk

south viper
#

oh in the _function

quasi condor
#

i think init.sqf is calling TAAG_fnc_startMission before description defines that function

little raptor
#

if you use CfgFunctions that is

quasi condor
#

then

#

it must be bug

south viper
#

working ๐Ÿ˜‰

player addEventHandler ["InventoryClosed", 
{
    if ("G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)) then 
    {
        
        if (!(gas_mask_effect_sound_playing)) then 
        {
            no_gas_mask = false;
            call BIS_fnc_VRFadeIn;
            gas_mask_sound_put_on = playSound "gas_mask_put_on";
            "RscCompass" cutrsc ["RscCompass","plain"]; // Show digital compass
            "gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
            gas_mask_effect_sound_playing = true;
            _function = 
            { 
                if (gas_mask_effect_sound_playing) then 
                {
                    gas_mask_effect_sound = playSound "gas_mask_effect";
                    [_this, _this, 19] call CBA_fnc_waitAndExecute;
                };
            };

            [_function, _function, 20] call CBA_fnc_waitAndExecute;

            
            if ((backpack player) == "B_CombinationUnitRespirator_01_F") then 
            {
                (backpackContainer player) setObjectTexture [2, "a3\supplies_f_enoch\bags\data\b_cur_01_co.paa"]; // Show hose segment
            };
        };
    } else 
    {
        no_gas_mask = true;
        deleteVehicle gas_mask_effect_sound;
        gas_mask_effect_sound_playing = false;
        "RscCompass" cuttext ["","plain"]; // Hide digital compass
        "gas_mask" cutText ["", "PLAIN"]; //Overlay off
        if ((backpack player) == "B_CombinationUnitRespirator_01_F") then 
        {
            (backpackContainer player) setObjectTexture [1, ""]; // Hide hose segment
        };
    };
}];

little raptor
quasi condor
#

"Functions\startMission.sqf" call BIS_fnc_execVM; will this work

cyan dust
#

=_= Good day, I'm trying to pack and run server side mod, but my init scripts never fire and I don't get it why. I do have config.cpp with

class CfgFunctions {
    class SOMETAG{
        class initServerMod{
            file = "initServerScripts.sqf";
            preInit = 1;
        };
    };
};

And as I understand, it must be called automatically on mission start, but that just never happens and I do not see any error messages in log files, it just.. not working. Any helb please?

quasi condor
#

wait

#

omg

little raptor
#

also if that worked then you can try spawning it

#
[] spawn TAA_Fnc_blabla
quasi condor
#

ok

wary python
#

If i add an EH to a playable unit in an MP mission, does it still work if that player respawns or would that be a new unit with no EH on it?

little raptor
cyan dust
quasi condor
#

Is there an event that detects the end of task?

little raptor
little raptor
#

aren't you the one who controls the task?

cyan dust
little raptor
#

it's not a function

cyan dust
#

Pardon? I don't quite get it

little raptor
#

read the wiki

cyan dust
#

I did =_= ok, guess I'm missing something, thanks

little raptor
#

and here's an example

quasi condor
little raptor
quasi condor
#

but i don't know how to control it

little raptor
#

but anyway I don't think it has one

little raptor
#

you're doing it

#

it's not magically "failed"

quasi condor
#

uh

#

so

#

i wanna make

#

if every task are "SUCCEEDED" and "FAILED",

#

I want to delete every task

little raptor
#

keep a list of all tasks

#

when one succeeds or fails, check if all are succeeded or failed

quasi condor
#
while (true) do {
  if ("task" call BIS_fnc_taskState isEqualTo "SUCCEEDED" || "task" call BIS_fnc_taskState isEqualTo "FAILED") then {
  blablablabla
  break
}
}```
#

like this?

little raptor
#

no. when did I say use a loop?

#

using a loop when you're in control of something is stupid

#

it's like you're the one who presses a button, but you're always asking has the button been pressed yet? meowsweats

quasi condor
#

no

#

is there another way?

little raptor
quasi condor
#

oh wait

#

i'm the dumbest guy in the world

#

I got it

little raptor
#

iirc they do

#

but not sure

cyan dust
little raptor
#

your path is incorrect

cyan dust
#
class CfgFunctions 
{
    class Main {
        class init {
            class main {
                file = "\init\fn_initServerScripts.sqf";
                preInit = 1;
            };
        };
    };
};

the file's address is itself is in
ROOT\init\fn_initServerScripts.sqf

And the error message is

Warning Message: Script \init\fn_initServerScripts.sqf not found

Like... what path is incorrect T_T

little raptor
cyan dust
little raptor
#

you must start with the addon prefix

little raptor
#

when you start a path with \ it means addon path, not relative path

cyan dust
#

Thanks, I guess I understand now.

tough abyss
#
systemChat "Happy holidays!"
#

actually, better yet

#
["Happy holidays!"] remoteExec ["systemChat"];
little raptor
#
_snowMan = "snowman" createVehicle [0,0,0];
_fireworks = [];
for "_i" from 1 to 10 do {
  _fire = "fireworks" createVehicle [0,0,0];
  _fire setVelocity [random 5, random 5, 100];
  _fireworks pushBack _fire;
};
sleep 3;
{
  _x setDamage 1;
} forEach _fireworks

๐Ÿ˜›

tough abyss
#

perfect

versed widget
#

is there a parent class for submersibles ?

lavish stream
#

SDV_01_base_F?

little raptor
#

it's a bad practice to check the "parent class" for objects

#

mods can create their own parent class

versed widget
#

than i will use PositionASLW to check i guess

little raptor
#

wat? thonk

versed widget
#

if its a vehicle and its beneath the seabed then its a submarine but i have to add a check to see if its damaged or not

little raptor
versed widget
#

rocks are classified as terrain objects or do they ? well then i have to add a 3rd check to see if a unit is in side lol

little raptor
#

that's what you should do

#

for example, check the simulation of the object

austere granite
#

A lot of terrain objects don't have configs :)

little raptor
austere granite
#

Ah yeah I was misreading, that's the intention then

pallid ravine
#

Do event handlers of the same event type fire in the order they are attached? Or is it unpredictable?

little raptor
#

but UI EHs fire in reverse order

pallid ravine
#

Awesome, thanks for the info!

still forum
leaden haven
#

Is there any way in MP to check if a player has finished Prologue Bootcamp when they join mp server?

chilly bronze
#

is there a quick way using scripting to force AI to seek cover?

#

i dont want to make my own script, if necessary

chilly bronze
#

is there a way to get the class type of a terrain object? ex, using nearestTerrainObjects, you can filter by a ton of object types such as "TREE","BUILDING","BUSH","HOUSE", etc. I've find you can use object isKindOf type to check if an object is a specific type but oddly I can't find an SQF function to find the type of a terrain object? I tried using BIS_fnc_objectType but it only returns houses and not rocks or trees

chilly bronze
#

my only solution is to create a list of all the class names i want to search for, then use nearestTerrainObjects on each individual classname in the list and save the found objects across the entire map in a hashmap where each key is the object type (ex "brickwall_01_l_5m_d_f.p3d") and its value is the class name (in this case, "WALL".) It takes 10+ minutes to run, but I only need to run it once per game map. Then, I copyToClipboard, save it in an sqf, executing the sqf file returns a hashmap with every map terrain object type and their specific classname so i can easily find any objects class type

tough abyss
#

"TREE", "BUILDING", "BUSH", and etc. are not class names, they're just filter strings for use in commands

#

many terrain objects do not have an associated config class, but if they do you can find them via typeOf like any other object

#

if you really want to just categorize them according to those strings you could just do something like this

#
private _categoryHashmap = createHashMap;
private _categories = ["TREE", "SMALL TREE", "BUSH", "BUILDING", "HOUSE", "FOREST BORDER", "FOREST TRIANGLE", "FOREST SQUARE", "CHURCH", "CHAPEL", "CROSS", "BUNKER", "FORTRESS", "FOUNTAIN", "VIEW-TOWER", "LIGHTHOUSE", "QUAY", "FUELSTATION", "HOSPITAL", "FENCE", "WALL", "HIDE", "BUSSTOP", "ROAD", "FOREST", "TRANSMITTER", "STACK", "RUIN", "TOURISM", "WATERTOWER", "TRACK", "MAIN ROAD", "ROCK", "ROCKS", "POWER LINES", "RAILWAY", "POWERSOLAR", "POWERWAVE", "POWERWIND", "SHIPWRECK", "TRAIL"];

{
  _categoryHashmap set [_x, nearestTerrainObjects
    [
      [worldSize / 2, worldSize / 2],
      [_x],
      worldSize * sqrt 2 / 2, 
      false
    ];
  ];
} forEach _categories;
chilly bronze
#

thats pretty close to what i did at first, but then i realized that if i had a specific object and wanted to find what category it would be in, you would have to search the list in each hashmap key (the tree category itself is 1.48866e+006 elements long) and that could take a long time for multiple objects and ruins the entire point of using a hashmap for speed

tough abyss
#

That's true but the overall approach is a death sentence for speed anyways

#

why do you need to store every single terrain object?

chilly bronze
#

well, i wanted to be able to characterize the surroundings of an AI so it can better chose where to take cover based on the type of terrain object

tough abyss
#

Should probably use the existing AI functions rather than rolling your own cover-seeking algorithm

#

the engine already has support for this type of thing

chilly bronze
#

Well, i was looking online and couldnt find anything. All the commands such as 'findCover' and 'setHideBehind' are broken commands that aren't implemented. I know the AI commanding menu has a seek cover action, but it doesn't seem to be available through SQF

tough abyss
#

What you want is AI behavior

#

Depending on the behavior type they will dynamically find appropriate cover

chilly bronze
#

I tried experimenting with different behaviors but I didn't notice a difference, I think because I am making the script for civilians. I'm not necessarily trying to create a complex cover system, just tell civilians to run and hide behind the first solid piece of cover nearby or run away based on the environment

tough abyss
#

It should work fine on civilians

#

iirc

#

might be worth looking into this

pale glacier
#

Hey lads
Please help with dedicated server playable unit..

What's the idea: A player gets close to a locked house and a trigger checks if he has a key object in his inventory and if yes, door is opened.

This is half the code, I just need the end of it ๐Ÿ˜
What is the proper command so the server checks the specific unit that activates the trigger if it has a key?

{'Keys' in (uniformItems _x + vestItems _x + backpackItems _x)}...
distant oyster
#
true in (thisList apply {'Keys' in (uniformItems _x + vestItems _x + backpackItems _x)})
``` Assuming this is the Condition of the trigger
little raptor
#
thisList findIf {'Keys' in (uniformItems _x + vestItems _x + backpackItems _x)} != -1
still forum
little raptor
#

but better use uniqueUnitItems

distant oyster
#

just post some bad code and you'll get an answer immediately ๐Ÿ˜†

pale glacier
#

Thanks a lot!!

versed widget
#
if (true) 
   then {
     while {true}    
  do  {
     if (cameraOn == objectparent player && cameraView =="EXTERNAL") 
         then {sleep 2;};
        };
//bunch of code 
};

i wanted to execute a bunch of codes once the cam view isnt External however it seems that it does not work

brave jungle
versed widget
#

in the place of that (true) im going to replace it with a variable so when it is enabled the while will start checking, even though i tried with while directly and didnt work either ๐Ÿ˜ฆ

brave jungle
#

cameraOn looks for an object
objectParent player will return <NULL-object>

#

try ```sqf
//check if in 3rd Person
if (_someVariableReturningTRUE) then {
while {true} do {
if (cameraOn == player && cameraView == "EXTERNAL") then {
sleep 2;
};
};
//bunch of code
};

//check if not in 3rd
if (_someVariableReturningTRUE) then {
while {true} do {
if (cameraOn == player && cameraView != "EXTERNAL") then {
sleep 2;
};
};
//bunch of code
};

#

that will fire when in 3rd person

#

to run everytime when not in 3rd person change cameraView =="EXTERNAL" to cameraView != "EXTERNAL", for example 1st person

#

I'd suggest you make some variable in the while so you can "destroy" it also PES_ThumbsUp

versed widget
#

cameraOn == player, means that when you are in a vehicle it wont activate as player != vehicle player, also != "EXTERNAL" is the same as == "INTERNAL", the "bunch of code is a little long thats why im trying to disable when External, sadly your code didnt work either ,i will try to add the variable inside the while and see what will happen ๐Ÿ™‚

brave jungle
#

add vehicle player

#

and it will do the same in vics

versed widget
#

did with no luck though objectparent player = vehicle player :))

brave jungle
#

What you after exactly?

versed widget
#

once that CBA variable that i will replace the true with is enabled via checkbox, the while code runs, and when it does everytime the player is in EXTERNAL view it disables the rest of the code via sleep command.

brave jungle
#

I wanna see it all cuz im sure theres a better way of doing it

#

Just at a glance i think you just be setting a variable and then running code depending on if its True or False

versed widget
brave jungle
#

kk ty

#

Go to ur dms a sec

valid abyss
pale glacier
#

Hey Good men
DEDICATED SERVER issue ๐Ÿ™‚

I have this script, when I'm pointing my gun on a specific civilian, he's doing some stuff I need (surrender and start to talk)..

((cameraView == "GUNNER" && (cursorObject == naknik) && player distance naknik < 5 ))

As you know, player is not something that dedicated servers like (or know..). What exactly should be there instead of player, so all playable units that "threaten" this civilian can do the same thing?

valid abyss
#

Maybe you could execute it locally on each client?

pale glacier
#

initPlayerLocal.sqf?
Would it work on dedicated? I have my concerns because of the player stuff

valid abyss
#

as long as its executed locally you should be able to use player without issues

copper raven
hazy pasture
#

So in the line of coding, do you guys think it'd be possible to create a working lightsaber?

pale glacier
#

Thanks man, I'll try

jovial cipher
pallid ravine
#

What can you do in a remoteExec addAction that would result in a kick from a server with battleeye?

tidal ferry
#

Hey, is there any way to make clickable diary records?

#

E.g. where you can click on certain specified text inside of a diary entry

#

And it'll execute code

#

Working on an idea for a reinsertion system to help my guys have a better time in ops

tidal ferry
#

Oh! Huh

#

Had no clue you could just add an execute tag

#

Thanks

tidal ferry
#

Hey, so another question

#

I'm looking to have a serverside script, that will remote execute another script on the machine of the logged-in admin

#

Any idea of the quickest way to grab a list of all machine IDs in a session?

bitter jewel
tidal ferry
#

Could probably check allPlayers using owner, yeah

#

Is that the most efficient way to do that?

#

Maybe something like this?

allPlayers findIf {
admin owner _x == 2;
};
#

Oh wait

#

Fixed to use allPlayers

brazen lagoon
#

this is a bit of a weird question, but lets say you have an FSM running. and then lets say that FSM uses 'call' on a function, which then calls a subsequent function that has an error because it tries using something that's nil

#

will this function continue?

#

basically, in an FSM for ALiVE, it makes this call: [_this select 0,"cleanupduplicatesections"] call ALiVE_fnc_OPCOM;

#

this function, near its end, iterates over a list and makes this call: [_logic,"resetObjective", ([_objective,"objectiveID"] call ALiVE_fnc_HashGet)] call ALiVE_fnc_OPCOM;

#

resetObjective does this, which can return nil, but then tries to use that nil value later: private _previousTacomState = [_objective,"tacom_state"] call ALiVE_fnc_hashGet;

#

How does using a nil value actually work in arma 3 sqf? Will this cause the whole call chain to fail, will just the one statement that uses the nil value fail?

#

will the fsm exit?

#

not entirely certain who to ask or where to look for this

tidal ferry
#

Got it figured out!

tough abyss
#

@brazen lagoon Setting something to nil in and of itself is not an error, it's actually a perfectly valid statement you can use to "delete" variables

#
_thisVar = nil;
// _thisVar no longer exists
#

the problem is the repercussions of said deletion

#

if you're using that deleted variable later on, you will get an undefined variable error which will terminate the script

brazen lagoon
#

@tough abyss yes that is the question I'm asking

#

it won't return to the calling script

#

it'll just kill it?

tough abyss
#

That is generally how exceptions work, yes

#

if you don't want that to happen you need to do exception handling

brazen lagoon
#

yes, that was how I thought they worked in sqf, I'm just double checking my assumption

#

because assuming things about sqf is a bad idea I've found

#

it does a lot of things subtly differently than other languages..

#

so anyway. let's say you have something like

#

actually lemme go to my computer so I can do some proper typing

#
test1 = {
  params ["_print", "_setNil"];
  _setNil = Nil;
  hint _setNil;
  hint _print;
};

["test", "test1"] call test1;

with my understanding of sqf, this will log a script error and hint nothing, correct?

#

but then lets also consider this situation:

test1 = {
  params ["_print", "_setNil"];
  _setNil = Nil;
  hint _setNil;
  hint _print;
};

test2 = {
  ["test", "test1"] call test1;
  hint "fn called";
};

call test2;```

Will this hint 'fn called'?
#

yes it does

#

even more confusingly: ```sqf
test1 = {
params ["_print", "_setNil"];
_setNil = Nil;
hint _setNil;
hint _print;
};

test2 = {
["test", "test1"] call test1;
};

call test2;

#

this doesn't do anything (I think because sqf is lazy evaluated): ```sqf
test1 = {
params ["_print", "_setNil"];
_setNil = nil;
_print = (_print + _setNil);
};

test2 = {
[1, 2] call test1;
};

call test2;

But if we try to add `hint str _print` to test1, it will throw "generic error in expression"
buoyant elm
#

why are you overwriting your function arguments? _setNil = nil;

#

anything after that line means _setNil is empty now

#

so your method is now trying to add 1 to nil

brazen lagoon
#

@buoyant elm yes, I wanted to see what this would do in the calling function

brazen lagoon
buoyant elm
#

my understanding is that depending on where you ru nthe script you can end up in a threaded or non-htreaded environment

brazen lagoon
#

well this is using call not spawn

buoyant elm
#

i think running them from the box in zeus is threaded, and non-blocking

#

also for sure scripts are not compiled unless you binarize them, in which case i don't know if it would tell you you have runtime errors

still forum
buoyant elm
#

that too, there's plenty of non-fatal errors you can have

brazen lagoon
#

i see

#

what would be fatal?

still forum
#

A game crash :D
I can't think of any

brazen lagoon
#

lmao

buoyant elm
#

the scripts seem pretty safe, it's just that each error you generate can slow down script processing in general

brazen lagoon
#

so this code block here:

private _previousTacomState = [_objective,"tacom_state"] call ALiVE_fnc_hashGet;
[assume _opcomID, _objective, _side, _factions are all successfully gotten (not nil)]
private _event = ['TACOM_ORDER_COMPLETE', [_opcomID,_objective,_previousTacomState,_side,_factions, false, []], "TACOM"] call ALIVE_fnc_event;```
#

if _previousTacomState is nil, it will whine about an unknown variable

#

but will this also crash the script that is calling the function this code is in?

buoyant elm
#

set it to {} ?

still forum
#

Yeah, but won't exit. It will just also nil

still forum
brazen lagoon
#

how so?

#

_event isn't whats returned upward

still forum
#

If it ends up returning a nil because of that, that can cause issues in the parent script

#

The way Arma handles errors and exits or not exits Scripts is mysterious and complex

#

Best to just not have errors

brazen lagoon
#

lol

buoyant elm
#

honestly, you should always be nil-checking and not jsut assumnig you have a useful value

brazen lagoon
#

ye, i've learned this the hard way

buoyant elm
#

no need to even call functions sometimes if all yoru data isn't there, saves a stack call

brazen lagoon
#

im looking into a bug someone found, not my code

#

I think when it was written they should have put a default value in the first call to hashGet but they neglected to

buoyant elm
#

a single nil-check would solve it

brazen lagoon
#

yep

buoyant elm
#

lazy scripting, or newbi programmers who weren't taught to distrust all data

#

never trust user input, and never assume your values are valid if they're important

brazen lagoon
#

tbh sometimes people just forget

#

its a shame too because this would be a function that would be relatively easy to test if there was an sqf test harness that existed

#

actually that seems like a @still forum question: can you run sqf scripts in any way outside arma? Like lets say I wanted to run tests against an sqf codebase

still forum
#

CBA has one

brazen lagoon
#

no kidding? I'll have to look into that

still forum
#

There is SQF-VM, a external SQF thing that can run code and aims to be as close as possible to Arma itself

#

CBA runs theirs ingame though

brazen lagoon
still forum
#

Ye

brazen lagoon
#

yeah, the cba thing is all in game. I was hoping for something you could have run against pull requests on github

still forum
#

SQF-VM can run most of CBAs unit tests.
Just not the ones that actually need to be ingame, with Units and Objects ans stuff

brazen lagoon
#

right right

#

so stuff where you mock out objects and such could easily run in sqf vm

still forum
#

Yeah

#

It has some support for objects, like setPos/getPos maybe.
But its aim is to implement SQF, not a whole game running behind it

tough abyss
#

the real pro tip is to make sure all of your code runs in factorial time ๐Ÿ˜Ž

buoyant elm
#

all my code is O(1)

tough abyss
#

O(N!^(N!)) is supreme

buoyant elm
#

oof

brazen lagoon
#

honestly

#

the hottest take is

#

for small N it doesn't matter

#

even horrendously inefficient/expensive algorithms can be good enough if your N is small

tough abyss
#

who cares about scalability right

brazen lagoon
#

ofc the flip side of this is also true, even very small improvements can make a huge difference on something that runs every frame

tough abyss
#

just assert(n < 5) and be done

brazen lagoon
#

no, but I just mean like... don't waste your time optimizing something that runs once at mission start and takes a few seconds, yknow?

tough abyss
#

indeed I'm just being a smartass

brazen lagoon
#

:^)

#

also arma is a great situation to prove uh... I'll need to double check the name of the law, but it's the one that says "as things become more parallelizable, the stuff that can't be will become the limiting factor more and more"

#

amdahl's law

tough abyss
#

Well and sqf also has the natural bottleneck of being an interpreted language rather than a compiled one

#

with a lot of functions taking runtime-compiled code params

brazen lagoon
#

in theory Arma supports an infinite number of AI, just keep throwing more HCs at it. In reality, you'll run into the server's single core + network being the limiting factor at like.. probably 200-250

pallid ravine
#

What is remoteExec restriction #23, and is there a reference to what battleeye restricts and what it does not?

little raptor
pallid ravine
#

I just read through the CfgRemoteExec page on the wiki and in the config viewer, but sadly I couldn't find any concrete examples of what battleeye is looking for when it is filtering through the script code.

#

I genuinely have no idea what's causing the issue. I'm going to paste the problematic code here, and hopefully someone knows what battleeye is fussing about.
https://pastebin.com/W6Dm8YNS

copper raven
#

check your battleye filters

pallid ravine
#

I've tried finding them but have had no luck. Where are they supposed to be saved?

pallid ravine
#

Disregard.

queen cargo
chilly bronze
#

do you guys think the enforce scripting language is better than sqf? i always find myself wanting to use objects and inheritance when im using sqf

leaden haven
#

I seem to have cracked it.

_bootme = getStatValue "BCFirstDeployment";

This will return 1 if the player has done Bootcamp campaign. So you can use an if statement and then alert the player that they need some exp before playing your mission. Would be very useful for Warlords...

#

Seems to work in MP from EDEN.

#

Nice code.

if (_bootme != 1) then {
        _message = _message + "Please finish the Bootcamp campaign before playing.<br /><br />";
} else {
        _message = _message + "Welcome to Afghanistan Zeus ops.<br /><br />";
};
fair drum
copper raven
brazen lagoon
#

@fair drum @chilly bronze simply by having hashmaps on release and functions with parameters that aren't hacked in its gonna be better honestly

#

the OOP features I'm worried about because I don't generally like OOP overuse. but it could still be useful in a lot of ways to have objects considering its common to hack in objects and polymorphism into sqf like some kind of horrifying amalgamation of tcl and C. like don't get me wrong it rocks that it works and I'm constantly impressed by the community, but it'd be so much more readable if it was native

brave jungle
#

I'm using __Eval( selectRandom[..7 indexes..]) but its only selecting index 1 and index 5. Any ideas why? It's done inside a non bin config

little raptor
#

maybe try __RAND_UINT8__ instead? thonk

brave jungle
#

Ahhh disnt know it existed :) will try when I get the chance, thanks for the info tho I can work woth it now PES_ThumbsUp

little raptor
#

actually better use a sqf command instead

#

e.g systemTimeUTC

#

and compute a new seed

brave jungle
#

Then just use random and then select with that

#

Cool cheers!

little raptor
#

yes

#

e.g. _time = systemTimeUTC; _seed = _time#6 + _time#5 * 1000 + _time#4 * 60000

brave jungle
#

#define BACKGROUND_IMAGE __EVAL([..arrayOfImages..] select ((systemTimeUTC#6 + systemTimeUTC#5 * 1000 + systemTimeUTC#4 * 60000) random 7))
When checking the config, its returning text = "any";. Now, I know these images work because my old method works, just only gives me 2 of the possible 7 (see above).
Is it possible random might not work in __EVAL?

brave jungle
#

Oh right course ๐Ÿ˜„

still forum
little raptor
brave jungle
#

just for my future reference, is there a list of stuff that doesn't work in preprocess on wiki?

still forum
brave jungle
#

ty for helping!

little raptor
brave jungle
#

Yeah, in the middle of just checking it shows all of them, eventually, but so far its done 3

#

Its a background randomizer on rscDisplayStart so can imagine its a bit tedious haha

#

So its done all but 1 so i'm gonna say yes it is randomizing correctly

little raptor
brave jungle
#

It seems to favour index 2-5

#

Will test also

#

Yeah seems to "duplicate" less often now

#

But still seems to favour certain integers

#

Anyhow that doesn't bother me really, glad its randomising properly now ๐Ÿ˜„

tough abyss
wary python
#

Hello, can anyone explain the highlighted line in this code? From testing it won't do anything but make it slower. And if i understand correctly it will just go through every element and add it to the new ResuppMags?

//GetMags script for resupply crate
ResuppMags = []; 
{
        ResuppMags = ResuppMags + 
        (magazines _x) +
        [(currentMagazine _x)] +
        (primaryWeaponMagazine _x) + 
        (handgunMagazine _x) + 
        (secondaryWeaponMagazine _x)
} forEach (playableUnits + switchableUnits + allPlayers); 
ResuppMags = ResuppMags select {count _x > 0};  <------------------
ResuppMags = ResuppMags arrayIntersect ResuppMags; 
copyToClipboard str ResuppMags;
hint str ResuppMags;    
little raptor
#

so it's always returning the whole array

#

(magazine names are never empty)

#

also that's horribly inefficient

#

(I mean the script itself, not just that part)

#

the part that's slowing it down for you is ResuppMags = ResuppMags arrayIntersect ResuppMags;

#

not the select

#

arrayIntersect is a single command and runs unschd

#

if the array is long it'll freeze the game

wary python
little raptor
#

yes

#

if you wanted to get the ammo count in the mag that's not the correct command

wary python
#

Okay, thanks a lot for the explanation :)

tight cloak
#

how would one fetch the side of an object from cursor target?

#

im using

_flagging = "cursorObject == (side == west)";

in an if ()

little raptor
#

side cursorObject meowsweats

tight cloak
#

bruh

#

sorry give me a moment to hold my head in shame

little raptor
#

it needs args

#

you can't write it like that

tight cloak
#

"side west" right?

little raptor
#

it takes an object/group

#

not side meowsweats

#

you're doing side SIDE

#

it should be side OBJECT or side GROUP

tight cloak
#

(side cursorObject == west);

little raptor
#

yes

tight cloak
#

thankyou

#

it was staring me in the face

#

im angry at myself rn

#

thankyou so much leopard

#

next question. how would one move a players weapon into the WeaponInHand action

#

as currently

player action ["WeaponInHand", player];
``` does nothing
little raptor
#

use the switchWeapon action

#

and iirc index 100

#

or 10 thonk

tight cloak
#

alas

#

i tried 1-15

#

and 97-102

#

all it does is either switch to secondary or put on back

#

not the gun to chest aiming at the floor

little raptor
#

I thought you meant on back meowsweats

#

what on earth is weaponinHand? thonk

tight cloak
#
WeaponInHand / WeaponOnBack
Description:    Soldier 'unitName' does nothing, 'target unit' moves his weapon from/to the safety position (gun held across chest pointing at the ground).
Change is persistent with player, but AI units will change back to suit their current behaviour mode. AI generally keep their rifles safe unless moving or targeting.

Syntax:    unitName action ["WeaponInHand", target unit]
unitName action ["WeaponOnBack", target unit]
Example:    
SoldierOne action ["WeaponOnBack", SoldierTwo]
#

@little raptor

#

what i was following

little raptor
#

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

#

there are also playActions for that you can try

tight cloak
#

having a browse of them rn

#

is it possible to force an input action?

#

inputAction "toggleRaiseWeapon"; this would work if i could "force" the player to do it

little raptor
#

no

tight cloak
#

how about safety? is it possible to flick that off and on?

tough abyss
#

God I wish

tight cloak
#

unbinding certain things then like primary fire maybe?

tight cloak
#

also getting an error here

waitUntil { side cursorObject =! west };

saying missing ;

spark sun
#

=! ---> !=

tight cloak
#

i feel like im having a stroke now. looking through my code there is a bunch of these tiny mistakes. half of my conditions have != and the other half have =!

tight cloak
jade acorn
#

Or force lower stance on a player

fervent kettle
#

how would one go about creating a trigger on certain coordinates? I've been googling it for an hour now

fervent kettle
#

yea, but in createTrigger where you set the position, what should go in there?
createTrigger ["None", getPos [0,0,0]]; for example doesn't work

#

I know I know, but not even google could help me out

little raptor
#

first of all the default trigger is EmptyDetector

#

and second of all:

{
  _trigger = createTrigger ["EmptyDetector", _x];
} forEach [_pos1, _pos2,...]
#

_pos1, _pos2, etc. are your coordinates (each in format [x, y, z])

jade acorn
#

I have nightmares about _x incident

#

No need for a loop if this is onetime

#

Unless i missed some part of the convo

little raptor
#

certain coordinates

#

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

jade acorn
#

Oh, i thought coordinates means one XY position

#

Mb then

fervent kettle
#

I assume I have to declare the positions manually with another line?

little raptor
#

you can just inline them

fervent kettle
#

like that? forEach [(0,0,0)]

little raptor
#

no

fervent kettle
#

Just one

little raptor
#

then no need for loop

jade acorn
#

Ha, I was right :3

little raptor
#
_trigger = createTrigger ["EmptyDetector", [x, y, z]];
fervent kettle
#

I see, no need for getPos

little raptor
pale glacier
#

Help please!
Any way to create a laser target so an AI can fire laser guided missile?
Didn't manage to pull this off, at all

#

I don't need the player to do that, just via script (cinematic purposes)

little raptor
pale glacier
olive ledge
#

is there altis discord

little raptor
#

I think it was B_laserTarget or something

little raptor
olive ledge
#

trying to find it's discord

#

That's what it has to do with this channel

spark sun
#

No.

#

Read description plz.

olive ledge
#

No

#

You're in the WRONG channel

#

This is for Arma

spark sun
jade acorn
# olive ledge This is for Arma

this is an Arma 3 server, but channel is dedicated for scripting. If you check the left column you can see many "#" symbols and text next to them, the text has meaning.

#

make sure you know the full name of the server you're looking for, because Altis is a map, and you have thousands of Altis Lifes etc.

sharp peak
#

I've got two trigger which is meant to only activate when there is a civilian present.
Set up as such:
Type; None
Activ; Civ
Activ type; Present
Not repeatable
Server only
Condition; this
Different activations are either
"GRFWin1" call BIS_fnc_endMissionServer;
"BLFWin1" call BIS_fnc_endMissionServer;
& 25 on timer countdown, all timer values

#

Both of these triggers are also the spawnpoint of the Blue & green teams

#

After mission start & 25 second passes - one of the two triggers gets activated, which one is on random, even through neither of them have any civilians present

#

Why, how, and what do I do to fix it?

little raptor
sharp peak
#

I thought about it, since it's above water, so it could be fish))

#

But it's 1x2x1, hovering above the sea, so don't think it's the fish either

#

Unless Arma has added flying fish in a stealth update ๐Ÿ‘€

little raptor
#

change the condition to:

this && {thisList findIf {_x isKindOf "CAManBase"} != -1}
#

see if it makes any difference

sharp peak
#

Alright, will try

#

The mission didn't end after 25 seconds, so I assume it worked, thanks!)

tough abyss
#

alien activating the trigger ๐Ÿ‘ฝ

#

maybe a civilian dust mote wandered into it

past wagon
#

I have a marker (an ellipse) and I need it to slowly move on the map from its current position to a set position. Is there a command that can help me with this? If not, I might need a little help with the math. I just need to be pointed in the right direction.

still forum
#

Old position, new position, interpolate by time

#

There is a interpolate command afaik?

#

You just need to come up with a 0-1 value that indicates the process of the move, you could just base that on current time

#

(time-_startTime)/10
10 seconds for it to move from pos1 to pos2 for example

#

And then you need to repeatedly update the position with the interpolated one

past wagon
#

okay

#

thank you

#

should I use BIS_fnc_interpolate?

tough abyss
#

but seeing as you (should be able to?) treat it as an object you could also just go with setVelocityTransformation

little raptor
little raptor
tough abyss
#

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

#

Works all the same

past wagon
#

okay, I will try these

#

yeah a marker doesn't work as an object because it's a string

little raptor
past wagon
#

well, what confuses me is that I need to interpolate a position, not a number. so which should I use?

little raptor
past wagon
#

so do I give it an array instead of a number?

little raptor
#

wut? you need array anyway

past wagon
#

oh

#

yeah the parameters are confusing me

little raptor
#

numbers are for interpolation value

tough abyss
#

Some BIS functions are drastically better than their command counterpart and vice versa

little raptor
#

the arrays (vectors) are the start and end vectors

past wagon
#
Syntax:
  vectorLinearConversion [rangeFrom, rangeTo, rangeValue, vectorFrom, vectorTo, clip]
Parameters:
  rangeFrom: Number - start "from" range
  rangeTo: Number - end "to" range
  rangeValue: Number - variable range value
  vectorFrom: Array - start "from" vector
  vectorTo: Array - end "to" vector
  clip: Boolean - (Optional, default false if true, range value will be clipped to stay within "from" -   "to" range
Return Value:
  Array - interpolated vector

This says it returns a vector.

tough abyss
#

No clue for this one, though lerp is fairly cheap regardless

past wagon
#

ohhh

little raptor
#

a position is a vector ๐Ÿ˜“

past wagon
#

hmm

#

okay so it basically interpolates any set of 3 numbers so what it is being used for is irrelevant?

tough abyss
#

Sure

little raptor
#

when you define an origin for a vector it becomes a position (so to speak)

past wagon
#

okay

tough abyss
#

Just think of it as a vector from [0,0,0]

#

Or whatever arbitrary origin

#

Same as a position

past wagon
#

ok

#

What are these parameters for? and are they not used if clip is set to false?

rangeFrom: Number - start "from" range
rangeTo: Number - end "to" range
rangeValue: Number - variable range value
little raptor
#

they're used for linear interpolation

#

interp = val / (To - From)

drifting sky
#

A2OA: Is it possible to get the AI to target and fire upon a position (or game logic??)?

little raptor
#

and then:

_interp = (_val - _from) / (_To - _From);
_newVec = _start vectorAdd ((_end - _start) vectorMultiply _interp)
#

that's what it does

#

if you use clip it clamps _interp to the range 0 and 1

#

so _newVec will always be between _start and _end

drifting sky
#

can they target invisible things? Some kind of game logic or something?

little raptor
#

not those hidden via hideObject. but you can create an invisible target yourself.

#

A3 CBA has an invisible target

#

you should be able to port it to A2 with no problem

drifting sky
#

can it have a side so that anybody whose side is its enemy will open fire upon it?

little raptor
#

yes

#

in fact it should

little raptor
#

(uses the tank simulation, so AI will target it with their launcher too)

drifting sky
#

is it a tank in order to get guys to use AT weapons against it?

little raptor
#

yeah

past wagon
little raptor
#

I don't know what you mean by "slice", but yeah

past wagon
#

yeah

#

okay

drifting sky
#

I'm wondering if those invisible tank targets were already in CBA for arma 2.

little raptor
#

they might be

#

I don't know about A2

little raptor
drifting sky
#

I presume it is. But I don't know how, so I'll have to find that information.

little raptor
#

all you need is a model with only view LOD

#

it can be created in object builder in like 10 seconds

drifting sky
#

but you also need some kind of config for it, right?

little raptor
#

yes

drifting sky
#

I don't know where to look to find a working example of a config

little raptor
#

check if A2 has one too

#

B_TargetSoldier

drifting sky
#

I think I found cba's invisible target config for A3. But I have a number of questions about it.

#
    class B_TargetSoldier;
    class CBA_B_InvisibleTarget: B_TargetSoldier {
        author = "$STR_CBA_Author";
        displayName = CSTRING(InvisibleTargetSoldier);
        scope = 2;
        scopeCurator = 2;
        scopeArsenal = 0;
        model = QPATHTOF(InvisibleTarget.p3d);
        icon = "CBA_iconInvisibleTarget";

        class HitPoints {};
    };
    
    class CBA_B_InvisibleTargetVehicle: CBA_B_InvisibleTarget {
        author = "$STR_CBA_Author";
        displayName = CSTRING(InvisibleTargetVehicle);
        model = QPATHTOF(InvisibleTargetVehicle.p3d);
        crewVulnerable = 0;
        type = 1;
        cost = 1000000;
    };    ```
#

There's no reference to 'simulation' first of all.

tough abyss
#

Anything not referenced is inherited

drifting sky
#

Inherited from what?

tough abyss
#

The target itself inherits B_TargetSoldier

#

the target vehicle inherits CBA_B_InvisibleTarget

drifting sky
#

so the vehicle targets are using whatever simulation B_TargetSoldier is using?

tough abyss
#

Anything not overridden is inherited, yes

drifting sky
#

I'm going to need to find an example written for A2.

#

I've found one from "zeu". However, they don't have a vehicle invisible target. Also, their config is really long, and uncommented, and it's not clear to me what parts are actually necessary to include, or if they have a purpose in conjunction with use as an invisible target.

brazen lagoon
#

anyone got any suggestions for a racing script? Like something that lets you (programatically) place a start, checkpoints, and an end?

past wagon
#

you could use waypoints

brazen lagoon
#

not really the same thing I dont think since there's no penalty for skipping checkpoints is there?

#

also, an idea I had was for destroyed vehicles to spawn at their last checkpoint, so waypoint wouldn't work for that I don't think

past wagon
brazen lagoon
#

not sure, lets say a few dozen

past wagon
#

just showing you one way you could do it

brazen lagoon
#

well you don't have to do that

#

just lemme know what your thought process would be

past wagon
#

okay

#

so you could have a variable for each player that keeps track of their progress

#

and put a trigger at each checkpoint

#

make the trigger activation for any player, and make it set that player's variable to true for that checkpoint or something

#

idk

brazen lagoon
#

right

#

yeah that's an idea I was considering

past wagon
#

and in the trigger code, they only get to complete a checkpoint if the LAST checkpoint is also complete. Else it just gives them a hint and says they need to complete the last checkpoint

leaden haven
#

Nice script, this prints your total Arma 3 playtime in-game.

_daysplayed = getStatValue "GamePlayedDays";

if (_daysplayed > 365) then { 
 player sidechat format ["You have played Arma 3 for %1 years total.", round(_daysplayed / 365)]; 
} else { 
 player sidechat format ["You have played Arma 3 for %1 days total.", _daysplayed / 365]; 
};
tough abyss
#

You have an error in your display of days.

hallow mortar
#

Does findEmptyPosition return ATL or ASL?

little raptor
hallow mortar
#

ugh

spark sun
vague geode
#

Does anyone happen to know the code that is executed by the default heal/repair action and the conditions under which they are shown?

Basically can someone tell me how the addAction-code of the heal/repair actions would look like?

copper raven
#

well the heal action im pretty sure is when your health is under 75%, and it heals you to 75%, for repair, no clue

versed gulch
#

Where can I find a sqf syntax highlighting plugin for notepad++

versed gulch
#

Thanks, the VS Code one is really nice, I will use that instead of notepad++

hallow mortar
grizzled lagoon
vague geode
grizzled lagoon
little raptor
brazen lagoon
#

what causes 'error zero divisor'?

#

is that an empty array? iirc if the index is out of range it'll say as such

brazen lagoon
#

suppose _path is an array of waypoints: _path set [count _path - 1, _waypoint];

#

if this is returning 'error zero divisor' is it likely that _path is an empty list?

sacred dove
#

I am just messing around with a localhost exile server. Is there a way I can spawn in an indy squad ai in my group? I am using NSS Admin console to execute scripts.

brazen lagoon
#

ok, i think i have a hunch on how to fix this

#

thanks leo

little raptor
sacred dove
#

sorry, the faction for players in exile is indifor. so I can spawn in indy ai but they are not grouped to me so I cannot control them etc

little raptor
#

how do you spawn them?

sacred dove
#

_trg setTriggerStatements ["this", "_unit = group player createUnit ['I_G_Soldier_AR_F', getPos player, [], 0, 'FORM']", ""];

little raptor
#

this should already spawn them in your group

sacred dove
#

Hmm... maybe the mission doesn't support it

vague geode
vague geode
brazen lagoon
#

maybe they outrank you and you're not the group leader

faint oasis
#

hi, can we get a "callback" with remote exec ? example : "I want to get a result of a function only on the server"

little raptor
faint oasis
little raptor
#

?!
you can write something like this:

//fn_remoteExec
params ["_args", "_fncName", "_callback"];
_result = _args call (missionNamespace getVariable [_fncName, {}]);
[_result] remoteExecCall [_callback, remoteExecutedOwner];
[_args, "my_fnc_bla", "my_fnc_callback"] remoteExec ["MY_fnc_remoteExec", 2]; //execute my_fnc_bla on the server, and return the result to my_fnc_callback on the client
faint oasis
sand summit
#

i'm in a bit of a pickle. i'm looking for a way to make use of the virtual arsenal's garage that works with multiplayer. so far, all i've been able to manage is clientside vehicles that are indestructible. any ideas?

hidden prism
#

There are a few mods that use thay sort of thing

#

I could find them tomorrow and show you but I donโ€™t know

misty loom
#

Is there a way to attach a parachute to a memory point on a container rather than use in game script?

harsh sphinx
#

Is there a function to detect whether MROT are spinning/engine has fully powered down?

little raptor
little raptor
little raptor
final sun
#

Hello, I have a simple question about breaking out of loops. I have this function that I want to completely break out of its foreach loop when the if statement is triggered. I've looked up "Break", "BreakOut" and "exitWith" but all of these break out of the if loop instead and the foreach loop continues. Am I using them wrong?

unitTargetFunc=
{
  params ["_unit","_arrayIndex"];
  {
   //select unit from array
    targetedThreat= (_x select 1);
    targetStatus = targetedThreat getVariable ["Targeted", false];
    //if unit is not already being targeted then do stuff
    if(!targetStatus)then
    {
      //unit is targeted and being shot
      targetedThreat setVariable ["Targeted", true];
      _unit disableAI "autotarget";
      _unit disableAI "target";
      _unit doTarget targetedThreat;
      systemChat format ["%1 targets %2",_unit,targetedThreat];
    }
    //else statement triggers for some reason
    else{
      //systemChat format ["unit is already targeted"];
    };
  }
  foreach Threats;
};
little raptor
final sun
little raptor
final sun
proven charm
#

what is the easiest way to get ammo left in a tank? should I just loop through the turrets or is there a better way?

little raptor
proven charm
#

I dont have high enough version for the alternate syntax :/

#

any tips on how to detect machine gun / cannon mags? and exclude smoke etc

quasi condor
#
23:54:25 Error in expression < selectRandom _buildings;
selectRandom (_building buildingPos -1);>
23:54:25   Error position: <_building buildingPos -1);>
23:54:25   Error Undefined variable in expression: _building
23:54:25 File path, line 15```
```sqf
params ["_taskLoca", "_vehicleName"];

_finalPos = [];

_radius = random [300, 500, 700];
_angle = random 360;
_rdPos = _taskLoca getPos [_radius, _angle];

_nearObjects = nearestObjects [_rdPos, ["HOUSE", "BUILDING"], 100];
_buildings = [];
{
    if (_x buildingPos -1 isNotEqualTo [] && {_buildings pushBack _x >= 4}) then {break;};
} forEach _nearObjects;
_building = selectRandom _buildings;
selectRandom (_building buildingPos -1);```
what..?
still forum
#

_buildings was empty, if its empty, then _building will be undefined

proven charm
tepid vigil
#

Hi, is there a situation where ASLtoAGL getPosASL _unit would function differently than getPos _unit? I want to replace getPos due to its inconsistent performance and I am wondering if that would break anything

little raptor
#

but you must stop using getPos anyway

#

also unless you specifically need AGL, I suggest you use ASL instead

tepid vigil
#

most commands need AGL / ATL afaik

little raptor
#

and almost no command uses ATL

#

it's mostly ASL and AGL

tepid vigil
#

alright, thanks

mental prairie
#

is it possible to create an eventHandler that checks if a unit is in an area?

mental prairie
#

how do I execute code that is active when a player is in a trigger?

#

I basically want to change a variable when a player gets into the trigger area

#

and for it to be repeatable

little raptor
#

add the code to the trigger onActivation statement

mental prairie
#

basically I'm making a covert script, where if player enters an area, it causes a variable to drop.

#

do I make an function

little raptor
#

I told you already. there's no such event handler

mental prairie
#

i meant a function, sorry

little raptor
#

up to you

#

if all you need is changing the variable on the clients there's no need for a function

#

you can just use something like publicVariable

#

although it should work just fine if you use a client-side trigger as well

mental prairie
#

so, If i want it to be diffrent for every player, i just put a client side trigger, and it won't affect the other players

little raptor
#

yes

mental prairie
#

ok thanks

versed widget
#

why while command does not work inside Getin and GetinMan eventhandlers ?

little raptor
versed widget
#

does all event handlers runs in unscheduled environments ?
and is there any alternatives as a solution ?

versed widget
#

that worked, thanks ! ^ ^

versed widget
#

once i put the code in a spawn inside the event handler i cant use the params of the eventhandler

little raptor
versed widget
#

how do i do that ? :))

little raptor
#

_this spawn

versed widget
#
player addEventHandler ["GetInMan", { [_this select 0] spawn {
params ["_vehicle", "_role", "_unit", "_turret"];

//code

}]; 

still doesnt work notlikemeow

spark sun
#

You forget a }

winged gull
#

Guys anyone know how to use the restriction module?

versed widget
#
      if (isnull objectparent player) then {
          player addEventHandler ["GetInMan", { [_this select 0] spawn {
                params ['_vehicle', '_role', '_unit', '_turret'];

                       
         if (_vehicle iskindof "tank") then {hint "daTank"};
             while {_vehicle  iskindof "car"} do {hint"you are 
                 in Car"; sleep 0.3}
                       
                       };
                      }];
                    };

still not working :3

little raptor
#

I said _this spawn

#

not [_this select 0] spaw

versed widget
#

tried with _this spawn didnt work, as soon as i changed _vehicle with objectparent player it worked, it seems that the variables are not registered

radiant siren
#

Need help with disabling a trigger and having it re-enable for activation when an object is within the trigger area after a script has ran, if that makes sense?

#

So, a trigger that activates only when a certain object is within the trigger area, and then it'll fire a script to run through addAction which in the script will enable another trigger but not activate it until said object is within the trigger area

#

(hope this is understandable haha)

little raptor
#

will enable another trigger but not activate it until said object is within the trigger are
wut?

#

that's the very definition of a trigger

tight cloak
#

I see wht he means (I believe anyway)

#

U want another trigger ready to be fired but not until the thing is in the area, just bind the addaction script to a variable and add it to activate condition with an && thislist

tight cloak
#

Yeah just make a variable and broadcast it to the server via publicvariable

radiant siren
radiant siren
#

object* not trigger

tight cloak
#

Yes as your basically telling the server "fire away" rather than give it a checklist before firing

radiant siren
#

yes, exactly. trying to have it wait until object is in the area ๐Ÿ™‚

tight cloak
#

Something along the lines of
Condition == true && object in thislist

radiant siren
#

this would go in the script?

tight cloak
#

No, activation condition of the one u want to be ready to fire

#

I hate train wifi

#

Give me a second and I'll write out how you should do it

First trigger
Activation = whatever
On activation
_Condition = true;
Publicvariable "_Condition";

2nd trigger
Activation =
Condition = true && object in thislist
On activation
Whatever else

#

Dont quote me exactly on the syntax (don't copy paste it directly and expect it to work), as I mention on mobile so scuffed writing = true

#

But that's what your looking for

radiant siren
#

yeah. the triggers will be disabled right?

tight cloak
#

What you have basically done is make it need both requirements met

#

So the object could be in the zone. But if _condition isnt true then no dice. Wont fire. And Vise versa

radiant siren
#

I just need the triggers disabled until a script is ran to enable them and then the object placed in the 2nd trigger area will be allowed to activate it

tight cloak
#

If the _condition is true but object isnt in zone. Wont fire. It waits until both are true then boom. Triggers

radiant siren
radiant siren
#

hope you have a fun train ride as well

tight cloak
#

Cheers, Londoners dont understand covid regulations so fingers crossed

#

If u need any help I can offer it in my limited capacity. I'm free for the next 2 hours

radiant siren
tough abyss
#

Probably worth mentioning that doing things in the form of boolean == true or boolean == false is bad practice

#

boolean values are usable directly in conditional expressions

#

so writing it as just boolean or !boolean is better practice

winter rose
#

depends on readability ofc, in some (rare) cases it's better to ==

tough abyss
#

true, always exceptions to things

winter rose
#
if (alive player == true)```
tough abyss
#

I feel like ```sqf
if (alive player)

is more readable
winter rose
#

of course, I was kidding with this one :D

tough abyss
#

Ah, haha

#
if (
  condition1
  &&
  condition2 || condition3
  && condition4
)
little raptor
winged gull
#

does anyone know how to deactivate a trigger?

radiant siren
winter rose
tight cloak
#

On deactivation exists also if you want to do cleanup after the script runs

versed widget
winged gull
#

wheres that go

versed widget
#

in the triggers activation
if ("the condition to deactivate") exitwith {};

willow hound
versed widget
#
             if (isnull objectparent player) then {
                  player addEventHandler ["GetInMan", {_this spawn {
                        params ["_vehicle", "_role", "_unit", "_turret"];

                       
                  if (_vehicle iskindof "tank") then {hint "daTank"};
                         while {_vehicle iskindof "car"} 
                               do {hint "You are in"; sleep 0.3}
                       
                        };
                      }];
                    };

still cant get the variables inside the params to work notlikemeowcry

tight cloak
#

Well. The more you know ig

jade acorn
willow hound
willow hound
jade acorn
#

I think so, some code first, then a bit of sleep and deleteVehicle

willow hound
#

You can't suspend (e.g. sleep) in a trigger.
A trigger being activated means that triggerActivated returns true and that the trigger will not activate again (until it is deactivated). This is only related to the On Activation expression in the sense that that expression is executed once every time the trigger is activated, but the code in the On Activation expression is not tied to the trigger otherwise.

jade acorn
#

i can do the sleep through spawn, technically. but away from this, how can I deal with a one-time trigger if it doesn't delete itself then?

willow hound
versed widget
#

good eye !, i switched from getin to getinman i thought they have the same parameters in order :p

willow hound
jade acorn
#

yeah my bad, I expressed myself wrong

little raptor
# winter rose oh, how?

when you want to compare the state of a condition to another one:

_condition1 == _condition2
little raptor
tough abyss
#

The only case I can think of where doing a direct comparison w/ true/false with a boolean value is truly necessary would be in a language w/ operator overloading

#

but it'd be extremely gross to overload == for a boolean value

little raptor
#

wat? what does it have to do with operator overloading? you're comparing the state of some boolean to another

#

e.g.

_state1 = alive player;

while {true} do {
  _state2 = alive player;
  if (_state1 != _state2) then {
    hint "state changed";
    _state1 = _state2;
  };
  sleep 1;
};
#

that's not the best example ofc, but you get the idea

copper raven
#

there is also a case where you have some unknown type, you can do _val isEqualTo true for example, probably a bit different from the topic, but still

tough abyss
#

I was talking about a case of boolean == true and boolean == false

#

which is what this was initially about

#

the topic was never about comparing two boolean variables, that obviously would require ==

winter rose
harsh sphinx
fair drum
#

if a script is local to a server, and you remote execute a command to the server, does it take up any network traffic to tell itself?

tough abyss
#

I'd imagine not, but why even remoteExec to begin with then?

flat eagle
#

hey guys. so im having trouble with getting a trigger to return a groupID. (truth be told i dont know how to ask the trigger for a groupID) any ideas?

tough abyss
#

Just get the group of whatever activated the trigger via group and feed that into groupId

maiden garnet
#

is there a way to insert the players name (or rather, the one thats reading it) in a structured text?

#

example: blah blah blah thanks [name of whoever is reading it]

tough abyss
#

Depends which name you want

#

if you want the one set as their identity use name

#

profile name is profileName

#

steam name is profileNameSteam

maiden garnet
#

profileName is what I want

#

my only question is.. how do i incorporate that into a structured text with it.. working?

tough abyss
#
format["Thanks %1!", profileName player];
#

or could vary depending on your exact usage

quaint star
cosmic lichen
#
[] spawn  
{ 
 while {true} do 
 { 
  sleep 900; 
  { 
   _x setUnitLoadout typeOf _x; //Reset unit's loadout back to what is defined in its class 
  } forEach allUnits - allPlayers; 
 }; 
};

Given that all units have the default loadout of their class you could do this. @quaint star

sharp grotto
#

When i run this on the server, the netID of uniformContainer & vestContainer is still starting with the clientOwner ID.
Shouldn't it be "owned" by the server instead of client ๐Ÿค”

_player = objectfromNetID "2:43206";
_player setUnitLoadout (getUnitLoadout _player);

When i do this the netID of uniformContainer is starting with 2:xxx ("owned" by the server).

_player = objectfromNetID "2:43206";
_player addUniform "U_B_CombatUniform_mcam";

https://gyazo.com/7ed9ee426ccc8d76359e1f2eb255d1d8

quaint star
cosmic lichen
#

You can use the original script for that and also wrap it in while (true) do

little raptor
#

netID doesn't change. it shows the original owner

sharp grotto
quaint star
cosmic lichen
#
[] spawn 
{
  private _cfgWeapons = configFile >> "CfgWeapons";
  private _mag = "";
  while {true} do
  {
    sleep 900; // Sleep time in seconds. 900 / 60 = 15 min
    {
      if (handgunWeapon _x != "") then 
      {
        _mag = (getArray (_cfgWeapons >> handgunWeapon _x >> "magazines")) select 0;
        _x addMagazines [_mag, 3];
      };
      if (primaryWeapon _x != "") then 
      {
        _mag = (getArray (_cfgWeapons >> primaryWeapon _x >> "magazines")) select 0;
        _x addMagazines [_mag, 8];
      };
      if (secondaryWeapon _x != "") then 
      {
        _mag = (getArray (_cfgWeapons >> secondaryWeapon _x >> "magazines")) select 0;
        _x addMagazines [_mag, 2];
      };
      sleep 0.1;
    } forEach (allUnits - allPlayers);
  };
};

Like this (not tested)

#

@quaint star

little raptor
little raptor
#

this channel is for SQF scripting questions, not Python

pliant stream
#

oh dear, doing this weapon and magazine thing in scheduled will absolutely cause duping or unwanted magazines and probably sqf errors due to null units

tribal ether
little raptor
tribal ether
quaint star
#

But now I encountered another problem, maybe Arma bug - AI refuses to switch pistol to main weapon and reload it. Same bug was when I tried mods that allow AI to rearm from crates.

quaint star
#

Your first script works well without issues. Thank you again

worn elm
#

Using the Ace Cargo framework, I've applied make an object carriable, any thoughts how I could increase the interaction distance .

spark sun
opal zephyr
#

Is anyone here familiar with arrayIntersect? I need to find a way to get the same result without excluding duplicate objects.
Example:
_arr1 = [1,2,3,4,5,2,3,4];
_arr2 = [4,5,6,1,2,3,5,6];
hint str (_arr1 arrayIntersect _arr2); // [4,5,1,2,3]

I need it to keep the multiple 2's and any other multiple numbers that are in both arrays

#

Side question: Can I subtract the contents of one array from another simply by doing (_arr1 - _arr2)?

willow hound
opal zephyr
#

Reading syntax 3 is seems like it should work, but no examples refer to it after that, so I guess ill assume it is working.

#

For the first question I had, Ive done this as an alternative and I think its working correctly, any input is appreciated.

for "_j" from 0 to (count _visibleObjects - 1) do {
                
           _loc = (_visibleObjects find (_visibleCache select (_j)));
                
           _stillVisible pushback (_visibleObjects select (_loc));
};```
#

This should be making _stillVisible into an array of all elements that are in both _visibleObjects and _visibleCache

digital rover
#

is there a way to reload compositions manually without restarting the editor session?

brave jungle
digital rover
#

yeah, I just think it'd be a scripting command if there was

brave jungle
#

think compos is handled by fncs

opal zephyr
pliant stream
#

no

opal zephyr
#

And you think that would give me an array containing things that were the same between the two arrays

pliant stream
#

it gives you the elements of _arr1 which are also present in _arr2

digital rover
opal zephyr
#

ill give both of these a try, thankyou

#

hmm yours didnt seem to work Untelo, it just shot back the same list as _arr1. Ill give SebsterBL's a try now

#

I believe your method is working SebsterBL, thankyou both for your help!

#

damn I was hoping this would solve my problem, it did not, ill keep looking

little raptor
opal zephyr
#

I know, I commented on it working just before I thanked them. That comment there refers to it solving the overall issue which is something else. I was hoping fixing this problem would fix the big picture, but it did not

little raptor
#

okidoo

opal zephyr
#

its not worthwhile asking in here for help with the big thing I dont think, too much stuff, would require a one on one or something

little raptor
#

you can try

opal zephyr
#

im trying to dynamically hide certain objects based on players line of sight, ive come across an issue where objects flick in and out of existence

#

im gonna try some stuff here, just thought of another approach to it, will let you know if it doesnt work out

#

I think it has to do with not saving the list of hidden objects correctly

carmine sand
#

Is there a script command for "Scan the Horizon" to execute instead using the GUI?

Like as example _unit doWatch bla bla

I dont want to use the doWatch stuff, just simple the Horizon stuff.. cant find any infos about this in the web /BI sites and here.

Maybe someone knows it, would be cool

Edit://

Its for automated defense turrets to give them some life but needs to be simple (addon integrated via Eventhandler Init)

warm swallow
#

Does waitUntil work inside an array? This is my code

#
{
    waitUntil {((_x distance killer) <= 10)};
_x say3d "heartbeat";
} forEach [p1, p2, p3, p4, p5, p6];```
willow hound
carmine sand
warm swallow
#

or should I have each in its own file?

limber panther
#

hello, i've got a question - in a multiplayer game i have a noticeboard, and that noticeboard has a script like this one: ```sqf
this addAction ["Means CVPI LB", {
private _vehicle = createVehicle ["M_CVPI", [14909,13771]];
_vehicle addAction ["Last 112 call", {
[caller_position] spawn gps_fnc_main;
}];
_vehicle addAction ["Last 911 call", {
[caller_position2] spawn gps_fnc_main;
}];
}];

past wagon
#

I'm pretty sure addItemCargoGlobal works for most

limber panther
past wagon
#

well, for items like the meds and explosives, use _vehicle addItemCargoGlobal [item, count]. For backpacks you need to use addBackpackCargoGlobal.

limber panther
#

allright so with this script a player can walk to the noticeboard, spawn a car and the car will have those items in its inventory

#

is that correct?

past wagon
limber panther
past wagon
#

np

#

how can I check if a position is unobstructed? I am placing several objects at random positions in a building via buildingPos. I do not want any two objects to be put in the same location, so I need to check if the chosen position already has an object.

willow hound
warm swallow
#

like

#
{
    waitUntil {((_x distance killer) <= 35)};
    _x say3d "heartbeat";
} forEach [p1, p2, p3, p4, p5, p6];

{
    waitUntil {((_x distance killer) <= 25)};
    _x say3d "heartbeatfast";
} forEach [p1, p2, p3, p4, p5, p6];

{
    waitUntil {((_x distance killer) <= 15)};
    _x playsound "chase1";
} forEach [p1, p2, p3, p4, p5, p6];```
#

@willow hound

astral lynx
#
_position = _center findEmptyPosition [0,0,"B_Boat_Armed_01_minigun_F"];
#

@past wagon

warm swallow
#

I think I'll use onEachFrame instead

astral lynx
#

otherwise it is executing the check as fast as it can wasting resources

warm swallow
#

so like a delay?

astral lynx
#

yeh uiSleep or sleep

warm swallow
#

oh whats the difference?

#

i've never heard of uiSleep

astral lynx
#

uiSleep uses uiTime not simulation time im not gonna pretend to know what it means but uiSleep is usually more reliable

#

Suspend execution of script for given uitime. uiSleep is a sleep method to delay script execution where script time/simulation time is stopped. uiSleep is basically using the system time (uiTime more specifically) and not simulation time. So in the cases where sleep command would get stuck indefinitely, uiSleep can still be used to effectively delay script execution. For example in a mission briefing or an editor or when simulation is paused in general.

warm swallow
#

ok

#

looking more into it, waitUntil is something that only happens once, so I think I'm going to use onEachFrame to check the distance instead. Thank you though!

astral lynx
#

@warm swallow actually i was dumb before that wont work

fresh crater
#

is possible to make a script that gives loadout when you aproach an object

astral lynx
#

all itll do is on the first loop wait for the first player in the array to get with 35meters then itll play the sound and then wait until the 2nd player in the array gets within 35meters

warm swallow
warm swallow
#

i wish there was an event handler for distance

fresh crater
# warm swallow you would have to get classnames of everything in loadout, (export loadout from ...

like this
[["GOLD_M4_Mk8_10_5_2","rhsusf_acc_nt4_black","CUP_acc_ANPEQ_15_Black_Top","rhsusf_acc_eotech_xps3",["rhs_mag_30Rnd_556x45_M855A1_Stanag_Pull",30],[],"GOLD_acc_MAGPUL_MVG_blk"],[],["CUP_hgun_Duty_M3X","","CUP_acc_CZ_M3X","",["16Rnd_9x21_Mag",17],[],""],["tfl_new_blk_fs_uniform_g",[["FirstAidKit",1]]],["M_MAR_CIRAS_Ranger_v3_1",[["16Rnd_9x21_Mag",4,17]]],["BDU_RangerBelt_v6_1",[["CUP_PG7VL_M",2,1],["CUP_PG7V_M",2,1]]],"Maritime_Cover_ComtacIII_Arc165","USP_BALACLAVA2",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch","Louetta_GPNVG_1_blk_alt"]]

warm swallow
#

you could just create a dummy ai with all the gear that you want your player to have when he enters the area, and use

player setUnitLoadout [getUnitLoadout loadoutplayer, true];
#

@astral lynx

onEachFrame
{
    _d1 = p1 distance killer;
    _d2 = p2 distance killer;
    _d3 = p3 distance killer;
    _d4 = p4 distance killer;
    _d5 = p5 distance killer;
    _d6 = p6 distance killer;
}
``` I have this, and I know I need to use if statements to play the sounds, but how will they fire if I only run the file its in at mission init
#

never mind I can use a while loop

#
{
    While {(_x distance killer) <= 35)]} Do {playsound "heartbeat"};
} forEach [p1, p2, p3, p4, p5, p6];``` i have this now
astral lynx
#

will still only play for the first person if they meet the conditions

#

for each only goes to the next element after the code has completed

#

so until the while {} condition isnt met itll continue to stay on that element until they no longer meet the condition

warm swallow
#

hmm

#
{
     [
    _x,                                        
    "Repair Generator",                                        
    "",    
    "",    
    "_this distance _target < 2",                    
    "_caller distance _target < 2",                        
    {
        _caller playMoveNow "Acts_carFixingWheel";
        remoteExec [titleText ["A Generator is Being Repaired", "PLAIN", 2]];
    },        
    {},                                                    
    {
        params ["_target", "_caller", "_actionId", "_arguments"];
        
        remoteExec [titleText ["Generator has been repaired", "PLAIN", 2]];
        _target say3D "s2";
        remoteExec [titleFadeOut 5];
        _target setVariable ["repaired", true];
        execVM "repaired.sqf";
    },                                                
    {
        _caller switchMove "AmovPercMstpSrasWpstDnon";
    },                                                    
    [],                                                
    25,                                                    
    0,                                                
    true,                                            
    false                                        
] remoteExec ["BIS_fnc_holdActionAdd", 0, _x];
} forEach [g1, g2, g3, g4];```
im using forEach here in a difference instance, but it can go in whatever order,
fair drum
#

just got home. lets see what yall been chatting about today.

fair drum
#

don't use uiSleep in most cases. sleep is fine.

limber panther
fair drum
warm swallow
#

should I put it in InitPlayerLocal?

fair drum
tough abyss
#

There's various issues with this. Aside from locality, forEach in sqf is not parallelized so you won't actually be creating multiple while loops at the same time as it seems you're assuming. Not only that, but your while loops will immediately end as soon as the player is outside of the 35m range and then never activate again unless this code runs again.

fair drum
#

sounds and ui, keep it local

warm swallow
#

got it.. how would you suggest I do that

fair drum
#

i would use onPlayerRespawn.sqf to create the loop and use while {alive player} do {} for your condition. it will exit when the player dies, and a new loop will be spawned when they respawn.

limber panther
#

or do i have to generally disable simulation first?

limber panther
warm swallow
fair drum
#

then modify it accordingly and put it in initPlayerLocal.sqf

warm swallow
#

ok

#

could I put an if statement inside of do?

fair drum
#

you can yes

warm swallow
#

nice!

fair drum
#
while {alive player} do {
  if (random 1 < 0.3) then {};
  //etc
};
warm swallow
#

one more question, how do I get sound to play on one client only. Like if I don't want everyone to hear it, only one player

fair drum
warm swallow
#

oh

limber panther
# fair drum do you need more guidance?

i appreciate your offer but this time i think i can handle this on my own ๐Ÿ™‚ i feel like it's a pretty straight forward script ```sqf
this addAction ["Means Sheriff Charger NEW", {
private _vehicle = createVehicle ["M_Charger12_NEW", [14909,13771]];
_vehicle addAction ["Last 112 call", {
[caller_position] spawn gps_fnc_main;
}];
_vehicle addAction ["Last 911 call", {
[caller_position2] spawn gps_fnc_main;
}];
_vehicle addBackpackCargoGlobal ["B_Bergen_hex_F", 1];
_vehicle addBackpackCargoGlobal ["TFAR_rt1523g", 1];
_vehicle addBackpackCargoGlobal ["CUP_B_SearchLight_Gun_Bag", 1];
_vehicle addBackpackCargoGlobal ["CUP_B_SearchLight_Tripod_Bag", 1];
_vehicle addBackpackCargoGlobal ["ACE_TacticalLadder_Pack", 1];
_vehicle addItemCargoGlobal ["TDD_Talon_Mag", 6];
_vehicle enableDynamicSimulation true;
}];

warm swallow
#

so something like this @fair drum

While {alive player} Do {
        if (player distance killer <= 35) then {playSound "heartbeat"}};
fair drum
#

remember to put a pause in there

warm swallow
#

where would I put it exactly?

#

and in this script, will the audio file called loop ***after ***it has ended, I don't want it to keep restarting you know?

fair drum
#

no, as it is, every time that if statement is true, its going to start the hearbeat file from beginning

#

so your pause needs to be at least the length of the sound file

warm swallow
#

i want the sounds to loop

#

gotcha!

fair drum
limber panther
fair drum
limber panther
warm swallow
#

can I also ask while I have your time, sometimes sound files that I put into the mission will at first will not be found, and then randomly sometime later stop working, its super annoying. And I check multiple times for typos, what else could it be?

fair drum
limber panther
#

thank you @fair drum ๐Ÿ™‚ will do it

#

...but tomorrow, it's already 3:45 am

fair drum
warm swallow
#

got it

#
While {alive player} Do {
        if (player distance killer <= 35) then {playSound "35"};
        sleep 23.55};

#

is this the correct utilisation of sleep?

fair drum
#

it can work that way. obviously it depends on how critical the accuracy of the time is. you can always do it unscheduled if you need more accuracy.

warm swallow
#

hmm

#

how would I switch it? and do you think it would be fine do have mutliple different While loops in initPlayerLocal for varying distances. Like 35, play one sound, 25 another, and so on?

fair drum
#

use a switch

opal zephyr
#

Sorry to cut into the existing convo here, but im trying to spawn an object on another objects position with createVehicle, but the object is off by a significant margin, is there a accurate position variable I can use? I tried visiblePosition, position, and positionASL

warm swallow
#

i thought about that but I would have to also include the sleep, thus if the player gets closer than that it wouldn't work

fair drum
opal zephyr
#

I was about to edit my message with collision being the issue, thankyou for the fast help!

fair drum
#

in mind, this may cause things to be arma'd

opal zephyr
#

all good in this case, its just for reference

warm swallow
#

ok,.

fair drum
#

alright tarkov's back up. fades away

opal zephyr
#

Major problem, when hiding objects in a while loop it causes the object to rapidly appear and disappear, causing a flickering affect. Is there a method that doesnt cause this?

opal zephyr
#
while {_render} do{

    for "_i" from 0 to (count allObjects - 1) do {

        if !(worldToScreen getPosASL (allObjects select (_i)) 
isEqualTo []) then{
            //if (([player, "VIEW"] checkVisibility [getPosASL player, getPosASL (allObjects select (_i))] > 0)) then {
        
            
                _visibleObjects pushback (allObjects select (_i));

            //};
        }
        else {
                _notVisibleObjects pushback (allObjects select (_i));
            
        };    
        
    };
    
    //systemChat (format ["All:%1", count allObjects]);
    //systemChat (format ["Vis:%1", count _visibleObjects]);
    //systemChat (format ["notVis:%1", count _notVisibleObjects]);
    
    
    {_x hideobject false} forEach _visibleObjects;
    {_x hideobject true} forEach _notVisibleObjects;
    
};```
#

@fair drum

little raptor
#

also your calculations are wrong

opal zephyr
#

Im new to advanced scripting, and using a for loop with "_i" let me specify only certain ones to go to _visibleobjects. I imagine there is a better way to do it with foreach, I just dont know it. Ill look into running it in an unschd env, didnt know that was something to take into account. And what do you mean the calculations are wrong

little raptor
#

worldToScreen getPosASL (allObjects select (_i)) isEqualTo []
iirc correctly this happened when object was offscreen thonk
an object has bounds. just because its position is offscreen doesn't mean it should stop rendering
(or was it when it was behind the camera? think_turtle )

little raptor
opal zephyr
little raptor
#

that still doesn't answer what you're trying to achieve with this

opal zephyr
opal zephyr
little raptor
opal zephyr
#

It seemed simple there

little raptor
#

I doubt you'll save any performance

#

not rendering performance at least

#

that's for sure

#

tho when you hide an object it also disables part of its simulation

opal zephyr
#

regardless of my reasoning behind it, ive been at it for a couple days now and would like to reach the end of it. Your help so far has been exceptional

opal zephyr
little raptor
#

there is no way

#

that's how hiding works

opal zephyr
#

hmm, ok. I thought that might be the case, ill work around it then

#

@little raptor im looking into the scheduling, it says code in triggers runs unscheduled. This code is spawned through a trigger, would it not be unscheduled then?

little raptor
#

similar to Old Man

little raptor
#

unless you've spawned it or something

opal zephyr
#

[] spawn J3FF_fnc_checkObject;

little raptor
#

and if you read spawn it says it's schd

opal zephyr
#

Oh I see, so the fact its in a trigger doesnt trump it then

#

is there a quick and dirty way to call it in game then

little raptor
#

it runs the code every frame

#

and unschd

#

also never ever use a while loop without sleep ever again (unless it's meant as a constant-time loop)

opal zephyr
#

for performance sake?

little raptor
#

yes

little raptor
opal zephyr
#

Thankyou for all your help tonight!

past wagon
#

what if I have findIf inside a forEach and I want to use the _x from the forEach?

cosmic lichen
#

assign the _x from forEach to a variable

tight cloak
#

am i doing something wrong here?

if ((side group cursorObject) != (west))
#

0 errors but doesnt do anything when not aiming at a blufor unit

warm hedge
#

Context?