#arma3_scripting

1 messages · Page 610 of 1

dull drum
#

there's a while loop further at the block code

#

so no calls for me 🙂

#

with sleeps

ebon citrus
#

what did you expect remoteExec does?

#

can he??

dull drum
#

well it's defined and it works

ebon citrus
#
functionName: String - function or command name.
While any function can be used, only commands and functions defined in CfgRemoteExec will be executed.```
dull drum
#

So it brings me back to the locality part 🙂

#

Because code block runs indeed

storm sierra
#

Add this into description.ext

class cfgFunctions {
    class rokunin {
       tag = "mytag";
       class core {
          file = "";
          class fuelingTimer;
       };
    };
};

class cfgRemoteExec {
    class Functions {
       mode = 1;
       jip  = 1;
       class mytag_fnc_fuelingTimer{
           allowedTargets = 0;
       };
    };
};

make a file called "fn_fuelingTimer.sqf", toss it into your mission folder.
put this into the sqf

private["_time", "_initTime"];
params ["_time", "_on"];
_time = RK_fuel_timer;
_initTime = _time;
"booyah!" remoteExec ["systemChat", -2, true]; // broadcast message everywhere except the server

I don't remember anything more

ebon citrus
#

possibly

#

still says function or command name.

#

not code

#

but if it works, that's good enough for me

#

anyways, i would have to see the rest of the code in fuelingTimer.sqf

#

@tough abyss not really

dull drum
#

well I've mentioned "func" from the general programming perspective, not as a BIS fnc

#

my fault

#

lemme do a pastebin really quick

ebon citrus
#

cheers

dull drum
#

also inb4 excuse my dirty code

ebon citrus
#

also, what is serverInit?

#

do you mena initServer.sqf?

#

@tough abyss he has no functions defined

#

he is defining a variable

dull drum
#

initServer

#

messing the name EVERYTIME

rain mural
#

Anyway to force a helicopter's copilot and gunner to get out?
It seems running the eject action on those specific units doesn't work

ebon citrus
#

AI or player?

dull drum
rain mural
#

It just doesn't kick them out

#

playableUnit

#

Currently controlled by AI

ebon citrus
#

are they AI or player?

rain mural
#

The other seats get ejected fine

ebon citrus
#

then you need to give them a waypoint

#

which "other"?

rain mural
#

Standard seats. Not gunner or co-pilot

ebon citrus
dull drum
#

@ebon citrus also it works perfectly well if called with "0" parameter in OnActivation. But messes the sleeps, so the timer ticks unevenly

rain mural
#

Well I want eject as it'll be used for multiplayer

ebon citrus
rain mural
#

Ooh ok

ebon citrus
#

@dull drum have you tried running [8, true] remoteExec ["fuelingTimer", 2]; from the debug console?

rain mural
#

Yikes 😄

ebon citrus
#

i'm still heavily on the part that you NEED to have a function or a command

#

a variable is no good

#

🤷‍♂️

#

would have to ask dedmen, but i cant bother to tag him

#

instead

#

@winter rose can you use code-blocks in a remoteExec instead of a command or function?

storm sierra
#

server environment vs local environment is different.
I can't remember if remoteExec are forced whitelist only by default now

winter rose
#

@ebon citrus you can remoteexec call or spawn yes

ebon citrus
#

nop

#

not that

#

i mean
defining code on server-side

#

into a variable

#

and then trying to remoteExec that variable

storm sierra
#

Who wouldn't run battleeye? xD

ebon citrus
#

like so:
client:
[8, true] remoteExec ["fuelingTimer", 2];
server:

fuelingTimer = {
    params ["_time", "_on"];
    _time = RK_fuel_timer;
    _initTime = _time;
    "booyah!" remoteExec ["systemChat", -2, true]; // broadcast message everywhere except the server};
winter rose
#

I would say perhaps

dull drum
#

@ebon citrus yup, I've run it from the console, as always "2" does nuthin, "0" works Ok

ebon citrus
#

@tough abyss you defined the codeblock on the same side

#

@dull drum dedicated or hosted multiplayer, just asking

rain mural
#

@ebon citrus doGetOut worked a charm ❤️

ebon citrus
#

👌

#

@tough abyss same client

#

i'm gonna go off the code and say, No

dull drum
#

first initServer.sqf execVMs the fuelingTimer.sqf, then runs remoteExec

ebon citrus
#

and even if you can, you Shouldnt

#

Sorry

dull drum
#

dedicated, but when testing local also does not compute

ebon citrus
#

i gave you a solution, which is doing functions instead

#

it's fine if you want to do it differently, but that's just what im comfortable with

winter rose
#

CfgFunctions are safer anyway.

ebon citrus
#

execVM probably executes a "call"

#

but i dont understand what remoteExecCall is for

#

ok, never mind

#

i do

#

Bohemia Naming scheme as always

dull drum
#

remoteExecCall is unscheduled, remoteExec afford sleeps in whiles

ebon citrus
#

not the trigger

dull drum
#

car in area, it works

ebon citrus
#

it's to do with the remote-Exec

dull drum
#

@tough abyss 10000%

#

everything loads, then I go to the car and drive 🙂

ebon citrus
#

anyways, 2 cooks

#

Come to me if you need help with functions

#

G4rrus can take over and handle this one

#

he seems more eager to deal with variable-soup

copper raven
#

[] execVM "file.sqf" is literally [] spawn compile preprocessFileLineNumbers "file.sqf". about remoteExecing a function that isn't defined on remoteExecing machine, yes you can, aslong as target machine has the function defined it'll execute, doesn't matter if the issuing machine doesn't know anything about it

dull drum
#

also just a question. why are you remoteExecuting on server instead of just making a server only trigger?
@tough abyss cause I need server to tick timer and send it's value to other clients. remoteExec 0 does it but timer value is messed up on different machines.

#

Because of course it just runs a copy of each code block for every computer in mp

winter rose
#

about remoteExecing a function that isn't defined on remoteExecing machine, yes you can, aslong as target machine has the function defined it'll execute, doesn't matter if the issuing machine doesn't know anything about it
Good to know, might add this somewhere on the wiki

crude vigil
#

It already exists somewhere

winter rose
#

I meant the remoteExec "unknownServerFunction" 🙂

dull drum
#

technically it's not unknown, its in missionNamespace

winter rose
#

server-side only

dull drum
#

after it goes from initServer execVM

crude vigil
#

Would one not expect it?

dull drum
#

server-side only
@winter rose true

winter rose
#

I could not be sure before that, so I guess it's worth writing somewhere - maybe the remoteExec(Call) page

dull drum
#

interesting

winter rose
#

systemChat has a local effect, but needs the interface to be init'd

#

if JIP, waitUntil { not isNull player };

dull drum
#

to hell with sChat I didn't get the timer broadcasting to the UI 🙂

#

ok, I'll check everything tomorrow, I suspect something in the mission messing up with remoteExec, for example some GameLogic leftover that could run the same sqf file as server initialization does

#

thanks for the help guys!

#

so something interferes on my side

#

but I could check only tomorrow as my main machine now blocked by sleeping bodies

chilly wigeon
#

Maybe better for #arma3_gui , but is there any way to tie a control back to the config entry it originated from?

#

Best I've seen is ctrlClassname which I suppose I could abuse in some sort of loop to just walk the entire heirarchy

astral dawn
#

you could perhaps add onLoad config entry and do something there

#

like set variable on control

#

In my practice I gave up IDCs and just scan for all controls until I find the one with given ctrlClassName btw, much more convenient

#
pr _allControls = allControls _display;
        //OOP_INFO_1(" ALL CONTROLS: %1", _allControls);
        pr _index = _allControls findIf {_className in [ctrlClassName _x, _x getVariable ["__tag", ""]]};
        if (_index != -1) then {
            OOP_INFO_1("  found control: %1", _allControls select _index);
            _allControls select _index
        } else {
            OOP_WARNING_1("  control not found: %1", _className);
            controlNull
        };
humble harbor
#

How do I get an actual instance of a unit's weapon instead of just a string with the weapon name?

winter rose
#

no can do

ebon citrus
#

@humble harbor like a proxy?

humble harbor
#

like a normal object hahahah

#

yeah I had the feeling this wouldn't be possible🤦🏼‍♂️

winter rose
#

and even then, you would not have the object itself, just a holder

uncut rapids
#

is there a way to see if a display is open if I create the display like this:

    disableSerialization;
    display = (findDisplay 46) createDisplay "RscDisplayEmpty";
#

when I use that the variable display returns "Display #-1"

robust hollow
#

then it is open

#

it means display with an idd of -1

#

when you close the display that variable will change to "No display"

uncut rapids
#

im more so talking about getting a boolean value if its open or not

robust hollow
#

isNull display; true = closed (use a better variable name though)

uncut rapids
#

I've tried findDisplay with that variable and that didnt work it said "Type display, expected number" then i tried -1 and it was always true

#

and yeah display isnt my actual variable, its just for simplification

robust hollow
#

there is probably more than one display that uses idd -1. it is like the default idd if you dont want to set a proper one.

uncut rapids
#

hmm alrighty then

#

okay that was it. I seriously don't know why that was such a big issue for me lmfao

#

thanks a lot @robust hollow

tough abyss
#

How to disable car explosion in safe area

uncut rapids
#

what do you mean by car explosion

tough abyss
#

yes

#

so

#

safe zone in

#

vehicle explosion,

exotic flax
#

a quick Google search gave me hundreds of quick (and dirty) solutions...

tough abyss
#

@exotic flax
did not give me

exotic flax
uncut rapids
#

that website is beautiful, thank you for that haha

marsh ermine
#

I have made a few very unsuccessful attempts at creating Red, White, Blue & Yellow in both the runway edgelight and the land flush light.
Just trying to add color to 2 of those types. Any help would be appreciated.
Thank you
its the runwaylights.sqf

winter rose
#

@marsh ermine please surround this message code with ```sqf (see pinned messages)

marsh ermine
#

apologies

warm hedge
#

He didn't said remove it...

marsh ermine
#

LoL, I'm aware. just was looking for someone that could help me figure out the Red, white, blue, green & yellow in the runwaylights.sqf
Thank you

winter rose
#

well, we can, but now I don't know what you were trying to do nor where you did run this code 😅 (and if it was all of it)

marsh ermine
#

can i send you the .rar?

warm hedge
#

meowhuh Why would you need to send the rar?

winter rose
#

just the script content and how you call it, you can use sqfbin.com if the content is too big

marsh ermine
#

sorry, been up late. okay its 1.8KB

#

//  RUNWAY LIGHT SCRIPT \\
//     BY AUSTINATST    \\
//         v.01         \\

null = [this,#] execVM "runwayLights.sqf";

Different Lights:
( USE for # )

1 = Yellow Navigation Light     ---   "Land_NavigLight"
2 = White Edge Light        ---   "Land_runway_edgelight"
2.1= Red Edge Light        ---    "Land_Flush_Light_red_F"
2.2 = Green Edge Light        ---     "Land_Flush_Light_green_F"
2.3 = Blue Edge Light         ---    "Land_runway_edgelight_blue_F"
2.4 = Yellow Edge Light        ---    "Land_Flush_Light_yellow_F"
3 = 3 Nav Lights            ---    "Land_NavigLight_3_F"

NOTES:
->(r,g,b,y) or (.1,.2,.3,.4) <-

USE A "SPHERE 25mm" AS YOUR OBJECT
THIS WILL BE MORE CONVIENENT
Then other objects but its not required.

*/

//Object arrays
_Light = _this select 0;
_LightType = _this select 1;
_LightDir = direction _Light;
_lightPos = getPos _Light;

//Deletes said object
deleteVehicle _Light;

//This creates the lights
if (_LightType == 1) then {
    _Light = createVehicle ["Land_NavigLight", _lightPos, [], 0, "CAN_COLLIDE"];
};
if (_LightType == 2) then {
    _Light = createVehicle ["Land_runway_edgelight", _lightPos, [], 0, "CAN_COLLIDE"];
};
if (_LightType == 2.1) then {
    _Light = createVehicle ["Land_Flush_Light_red_F", _lightPos, [], 0, "CAN_COLLIDE"];
};
if (_LightType == 2.2) then {
    _Light = createVehicle ["Land_Flush_Light_green_F", _lightPos, [], 0, "CAN_COLLIDE"];
};
if (_LightType == 2.3) then {
    _Light = createVehicle ["Land_runway_edgelight_blue_F", _lightPos, [], 0, "CAN_COLLIDE"];
};
if (_LightType == 2.4) then {
    _Light = createVehicle ["Land_Flush_Light_yellow_F", _lightPos, [], 0, "CAN_COLLIDE"];
};
if (_LightType == 3) then {
    _Light = createVehicle ["Land_NavigLight_3_F", _lightPos, [], 0, "CAN_COLLIDE"];
};

//Sets light params from object
_Light setDir _LightDir;
_Light setPos _lightPos;```
winter rose
#

Yes…?

marsh ermine
#

this is the script, I'm attempting to make edgelight and flush lights in Green, Red, White, Blue and yellow. I've made attempts but i'm not sure what i'm doing wrong....

winter rose
#

What is the issue? Any error message?

marsh ermine
#

everything is in this script works as intended.
I need edge lights and flush lights in all colors.
I'm lost on what I'm messing up on.

hallow mortar
#

What exactly are you doing, and what actually happens when you do it?

marsh ermine
#

I need to make more script, adding to this, to make a variety of runway lights.

hallow mortar
#

You can only do that if those additional types of runway lights actually exist in the game. I can't answer that.

#

If there is (for example) no white flush light object for the script to spawn, then it cannot be done.

marsh ermine
#

Right, but the flush light exists and the color white exists, shouldn't i be able to script that together. Or am i just that big of an idiot.

warm hedge
#

Excuse me, so you want to make more variants to this script, but don't know what are the classNames?

umbral nimbus
#

sorry, been up late. okay its 1.8KB
@marsh ermine wount it be more efficient to use a switch instead of a whole bunch of if's?

marsh ermine
#

Yes, I'm reaching out here, because I'm very naive.

hallow mortar
marsh ermine
#

I'm making an airport in Arma Eden Editor for our group from scratch.

warm hedge
#

Won't work with those objects

winter rose
#

@marsh ermine classnames (the "light names" between quotes) are defined by addons and game data. If nothing defines e.g a purple light, then you cannot create one like this.
Maybe,but it is not sure, maybe some lights allow for setting their colour, but this is not guaranteed.

hallow mortar
#

I very much suspect that lights are available in all the colours that would be present at an actual airport. Airport navigational lights are like reflective road markings, the colours mean things. So if you need a light that doesn't exist...you probably don't actually need it.

umbral nimbus
#

Since a few people are reading...I have a little scripting question my self.
It may be a lack of coffee. I dont know.
here it comes:

marsh ermine
#

its not necessarily the color, but certain colors are attached to different object (some are flush to the ground and don't project a distance) others project a distance but don't have a variety of color

hallow mortar
#

the different object types are probably appropriate for the purposes of the lights, e.g. flush lights for markings that planes might need to drive over

umbral nimbus
#
    [
        _x,                                            // Object the action is attached to
        "Mission Control",                                        // Title of the action
        "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",    // Idle icon shown on screen
        "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",    // Progress icon shown on screen
        "_this distance _target < 1.7",                        // Condition for the action to be shown
        "_caller distance _target < 1.7",                        // Condition for the action to progress
        {},                                                    // Code executed when action starts
        {},                                                    // Code executed on every progress tick
        {    (_this select 1) assignCurator mission_control;
            openCuratorInterface; 
            if (local (_this select 1)) then {
                ["CuratorAssign",["",(_this select 1)]] call bis_fnc_showNotification;
                [(_this select 0), (_this select 1)] execVM "disconnect_MC.sqf";
            };
        },                // Code executed on completion
        {},                                                    // Code executed on interrupted
        [],                                                    // Arguments passed to the scripts as _this select 3
        1,                                                    // Action duration [s]
        0,                                                    // Priority
        false,                                                // Remove on completion
        true                                                // Show in unconscious state 
    ] remoteExec ["BIS_fnc_holdActionAdd", 0, _x];    // MP compatible implementation
} foreach MC_devices;```
hallow mortar
#

you can try digging through the configs to see if there are some other types available, but it seems likely that a dedicated airport light creation script already accounts for everything you need

umbral nimbus
#

Im trying to make a laptop, connect you to Zeus

#

and when you walk away it disconnects.

#

It works when I just send the commands through the debug console

#

but doesnt respond to this

marsh ermine
#

okay, thank you everyone

hallow mortar
#

@marsh ermine just one thing. Are you calling this script by using its example command (null = [this,#] execVM "runwayLights.sqf";) in the editor init field of an object?

marsh ermine
#

I am @hallow mortar

hallow mortar
#

In multiplayer, you are executing the script for each client, so if you have for example 5 clients + server, every light will be created 6 times.

marsh ermine
#

won't the headless clients take that off of the clients?

hallow mortar
#

No, headless clients have nothing to do with this.

#

Headless clients are for offloading AI processing, they don't prevent clients from executing scripts.

marsh ermine
#

or making them simple objects won't make the lights functional correct?

hallow mortar
#

Simple objects are not the solution. That's a performance saving measure but there is an easy way to make it just not create 6 extra lights

#
if (isServer) then {_null = [this,#] execVM "runwayLights.sqf";};```
use this instead
marsh ermine
#

thank you

digital rover
#

Wanna see something nightmarish?

private _gunnerDirectionModel = -deg (_vehicle animationSourcePhase "mainturret");
private _gunnerElevationModel = deg (_vehicle animationSourcePhase "maingun");
private _gunnerVectorModel = [1,_gunnerDirectionModel,_gunnerElevationModel] call CBA_fnc_polar2Vect;
private _gunnerVectorWorld = _vehicle vectorModelToWorld _gunnerVectorModel;
private _gunnerWorldAngles = _gunnerVectorWorld call CBA_fnc_vect2Polar;`
warm hedge
#

Check the pinned message to format

hallow mortar
#

@umbral nimbus it appears that your completion code executes the disconnection script immediately after giving you Zeus. I don't know the content of the disconnection script, but if it removes zeus then perhaps it is being removed too fast for you to notice.

umbral nimbus
#

here is what is does:

hallow mortar
#

Also, using params is much easier to read than using this select x all the time

umbral nimbus
#
waitUntil {sleep 2; ((_this select 0) distance (_this select 1)) > 3};
player sideChat "disconnect";
[] remoteExec ["unassignCurator", mission_control];
["CuratorUnassign",["MC Link disconnected",""]] call bis_fnc_showNotification;```
#

And yes correct regarding params. Will do

#

so it waits until you step away from the laptop in this case

#

it all works. except connecting and disconnecting Zeus

#

the rest of the script runs

hallow mortar
#

I'm not sure about connecting, but I can tell you that in the disconnection script the remoteExec is not formatted correctly

umbral nimbus
#

allright. lets look at connecting first

#

Ive tried the following two:

hallow mortar
#

When I say it's not formatted correctly I mean that's why it's not working

umbral nimbus
#

and

(_this select 1)] remoteExec ["assignCurator", mission_control];```
#

I understand

#

But lets look at connecting first

#

mission_control is the zeus module

hallow mortar
#

Your second method is also an incorrectly-formatted remoteExec

umbral nimbus
#

aah then there is my problem for sure

#

oh wait typo

#

[(_this select 1)] remoteExec ["assignCurator", mission_control];

#

missing [

#

but that's in there.

#

even then it doesnt work

hallow mortar
#

You will need remoteExec because assignCurator is a server-only command and must be sent to the server from the client that's executing the action. But that remoteExec is wrong.

umbral nimbus
#

ok help me out

#

what am I doing wrong

hallow mortar
#

here is an abstract example of a correct remoteExec:

[left parameter,right parameter] remoteExec ["command"]```
#

What you are doing is:

[left parameter] remoteExec ["command",right parameter]```
umbral nimbus
#

and not the ,2 to exec on the server only?

hallow mortar
#

yes, the ,2 as well, but I was going to get to that in a second

umbral nimbus
#

haha ok

hallow mortar
#

Doing it without the target parameter (,2) would default to executing it everywhere, which is inefficient but not a huge issue in this case since the command only works on the server

#

unAssignCurator is a server-only command too, so you need to do the same thing for that.

umbral nimbus
#

however that only has the 2nd argument (on the right of the command). I can just put it in there on its own?

#

like:

#

[mission_control] remoteExec ["unassignCurator" ];

hallow mortar
#

Yes

umbral nimbus
#

ok

#

let me give it a shot. stby

#

yup works as intended now

#

thanks mate

#

somehow got confused by BIS's description of the RemoteExec I think

digital rover
#

It does put the cart before the horse somewhat

#

I've taken to just doing [{some code}] remoteExec ["call"], which is objectively worse but much more readable. Doesn't always work though

vague geode
#

I have Carrier Strike Group with a total of 42 turrets in one of my missions. Because players shouldn't have access to them they are locked for players and to prevent them from crowding up the UAV list in the UAV Terminal I have placed 42 NPCs with UAV Terminals that connect to those 42 "fleet turrets" thus hiding them from the UAV Terminals of the players. The only problem is that the first person that joins still has all 42 in the list of their UAV Terminal even after respawn.

Does anyone know a way around that? Is there any possibility to hide those turrets from the UAV Terminal of the first player as well?

winter rose
#

JIP you mean? @vague geode

hallow mortar
#

You could probably save some time by having some of them be placed empty, I can't imagine you'll ever need all 42 of them to be operational

#

Also, and this is just a guess, try placing it as an empty object then giving it an ordinary rifleman as crew. Without the special UAV AI brain it may not be connectable. (MAY, GUESS)

vague geode
#

@winter rose No, on mission start the NPCs UAV Terminal gets connected to the turret by <NPC> connectTerminalToUAV <fleet turret>; in their init section. The first player that joins on mission start has all 42 turrets in the list of their UAV Terminal but everyone else doesn't as expected since the NPCs are connected to it.

So for all JIP players none of the fleet turrets are visible in their UAV Terminals...

winter rose
#

where is the code run…?

vague geode
#

On the server, I think. It's in the init section of those NPCs but I am not sure whether or not I put a server check in...

umbral nimbus
#

try putting it i the serverinit.sqf

#

hmm Object Init fields are called before that....🤔 nevermind

winter rose
#

do -not- put this in the init field.

umbral nimbus
#

no it wont

#

it keeps the UAV from doing its own attacks and stuff

#

or atleast movement

hallow mortar
#

it's somewhat debatable how effective that command actually is, but yeah this isn't what it's for

umbral nimbus
#

it is effective actually

#

for example. it keeps the Cruise missile launcher from enaging data linked Laser spots

winter rose
#

yeah I wasn't sure if it worked like "do your stuff when I don't control you" or "cannot be controlled"

winter rose
#

^

#

adding it to Remote Control command group NOW

umbral nimbus
#

@winter rose No, on mission start the NPCs UAV Terminal gets connected to the turret by <NPC> connectTerminalToUAV <fleet turret>; in their init section. The first player that joins on mission start has all 42 turrets in the list of their UAV Terminal but everyone else doesn't as expected since the NPCs are connected to it.

So for all JIP players none of the fleet turrets are visible in their UAV Terminals...
@vague geode

Maybe remove the UAV terminal

#

make it an object to pick up

#

or...add it a second later by script to its inventory

hallow mortar
#

I've personally observed inconsistent behaviour as a result of setAutonomous. It seems to stop some AVs from doing things, but I've also had the Mk45 turret engage targets at will despite being, in theory, affected by that command.

vague geode
cold glacier
#

Yeah, that's entirely possible.

hallow mortar
#

Only once per pickup, it accepts an array of objects as the parameter for UAVs to block

cold glacier
#

Do you actually need these turrets to be able to fire @vague geode?

hallow mortar
vague geode
#

@cold glacier Absolutely, otherwise the Carrier would be completely defenceless which defeats the whole purpose of having it in the first place...

cold glacier
#

Also, and this is just a guess, try placing it as an empty object then giving it an ordinary rifleman as crew. Without the special UAV AI brain it may not be connectable. (MAY, GUESS)
Yeah, this suggestion from Nikko is best idea I've heard then.

#

No idea if it'll work, but it might.

hallow mortar
#

Potential alternatives:

  • turrets are secretly friendly INDFOR (only works if you don't need INDFOR to be hostile for other reasons)
  • design the mission so that the carrier doesn't need to come under attack
  • give them a recon team instead of free eyes in the sky
vague geode
#

Also, and this is just a guess, try placing it as an empty object then giving it an ordinary rifleman as crew. Without the special UAV AI brain it may not be connectable. (MAY, GUESS)
@hallow mortar I am not sure whether that works or not, since I have another problem that might be cause but this. I have added some UAVs to the CfgWLRequisitionPresets of my custom Warlords mission but whenever one of them gets called/bought they are not listening to orders, even when brought up into the air again after landing and then given a waypoint to fly to they just turn around and fly out of the map.

I think the problem is that the function BIS fnc WLAircraftArrival spawns them empty and then adds crew to it. The UAVs can still be connected to with a UAV Terminal they are just "dumb".

hallow mortar
#

idk man I don't know whether it works either. The idea is really that you would test it, it's the only way to find out

winter rose
winter rose
#

I don't see what you mean (F5 the page @tough abyss 😉)

wind ingot
#

Did the Init event handler suffer modifications in the last 2 years?
I used to have:

    player addEventHandler ["Init", {```
#

But it no longer triggers

#

Wiki does indeed say "Triggered whenever an entity is created. Cannot be used in scripts, only inside class Eventhandlers in config. e.g: "

winter rose
#

and you used it where?

wind ingot
#

I have a mod that is HUD. The purpose of this Init was incase the player started a mission inside a vehicle the HUD would show up. This used to work but apparently not anymore

winter rose
#

weird, but there shouldn't have been any changes

wind ingot
#

I already have the GetInMan, SeatSwitchedMan, for all other scenarios

#

But this used to work, at first I thought was a problem with the script or something, but even setting in the mission init doesn't work either.

winter rose
#

ah wait
where did you place this code?
addEventHandler ["Init", {}] should not work

only through config init = ""

wind ingot
#

So, I should change this to config.cpp?

#

Or it just basically doesn't work anymore the way it used to

warm hedge
#

addEventHandler ["Init",{}] basically doesn't make sense in scripting context

wind ingot
#

I guess so. Was just a cheap trick i used to have to run something at begining.

#

It really doesn't...

#

That was really dumb of me. Instead of:

    player addEventHandler ["Init", {
        CODE
    }];```
#

I should have just put the CODE as main without event handler

winter rose
#

just run the code yes 🙂

wind ingot
#

I guess I'm surprised that even was a thing then xD

winter rose
#

I am surprised it ever worked yes ^^

hallow mortar
#

I guess technically it would make sense for it to work, it's just...completely redundant

wind ingot
#

Actually, maybe there's a case scenario but even then there's alternatives

#

I do have a:

        ["vphud", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
    }];```
#

So when the player respawns, the script runs from begining or should I force a respawn event handler of some kind?

#

Yup, there's a respawn event handler, gotta add that one

winter rose
#

and not draw when the player is dead, without adding/removing

wind ingot
#

Gonna check that

#

😮 that's exactly what I need

#

That might even improve the "onEachFrame" paradox which performance aficionados could easily get angry about that constantly executing code

#

Hmm

#

That's a missionEH, I'm doing a stackedEH, gonna take a better look

#

hmm, i should just actually change the whole thing

#

Thanks Lou 👍

real tartan
#

how to check if some unit is remotely controlled by player (ZEUS) ?

warm hedge
real tartan
#

when you are zeus and remote control unit (not remote control with terminal)

digital rover
#

They are the same thing, UAVControl returns ZEUS for ZEUS-controlled unit.

warm hedge
#

^ Remote controlling unit is basically the same thing with UAV

winter rose
#

should I add UAVControl to remoteControl seeAlso?

#

(wait, it already is there)

#

UAVControl is not a getter for remoteControl (just checked)

warm hedge
#

Oh?

digital rover
#

What do you mean not a getter?

winter rose
#
player remoteControl joe;
UAVControl joe; // [objNull, ""]
real tartan
#

*insert_sad_face

#

so I guess I need to wait for getter or use that hacky solution "SQF_fnc_remoteControlledBy"

winter rose
#

I don't know how Zeus works, if it's by selectPlayer or remoteControl (I guess the latter though)

real tartan
#

I mean, I don't need to check, who is driving, just check if it driven by curator (true/false)

young current
#

but does ```sqf
player remotecontrol joe

#

although what happens to the original unit

#

or do both count as player

winter rose
#

no, player remains player

real tartan
#

isPlayer joe return false on remote-controlled unit by zeus

winter rose
#

if you kill the player unit, the game ends

#
player distance cameraOn; // 8m
fallow prairie
#

Hi guys, if I want to create a countdown timer which uses a trigger to add addition time to that count. How would one go about creating one

wind ingot
#

A global var or local server var if trigger is server side only, that would add time to that countdown var would be a good aproach i think.

#

Look up forum or here for countdown examples, depending on when you want the countdown to start you'd have to implement it diferently.

#

I think triggers actually can have countdown themselves but I don't know if you can mess with their timers so I wouldn't recommend that approach.

thick merlin
#

'''test'''

#

test

wind ingot
#

``sqf

#

but with 3 `

thick merlin
#

rgr

winter rose
#

```sqf
see pinned message 😉

thick merlin
#

this ok?

#

ta

#

i have a scripted waypoint i have made up to work in sp and mp but its not working in mp at all now..

#

heres the script.Any help would be appreciated.:)

#
_pos = _this param [1,[],[[]],3];

waitUntil {
        sleep 1;
 (istouchingground vehicle player) && (vehicle player distance _pos < 400)
};

{ _x enableai "move" } forEach units grp1_b;
{_x assignascargo h2} foreach units grp1_b;
{[_x] ordergetin true} foreach units grp1_b;
{ _x setunitpos "up" } forEach units grp1_b;

activate1 = true;


waitUntil {
        sleep 1;
        {!(alive _x) || _x in h2} count units grp1_b == count units grp1_b;
    };

gunner1_b vehicleRadio "RadioMsg_troops_on_board";*/
#

It doesnt make it to grp1_b line

#

iam executing it thru the scripted waypoint

winter rose
#

It doesnt make it to grp1_b line
which one?

#

also, player varies depending on the machine it is run on

thick merlin
#

the first enable ai move commands

winter rose
#

player varies depending on the machine it is run on
sooo why it works in SP, but not in MP

thick merlin
#

not sure

winter rose
#

I am, don't worry about it

thick merlin
#

the waypoint holds at the pos

winter rose
#

yes, it waits until player's vehicle is close to _pos

thick merlin
#

rgr

#

but the ai wont board

#

like in sp

#

ive changed the player vehixle command to the heli name but no good

jade abyss
#

erm, is /* removed in your script?

thick merlin
#

yup

#

thnx

jade abyss
#

kk

thick merlin
#

i had a go at remote execting but i had no luck

thick merlin
#

nvm. found a workarpund

#

*workaround

umbral nimbus
#

dont use 'player' im MP

hallow mortar
#

You can totally use player in MP as long as you use it in the appropriate locality

umbral nimbus
#

well yeah true

#

if

hollow lantern
void ivy
#

it there a way to define a custom waypoint (e.g. the ones you can make in-game by shift+clicking the map) via script? Of course there is addWaypoint, but I think that can only create standard waypoints.

still forum
#

I think that shift click waypoint has a special name

#

there's a script command to retrieve it

winter rose
#

customWaypoint iirc

#

@void ivy ↑

#

define, nope
get, yep

void ivy
#

@still forum @winter rose Thanks for the info. Define is what I was looking for but I guess that just means I'll be working with regular waypoints.

fair drum
#

ever add a case sensitivity note to the arma_3_respawn#respawn templates wiki?

winter rose
#

adding it now

#

done @fair drum

spark rose
#

So right now i have a script that rolls twice from a selection of four locations. The first is the start location for a convoy, the second is the destination. It works perfectly, randomizing the convoy route. Except for when it randoms the same start and destination

#

any way to fix that other than doing a series of if/then statements for my second roll?

#

basically now, i do this twice ```sqf
_marker2 = createMarker ["Ground_convoy_end", position tester];
_marker2 setMarkerType "mil_triangle";
_marker2 setMarkerText "Enemy Convoy Destination";
_marker2 setMarkerColor "ColorRed";

_RandCorp2 = floor (random 4);
switch (_RandCorp2) do {
case 0: {
_marker2 setMarkerPos _start1;
};
case 1: {
_marker2 setMarkerPos _start2;
};
case 2: {
_marker2 setMarkerPos _start3;
};
case 3: {
_marker2 setMarkerPos _start4;
};
default { hint "default" };
};

#

only substitute _marker1 for the other

winter rose
#

randomise the array order, then take only the first two elements 😉

#

@spark rose

#
private _baseMarkers = ["marker1", "marker2", "marker3", "marker4"];
private _markers = _baseMarkers call BIS_fnc_arrayShuffle;
_markers resize 2;
_markers params ["_start", "_finish"];
```@spark rose
spark rose
#

Oh i see

#

well gee wiz, that's a whole lot simpler

hallow mortar
#

You can also remove elements from arrays once you've selected them by using the - operator

#

in this case Lou's solution is clearly superior but it's a related useful trick

winter rose
#

Lou's solution is clearly superior
that's all I decide to keep from your comment \o/

#

Lou's (…) clearly superior
😁

obtuse quiver
#

Hey guys, i have this MP scenario where one player plays as the bad and mean zombie, since he can jump there is a possibility where if he hits something mid jump he will take fall damage and eventually die, i cannot disable fall damage and bullets damage since i wants him to die if shot, i was thinking... is there a way that the zombie gets slow down or frozen in place for a small amount of time when shot?

#

if he can get slow down then it's ok if he's immortal

#

@ me if you have any solution!

ebon citrus
#

@obtuse quiver you can make him invulnerable to fall damage

winter rose
#

(and car ramming in the process)

ebon citrus
#

You can also separate vehicle damage and fall damage, if i recall correctly

#

Falldamage doesnt have a source, i think

#

Or an instigator, i dont remember

#

Play around with it a bit

obtuse quiver
#

im basically code illiterate could you give me the code to copy and paste if it's not a problem of course? 🙂

#

this addEventHandler ["HandleDamage", {
params [ "_damage" ];
}];


is this right?

winter rose
obtuse quiver
#

so, i read the article but i still don't understand 😅

copper raven
obtuse quiver
#

confused italian noises

winter rose
#

I noticed 😛 @copper raven

copper raven
tough abyss
#

Turn off seeing players and vehicles near me

winter rose
#

@tough abyss … ?

obtuse quiver
#

close your eyes i guess

tough abyss
#

@winter rose
I can see enemies around me on the map

copper raven
#

difficulty settings

#

mapContent = 0; in server profile

tough abyss
#

thx

obtuse quiver
#

this addEventHandler ["HandleDamage", {if ((_this select 4) == "") then {0} else {_this select 2};}]; this worked! thanks guys!

tough abyss
#

@copper raven

winter rose
#

@tough abyss that's not scripting. if you are setting up your server, head towards #server_admins. if it is for your own settings, see #arma3_questions. Thanks

inland valve
#

adding scripts to existing mission, the script files include initPlayerlocal.sqf , does this folder simply go in my mission folder or do I need to copy/paste the contents into my mission ?

winter rose
#

…perhaps?
it depends on how the scripts are made. If you downloaded from the webz, there must be a readme

inland valve
#

i just dont see when he actually add this to an existing mission,

#

ok found this too, trying...

#

ok copied but now I have 2 files called init, should they be combined? how?

inland valve
#

not sure I understand what to learn from that link

#

In this tutorial from the script maker he says you dont need to copy his init file if you have one, I do have one but I thought I needed the info from his init as well as mine, do I need to copy the actual text from his init and paste it onto mine (after a ";" of course) ?

ebon citrus
#

but ehhh...

#

if you send me the init file, i'll tell you if you need it or not

#

@inland valve youre supposed to read the article and understand what those files are for

inland valve
#

does that article explain that?

ebon citrus
#

did you read the article?

inland valve
#

...I mean, obviously but

ebon citrus
#

Look, buddy

#

nobody here can help you unless they know what's in that file

#

i gave you the advice i could and extended the offer of helping you, granted you let us into what's going on

inland valve
#

its the init file from the smoke script I had mentioned earlier
if ((!isServer) && (player != player)) then {waitUntil {player == player};};

//titleText ["Smoke Signal Script DEMO", "BLACK FADED", 0.2];

setViewDistance 2000;

[] execVM "briefing.sqf";

[] spawn {
sleep 10;
[s1,"red"] execVM "AL_smokeSign\al_object_smoke.sqf";
sleep 1;
[s2,"white"] execVM "AL_smokeSign\al_object_smoke.sqf";
sleep 2;
[s3,"blue"] execVM "AL_smokeSign\al_object_smoke.sqf";
sleep 1;
[s4,"green"] execVM "AL_smokeSign\al_object_smoke.sqf";
sleep 3;
[s5,"orange"] execVM "AL_smokeSign\al_object_smoke.sqf";
sleep 2;
[s6,"yellow"] execVM "AL_smokeSign\al_object_smoke.sqf";
sleep 1;
[s7,"purple"] execVM "AL_smokeSign\al_object_smoke.sqf"
};

ebon citrus
#

codeblocks

inland valve
#

its the init

ebon citrus
#

check pinned messages

#

ok, what do you intend to do with this?

#

from what i can see, you dont need any of it

#

unless you want to run the demo

#

but i guess youre not intending on running the demo

inland valve
#

Im trying to have smoke signals in my mission

#

I did

ebon citrus
#

urgh, ok

#

you dont need any of that

#

you can go with a blank init.sqf

#

if this is all that's in it

#

how much experience do you have in scripting(sqf)?

inland valve
#

Ive never copied script into a mission before, so zero

ebon citrus
#

have you ever written script?

#

do you know the syntax

#

do you know the structure

#

are you familiar with majority of the common commands?

inland valve
#

Im slowly figuring it out with very simple things

#

no

ebon citrus
#

do you want to?

inland valve
#

Im very new to it

ebon citrus
#

or do you just want to run this particular script

inland valve
#

I just want to run this one, I need to glean what I can, otherwise I drive people nuts

#

...glean from small scripts, make changes etc

ebon citrus
#

ok, jsut run [<object>,<color-string>] execVM "AL_smokeSign\al_object_smoke.sqf";

#

drop the AL_smokeSign folder into your mission root

#

you might need to combine some parts from the description

#

if you want to use the sounds

#

everything you actually need is in the smoke_signal.txt

#

so copy/merge (CORRECTLY!) the description.ext, initPlayerLocal.sqf and all the other folders

#

init.sqf is not necessary

#

if you have 0 understanding into scripting and missionmaking, then i would recommend you read up on a little

#

you should try to get a basic understanding into what all these files youre meddling with do

inland valve
#

lol reading up on it and getting a basic understanding is what were doing hehe, thanks for the help! MisiionMakers you say? this isnt script?

#

@ebon citrus thanks

ebon citrus
#

it is a script

#

but youre not having any problems with scripting

#

youre having problems with setting up your mission

inland valve
#

I see

#

...but sorry earlier you said just run[<object>,<color-string>] execVM "AL_smokeSign\al_object_smoke.sqf";

#

this goes into my existing init.sqf ?

#

...sry gimme a sec im slow\

ebon citrus
#

quoting from that article i sent you:
init.sqf: Executed when mission is started (before briefing screen)

#

so no, unless you want to run it before the mission starts

#

also, you need to fill it

#

[<THE OBJECT WHERE YOU WANT THE SMOKE TO SPWN GOES HERE!!!>,<THE COLOR YOU WANT THE SMOKE TO BE GOES HERE!>] execVM "AL_smokeSign\al_object_smoke.sqf";

#

aalso, read the smoke_signal.txt in the example mission

#
Spawn smoke signal using objects

[object name,color] execVM "AL_smokeSign\al_object_smoke.sqf";

Color options:
"white"
"red"
"blue"
"green"
"orange"
"yellow"
"purple"


Example
[smoke_obj,"red"] execVM "AL_smokeSign\al_object_smoke.sqf";```
#

youre jumping off the deep end a bit here

#

it all might seem overwhelming if you start here

inland valve
#

its not that I dont read these things (or watch his videos) it just seems like hes talking about different ways to use this and I just want one

ebon citrus
#

again, im not getting your problem here

#

what do you want?

#

im not getting it

inland valve
#

ok, thanks. I dont want to frustrate anyone

ebon citrus
#

@inland valve youre not frustrating anyone. Your problem is that you cannot make a coherent question that is on topic

inland valve
#

copy, thanks for the help

ebon citrus
#

so to call the smoke object

#

and to me it seems like you dont read these things and dont watch the guides.... or atleast you dont understand them

inland valve
#

You are right, I am still going through all of it, and I do not understand it yet, sorry, its frustrating

ebon citrus
#

stop saying sorry, youre not doing anything wrong

inland valve
#

and to me it seems like you dont read these things and dont watch the guides.... or atleast you dont understand them

#

seem worthy of applology

ebon citrus
#

not at all

#

this is what i see. What i see is not always the whole picture

#

which is why im saying that you need to be more clear and coherent with your questions

#

and be on topic

#

help me help you

inland valve
#

Its difficult to be on point when asking questions about subjects in which I have no knowledge... analagous to asking the proper way to ask the proper way in another language...?

#

im kind of cutting/pasting here

ebon citrus
#

ok, well

#

you now know what the init.sqf does

tough abyss
#

why does inGameUISetEventHandler have to overwrite globally ugh

#

and there isnt even a way to check if it's in use by other mods

ebon citrus
#

is that a question?

tough abyss
#

just venting

unreal scroll
#

I'm trying to make a functions to correct some savegame file with incorrect entries.
For entries with <NULL-object> it works well (using tolower str comparison with "<null-object>").
But, for example, I have an entry ["gang25",<null>]
And IDK what can I do with the second list element.
I can't convert it to string, or compare with something to replace it. Any ideas?
I had some weird ones, like getting this list's element length (it counts well), then getting some variable with the default value from each element, and make a comparison between the first length and number of variables that are not equal to default value... But I want to believe there is a much easier way ))

signal sky
#

Yet another getAllHitPointsDamage question...

Currently working on a ballistic/armor/damage calculator test mission to debug armor values for a gear mod. I’m running into an issue using the “hitPart” EH as it returns the “_selections” hit on the P3D model, but those do not directly correlate to the “HitPoints” from the configs or getAllHitPointsDamage.

Am I missing something here? Not sure if ACE 3 is causing an issue. @winter rose you seem to be versed in the command...any thoughts?

astral dawn
#

I can't convert it to string, or compare with something to replace it. Any ideas?
use isNil ? @unreal scroll

#

if (isNil {_array select 1}) then {}

#

or you can make a recursive search for isNil in the array

#

Also it's better to not save such things at all, so prior to saving you should check if you are about to save incorect data

unreal scroll
#

isNil doesn't work, I tried

astral dawn
#

so is it a string with value "<null>"?

unreal scroll
#

"Also it's better to not save such things at all"
Of course. And it does not exclude the load check 🙂 Something could happens.

"so is it a string with value "<null>"?"
No, it is not a string, of course, otherwise I would made it easily ))

astral dawn
#

well then find out which type it is with typeName

#

I'd guess it's nil

unreal scroll
#

It prevents any attempts of processing it

#

So nothing returned at all

astral dawn
#

so what does isNil {} say?

#

false?

unreal scroll
#

Nothing

astral dawn
#

isNil returns nil?

#

how did you use isNil? Maybe you used it wrong?

#

only valid variants of isnil are:
isNil string - string is variable name
isNil code -

unreal scroll
#

isNil (_array select 1)

astral dawn
#

yes it's wrong

#

I typed it wrong first

unreal scroll
#

Anyway, even select command returns nothing

astral dawn
#

then it's nil I guess

#

private _value = _array select 1;

isNil "_value"

or

isNil {_value}

unreal scroll
#

Ah, {}. Thanks ))

#

Syntax, syntax...

spark rose
#

Anyone know why using getpos on a piece of gear (backpack) returns a location that is not the actual location of that gear?

#

For instance, using getpos on the backpack i get [17887.1,10722.8,-50.9157]

#

standing directly above it and using getpos player i get [8943.59,5361.01,0.00161743]

tough abyss
#

maybe you could just add a -y vector to the player's position to get the backpack position xd

#

since backpack is always behind the player

unreal scroll
#

Use modeltoworld (and worldtomodel) - to the relative backpack position, for example. As I understand, you want to show some visual effects based on its position?

tough abyss
#

@unreal scroll you mean player worldtomodel getpos pack ?

fair drum
#

So I have this as my onPlayerRespawn.sqf... any interesting ways I could possibly go about making it so that players could choose to either spawn on the ground or up on a drop?

https://sqfbin.com/gupumixenogiwemehiyu

unreal scroll
#

No, I mean a player can't interact with the backpack as it was an object, so he need to do what he wants to do with the relative coords.
Like attaching a light. Anyway , depends on a purpose.

wheat island
#
// Get the names of all the crates
private _crateName = [
    missionNamespace getVariable ["base_box_1"]
];

// Get the game object as referenced by _crateName
_crateName select 0;

// Get the cargo of the crates
private _crateBackpackCargo = [getBackpackCargo _crateName];
private _crateMagazineCargo = [getMagazineCargo _crateName];
private _crateWeaponCargo = [getWeaponCargo _crateName];
private _crateItemCargo = [getItemCargo _crateName];

//Add the items to a global array
missionNamespace setVariable ["CrateCargo", _crateCargo, true];
#

help plz

fair drum
#

with...

wheat island
#
private _crateItemCargo = [getItemCargo _crateName];```
exitwith : expected Object, not array
#

what do

fair drum
#

your second line does nothing

#

try creating a new variable like

_cratename2 = _cratename select 0;
#

then using that later

unreal scroll
#

All of the code is... weird.

tough abyss
#

aren't objects already pass by ref?

#

you dont need to wrap the object in array

unreal scroll
#

missionNamespace getVariable ["base_box_1"] - wrong syntax

wheat island
#

_crateName is a list of about 10 boxes. In this example, it's only 1, solely for testing.

unreal scroll
#

missionNamespace setVariable ["CrateCargo", _crateCargo, true];
no need to make it global, it is global already.

wheat island
#

right

#

so I made some changes and was able to get it to run

#

I need _crateName as an array, is there a way to do that with public names?

#

One works, I just can't seem to get multiple to work when combining them into an array

unreal scroll
#

private _crateName - what is stored here? If it is a class, then you can't get anything from it.
If you want to save/load (you want to save it in missinnamespace, so it is supposed you want to save it), then you should not save the object itself, it will not be saved.

wheat island
#

_crateName is supposed to contain the variable names of a handfull of boxes

unreal scroll
#

Variable names? Stored? Why? Maybe you want to save the variable values? 🧐

wheat island
#

basically, I want to grab the contents of a handful of boxes and pipe the contents over to an ACE arsenal

#

The variable _crateName doesn't last more than maybe a second

unreal scroll
#

Then why you want to use missionamespace? It is a very weird decision. Use server variable.

wheat island
#

I understood it as, object names were stored in missionNameSpace?

unreal scroll
#

Yup. But maybe there is no need to use global variables, if the TTL "maybe a second"?

wheat island
#

Without using a global variable, how would I get the variable names of the boxes I'm trying to access?

unreal scroll
#

What is the "variable names of the boxes"?
Boxes are the objects. Variable names are just variable names. It can be linked with object, and may not.
Variable value can be linked with name[s] of object, objects, etc.
You need to explain you purposes well.

If you want to get a cargo from nearby boxes, then just:

  1. Do foreach cycle for each nearest ammoboxes, and get the content of it (nearobjects, nearestobejects, etc)
  2. Put the content into one variable, and pass it to ACE arsenal.
private _ammoboxes = (collect the ammoboxes objects here);
private _cargo = [];
{
    _cargo pushback (conntent of a box);
} foreach _ammoboxes;
spark rose
#

Use modeltoworld (and worldtomodel) - to the relative backpack position, for example. As I understand, you want to show some visual effects based on its position?
@unreal scroll Thanks Max, I'll try that

fair drum
#

i have two respawn points, one is a squad leader, other is a marker. how would i go about making it so that I can call a different script depending on the respawn type? object or marker?

#

cause right now, my scripts apply to all respawns available

tough abyss
#

measure player's distance between leader and marker?

#

whichever is closer means player respawned there

wheat island
#

@unreal scroll I got it to work. The syntax threw me for a loop, I will say.

#

thanks man!

#

(or woman)

fallow prairie
#

Guys, if I create a countdown timer using while loop and want to add time by killing a ai how would one go about writing it.

supple leaf
#

any AI or just a specific unit?

fallow prairie
#

Any ai

supple leaf
#

I'd give all of them a new killed eventhandler, make your timer global and add to that that

#

or maybe you could work with the players score?

fallow prairie
#

Okay let's cut out the ai for a sec. Let's say the countdown timer which runs in a while loop. And I add time to it let's say another 60seconds. I would update the variable by adding the remaining time left with the added time which is 60 . How do I let that timer go down again because in the while loop this variable will continue to add instead of going down again

#

So is the while loop the best for countdown ?

#

Or is there another way of executing it

supple leaf
#

something like

#
mytimer=60;
while {mytimer > 0} do {mytimer = mytimer - 1; sleep 1;}
hallow mortar
#

Don't add the time in the while loop. Have the time be a public variable that is modified in two places: down 1 once per second by the while loop, and up 60 by an event handler whenever someone murders a robot

supple leaf
#

this will tick down every second, you can add other stuff into the do loop to check for, some if x then mytimer=mytimer + 10

hallow mortar
#
while {(missionNamespace getVariable ["mytimer",60]) > 0} do {
    _currentTimer = missionNamespace getVariable ["mytimer",60];
    _newTimer = _currentTimer - 1;
    missionNamespace setVariable ["mytimer",_newTimer,true];
}```
then in an event handler, probably an MPKilled event handler so you only need one:
```sqf
    _currentTimer = missionNamespace getVariable ["mytimer",60];
    _newTimer = _currentTimer + 60;
    missionNamespace setVariable ["mytimer",_newTimer,true];

I'm not sure the best way to check for being an AI in the EH. isPlayer is the obvious one, but on the other hand it might return false even if it was a player because they're not a player once they're dead. The most foolproof way IMO would be to know which faction(s) all your target AI will belong to and check against that.

fallow prairie
#

Thanks guys will give it a try appreciatecit

ebon citrus
#

@supple leaf prefer uiSleep when time is critical

#

Say, a timer for example

wheat island
#

I'm running into a wall

#

how do you get getMagazineCargo (and similar fnc) to apply to an array of objects, like nearestObjects?

#

I tried manually entering the objects into getMagazineCargo and I get an expression error

#

curious

supple leaf
#

Thanks from me aswell Nikko and Nica

hallow mortar
#

oh yeah you do need a sleep or uiSleep in my while loop example as well, I just forgot to put it in

#

@wheat island forEach

thick merlin
#

Some of you regular's need to take a break from these forums for a bit.You cannot expect people who come here for help to be able to have coding knowledge.Thats why they are here.If they have trouble communicating their problems it is because they themselves are trying to learn.I have interests in most aspects of modding and even after modding since ofp i still learn and find myself asking seemingly silly questions.Btw,I am a qualified sound engineer and have made many terrains and mods in different game engines.But, i know only the basics of scripting.Ive also contributed to the development of the arma series itself.The point is, if helping ppl or answering questions is getting stressfull ,take a break.I do every 4 or 5 years.

#

Thanks.

ebon citrus
#

Valid point, but monocausality doesnt exist

#

People coming in here should also put some effort into their questions

#

What infuriates me personally most is when people come in here asking for things they should ask in #creators_recruiting

#

Put some effort into it

#

If you make script and it doesnt work, that is 100 times better than asking here for people to explain to you how your idea would be turned into a script

#

Now, let's keep the discussion on topic

astral dawn
#

I'd say it's worth to have some generic programmic knowledge before diving into specific topics of the platform. So yes, we should expect people to know programming basics, otherwise it makes no sense.

ebon citrus
#

Well, as long as it's scripting related

wind ingot
#

I was looking at the optimizations page and it struck me a bit of wonder.

if ([] call check_rendering_conditions) then {
        [] spawn render_vphud;
    };

I made this a couple years ago and I know I did it like this for a reason, but I'm just not sure why in the if I used call and in normal execution i used spawn. Or perhaps is not even the best way to execute these functions.

vague geode
#

Is it possible to make an IR strobe also visible on thermals? I am trying to use them to mark friendly units e.g. in the Blackfish's thermal scope...

winter rose
#

Not via scripting I am afraid

wind ingot
#

Messing with configs. Try to find another kind of object that also shows thermal values, you could try reverse engineer and add those characteristics to a new IR strobe.

astral dawn
#

I was looking at the optimizations page and it struck me a bit of wonder.

if ([] call check_rendering_conditions) then {
        [] spawn render_vphud;
    };

I made this a couple years ago and I know I did it like this for a reason, but I'm just not sure why in the if I used call and in normal execution i used spawn. Or perhaps is not even the best way to execute these functions.
We can't know either without knowing what render_vphud does 🤦

vague geode
#

@winter rose Is there another way (particles etc) to mark friendly units with some kind of blinking on thermals?

astral dawn
#

Actually yes we can know why you used call, because spawn returns a handle to spawned script

wind ingot
#

However my doubt is that perhaps only vehicles (humans deep down are vehicles too), that have such thermal characteristics.

ebon citrus
#

IR strobes are vehicles

wind ingot
#

@astral dawn My guess is that because of the if being a evaluation that needs a return and also has things depending on it, i used call because like wiki says "waits for it to finish and return"
While the rest being a normal execution not in a rush i used spawn. "Adds given set of compiled instructions to the scheduler. Exactly when the code will be executed is unknown" 🤷‍♂️

#

render_vphud is the core function of the addon, renders a hud using draw3d

astral dawn
#

Should have done it in call then

winter rose
#

@vague geode in A2 strobes may have worked in TI, I am not sure to remember that properly
you may create a "thermal effect" drop, I don't know if they are detected by thermal, needs testing
usually, thermal thing would need an addon

vague geode
#

@winter rose I think I found a way to get the IR strobe to show up on thermals. My only problem now is to properly synchronize the flashes of the IR strobe and the flash of the particle.

Does anyone happen to know exactly in which interval the IR strobe flashes and how long each flash takes?

"B_IRStrobe" createVehicle getPos this attachTo [this, [0.03, 0.03, 0.03], "leftshoulder"];
_null = attachedObjects this select 0 spawn {
  while { true } do {
    _source = "#particlesource" createVehicle getPos _this;
    _source setParticleClass "MissileDARExplo";
    _source attachTo [_this,[0,1.333,0]];
    sleep 0.5;
    deleteVehicle _source;
    sleep 0.5;
  };
};
winter rose
#

either check the config… or time it ^^"

#

but even if you don't sync it, it's not a big deal at all
and because in MP you may have trouble sync'ing it precisely
and because when in TI, you don't see the IR flash

#

@vague geode

vague geode
#

@winter rose Yeah, I know that you don't see the IR flash in thermals BUT you see the MissileDARExplo particle in night vision...

winter rose
#

ah well
try ["\A3\data_f\ParticleEffects\Universal\Refract",1,0,1] perhaps?

vague geode
#

@winter rose Is it possible to use a deactivated version of the IR strobe? That why I would not need to worry about synchronization at all since the IR strobe wouldn't emit anything...

What do you mean with try ["\A3\data_f\ParticleEffects\Universal\Refract",1,0,1]? Where should I put it and how do I use it?

winter rose
#

instead of missile explosion, try a thermal deformation? I am not sure it works though (see the wiki for particle settings)

vague geode
#

@winter rose I am sorry but I don't understand what you are suggesting nor how to do it...

vague geode
#

@winter rose But how do I use any of that on the IR strobe? I can even find the Blinking1 effect (configfile >> "CfgAmmo" >> "B_IRStrobe" >> "NVGMarkers" >> "Blinking1") in CfgCloudlets...

winter rose
#

you use it the same way you did _source setParticleClass, but with setParticleParams?

ebon citrus
#

I do get what youre after, but do also consider this. IR strobes are not visible in most thermals

#

They dont output enough heat to be visible

#

Well, remarkably visible

#

Try NV for IR strobes

#

You could add some sort of FOFI gui for the gunner using thermals, if you want to

#

Like friendlies being outlined by a small box

vague geode
#

@ebon citrus I know that they are only visible in night vision but not on thermals but making them visible on thermals is the whole point of this coversation.

ebon citrus
#

I understand that you want them to, and that is fine and all, but they are realisticly not meant to

#

Keep on going though, if you feel like it

wind ingot
#

Let the guy have some fun 😉 Imagine the chinese invented a new tech 😛

winter rose
#

well… yeah?

ebon citrus
#

Personally, if i were to be asked to do this, i would suggest a FOFI

#

That would add faint bixes around friendlies

#

(Is this not a thing already?)

#

I remember there was a hud mod at some point that added tags on friendly units on thermals

vague geode
#

I understand that you want them to, and that is fine and all, but they are realisticly not meant to
@ebon citrus I may be mistaken, but isn't thermal imaging nothing else than infrared emission measurement?

ebon citrus
#

Not really

#

It is a very narrow band

#

The IR the IR beacons is the near infrared

#

Which is "almost visible light"

#

Not heat

#

Well, not traditional heat

#

This is picked up very clearly with night vision equipment

#

And cameras

#

Grnated you remove the IR filter

#

Infrared imaging equipment usually filters out the near infrared or doesnt sense it at all because it would generate so much noise that it would make all the other readings useless

#

There are some 4th gen(?) NV equipment that combine both infrared and night vision in a smart way

#

Not my field of expertice, though

#

So dont quote me on this

winter rose
ebon citrus
#

Yep

#

Im just giving an alternative solution

#

I'll be leaving you 2 to have fun

winter rose
#

kicked the ants' nest and leaving, thanks!

vague geode
#

@winter rose I still don't get how I can use that on the IR strobe. What I am doing in the code I send you is creating a completely new particle source and then adding the MissileDARExplo effect on it. Are you suggesting I handicraft a new particle by bodging together certain parts that are already existing?

@ebon citrus "Thermographic cameras usually detect radiation in the long-infrared range of the electromagnetic spectrum (roughly 9,000–14,000 nanometers or 9–14 µm) and produce images of that radiation, called thermograms." https://en.wikipedia.org/wiki/Thermography

winter rose
#

@vague geode I am saying "don't use a particle class, but define it with params" yes

ebon citrus
#

Ok, as i have been tagged to the topic i am back

#

Yes, they detect infrared in a soectrum which does not include the near infrared

#

Near infrared is at 780-2500nm

#

Far below 9000nm

#

The point is that near infrared is not actually heat

#

Hot objects, unless INCREDIBLY HOT, dont emmit Near infrared

#

@winter rose i didnt kick the ants' nest, i simply pointed out a fact, offered an alternative solution and saw myself the opportunity to go and take a shower because my solution was not suitable

winter rose
ebon citrus
#

I meant find my programming socks

winter rose
#

"programming" socks right 👀

vague geode
#

@winter rose Ok, I think I get what you are suggesting now but I fear that's a bit beyond my understanding and as such my capabilities...

@ebon citrus Ok, but assuming someone would make an IR strobe that would emit infrared light in an electromagnetic spectrum of 9,000–14,000 nanometers it would show up on thermals, wouldn't it? And if that's possible why wouldn't someone want to give that equipment to their men for use when danger close air support e.g. by an AC-130 in needed?

winter rose
#

what I get is you want to do something like the COD Modern Warfare AC130 mission yeah

vague geode
#

@winter rose Yeah, kinda, but not that clear since that would make it even more unrealistic, wouldn't it?

winter rose
#

well, I think there might be a way (not 100% sure of TI without IR thing)

#

@vague geode the thing with your missile thing that you can see in NVGs, why not simply remove the whole IR strobe?

ebon citrus
#

@vague geode we're a bit offtopic-ish soon. If yiu want to continue this in DMs, im more tham happy to do that.

vague geode
#

@winter rose Yeah, I could do that. I also realized that using the MissileDARExplo effect isn't ideal because if you move you have a fire trail behind you. Not to great. I would need to disable physics effects on that particle effect.

@ebon citrus No need.

ebon citrus
#

Alright. I'll keep it simple without dwelling into the physics too much. We dont, because we cant

#

Or rather the drawbacks outweigh the benefits

vague geode
winter rose
#

so it's technically doable 😁

spark rose
#

So how do you force addAction to move with a piece of player equipment? Right now I have a vest on the ground, but when it's picked up, the Action remains where the vest was

winter rose
#

did you add the action to the ground holder by any chance?

spark rose
#

I created a vest in 3d3n, gave it a variable name, then addAction in the init box

#

Something tells me this is wrong...

winter rose
#

so yeah, the action is on the ground holder

#

3den 😉

spark rose
#

Okay

#

3den

#

l33t 3ng1n3s!

#

okay enough of that, i don't know anything about ground holders, but i will go read

winter rose
#

it's an (invisible) object that shows what it contains

#

the vest itself is not an object, in a way

spark rose
#

okay

young current
#

the player who wears the vest is the object that should have all the actions imo

#

and just conditions to show them when the vest is loooked at on groumd or when it is worn

spark rose
#

@young current I thought about doing it that way, but it seemed more complex then just doing addAction on the vest

winter rose
#

no can do, "add action to the vest"

#

wait, unless I am mistaken, hold on

#

try sqf vestContainer player addAction [...]perhaps?

young current
#

I doubt it would work but worth a shot

winter rose
#

I doubt it too - also not sure it would remain after dropping/taking

exotic flax
#

for a vest it would be vestContainer instead 😉

winter rose
#

ah yes, bad copy/paste 😛

spark rose
#

yeah, that doesn't seem to work

#

back to the drawing board

#

i'll just add to the player and remove upon donning/doffing

copper raven
#

u can play with take/put event handlers, and save action data on the holder with setVariable or something.

foggy moon
#

If you limit access to what gear players can wear, you could designate a specific type of vest not available anywhere else, and just add the action to all players with a condition of wearing that type of vest

young current
#

this is what I thought was the case to begin with

spark rose
#

What i did is almost exactly that Raynor, and then removed the action when they no longer had the vest

#

I used a Rebreather, which is available nowhere else than this one location

hallow mortar
#

Using the action condition to only show it when the player is wearing the vest is much better than having custom add/remove logic. It's essentially foolproof and is technically much simpler.

spark rose
#

is deleting a module not as simple as deleteVehicle?

winter rose
#

it is, but its effects may remain 🙃

spark rose
#

oy.

#

so i'm better off not using one (smoke)

winter rose
#

if you can avoid, avoid

#

I don't know how this one works, and you could always find a weird workaround but script it if you can

sacred turret
#

how do I create an object at player position but on the sky?

winter rose
#
getPosATL player vectorAdd [0,0,500]
```@sacred turret
sacred turret
#

thank you!

#

is there a way to make it spawn with a parachute?

winter rose
#

yes, you would need to create a parachute vehicle first then move the guy in driver (unless it's an object?)

fair drum
#
player setPos ((getPosATL player) vectorAdd [0,0,500]);
private _chute = "Steerable_Parachute_F" createVehicle [0,0,0];
_chute setPos (getposATL player);
player moveInDriver _chute;
acoustic abyss
sacred turret
#

ok, thank you guys

sonic thicket
#

I am trying to figure out how to create a module and then later delete the module, could anyone help me figuring out how to delete the module? The part that creates the module is already created and working just fine:

private _moduleGroup = createGroup sideLogic;
"Ravage_Hordes" createUnit [getMarkerPos "cap_test_spawn", _moduleGroup,
"
this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];
"
];
#

Missionnamespace seem to provide a solution

copper raven
sonic thicket
#

Hmm, im trying to fiddle around but I cant get it to work. I should note that I'm putting this in a trigger and I am putting the delete part in something else

#

I was not really clear about that part ^ because that changes some thing I guess

#

The whole idea is to have a ravage zombie horde placement spawning in at a certain moment and then deleting that horde placement as the player.. turns a lever or something

winter rose
#

you won't obtain that by deleting the module I'm afraid, unless it is specifically built for this behaviour

sonic thicket
#

How about setVehicleVarName on the module's init?

winter rose
#

what about that?

sonic thicket
#

Well, having that on the init of the module EG: this setVehicleVarName "_DelModule"; and then deleting with deleteVehicle _DelModule;

#

its probably not that easy though

#

Ah and well yeah... deleting the module probably doesnt work but still worth a try

winter rose
#

yep forget about setVehicleVarName, it's not its usage

sonic thicket
#

That's a bummer

#

In that case i have absolutely no clue on how to get this working XD Unless I manually put in a horde of zombies or make a horde spawn script.

The thing is with manually spawning the zombies their behavior is quite odd. My guess is that they are missing a init

copper raven
#

u can look at the functions they run, and see if you can find some ways to access the emitters/whatever, people usually setVariable stuff on the logic itself

sonic thicket
#

that's a good idea, thanks for the tip

#

well, there we have it: rvg_fnc_horde_spawn {};

#

And I give up on that, instead I will be putting the ravage module somewhere in the middle of nowhere sky and use MoveTo to re-locate it to the place it needs to be, hacky but maybe it works

winter rose
#

a module is only a non-physical object on which scripts are applied – if the scripts are not planned to deal with this object later, it is useless; many modules can be spawned then deleted
but moving the virtual object will not relocate your zombies

exotic flax
#

meowhuh unless your module has a script which will also add waypoints around itself for AI to move to

sonic thicket
#

In that case, could you show me how to create the module by trigger 1 and remove the module by trigger 2 because I've hit a brick wall

#

I just have no clue on how to reference, when a module is pre-created it's the variable name but I've tried setting this without any luck

winter rose
#

deleteVehicle will delete the module.
maybe not its effects.

sonic thicket
#

Tested it and well yeah that happeens

#

Thanks a ton for the help 🙂 I

#

I'll be using individual AI's instead

tough abyss
#

does anyone know if magazines and magazinesDetail always order the items the same way?

#

im trying to find out magazine id and cr from just knowing the class name

ebon citrus
#

@tough abyss what's the purpose?

#

And no, as soon as the inventory is altered, the order can change

tough abyss
#

UseMagazine action requires magazine id but I only have magazine class

ebon citrus
#

Different types are always ordered the same

tough abyss
#

currently I'm counting the index of the magazine from magazines player then use that index to get magazine id from magazinesDetail

ebon citrus
#

Ehhh

tough abyss
#

i'm aware the order can change but I just need the ordering to be the same between magazines and magazinesDetail

ebon citrus
#

Why not just get the id with the classname

tough abyss
#

what do you mean

ebon citrus
#

Get the name of the magazine from its config and look for a matching string in the magazineDetails list

#

Then fetch the ID from that entry

tough abyss
#

what if there's two types of magazines with the same display name?

ebon citrus
#

Then it doesnt matter, does it?

#

And you shouldnt have 2 magazines with the same name unless they fill the same purpose

tough abyss
#

that's a good point

#

and what about localization?

ebon citrus
#

Localisation is accounted for

#

Since the names come from the same stringtable

tough abyss
#

I kinda need to magazine to be fired off immediately since I'm dealing with explosives

ebon citrus
#

Erm...

#

Set the reload time then?

#

I dont get what's the problem

tough abyss
#

loadMagazine only loads the magazine doesnt it?

#

how would I fire it after it's done?

#

just call fire?

ebon citrus
#

Any of the 1000000 commands to fire a weapon, yes

#

You can even dictate the magazine to fire with fire

#

Some of them work better than others

#

So keep that in mind

tough abyss
#

hmm this looks a lot better, thanks!!

quasi rover
ebon citrus
#

@quasi rover check the description if createVehicle

#

You forgot to dictate CAN_COLLIDE

warm hedge
#

CAN_COLLIDE or use setPos after spawning

quasi rover
#

Oh I see. thanks guys, I never thought of it.

spark turret
#

Is there a way to have a field pop up and have the player input text (or a number in my case)?

winter rose
#

Yes, see dialogs on the wiki

winter rose
#

Good luck! 👍

fair drum
#

What a... useless calculator lol

spark turret
#

Someone posted it yesterday in a memes channel and i find it absolutely hilarioud

#

Need that in arma

winter rose
spark turret
#

Currently in a train, will look into it asa i get home

austere granite
#

Should just say you're a manlet with that input

winter panther
#

I need some help with High Command. I'm adding groups to player's high command dynamically, using hcSetGroup. However, I noticed this doesn't work well if the player isn't synced to a HC Commander module. Without that, the newly added HC Groups don't have an icon, and the player can't give orders to them. Do anyone knows what does the HC Commander module do, and if there's a way to replicate it with scripts? (So I don't need to add an HC Commander module to every playable unit)

spark turret
#

Should just say you're a manlet with that input
@austere granite
I thought about that but the whole joke is that the calculator does absolutely nothing.

winter panther
#

so if he has a commander module all is fine? even if you add groups mid mission?
@tough abyss yeah. If I place a commander module synced to the unit, adding groups to the units HC works fine. Without the module, HC doesn't work. I'm trying to find a way to make it work without the module. I assume that module executes some init function or something like that, but I don't know what exactly.

winter panther
#

hmm after experimenting a bit, this is what I came up with:

private _logicGroup = createGroup sideLogic;
private _HQModule = _logicGroup createUnit ["HighCommand",position player,[],0,"NONE"];
private _HQModuleSubordinate = _logicGroup createUnit ["HighCommandSubordinate",position player,[],0,"NONE"];
_HQModule synchronizeObjectsAdd [player,_HQModuleSubordinate];

Since modules are logic objects, they need to be created with createUnit. I put them on a logic group. The "HighCommandSubordinate" is necessary because adding only a "HighCommand" makes nearby groups automatically join the player, which usually means your own group is shown in the HC Bar.

#

That works. I just need to check if there isn't another HighCommand module attached to the player to avoid duplication. Thanks!

obtuse quiver
#

is it possible to recreate ttt? i just need something that randomly select one player to be the traitor and the other innocents

winter rose
#

ttt?

obtuse quiver
#

trouble in terrorist town

#

someone get selected to be the killer

#

everyone has the same weapon

winter rose
#

ah, I don't know that ^^ but for your question:```sqf
private _killer = selectRandom playableUnits;

obtuse quiver
#

Ty so much you are my lord and saivor

#

sorry, where should i put it and how do i know if i am the selected player? 😅

#

Init.sqf right?

winter rose
#

it depends ^^
initServer.sqf I would say, as the server should be the one taking decisions

obtuse quiver
#

Oh yeah right

#

and if i wanted to show a message like "Traitor"

spark turret
#

Hmmmm is ttt something official?

#

I thought one of my old clan members invented it

obtuse quiver
#

Nah

spark turret
#

I actually scripted this gamemode

obtuse quiver
#

it's a very old gamemode

spark turret
#

Ah Okay

obtuse quiver
#

teach me master

winter panther
#

TTT in arma? didn't know that was a thing

#

I only know it from GMod

spark turret
#

Uh i might even find the mission. I dont think its usable out of the box

#

But you can look over the code
Assuning that i find it

obtuse quiver
#

Oki

spark turret
#

Iirc i made a flag with an addaction that teleports ppl into the zone and then randomly spawned lootcrates and premade locations

obtuse quiver
#

so if you spawned in a location you where the traitor?

spark turret
#

I think everyone gets teleported to a semi random pos and after 2 minutes the traitor gets a hint that he is it

obtuse quiver
#

do you remember how you did the hint thing?

winter rose
#

remoteExec?

ebon citrus
#

Might do Arma 3 TTT when i get back

#

Sounds like a fun project

spark turret
#

I cant find it

winter rose
#
private _killer = selectRandom playableUnits;
sleep 3;
["you are the killer."] remoteExec ["hint", _killer];
["you are not the killer."] remoteExec ["hint", - owner _killer];
spark turret
#

Its probably lost to the void but in theory not to complicated

#

The random lootcrates were the most complicated tjing i guess

obtuse quiver
#
private _killer = selectRandom playableUnits;
sleep 3;
["you are the killer."] remoteExec ["hint", _killer];
["you are not the killer."] remoteExec ["hint", - owner _killer];

@winter rose I'll try this now!

winter rose
#

tell me when it does*(n't)* work ^^

obtuse quiver
#

Worked just fine!

#

ty again

winter rose
#

my pleasure
note that it might hint both cases if there are AI and the server is a player

#

if it's no AI, perfect

obtuse quiver
#

No ai just 7 italians with guns

winter rose
#

the recipe for a catastrophe 😛

obtuse quiver
#

hahahahaha

winter panther
#

anyone knows a way to prevent switching effective commander on a vehicle? besides reassigning it to the driver all the time

#

I have a group of drivers under HC control, and if the player is inside one of the vehicles (and no other unit is inside besides the driver), that vehicle will refuse to follow its commander orders, because the player is now the effective commander, and can control the vehicle with AWSD

#

as soon as the player leaves, the vehicle moves again

#

I need to find a way to lock the effective commander to the driver

winter rose
#

give him a higher rank

winter panther
#

hmm that didn't work. The gunner always becomes the vehicle effective commander, regardless of its rank

#

the only way I found to make the AI ignore the effective commander, is to reassign the driver as commander every time someone enters the vehicle (that's when the commander is recalculated)

#

maybe if I could detect when someone enters the vehicle, I could reassign the driver automatically

crude vigil
winter panther
#

yeah, I ended up adding an ACE option to the interaction menu, to execute that command. The problem is that the effective commander is overriden every time someone gets in or out, and it gets recalculated. I was looking for a more automatic solution, but I didn't want to make a mess of event handlers or while loops, so I added that option.

crude vigil
#

Ok so it is not preventing engine from calculating it? I could not be sure because of the last line of the explanation in page.

winter panther
#

I'm adding ACE options to convert squad units to High Command groups, so I can make vehicle convoys on demand. That's why I needed the driver to stay as effective commander at all times.

crude vigil
#

You can just use an getIn event handler(it is triggered upon someone goes inside the vehicle) and setEffectiveCommander when that handler is triggered.

winter panther
#

yeah, it sets the current effective commander, but it doesn't prevent the engine from recalculating it sadly

crude vigil
#

That would be the correct approach, not a mess.

#

yes, and you are saying it is calculated every time someone goes in.

#

so in that case, you can just put an event handler, and execute the command each time engine changes the effective commander.

#

same thing for when someone gets out as well.

winter panther
#

yeah I tried that approach, but I didn't want to think of all the conditions in which the event handler should stop working haha, so I added a manual option instead. But yeah I should probably do that

crude vigil
#

You care about a specific vehicle or you want player to become effective commander every vehicle he gets into?

winter panther
#

nah, I added an ACE option to move selected units from your squad, to an HC group. If those units are inside a vehicle, I make them stay there, and if there's more than one, it becomes a convoy. The idea is to make the convoy ignore player commands, and only follow the group leader orders

#

otherwise, any vehicle where a player is gunner will refuse to follow the convoy

crude vigil
#

so you want player not to become effective commander, just a gunner?

winter panther
#

all that is done the moment the new group is created, so only those vehicles should be affected. An event handler should do the trick

crude vigil
#

I didnt understand how ACE option is relevant to that at all.

winter panther
#

yeah, I want to make it so if players get in/out of those vehicles, they won't be able to control them manually

#

the ACE part is irrelevant. I just mentioned it to explain what I was trying to do

#

I'm also worried about locality. I'm pretty new to Arma scripting so I don't know much about how that stuff works. If player A executes the ACE action, creating the convoy, and the event handler is created there, what happens if player A disconnects? will the event handler still run? The wiki seems to indicate it won't

crude vigil
#

is it multiplayer?

winter panther
#

yes

crude vigil
#

event handler runs based on where you put, if it is on player, it will be destroyed, if it is on another object, it will remain..

#
<vehicle> addEventHandler ["GetIn", { //<vehicle> is ur vehicle variable.
    params ["_unit", "_role", "_vehicle", "_turret"];
        [_vehicle, driver _vehicle] remoteExec ["setEffectiveCommander", 0];
}];
#

that should be as easy as it is , if I did not misunderstand.

winter panther
#

yeah, that should work. However, the getIn event handler doesn't work when changing seats apparently

#

and I'm pretty sure Arma recalculates the effective commander there too

winter panther
#

ah nice

crude vigil
#

write the same for these too, then :P

#

you got example, time to practice :)

#

it is based on the vehicle, so no locality issue either, dont worry.

winter panther
#

thanks Talya! you helped me a lot 🙂

crude vigil
#

Oh and yeah, the object inits are run on every machine but this is enough this to be run on server, so you might wanna write it somewhere properly. Guess missionmakers prefer init.sqf etc. so you may use it. I dont know though, I hate adding extra files for scripts and usually use game logics. So up to you I guess.

#

@winter panther I just read it properly, it has to be run on every machine , this particular command so updated the code to do that.

brave jewel
#

So.. I am working on a lootspawn script and I need you guys to give your two cents:
The problem is I am getting errors that _muzzle, _optics, etc are not defined. I have no idea why or what could cause this.. here is the script snippet that throws the error :

_weapon = _weaponArray call BIS_fnc_selectRandom;
                _compatibleItems = [];
                
                _MuzzleSlot = getArray (configFile / "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");
                _Muzzle = selectRandom _MuzzleSlot; 

                _CowsSlot = getArray (configFile / "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
                _Optic = selectRandom _CowsSlot; 

                _PointerSlot = getArray (configFile / "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems");
                _Pointer = selectRandom _PointerSlot; 

                _UnderBarrelSlot = getArray (configFile / "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> "UnderBarrelSlot" >> "compatibleItems");
                _UnderBarrel = selectRandom _UnderBarrelSlot;
                
                _compatibleItems append _Muzzle;
                _compatibleItems append _Optic;
                _compatibleItems append _Pointer;
                _compatibleItems append _UnderBarrel;
                hint str _compatibleItems;
                _attachment = _compatibleItems call BIS_fnc_selectRandom;
                _holder = "WeaponHolderSimulated" createVehicle [0,0,0];
                _holder setPos _x;
                _holder additemCargoGlobal [_attachment, 1];```
crude vigil
#

` <-- this is what u re looking for.

brave jewel
#

thanks 😄

crude vigil
#

Also write 'sqf' after the first 3 of those.

brave jewel
#

that was kinda embarrassing 😄

#

uuh thats awesome, thanks!

winter panther
#

oh so I should use remoteExec to execute stuff on all machines. Nice, thanks again!

crude vigil
#

@brave jewel Do every weapon have at least one compatible accessory in every category?

brave jewel
#

Oh that might be the case! Nice input, ehm so I should probably put in a failsafe right?

crude vigil
#

or you can just try running your code till you hit the lucky scenario :)

#

since it is random weapon ^^

brave jewel
#

hmm well this is not in my interest as it will be an mp mission and I don't want errors to show up for people 😛

#

Any Idea how I could make the script ignore the variable then?

crude vigil
#

check if _xxxSlot > 0 ?

brave jewel
#

I was thinking about: ```sqf

            if !(_Muzzle == "") then {_compatibleItems append _Muzzle};
            if !(_Optic == "") then {_compatibleItems append _Optic};
            if !(_Pointer == "") then {_compatibleItems append _Pointer};
            if !(_UnderBarrel == "") then {_compatibleItems append _UnderBarrel};
#

okay that didn't work out

crude vigil
#
{
     _slot = getArray (configFile >> "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> _x >> "compatibleItems");
     if (count _slot > 0) then {
         _compatibleItems pushBack (selectRandom _slot);
     };
} forEach ["MuzzleSlot", "CowsSlot", "PointerSlot", "UnderBarrelSlot"];
#

I forgot a lane, but u get the idea.

brave jewel
#

never worked with pushback, what does it do again?

languid tundra
#

adds an element to the end of the array

brave jewel
#

Ahh alright

#

Got that

#

Still got an error

#

its for :```sqf
if (_slot |#|> 0) then {
Error: Type Array, expected Number, Not a Number

crude vigil
#

I always forget to use count,

#

always....

brave jewel
#

oh wait you edited the code in the last second haha

#

😄

#

still says _attachment is undefined :x

#
               {
            if (_spawnchance select 4 > floor(random 100)) then //attachments
            {
                _weapon = selectRandom _weaponArray ;
                _compatibleItems = [];
            {
                 _slot = getArray (configFile / "CfgWeapons" >> _weapon >> "WeaponSlotsInfo" >> _x >> "compatibleItems");
                 if (count _slot > 0) then {
                     _compatibleItems pushBack (selectRandom _slot);
                 };
            } forEach ["MuzzleSlot", "CowsSlot", "PointerSlot", "UnderBarrelSlot"];
            
                hint str _compatibleItems;
                _attachment = selectRandom _compatibleItems;
                _holder = "WeaponHolderSimulated" createVehicle [0,0,0];
                _holder setPos _x;
                _holder additemCargoGlobal [_attachment, 1];
            };
        } forEach _buildingPos;
crude vigil
#

and what does the hint return? Since we are working with abstract stuff here. 😅

brave jewel
#

Well the hint returns literally [] 😄

crude vigil
#

well , one more thing to add safety I believe then just like rest.notlikemeow

#

why are you even using that function while you have selectRandom?

brave jewel
#

I like to switch between both :x

crude vigil
#

half of lines are using function, half of them are using command.

#

You do not want to write the same command everywhere, so spicing up things huh?

#

Adding some different taste to your code.

brave jewel
#

haha yea xD

#

okay edited the stuff above 😄

#

still no luck tho

crude vigil
#

I still dont see _compatibleItems empty scenario handled!

#

I am also afraid to ask why it keeps coming empty all the time.

brave jewel
#

I have no idea :/

#

Everything else in this script works except of this piece of... letters and numbers

crude vigil
#

Will you edit the code to handle empty case of _compatibleItems?

#

it is why _attachment becomes undefined.

#

Altho no compatible accessories even in that level raises suspicion about whether or not you properly receive the compatible items.

brave jewel
#

I finally understood what you meant with this xD I'm a little dummy 😄

crude vigil
#

You will get used, it just takes time.

brave jewel
#

Okay it at least spawns stuff now but the next problem is: It only spawns smg flashlights 😄

#

I have at least 7 M4 variants in the _weaponArray so it should have no problem to sometimes select that at random