#arma3_scripting

1 messages ยท Page 675 of 1

fair drum
#

it is the weirdest thing. I only have a few mods on right now. your dev tools, some of polpox's stuff. nothing really that would effect chat channels

little raptor
#

[_channel, [player]] remoteExec ["radioChannelAdd", 2];

fair drum
#

so it worked for about 4 seconds, then was removed once I spawned. yet I still show added under radiochannelinfo. the channel works fine in SP editor where I can force a customChat with script. but when in multiplayer, I can't even force a customChat either through the server or player.

little raptor
#

add the channel with some delay after it's created

#

like a few seconds

fair drum
#

hmmm let me try that

#

so now I've narrowed it down to the respawn menu. while in the respawn menu, I can access the channel, but the moment I spawn, it gets removed. all i have is the menuPosition respawn template and nothing in my onplayerrespawn.sqf even touches chat channels

little raptor
#

in fact you should touch onplayerrespawn!

fair drum
#

yes, but I'm still showing in the array of added units while in my new body

#

with the transferred vehiclevar

little raptor
#

in onplayerrespawn

fair drum
#

that looks to have fixed it. what was confusing me is I didn't even know to think of that because everything was still showing that I was added to channel at all times. even when I was the new unit and had my editor reference.

fair drum
dry python
#

load.sqf:

_test1 buttonSetAction "profileNamespace setVariable ['myTest', 1]; saveProfileNamespace; closeDialog 0;";
_test1 ctrlShow true;```
output.sqf:

_test2 = profileNamespace getVariable ["myTest", 0];
diag_log format["Test: %1", _test2];

#

when its loaded i dont get a 1... only if i reconnect or die.

#

anyone know why and how to solve?

warm hedge
#

I thought I said ENTIRE, not a part of them. Those two don't make sense

dry python
#

i cant post the whole wasteland script..

#

:/

fair drum
#

put it on sqf bin

dry python
#

nvm ill keep testing myself, thanks anyway

fair drum
#

its freeeeeeeeeeeeeeeeeee and no signups needed

golden storm
#

Hello everyone, so, a quick question, it might make you want to slap me and i understand you.

What i'm trying to do is to get the game to respawn players inside a vehicle, checking if it's empty or not, if it is, then respawn the player inside that vehicle, if it's not, then select another vehicle (there're 12 vehicles, each with a single unit capacity), what i have is this but even i know it is SOOOOOOO wrong:

_respawnVeh = {respawn_west1, respawn_west2};

if (hasInterface) then {
    player addEventHandler ["Respawn", {
    {{alive _x} count crew _respawnVeh == 0} forEach _respawnVeh;
    if crew == 0 do 
        {player moveInCargo _respawnVeh};
    }];
};
warm hedge
#

if crew == 0 do meowsweats

fair drum
#

Are you using anything like the menu position system?

golden storm
#

@warm hedge Is it THAT bad? Sorry i'm used to scripting simpler things (i'm not adept at programming or anything, but i'm trying to learn)

@fair drum I'm trying to set the respawn trough the init.sqf

warm hedge
#

More like it's simply illegal.
crew is a reserved variable because it is a command, and that is not a way to use this command.
do is also not a suitable command to use if, then instead

golden storm
#

Huh, neat, i'll revisit the code completely

#

Thanks @warm hedge

sharp grotto
#

Is there a way to check if a player is muted via the player list ?
I want to mute a player in sidechat/direct if he got muted by another player (via HandleChatMessage) ๐Ÿค”

outer fjord
#

Hello, I'm sorta confused on defining variables with just unit names. Exactly why doesn't the game like this set up? ๐Ÿ˜…

Unit1 = "I_soldier_UAV_06_F";

RemoveBackpackGlobal Unit1;```
#

It seemed to work for vehicles themselves, but units seem to need a extra step

warm hedge
#

Unit1 is not an object, but just a string

outer fjord
#

Uh, how would I unstring that? I want it to keep it generic for that specific class.

#

Because I tried just
RemoveBackpackGlobal "I_soldier_UAV_06_F"; and generic error as well.

robust hollow
#

you'd probably need something like this

{
    if (typeOf _x == "I_soldier_UAV_06_F") then {removeBackpackGlobal _x};
} forEach allUnits;
#

or alternatively remove it before/when spawning them, depending on when this is used

outer fjord
#

It's used on inti it seems on liberation framework. But typeOf _x == shoudl work for both ways yea?

#
[[KP_Liberation_infantry_laa], {removeBackpack _this;}]``` This is part of the array I wrote out as part of their file that fires off on any unit spawn.
warm hedge
#

Isn't allUnits select {typeOf _x == "I_soldier_UAV_06_F"} better?

robust hollow
#

idk, wouldnt think so. why loop through all units just to loop through some of them again?

outer fjord
#
/* - Specific object init codes depending on classnames.
Format = [Array of classnames as strings, Code to apply]
_this is the reference to the object with the classname */

KPLIB_objectInits = [
    [["Flag_White_F"], {_this setFlagTexture "res\NFG\Prototype200x200.paa";}],
    [["Land_HelipadSquare_F", "Land_HelipadCircle_F", "Land_HelipadRescue_F"], {{[_x, [_this, true]] remoteExecCall ["addCuratorEditableObjects", 2]} forEach allCurators;}],
    [[FOB_box_typename], {_this call F_setFobMass; [_this] remoteExecCall ["F_setLoadableViV", 0, _this];}],
    [[KP_liberation_recycle_building], {_this setVariable ["ace_isRepairFacility", 1, true];}],
    [[KP_liberation_small_storage_building, KP_liberation_large_storage_building], {_this setVariable ["KP_liberation_storage_type", 0, true];}],
    [KP_liberation_medical_facilities, {_this setVariable ["ace_medical_isMedicalFacility", true, true];}],
    [KP_liberation_medical_vehicles, {_this setVariable ["ace_medical_medicClass", 1, true];}],
    // Hide Cover on big GM trucks
    [["gm_ge_army_kat1_454_cargo", "gm_ge_army_kat1_454_cargo_win"], {_this animateSource ["cover_unhide", 0, true];}],
    [[KP_Liberation_infantry_lat], {removeBackpack _this;}],
    [[KP_Liberation_infantry_laa], {removeBackpack _this;}]
    [["Flag_White_F"], {_this setFlagTexture "res\NFG\Prototype200x200.paa";}],
];```

Is the full file
warm hedge
#
{

} forEach (allUnits select {typeOf _x == "I_soldier_UAV_06_F"})```, I mean
robust hollow
robust hollow
outer fjord
#

mmm, just weird that they have vehicles and other objects work fine but not infantry. Could just be set up that with with KPLIB_objectInits

#

thank you for your help btw.

warm hedge
copper raven
#

with more units select will be faster

proven charm
#

Why isn't this code I got from the forums doing anything: _center = createCenter sideLogic; _group = createGroup _center; _pos = getpos player; _cas = _group createUnit ["ModuleCAS_F",_pos , [], 0, ""]; _cas setVariable ["vehicle","O_Plane_CAS_02_dynamicLoadout_F"]; _cas setVariable ["type", 1];

proven charm
#

console

little raptor
proven charm
#

not sure I think the virtual cas class name is something like : "SupportProvider_Virtual_CAS_Bombing"

cosmic lichen
little raptor
proven charm
#

@little raptor thx man that works ๐Ÿ™‚

#

hmm what's weird is that with unsung planes the planes seem to blow them self up when firing

little raptor
#

or do they explode when they spawn?

proven charm
#

they fire then blow up

#

yep they shoot them self in air

#

vanilla planes seems to be ok

little raptor
#

do they have counter measure?

proven charm
#

idk

little raptor
#

well they fire their counter measure after shooting

#

maybe it's "bound" to something else in unsung

proven charm
#

I'm testing all the unsung planes, bit hard to know which plane is good for CAS though with all the loadout abbreviations

#

Here's the list: ``` blows up:

  • AF
    uns_F4E_GBU
    uns_F4E_AGM
    uns_A7_AGM
  • Navy
    uns_A7N_AGM
    uns_F4J_AGM

ok:

  • AF
    UNS_F111_AGM
    uns_f105D_AGM
    uns_f100b_AGM
  • Navy
    uns_A4B_skyhawk_AGM
    uns_A6_Intruder_AGM
#

so its with some planes only

warm hedge
#

There's a short lag between an unit in a group's dead and the leader recognizes that he's dead now and kick him out from the group. Is there any command/function to remove this lag?

winter rose
#

reveal mayhaps but I wouldn't hold my breath

warm hedge
#

Unfortunately reveal is not the thing, so you don't need to worry about to die

little raptor
proven charm
#

can you change the mouse cursor like zeus does?

little raptor
proven charm
#

oh no :/

little raptor
# proven charm oh no :/

I'm not absolutely sure.
you can check the Zeus files, see if there's any "reference" to those mouse icons.
if you find anything let me know! I also needed this a while ago but gave up.

proven charm
#

yea I already did check the curator files..

warm hedge
#

IIRC there's no possibility than a map GUI control?

proven charm
#

yes map should be possible

#

The cursors are defined in configFile >> "CfgWrapperUI" >> "Cursors" . that's all I know

tough abyss
#

Hello everyone, does anyone have a problem that the BIS_fnc_kbTell dialogs go too fast and don't play sound? Although subtitles appear.

winter rose
#

if you use a simple module/Logic, it will speak MickeyMouse-y

tough abyss
#

Thank you, but I have it marked in the config (actor= "DB_HQ"). Or do you mean the 6 parameter BIS_fnc_kbTell?

tough abyss
#

This is a unit on the base.

winter rose
#

oh, that's weird then. I only encountered this issue if it was a Logic speaking

tough abyss
#

Thanks for the help, I'm just working with BIS_fnc_kbTell for the first time. And my task is to make radio conversations between the HQ and the player.

still forum
dusty whale
#

where are ace-functions defined?

#

because they sure as heck are not in cfgFunctions

dry python
#

doesnt work, same issue

little raptor
#

functions are defined in XEH_PREP.hpp

little raptor
fair drum
#

is stacking switch dos a bad idea on performance vs just stacking if thens or using a fsm?

little raptor
fair drum
little raptor
#

(if the conditions are fixed/predictable)

fair drum
#

well if they are all the same, with these amount of conditions, I'd rather be visual with a FSM editor

dusty whale
#

since when did that happen?

#

and why is that a thing?

little raptor
#

there's no way to make loading times faster besides that

little raptor
dusty whale
#

it sure as heck doesnt load the changes i make to files, so why does it need to recompile if nothing changes?

digital hollow
little raptor
#

@still forum is what I said true?!
#arma3_scripting message
(do cfgFunctions recompile in every mission)
as a dev you should know

still forum
#

There is a cache in uiNamespace

#

If you don't set allowRecompile or filePatching or whatever it should copy from there

#

Not sure, that initFunctions script is huge :u

little raptor
#

I'm not sure why CBA would claim that it speeds up the loading times if otherwise meowsweats

fair drum
fair drum
#

guess I gotta read up on those lol

little raptor
#

conA -> condB -> load codeAB
kind of thing

#

very fast

#

but tedious to set up

fair drum
#

got a quick small example?

winter rose
little raptor
# fair drum got a quick small example?
call {
    if (A) exitWith {
        if (A1) exitWith {
          //code A1
        };
        if (A2) exitWith {
          //code A2
        };
    };
    if (B) exitWith {
        ...
    };
    if (C) exitWith {
        ...
    };
};

Transforms into:

hm = createHashMapFromArray [
[
    A, createHashMapFromArray [
        [
            A1,
            {
              //code A1
            }
        ],
        [
            A2,
            {
              //code A2
            }
        ]
        
    ]
],
[B, ...]
[C,...]
]

call (hm get A get A1)
#

of course the best way to set those is with a code that generates it automatically

#

I have an example of that too but it won't fit here meowsweats

fair drum
#

ah so I was messing around with the first example then a hour ago

#

but I didn't continue with it enough

winter rose
little raptor
#

(you won't be doing that if you "cache" the name of the function and load it from uiNamespace)

brisk tusk
#

Hey guys. I'm trying to find a way to set a specific type of ammo on a crew served weapon. From what I've found, I think I should be using the setMagazineTurretAmmo into the turret's init, but I'm not to sure as I keep getting an error whenever I try

little raptor
#

and post your code

brisk tusk
#

did a bit more. Ended up stopping the error, but nothing happens

#

ye 1 sec

#

vehicle setMagazineTurretAmmo [UK3CB_BAF_23Rnd_40mm_G_Box, 6, UK3CB_BAF_Static_L134A1_Deployed_Low]
&
vehicle addMagazine ["UK3CB_BAF_23Rnd_40mm_G_Box", 15];

#

pasted into the turret's init

little raptor
#

magazineClass is a string

#

turretPath is an array

brisk tusk
#

Gotcha. I really don't know much of this, so I didn't realize when reading the wiki

still forum
brisk tusk
#

I'll take another shot at this. Thanks for helping!

little raptor
still forum
#

yeah, you can have only the side.
But not really easy to have a automatic fallback ala (if side+class not found, try only side)

#

well easy yes but performant

brazen lagoon
#

Any ideas on why my paradrop script seems to work locally but not on a server?

#

(vehicle _player) setPosATL [_position select 0, _position select 1, 2000];

#

this seems like its the problem

fair drum
#

what value did you give _player

brazen lagoon
#

when I click somewhere it teleports me for a split second and then tps me back

fair drum
#

also post the whole script on sqfbin.com and paste it here

brazen lagoon
#

sure, sec

#

it's remoteexec'd like this: [clientOwner, (getPlayerUID player), _pos] remoteExec ['SG_fnc_paradrop', 2, false];

fair drum
#

nvm. give me a sec to read it all

#

line 26, what are you trying to do with that?

brazen lagoon
#

uhh ok so on the client end

#

the activation trigger looks like this: sqf _actionid = player addAction [ "Paradrop Vehicle", { openmap [true,false]; titleText ["Select Map Position", "PLAIN"]; onMapSingleClick " [clientOwner, (getPlayerUID player), _pos] remoteExec ['SG_fnc_paradrop', 2, false]; false " }, nil, 5, false, true, "", "" ];

#

so this is trying to clear the onMapSingleClick on the client after the drop happens

little raptor
#

player setVariable ['actionid', _actionid, true];

#

does it matter?

#

to others

brazen lagoon
#

true

little raptor
# brazen lagoon true

I mean if you needed the id the non-public variant was ok. I was asking why you're making it public

brazen lagoon
#

i dont follow

#

oh

fair drum
#

set last to false

brazen lagoon
#

does setVariable broadcast over the network?

fair drum
#

if its true it does

little raptor
#

when you set the public flag yes

brazen lagoon
#

oh yeah. I think i set that to true at some point but it isnt necessary anymore

#

yeah I'll remove that

fair drum
#

so your script is executing, you are just being teleported and then back again instantly?

brazen lagoon
#

@fair drum ok but I want onMapSingleClick to stay that function

#

like, I want that to be called every time there's a click event until it succeeds

little raptor
fair drum
#

use the actual event handler

brazen lagoon
#

what does that mean

little raptor
#

Since Arma 3 v1.58 a stackable MissionEventHandler is available and should be used instead: MapSingleClick.

brazen lagoon
#

ah ok. and then probably call remoteExec to delete the event handler when the drop is successful

brazen lagoon
#

because the actual drop is run on the server

little raptor
#

so?

#

the action is local

fair drum
#

your addmissioneventhandler is local

brazen lagoon
#

right, but how would the local machine know when to remove it otherwise?

#

I guess I could have a waitUntil position change or something

little raptor
#

no

#

like I said the click is local

#

ok I see what you mean

#

nvm

brazen lagoon
#

ok, but I don't want the event to keep firing every time a player clicks on the map

#

well i do but only until it actually succeeds

#

then I want it to stop happening

#

but yeah I'll modify it to use eventhandlers and see if that fixes it. Not sure why that would be the reason I get teleported back though. it seems like I get 1 frame of being in the right spot and then I get sent back

little raptor
#

let me read your script

brazen lagoon
#

ok

tough abyss
#

I have faffed around with Event Handlers and all that (bear in mind I'm not very 'script' minded) and cannot manage to lock the co - pilot seats of my helis? I have the pilot locking working. Any help would be appreciated

this addEventHandler ["GetIn", { if (driver (_this select 0) == (_this select 2) ) then { if (!(vehicleVarName (_this select 2) in allowedPlayers)) then { moveOut (_this select 2); Hint "You are not Allowed!"; }; }; }];

fair drum
little raptor
#

@brazen lagoon first of all, don't use getPos
second of all, I think the problem is here:

_chute = createVehicle ['i_parachute_02_f', getPos vehicle _player, [], 0, 'can_collide'];
        _chute setVelocity _velocity;
        vehicle _player attachto [_chute, [0, 0, 2]];

do this instead:


    [false,false] remoteExec ["openmap", _caller_id, false];
    [_player] spawn {
        params ["_player"];
        _pos = [_position select 0, _position select 1, 2000];
        vehicle _player setPosATL _pos;
        waitUntil {getPos _player select 2 < 250};
        _velocity = velocity vehicle _player;
        _chute = createVehicle ['i_parachute_02_f', _pos, [], 0, 'can_collide'];
        _chute setVelocity _velocity;
        vehicle _player attachto [_chute, [0, 0, 2]];
        waitUntil {(getPosATL _player select 2) < 5};
        deleteVehicle _chute;
    };
#

(also I swapped one of your getPosATLs with getPos

#

(I know I said don't use it but you should here)

brazen lagoon
#

what's the reasoning behind not using getPos

little raptor
fair drum
little raptor
fair drum
#

i 'think' the copilot is considered a gunner

brazen lagoon
#

basically its mixing position types?

little raptor
#

yes

brazen lagoon
#

gotcha

tough abyss
little raptor
brazen lagoon
#

hmm ok lemme try it out in sp again and then ill test on the server if it works

little raptor
#

fix it yourself meowsweats

#

_pos = [_position select 0, _position select 1, 2000];

#

_position is not defined

brazen lagoon
#

oh right

little raptor
#

just define pos in the outer scope and pass it as param

brazen lagoon
#

well I just changed the spawned script to take in position

#

@little raptor the problem is this creates the chute at 2000m

#

which then tps you back up

#

so I think you do actually need to get the position of the vehicle

little raptor
#

I didn't notice the waitUntil

brazen lagoon
#

yeah, I think I fixed it

#

gonna see if this works now

little raptor
#

I hope it's not getPos again

brazen lagoon
#

getPosATL

little raptor
#

use ASLtoAGL getPosASL

brazen lagoon
#

which I think is the one that createVehicle wants?

little raptor
#

createVehicle needs AGL

#

(ATL is not an "official" format)

brazen lagoon
#

oh weird, the wiki says its only AGL if its a boat or amphibious

#

ah

little raptor
#

on land: AGL = ATL
on sea: AGL = ASLW

brazen lagoon
#

makes sense

fair drum
tough abyss
brazen lagoon
#

@fair drum @little raptor nope, it's still doing it. it's teleporting me for a split second then sending me back

fair drum
fair drum
tough abyss
fair drum
#

are your allowed players using the same unit class?

#

like say, a pilot from the editor?

tough abyss
#

My entire ORBAT is using the same class, team_lead, but I can change that easily

fair drum
#

which vehicle are you using, ill look up the positions

#

incoming mod vehicle =(

tough abyss
#

๐Ÿ˜‚ Get ready:

  • Apache (Apache Project)
  • Wildcat (3CB)
  • Griffin (RHS Retexture)
  • Chinook (CH-47 Mod)
  • Puma (RKSL)
  • Merlin (3CB)

If it is simple to get the positions I can do that if you tell me how?

fair drum
#

copilot is a turret

tough abyss
little raptor
brazen lagoon
#

figured it out

fair drum
brazen lagoon
#

seems to be a race condition of some sort. the first setPos isn't running fast enough so the rest of the code is basically a no-op because the vehicle is never actually set to that altitude

little raptor
#

I thought passing the position directly to createVehicle would fix it meowsweats

brazen lagoon
#

yeah it's odd

#

but nothing a waitUntil won't fix

#

or shit even just a sleep but that's hacky

tough abyss
fair drum
tough abyss
fair drum
fair drum
# tough abyss [[heliD,"driver",-1,[],false]] [[heliD,"gunner",-1,[0],false]]
this addEventHandler [
    "GetIn",
    {
        params ["_vehicle", "_role", "_unit", "_turret"];

        private _turretCrew = fullCrew [_vehicle, "turret", true];

        if (driver _vehicle isEqualTo _unit || _turretCrew findIf {_unit isEqualTo _x#0} != -1 || gunner _vehicle isEqualTo _unit) then {
            if !(_unit in allowedPlayers) then {
                moveOut _unit;
                hint "You are not allowed!";
            };
        };
    }
];

just trying to verify that the modded vehicles don't have something that won't work with this

#

cause I want to see if those modded heli's have their crew members as "turret" like the taru bench does

tough abyss
# fair drum i mean one of the transport helis. and when i say load it up, i mean load it up ...

[[heliD,"driver",-1,[],false],[B Alpha 1-1:7,"cargo",2,[],false],[B Alpha 1-1:8,"cargo",3,[],false],[B Alpha 1-1:9,"cargo",4,[],false],[B Alpha 1-1:10,"cargo",5,[],false],[B Alpha 1-2:1,"cargo",6,[],false],[B Alpha 1-2:2,"cargo",7,[],false],[B Alpha 1-2:3,"cargo",8,[],false],[B Alpha 1-3:1,"cargo",9,[],false],[B Alpha 1-3:2,"cargo",10,[],false],[B Alpha 1-3:3,"cargo",11,[],false],[B Alpha 1-3:4,"cargo",12,[],false],[B Alpha 1-3:5,"cargo",13,[],false],[B Alpha 1-3:6,"cargo",14,[],false],[B Alpha 1-4:1,"cargo",15,[],false],[B Alpha 1-5:1,"cargo",16,[],false],[B Alpha 1-5:2,"cargo",17,[],false],[B Alpha 1-5:3,"cargo",18,[],false],[B Alpha 2-1:1,"cargo",19,[],false],[B Alpha 1-6:1,"cargo",20,[],false],[B Alpha 2-2:1,"cargo",21,[],false],[B Alpha 2-4:1,"cargo",22,[],false],[B Alpha 2-3:1,"cargo",23,[],false],[B Alpha 2-6:1,"Turret",-1,[0],false],[heliG,"gunner",-1,[1],false],[B Alpha 1-1:4,"Turret",-1,[2],false],[B Alpha 1-1:5,"Turret",0,[3],true],[B Alpha 1-1:6,"Turret",1,[4],true]]

Co-Pilot is Alpha 2-6

fair drum
#

how many side gunners does that vehicle have?

#

i count 4?

tough abyss
#

So it's the chinook, so there are the side gunners on the Miniguns however it classes the end seats of the benches as turrets

fair drum
#

I see, well if you don't care about those end bench seats then that will do fine. didn't add the gunner _vehicle isEqualTo _unit though

tough abyss
#

Right now I don't, we rarely fill up a full chinook. If I did does it become a pain?

fair drum
#

you just can't use those last two seats as a normal infantry man

#

not a big deal imo

tough abyss
#

Yeah that's fine, I'm just going to check my others hold on

#

[[grifD,"driver",-1,[],false],[B Alpha 4-5:1,"cargo",4,[],false],[grifG,"gunner",-1,[0],false],[B Alpha 3-3:1,"Turret",0,[1],true],[B Alpha 3-4:1,"Turret",2,[2],true],[B Alpha 3-5:1,"Turret",5,[3],true],[B Alpha 3-6:1,"Turret",7,[4],true],[B Alpha 4-1:1,"Turret",1,[5],true],[B Alpha 4-2:1,"Turret",3,[6],true],[B Alpha 4-3:1,"Turret",6,[7],true],[B Alpha 4-4:1,"Turret",8,[8],true]]

fair drum
#

oooo that ones a fat rip

#

is that an open bench seat one that everyone can shoot from?

tough abyss
#

Long and short of it yeah

fair drum
#

do you care if non heli crew get into the side turrets on other vehicles like the chinook?

tough abyss
#

No not particularly, my main effort is to stop those that aren't pilots flying

fair drum
#

oh well let me change that then

tough abyss
#

Understood

fair drum
# tough abyss Understood
this addEventHandler [
    "GetIn",
    {
        params ["_vehicle", "_role", "_unit", "_turret"];

        private _turretCrew = fullCrew [_vehicle, "turret", true];
        private _copilotName = (_turretCrew select 0) select 0;

        if (driver _vehicle isEqualTo _unit || _unit isEqualTo _copilotName || gunner _vehicle isEqualTo _unit) then {
            if !(_unit in allowedPlayers) then {
                moveOut _unit;
                hint "You are not allowed!";
            };
        };
    }
];

try that

#

fixed

tough abyss
fair drum
#

'probably'

tough abyss
#

Roger ๐Ÿ˜†

polar anchor
#

hello, i downloaded arma 3 just today and i was looking at the scrpting page, i was wondering where should i add an event handler, for example, should i use addEventHandler in a file such "initPlayerLocal.sqf"? so when it gets triggered it gets called for the player? and what parameters can i use for "this" before the addEventHandler? i know i can use player but can i use any other entity? if yes, how do i add an event handler for all the entities (both players and bots)?

hallow mortar
#

All of these things depend on the exact type of event handler and what you want it to do

polar anchor
#

can u be a bit more specific?

tough abyss
polar anchor
#

not at all

#

i know some c++

#

it doesn't look to hard

#

just need to figure out few things

little raptor
#

good

#

well what you ask doesn't have an easy answer
in multiplayer scripting "locality" is an important concept

fair drum
#

downloaded arma 3 and instantly goes to scripting. mah man

little raptor
#

there's no straight answer to "where should I put this?"

#

it depends what commands you're using

fair drum
#

I can think of one thing ๐Ÿ˜‰

polar anchor
#

for example what if i want to hint to everyone played joined the mission?

#

and what if i want to print player killed this entity?

#

still for everyone?

#

in a multiplayer mission?

fair drum
#

lots of different concepts in those. read the multiplayer scripting page, locality, and variables pages

little raptor
#

the answer to that would be:

  1. a hint in initPlayerLocal.sqf
  2. for kiiled: a killed or (MPKilled) event handler, which remoteExec (broadcast over network) a systemChat for everyone
#

I can show you some docs/tutorials to get started

#

since you know C++ it won't be hard for you

#

you can also find some other learning docs at the bottom

polar anchor
#

thank you

little raptor
polar anchor
#

something like this would work?

#
player addMPEventHandler ["MPKilled", {
    params ["_unit", "_killer"];
    if (isPlayer _unit && isPlayer _killer) then {
    { hint format "%1 killed %2", name _killer, name _unit} forEach allPlayers - _headlessClients;
    }
}];```
#

?

#

inside initPlayerLocal.sqf?

little raptor
#

not bad for a beginner ๐Ÿ˜‰
but no! ๐Ÿ˜„

polar anchor
#

what's the issue there?

little raptor
#

first of all your syntax for format is wrong
https://community.bistudio.com/wiki/format
it takes an array on the left
it should be:
format ["%1 killed %2", name _killer, name _unit]
second of all:

EH code will trigger globally on every connected client and server
so you should've only added one hint, not forEach

#

but I gotta hand it to you, I'm still really impressed that you just installed Arma and got so far! ๐Ÿ˜„

polar anchor
#

its basically c++ lol

#

u just read the wiki

#

is this better?

#
player addMPEventHandler ["MPKilled", {
    params ["_unit", "_killer"];
    
    if (isPlayer _unit && isPlayer _killer) then {
    format ["%1 killed %2", name _killer, name _unit] remoteExec ["hint", -2];
    }
}];```
little raptor
#

you learned how to use remoteExec already?!
I had to explain it a million times to some people! ๐Ÿ˜„
anyway, no need for it tho

#

the EH triggers globally for everyone

polar anchor
#

i literally just read the wiki of remotexec lol

#

looks like people dont read it xd

little raptor
#

well "some people" couldn't read it!

#

yeah

polar anchor
#

thx for all the docs and stuff ๐Ÿ˜‰

#

really appreciate it

#

๐Ÿ˜„

little raptor
polar anchor
#

is it the same of c++?

little raptor
#

sort of

#

not entirely

#

for example >>, or ^ , etc. do not have the same precedence/meaning

polar anchor
#

oh ok i see

#

ty

fair drum
#

@little raptor when you do your switch evaluations using

private _variable = call {
  if (blah) exitWith {};
  if (blah) exitWith {};
};

i have to add arguments like a traditional call right? or in this instance will it pull in local variables from earlier in the script?

brazen lagoon
#

any idea why this addAction doesn't work? It shows up in the listing of actions but doesn't actually seem to trigger.

#
this addAction [ 
  "HALO Jump", 
  { 
    openmap [true,false]; 
    titleText ["Select Map Position", "PLAIN"]; 
    _mh_id = addMissionEventHandler ["MapSingleClick", { 
      params ["_units", "_pos", "_alt", "_shift"]; 
      [clientOwner, (getPlayerUID player), _pos, false] remoteExec ['SG_fnc_paradrop', 2, false]; 
    }]; 
    [player, _mh_id] spawn { 
      params ["_player", "_mh_id"]; 
      diag_log format ["player: %1, id: %2", _player, _mh_id]; 
      waitUntil {!visibleMap || ((getPosATL _player select 2) > 1500)}; 
      removeMissionEventHandler ["MapSingleClick", _mh_id]; 
    }; 
  }, 
  nil, 5, false, true, "", ""
];```
little raptor
#

like a code in if () {} or while or etc.

fair drum
#

this pleases me

polar anchor
#

how do i repeat an action infinitely?

#

i crashed with this

        while {true} do {
            _unit playActionNow "agonyStart";
            sleep 1;
        }```
little raptor
# fair drum this pleases me

also note that in the unary version of call, _this is what would be in the parent scope:
in other words:

[1] call
{
  call {
    params ["_1"]; //<-works and _1 is now 1
  }
}
polar anchor
#

yes

little raptor
#

where did you execute it?

#

in debug console?

polar anchor
#

initPlayerLocal


player addEventHandler ["HandleDamage", {
    params ["_unit", "_selection", "_damage"];

    _firstTime = true;
    if (_firstTime && isPlayer _unit && _damage > 0.9) then
    {
        _firstTime = false;
        _unit setDamage 0.9;

        while {true} do
        {
            _unit playActionNow "agonyStart";
            sleep 1;
        }
    }
}];```
smoky verge
#
[] spawn { 
{ deletevehicle _x;   
  } forEach (getMissionLayerEntities "hangar" select 0);

shouldn't this delete everything inside of the hangar layer?
its not doing that

little raptor
#

you need to learn about the scheduled environment too

polar anchor
#

yeah i guess

little raptor
polar anchor
#

what's the problem?

little raptor
fair drum
#

gotta have a spawn in there before you can use sleep commands

little raptor
#

@polar anchor spawn is sort of like thread detach in C++

#

but it's not actually multithreaded

polar anchor
#

oh okk

little raptor
#

the scheduler runs "serially"

#

you don't have to worry about mutex and stuff meowsweats

little raptor
smoky verge
#

ingame

#

after mission start

little raptor
fair drum
#

ughhh... i just started realizing the my VSC formatter for sqf keeps lowercasing random things which screws up my case sensitive things!!!!!

little raptor
#

(if you're not doing that in SP)

smoky verge
#

I tried it in SP first but its not working
oh..

little raptor
#

(getMissionLayerEntities "hangar" select 0)

#

run this alone in debug console

little raptor
#

such as animDone

smoky verge
little raptor
#

I couldn't see anything

little raptor
#

it's missing a }

smoky verge
#

goddamit

#

weird I was expecting arma to report an error like that

little raptor
#

no it doesn't report error for unclosed brackets

smoky verge
#

I guess they didn't expect my levels of noobness
pepehands.gif

polar anchor
#

how do i spawn code inside an event ?

little raptor
polar anchor
#

got it thx

little raptor
# fair drum this pleases me

you should also be careful! you may inadvertently overwrite a variable.
that's where private comes into play (it's not necessary otherwise)

winter rose
#

but still a good practice with no downside

#

I see you ๐Ÿ‘€

polar anchor
#

two more questions:
i'm trying to do a system where if you die, you don't directly die but u get wounded and u can get healed (haven't finished yet), at the current state i would like to know how can i do something like i did below but working? xd. the two variables outside the event are errors, how would i do something like i meant correctly? second question: i'm adding an event handler inside another event handler, is that corrent? if so what can i do if both of them have one parameter with the same name? how can i distinguish them?

sqfwaitUntil { !isNull player };

private _isFirstTime = true;
private _isKillable = true;

player addEventHandler ["HandleDamage", {
    params ["_unit", "_selection", "_damage"];
    if (!_isKillable && _damage > 0.9) then
    {
        _unit setDamage 0.9;
        exitWith {}
    }

    [_unit, _damage] spawn
    {
        params["_unit", "_damage", "_isFirstTime"];
        if (isPlayer _unit && _damage > 0.9) then
        {
            if (_isFirstTime) then 
            {
                _isFirstTime = false;
                _unit setDamage 0.9;

                // First time it would be killed, he gets invulnerability for one second
                _isKillable = false;
                _unit switchAction "agonyStart";
                sleep 1;
                _isKillable = true;

                _unit addEventHandler ["AnimDone", {
                    params ["_unit", "_anim"];
                    if (_anim == "agonyStart") then
                    {
                        _unit switchAction "agonyStart";
                    }
                }];
            }
        }
    };
}];```
#
  • if there is anything else you would suggest me to improve on i would appreciate it
fair drum
#

so say I have a variable peanuts how can I rename that peanuts_1 etc for indexes. if it was a string I would have just done "peanuts_" + str _i to get my "peanuts_index"

polar anchor
#

like bad syntax or stuff like that

robust hollow
fair drum
#

yeah that was my backup plan. didn't know if there was a way with global variables

robust hollow
#

missionNamespace setVariable is global variables (if executing in the missionNamespace)

fair drum
#

will _forEachIndex work inside of an apply?

little raptor
# polar anchor two more questions: i'm trying to do a system where if you die, you don't direct...

the two variables outside the event are errors
ok, so first of all, you're using local variables. local variables are preceded with an underscore _
a local variable is only visible to the current scope and scopes created directly from the current scope (called, if, while, etc.)
an event handler is not a "direct scope" (it is executed somewhere else)so it doesn't see your variable

second of all, you can use the unit's "namespace". check setVariable

i'm adding an event handler inside another event handler, is that corrent?
not really. at least not the way you did it

another issue with your code is that you should return something with your handleDamage EH. it's not overriding the damage right now
in sqf, to return something, you end the code with a statement that returns a value:

call {
  1; //returns 1
};
call {
  alive player; //return a bool
};

note that this is wrong:

call {
  _alive = alive player; //return nothing
};
little raptor
#

@polar anchor another issue with your code is the exitWith
it takes an "IF" on the left

if (cond) exitWith {};
polar anchor
#

๐Ÿ˜ซ๐Ÿ˜ณ

little raptor
#

and you might wanna take a look at lazy eval for conditional statements:

if (a && {b && {c}}) exitWith {};
```it's a bit more advanced
polar anchor
#

2am donโ€™t blame me ๐Ÿ˜†

#

What about those 2 private variables?

#

How can I use them outside the EH?

little raptor
#

I explained them

polar anchor
#

I tried removing the _ but getting the same result

#

So is the _ implicitly setting a variable privateโ€™s

little raptor
#

you shouldn't put private then

polar anchor
#

?

little raptor
polar anchor
#

I obv removed the private keyword too

little raptor
#

a local variable is not necessarily private

little raptor
cosmic lichen
polar anchor
#

Is _ just a convention?

little raptor
fair drum
#

would this get me the intended result of skipping a vehicle spawn if the vehicle that was created last loop is still alive? (loop and other stuff not shown) launcher is basically the silo or capture point
https://sqfbin.com/iyuxuyudawewojiyuhay

little raptor
#

it actually makes the variable local

#

the variable is destroyed when the scope ends

cosmic lichen
#
 if (_type == "attackheli") exitwith {};
            if (_type == "mrap") exitwith {};
            if (_type == "quad") exitwith {};
            if (_type == "tank") exitwith {};
            if (_type == "truck") exitwith {};
            if (_type == "antiair") exitwith {};
            if (_type == "apc") exitwith {};
``` ![notlikemeow](https://cdn.discordapp.com/emojis/700311897937018890.webp?size=128 "notlikemeow")
polar anchor
#

But isnโ€™t it already local to the scope of where u declare it?

fair drum
#

haven't put anything there yet

This is an example of the array being pulled in earlier

L2_arudy_vehicle_positions = [
    ["tank", [5667.15, 6990.76, 0], 234],
    ["apc", [5653.15, 7003.32, 0], 167],
    ["antiair", [5666.75, 7013.35, 0], 199],
    ["truck", [5621.29, 7019.85, 0], 176]
];
polar anchor
#

So why would I use _

#

To specify that it is local?

little raptor
#

oh you were referring in general?

#

no

#

a = 1

#

won't destory

#

it's global

polar anchor
#

At the end of scope?

#

Oh

fair drum
polar anchor
#

So without _ itโ€™s global and with it itโ€™s local, indipendently of where u declare it (scope)?

polar anchor
#

Btw gotta go now thanks for you help, tomorrow Iโ€™ll try to understand better

#

Thanks ๐Ÿ˜‹

little raptor
#

np

cosmic lichen
fair drum
cosmic lichen
#

and call {...exitWith} will not exit your script if that is what you wanted

fair drum
#

I haven't put anything in the exitWiths yet for that section. but in the first section with the positionsarray is what I'm going for in the end

#

ill fill them in real quick

cosmic lichen
#

I still don#t get your ealier question

#

If you wanna check if the vehicle is still alive then just save it in a global var and do alive Myvehicle

fair drum
#

its gonna be potentially an array of 10s of units. let me flesh it out and give you a full view of it

fair drum
#

nvm I figured something out with using set and the array

little raptor
fair drum
fair drum
#

what would be the best way to learn how to make a large 3d plasma shield dome (or even something simple like what a trigger looks like in the editor or ingame with visible triggers turned on)? would it require some sort of 3d model import? maybe I could do it with a particle effect? not sure where to start

#

like the draw trigger areas in preferences ( i think its 3den enhanced tho)

robust hollow
#

idk how editor does it, but there is a 3d sphere virtual object. maybe scale that to the size you need ๐Ÿคท

fair drum
#

i think that has collision though. let me try to fly a plane through it. i need something with no collision

#

it actually doesn't. thats nice

#

could probably add an electric type texture

little raptor
# fair drum ooone day i'll get to learning them lol

They're just like array of [key, value] pairs. Except they provide "constant time lookup" for keys. (unlike arrays, you don't have to go thru the elements one by one to find them; a hash function will calculate what it "maps" to and takes you there, which can be significantly faster if you have lots of elements)
Basically they're similar to this array:

[
[key1, val1],
[key2, val2],
...
]
#

If you have key1, you get val1 without having to loop through the elements, etc.

cyan dust
#

Good day. Is there a way to get all the subfolders of the certain folder inside mission? And get all the filenames inside subfolder

warm hedge
#

I don't think there's a command to get every files in a mission folder

warm hedge
#

One thing you can do is to make a ticket and spam @dedmen (jk) ๐Ÿคž

cyan dust
warm hedge
#

The thing I did to achieve similar is list every files in a file ๐Ÿ™ƒ

cyan dust
karmic silo
#

Im looking to make a tool that measures distance that the bullet has travelled once fired, yet simply dont know how id start, id appreciate any help.

copper raven
#

fired event handler

still forum
warm hedge
#

So slightly different thing is required than addonFiles?

cyan dust
cyan dust
warm hedge
#

Nop, for Ded

still forum
#

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

frosty scarab
#

Anyone know a good way to check if a player is walking up a steep hill (which would force them to walk as apposed to run when holding shift)

frosty scarab
#

i'll have a play around with it

#

Angles > 17 or < -17 seem to force walking

vague geode
#

Can I compile .fsms the same way as .sqfs?

BIS_fnc_function = compileFinal preprocessFileLineNumbers "filepath/file.fsm";

hollow thistle
#

No

#

you exec fsms via execFSM

#

Also, use compileScript instead of compileFinal and preproc.

vague geode
hollow thistle
#

There's no way. If you're using CfgFunctions you can define a function that points to FSM but it's just a wrapper function that does execFSM under the hood.

pulsar bluff
#

no need to use compilescript ...

vague geode
hollow thistle
#

In an addon, yes. I don't see how it's related to "compiling" an fsm into variable.

vague geode
#

Because you can store .sqf-scripts outside of the mission folder and then compile them into a variable thus preventing the script itself from being downloaded...

still forum
still forum
#

you can execFSM on server.

#

But you cannot execFSM on client and get a file that only the server has and transfer it to client

vague geode
still forum
#

yeah

pliant stream
#

they can be in an addon too

still forum
#

atleast I don't know a way not to

vague geode
polar anchor
#

hey, i'm learning how to make GUIs but i am always getting an error "Resource not found" when i try to show it.
This is my Description.ext:

#include "BaseComponents.hpp"
#include "MyComponents.hpp"

this is MyComponents.hpp: https://pastebin.com/g5vVAjRr
and this is BaseComponents.hpp: https://pastebin.com/FD9BUqTv
what's the issue?

copper raven
#

how are you trying to show it?

polar anchor
#

tried with createDialog "Test";

#

and cutRsc["Test", "PLAIN"]

#

none of them worked

copper raven
#

openDialog?

polar anchor
#

create

copper raven
#

well cutRsc won't work because you need to define the resource in RscTitles, but createDialog should work ๐Ÿค”

little raptor
#

it's missing some definitions.

#

not sure if they're mandatory

copper raven
#

with what he has right now it should show up

polar anchor
#

i've included everything in BaseComponents

#

CTRL + P in game gui editor

copper raven
#

run isClass (missionConfigFile >> "Test") in debug

#

what does it return

polar anchor
#

0

#

false

#

i know it doesn't find that class but why

#

i've done everything correctly (?)

#

๐Ÿค”

little raptor
copper raven
#

description.ext.txt perhaps? ๐Ÿคฃ (no idea)

cosmic lichen
#

why not use import ?

polar anchor
#

still not working

#

but thx

polar anchor
copper raven
cosmic lichen
#

import RscPicture;
....

your GUI

#

no need for all that other crap

polar anchor
#

and remove basecomponents.hpp?

cosmic lichen
#

Works for me ยฏ_(ใƒ„)_/ยฏ

polar anchor
#

wtf

little raptor
polar anchor
cosmic lichen
#
import RscPicture;
import RscCombo;
import RscText;
import RscButton;

class Test
{
    idd = 5000;
    class ControlsBackground
    {
        class PictureBackground: RscPicture
        {
            idc = 1200;
            text = "#(argb,8,8,3)color(0,0,0,0.5)";
            x = 0.391719 * safezoneW + safezoneX;
            y = 0.368 * safezoneH + safezoneY;
            w = 0.221719 * safezoneW;
            h = 0.275 * safezoneH;
        };
    };
    class Controls
    {
        class ComboWeapons: RscCombo
        {
            idc = 2100;
            x = 0.490719 * safezoneW + safezoneX;
            y = 0.4285 * safezoneH + safezoneY;
            w = 0.0876563 * safezoneW;
            h = 0.022 * safezoneH;
        };
        class TextWeapon: RscText
        {
            idc = 1000;
            text = "Weapon:"; //--- ToDo: Localize;
            x = 0.438125 * safezoneW + safezoneX;
            y = 0.423 * safezoneH + safezoneY;
            w = 0.0360937 * safezoneW;
            h = 0.033 * safezoneH;
        };
        class ButtonGive: RscButton
        {
            idc = 1600;
            text = "Give"; //--- ToDo: Localize;
            x = 0.475766 * safezoneW + safezoneX;
            y = 0.58624 * safezoneH + safezoneY;
            w = 0.0515625 * safezoneW;
            h = 0.022 * safezoneH;
        };
    };
};```
polar anchor
#

it has no sense

#

still not working

little raptor
#

or just restart?

polar anchor
#

restart

little raptor
#

you must close it

polar anchor
#

ooooooooooooooof

little raptor
#

go back to eden and come back

cosmic lichen
#

just hit save

#

in eden editor

#

then do findDisplay 313 createDisplay "test"

#

no need to ever preview the mission

polar anchor
#

works

cosmic lichen
#

Every time you do a change, hit save

polar anchor
#

ok thank you guys

#

๐Ÿ˜‰

cosmic lichen
#

yw

polar anchor
#

one more question: why 313 as idd?

cosmic lichen
#

313 is the Eden Editor display IDD

little raptor
#

eden display

#

common displays:
313 eden
46 mission
12 map (and displayCtrl 51 is the map ctrl)
49 pause display

polar anchor
#

ok got it

#

๐Ÿ‘

little raptor
#

right! ๐Ÿ˜„

cosmic lichen
#

Nice party knowledge there

exotic tinsel
#

is there a way to get the config ref from a class name?
I know i can do this on an object "configOf player;" but i have class names in an array id like to look the display name for but they are not all in cfgVehicles.

#

if your going to go that way I think this would be better.

private _config = [
"CfgVehicles",
"CfgWeapons",
"CfgMagazines",
"CfgAmmo",
"CfgGlasses"
] select {isClass (configFile >> _x >> _x_object_type)} select 0;
private _x_object_name = getText (configFile >> _config >> _x_object_type >> "displayName");
exotic tinsel
#

ok so how does yours solve my problem? yours returned a number.

little raptor
#

you were supposed to adapt it

winter rose
exotic tinsel
winter rose
exotic tinsel
#

thats what i did. you post something partial, someone adapts it and gets a solution. so ive done everything you wanted me to do.

#

ok yeah im walking a way now.

tough abyss
#

Hello. I want to make interactive pop-up dialog sequences, and add some dialog critical choices that change side relations in-game. But I have zero experience with scripting.

  • Can someone point me in the right direction and/or give me tips to get started?
  • Should I make something simpler first?
  • (Willing to spend hours tweaking code)
exotic tinsel
#

@tough abyss google arma create ui tutorial. You will find all links and vids that will help you get started.

#

@still forum @little raptor
It may not be the best but I went with this, hope its useful to someone else.

private _x_object_type = _x select 0;
private _config = ("true" configClasses (configFile)) select {isClass (_x >> _x_object_type)} select 0;
if !(isNil "_config") then
{
    private _x_object_name = getText (_config >> _x_object_type >> "displayName");
    _ctrl_object_id = _ctrl lbAdd _x_object_name;
    _ctrl lbSetData [_ctrl_object_id, _x_object_type];
};
still forum
#

thats pretty terrible actually

#

configFile >> configname _x
thats nonsense.
_x == configFile >> configname _x
already. You're walking backwards just to be able to walk forwards again

#

Also your ("true" configClasses (configFile)) is nonsense for classnames.

classnames can only be in CfgVehicles, CfgWeapons, CfgMagazines, CfgAmmo, CfgGlasses or UI classes which your code wouldn't find

long hatch
#

hi, how can i manipulate a path using variables example:

if ((uniform player) in ["uniform_1", "uniform_2", "uniform_3"])
 then {_myVar = "blk"} else {_myVar = "wht"};

player setObjectTextureGlobal [3, "path\to\imgae\custom_"_myVar"\file_"_myVar".paa"];

This for example won't work and i wasn't find a clue to solve this by myself. Hope some one can give me a tip.

copper raven
still forum
#

no you don't

copper raven
#

yeah

still forum
#

and with findif it would be even better, like Leopard posted

#

not sure why some people insist on making backwards steps blobdoggoshruggoogly

copper raven
#

can also use hashmap to cache

#

as he wants displaynames

long hatch
#

Yes i see was free typing ๐Ÿ˜„ ^^

exotic tinsel
#

yes so origannly i wanted a solution just for display names. Then i thought id make something that would work allow you to look up any thing by class name or what ever if i want it for terrain objects so i wrote what i posted.
This is what im using for my UI though. hope it makes you all happy.

private _config = [
    "CfgVehicles",
    "CfgWeapons",
    "CfgMagazines",
    "CfgAmmo",
    "CfgGlasses"
] select {isClass (configFile >> _x >> _x_object_type)} select 0;
if !(isNil "_config") then
{
    private _x_object_name = getText (configFile >> _config >> _x_object_type >> "displayName");
    _ctrl_object_id = _ctrl lbAdd _x_object_name;
    _ctrl lbSetData [_ctrl_object_id, _x_object_type];
};
still forum
#

also if x then {_myVar = "blk"} else {_myVar = "wht"};
can be written as
_myVar = if x then {"blk"} else {"wht"};
or
_myVar = ["wht","blk"] select x

copper raven
#

select is the most optimal here

still forum
#

findIf might be slightly better

#

yes, due to all the config lookups findIf will probably be better

copper raven
#

oh yeah, i meant what you wrote

still forum
#

ah :u

tender fossil
#

Can publicVariable event handlers contain e.g. waitUntil?

hollow thistle
#

no, it's unscheduled.

past wagon
#

if I am making an array, can I put [] as one of the items in the array to make it empty?

#

for example, I want it to randomly select a weapon, but I want there to be a chance that it will not select any weapon

willow hound
#

Weapons as in weapon class names?

past wagon
#

yes

#

this is my array

little raptor
#

""

past wagon
#

ok

#

[""] thats actually what I did at first but i second guessed myself

little raptor
past wagon
#

if it is a weapon with a magazine, would it be ["",""]

little raptor
#

this will have a 1/nth chance of being selected

past wagon
#

yea

#

my array looks like this:

_weaponArray = [["weapon1", "mag1"], ["weapon2", "mag2"], ["", ""]];
#

would that work the way I want it to?

weary hare
#

Is it possible to change a config property for ammo through a script? Trying to make flare rockets with changeable fuse distances and want to know if it's worth attempting.

little raptor
copper raven
little raptor
#

or that

#

you'll also have to provide the weights

past wagon
#

its alright, i dont need a specific chance

little raptor
willow hound
past wagon
#

yeah but I can put it in multiple times

#

to adjust

little raptor
#

and saves you typing

past wagon
#

but there are only like 7 weapons lol

#

its ok its ok

#

as long as it works

weary hare
willow hound
#

Best ask that in #arma3_config, they know how to perform that kind of sorcery.

past wagon
#

what would 2 + (round random 2) be?

little raptor
past wagon
#

okay

#

im looking at the wiki rn so i can understand what it does

still forum
past wagon
#

would this code repeat 5 times?

r = 0;
while {r < 5} do {
  //code
  r = r + 1;
};
valid abyss
#

yes

long hatch
#

https://pastebin.com/3mGXkyqu ok the code is working so far, when used in the Debug Console, but as function it won't work, the path that i want to generate using the suggested format Command returns in the function any instead of blk or wht.

still forum
#

aby means undefined variable

#
private _ranksColorSwitch = "blk";
 
_ranksColorSwitch =

thats nonsense, why set it twice right next to eachother.

Just
private _ranksColorSwitch = if

valid abyss
#

Is there any way to make music play in a 3D environment ?

still forum
#

"suggested format Command returns in the function any instead of blk or wht." which one exactly?

little raptor
#

otherwise playSound3D

valid abyss
still forum
#

Do you have it in CfgSounds?

valid abyss
#

It's from a mod called Rome Music

still forum
still forum
valid abyss
#

How would i do that?

little raptor
willow hound
#

@wicked roost !wiki Description.ext#CfgSounds when?

little raptor
#

@wicked roost ๐Ÿ˜›

long hatch
still forum
#

no....

#

yes?

#

I don't understand that question. doesn't make sense to me

#

add diag_log and check

#

sounds like your _ranksColorSwitch is nil, did you really send the full script or did you copy-paste snippets together?

long hatch
#

It's the full script

#

No Snippets

little raptor
still forum
#

Ah derp

#

Your variable is undefined

#

You're not passing it to the script inside the action

#

And as far as I can see ace_interact_menu_fnc_createAction doesn't give you the ability to specify arguments

tender fossil
#
    _handleSidePlayer = [_requestID, _side] spawn WFBE_CO_FNC_MonitorHandleSkills;

    if (_side == west) then {
        _opposingSide = east;
    } else {
        _opposingSide = west;
    };

    _handleOpposingSidePlayer = [_requestID, _side] spawn WFBE_CO_FNC_MonitorHandleSkills;

    publicVariable "WFBE_SRV_VAR_RequestPlayerSkill";

    ["INFORMATION", format ["RequestSkill.sqf: Waiting for the team score calculation threads to finish... _requestID: %1", _requestID]] Call WFBE_CO_FNC_LogContent;

    waitUntil {(scriptDone _handleSidePlayer) && (scriptDone _handleOpposingSidePlayer)};

(NOTE! Arma 2) Any idea why the last line throws a "Generic error in expression"?

still forum
#

Possible fixes are , make it a global variable, or setVariable it onto the player, or compile your action statement from string, or check the players uniform everytime inside the action statement

#

if you don't expect the player to change uniform (which you already aren't checking), I'd say just make it global variable

past wagon
#

can I use addItemCargoGlobal to add both magazines and vests to a container?

little raptor
#

wat?

#

just call them

past wagon
#

what is a vest?

#

what cfg group?

still forum
#

CfgWeapons

#

but items are too

past wagon
#

ok

still forum
#

magazines aren't

past wagon
#

so addItemCargoGlobal works for a vest, right?

still forum
#

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

#

try

past wagon
#

i dont have arma open rn

still forum
#

backpacks and weapons are also CfgWeapons but they also have seperate commands

still forum
past wagon
#

ok so what is the command for a vest?

digital hollow
#

addItemToVest

little raptor
#

(global if MP)

past wagon
#

ok

#

but does that also work for magazines?

little raptor
#

probably

past wagon
#

bro why does no one know

little raptor
#

because we haven't tried

past wagon
#

ooooooooooooooooooooooooooooo

#

ok i will try

#

time to open arma 3

#

bruh

little raptor
#

I mean yes

past wagon
#

is it:
Yes, No, or I don't know?

little raptor
sharp grotto
#

Half the fun is trying to solve problems yourself without any help ๐Ÿ˜› (imho)

still forum
#

try and write on wiki ๐Ÿ˜„

little raptor
#
  • cfgMags
past wagon
#

this is basically my question:

#

Which of the following works on both Vests and Magazines?:
addItemCargoGlobal addWeaponCargoGlobal addMagazineCargoGlobal

#

im guessing its not the third

little raptor
#

as I told you

past wagon
#

ok

#

oh yeah

#

im dumb

#

forgot you told me that LOL

little raptor
#

it also works on weapons

past wagon
#

ok

#

so why do the other two even exist?

little raptor
past wagon
#

ohh

#

yeah that makes sense

little raptor
past wagon
#

ok

#

perfect

past wagon
#

addItemCargoGlobal should still work in singleplayer, right?

little raptor
#

ye

past wagon
#

okie

#
_weaponArrayOne = [
    ["srifle_EBR_F", "20Rnd_762x51_Mag"], 
    ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2, 
    ["arifle_MXM_F", "30Rnd_65x39_caseless_mag"], 
    ["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2, 
    ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], 
    ["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2, 
    ["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2, 
    ["", ""], 3];
r = 0;
while {r < 4} do {
    _weaponAndMag = selectRandomWeighted _weaponArrayOne;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addWeaponCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
    r = r + 1;
};
_weaponArrayTwo = [
    ["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2, 
    ["LMG_03_F", "200Rnd_556x45_Box_F"], 2, 
    ["launch_RPG7_F", "RPG7_F"], 
    ["V_HarnessOGL_brn", ""], 
    ["",""], 4];
r = 0;
while {r < 2} do {
    _weaponAndMag = selectRandomWeighted _weaponArrayTwo;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addItemCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
    r = r + 1;
};
_itemArray = [
    "HandGrenade", 
    "optic_Arco_blk_F", 2
    "optic_Hamr", 2];
r = 0;
while {r < 2} do {
    _item = selectRandomWeighted _itemArray;
    if (_item == "HandGrenade") then {
        AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
    }
    else {
        AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
    };
    r = r + 1;
};
#

any idea why this isnt working in the init.sqf file?

#

nothing happens. i dont even get an error message

#

and AirdropCrate is the name of the container that I want this stuff added to

still forum
#

what

#

why not just use a for loop

#

what is this mess :u

#

and why global variables for your loop iteration, and why global variables without tag
global variables should always have a tag, and use local variables if you don't need global, like here.

#

What are these empty weapon classnames?
Why are there duplicates in there?

Do you know that selectRandomWeighted exists?

#

you are missing private's on your variables

#

Why are you using addWeaponCargo for the weapons at the top, but then use addItemCargo for the weapons in the middle?

#

select 0;
select 1;

just use _weaponAndMag params ["_weapon", "_mag"]

past wagon
#

uhhhhh

#

dont worry about it

#

the reason im using addItemCargoGlobal for the second weapon array is because there is a vest included

#

it doesnt matter tho

#

@still forum what is the reason that im not getting anything added to the crate? is it because of the variables?

still forum
#

I just see a huge mess ยฏ_(ใƒ„)_/ยฏ

past wagon
#

but i dont know why its not working

#

is there anything about it that would make it not work?

still forum
#

_item == "HandGrenade" that will never work and only trigger error, an array can never equal a string

past wagon
#

but _item = selectRandom _itemArray

still forum
#

no but

little raptor
past wagon
#

oh

past wagon
little raptor
#

yes

#

it has an error

#

,

still forum
#

all of them do

past wagon
#

got it

little raptor
#

and why are there duplicates?

#

just use weighted

still forum
#

I already tried asking that and didn't get an answer

#

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

past wagon
#

i dont know how to use weighted

winter rose
#

then we can explain?

past wagon
#

sure

still forum
#

Learning new things trains the brain, can recommend

past wagon
#

yeah thats what im looking at rn

#

is it selectRandomWeighted _array [number, weight]?

winter rose
past wagon
#

so wait

#

do I have to change the array itself?

little raptor
#

yes

past wagon
#

ok

little raptor
#

just put the weight next to each element

still forum
#
_itemArray = [
    "HandGrenade", 
    "optic_Arco_blk_F", 
    "optic_Arco_blk_F", 
    "optic_Hamr", 
    "optic_Hamr"
];

selectRandom _itemArray

->

_itemArray = [
    "HandGrenade", 1,
    "optic_Arco_blk_F", 2, // 2x chance
    "optic_Hamr", 2
];

selectRandomWeighted _itemArray
#

The commata have been added

dreamy kestrel
#

Q: re: HASHMAP is there a way to get the values in the same way we get the keys?
Or must we do this: _hashmap apply { _x#1; }?

still forum
#

apply doesn't support hashmap as wiki says

dreamy kestrel
#

cool, good to know, ty

dreamy kestrel
#

or rather have to take a long way round it then, introduce a function that does it

past wagon
#

does it look better now?

#
_weaponArrayOne = [
    ["srifle_EBR_F", "20Rnd_762x51_Mag"], 1, 
    ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2, 
    ["arifle_MXM_F", "30Rnd_65x39_caseless_mag"], 1, 
    ["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2, 
    ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], 1, 
    ["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2, 
    ["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2, 
    ["", ""], 3];
r = 0;
while {r < 4} do {
    _weaponAndMag = selectRandomWeighted _weaponArrayOne;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addWeaponCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
    r = r + 1;
};
_weaponArrayTwo = [
    ["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2, 
    ["LMG_03_F", "200Rnd_556x45_Box_F"], 2, 
    ["launch_RPG7_F", "RPG7_F"], 1, 
    ["V_HarnessOGL_brn", ""], 1, 
    ["",""], 4];
r = 0;
while {r < 2} do {
    _weaponAndMag = selectRandomWeighted _weaponArrayTwo;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addItemCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
    r = r + 1;
};
_itemArray = [
    "HandGrenade", 1, 
    "optic_Arco_blk_F", 2
    "optic_Hamr", 2];
r = 0;
while {r < 2} do {
    _item = selectRandomWeighted _itemArray;
    if (_item == "HandGrenade") then {
        AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
    }
    else {
        AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
    };
    r = r + 1;
};
little raptor
#

missing weights

past wagon
#

how

#

didnt I just add them?

#

isnt that the number next to the string?

still forum
winter rose
#

"1"

past wagon
#

oh

#

yeah

dreamy kestrel
#

HASHMAP get values function, i.e.

private _getHashMapValues = {
  private _map = _this;
  keys _map apply { _map get _x; };
};
little raptor
#

forEach is faster

dreamy kestrel
#

how so? illustrate...

little raptor
#
_vals = [];
{
  _vals pushBack _y;
} forEach _map;
still forum
#

you are taking the keys and copying them, then iterate through all of them and do a hashmap lookup for EVERY key

#

forEach just iterates once, no lookups, no keys fetching, no keys copying

dreamy kestrel
#

oh okay I see

#

shame that, or would apply do the same? i.e. _map apply { ... }

still forum
dreamy kestrel
#

LOL

#

I have to ask, you know...

still forum
#

No you don't

dreamy kestrel
#

yes, yes I do

still forum
#

You don't have to ask a question that you already received the answer to

dreamy kestrel
#

I am trying to shave a pushBack operator out of it... ๐Ÿ˜›

little raptor
dreamy kestrel
#

assuming apply de-cons to _x, _y, etc

little raptor
#

speaking about arrays here

dreamy kestrel
#

forEach works for HASMAP? that was the question.

little raptor
#

yes

willow hound
#

!wiki HashMap

winter rose
willow hound
#

I do ๐Ÿ˜ฆ

still forum
copper raven
#

foreach with hashmaps doesn't set the _forEachIndex, but i guess it's intended right? doesn't make a lot of sense to provide it

still forum
#

it does

copper raven
#

๐Ÿค”

little raptor
still forum
#

see!

#

๐Ÿ™ƒ

#

crap

copper raven
#

๐Ÿค”

little raptor
#

the order never stays the same

dreamy kestrel
#

it might be intuitive, who knows.

still forum
#

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

#

people expect it because every other forEach does it

dreamy kestrel
#

but then again SQF expects a semi-colon after curly brace close, so...

still forum
#

and it doesn't cost me anything to give you a counter

little raptor
dreamy kestrel
still forum
#

I also created a system that lets me add a _forEachIndex to every loop

#

together with the continue/break

#

just been too lazy to make a command for it

dreamy kestrel
#

verified apply does not support hashmap, assuming select neither

still forum
#

@little raptor I can understand the thing you got muted for now

still forum
#

At some point you just gotta get out the block button, its healthier

willow hound
still forum
#

I also don't understand why someone needs to verify something thats written on wiki and that the guy who friggin made hashmaps already literally told you directly just minutes ago.

#

But some people...

winter rose
dreamy kestrel
#

I'm sure it is accurate; pardon me if I don't take your word for it @still forum , or anyone's.

past wagon
#

Sorry guys, i had to go for a little. so this is what i have. does the code look like it should work? or are there still problems with the variables? this is being tested in singleplayer but its intended to be multiplayer. its in the init.sqf file

_weaponArrayOne = [
    ["srifle_EBR_F", "20Rnd_762x51_Mag"], 1, 
    ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2, 
    ["arifle_MXM_F", "30Rnd_65x39_caseless_mag"], 1, 
    ["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2, 
    ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], 1, 
    ["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2, 
    ["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2, 
    ["", ""], 3];
r = 0;
for "_i" from 1 to 4 do {
    _weaponAndMag = selectRandomWeighted _weaponArrayOne;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addWeaponCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
};
_weaponArrayTwo = [
    ["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2, 
    ["LMG_03_F", "200Rnd_556x45_Box_F"], 2, 
    ["launch_RPG7_F", "RPG7_F"], 1, 
    ["V_HarnessOGL_brn", ""], 1, 
    ["",""], 4];
r = 0;
for "_i" from 1 to 2 do {
    _weaponAndMag = selectRandomWeighted _weaponArrayTwo;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addItemCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
};
_itemArray = [
    "HandGrenade", 1, 
    "optic_Arco_blk_F", 2
    "optic_Hamr", 2];
r = 0;
for "_i" from 1 to 2 do {
    _item = selectRandomWeighted _itemArray;
    if (_item == "HandGrenade") then {
        AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
    }
    else {
        AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
    };
};
winter rose
#

don't r

#
for "_i" from 0 to 3 do {
  // ...
};```
#

@past wagon

past wagon
#

is 3 the number of times the code repeats?

winter rose
#

no, it's "from 0 to 3" so 4 times
but you can also do "from 1 to 3"

past wagon
#

could I do from 69 to 420

winter rose
#

yup

past wagon
#

cool

winter rose
#

would be 420 - 69 + 1

past wagon
#

yeah

#

ok

winter rose
#

so #352 he he

past wagon
#

changed it

#

so how does it look now?

#

i will test it

little raptor
past wagon
#

....

#

uh

#

you mean the for "_i" from 1 to 2 do {?

#

that is supposed to repeat twice

little raptor
#

yes

past wagon
#

ok

#

thanks

#

i also have one that repeats 4 times

#

you know whats even better than using for or a while loop with a variable?

#

just copying and pasting the code as many times as you want it

#

works every time ๐Ÿ‘

little raptor
winter rose
#

or, a bit slower but maybe a bit simpler to read:

{ } forEach [1, 2, 3, 4];
past wagon
#

lol

#

ok

little raptor
#

resize 4

past wagon
#

there is still nothing in the crate

#

and im not getting any error message or anything

#

any ideas why its not working?

little raptor
#

what is airdropcrate?

past wagon
#

im executing in init.sqf

#

@little raptor

past wagon
still forum
#

add logging and see what happens where

#

diag_log or systemChat

past wagon
#

ok

#

where should I put the systemchat?

#

@still forum

still forum
#

wherever you want to log things

#

so.. everywhere

past wagon
#

im confused

#

what is this for?

still forum
#

logging

#

If you see your log message, you know that line of code executed

#

log some variables too, and you know that line of code executed and what the variables were

past wagon
#
_weaponArrayOne = [
    ["srifle_EBR_F", "20Rnd_762x51_Mag"], 1, 
    ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], 2, 
    ["arifle_MXM_F", "30Rnd_65x39_caseless_mag"], 1, 
    ["srifle_DMR_03_multicam_F", "20Rnd_762x51_Mag"], 2, 
    ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], 1, 
    ["arifle_ARX_hex_F", "30Rnd_65x39_caseless_green"], 2, 
    ["SMG_03_TR_khaki", "50Rnd_570x28_SMG_03"], 2, 
    ["", ""], 3];
for "_i" from 1 to 4 do {
    _weaponAndMag = selectRandomWeighted _weaponArrayOne;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addWeaponCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 3 + (round random 4)];
};
systemChat "Test";
_weaponArrayTwo = [
    ["LMG_Mk200_F", "200Rnd_65x39_cased_Box"], 2, 
    ["LMG_03_F", "200Rnd_556x45_Box_F"], 2, 
    ["launch_RPG7_F", "RPG7_F"], 1, 
    ["V_HarnessOGL_brn", ""], 1, 
    ["",""], 4];
for "_i" from 1 to 2 do {
    _weaponAndMag = selectRandomWeighted _weaponArrayTwo;
    _weapon = _weaponAndMag select 0;
    _mag = _weaponAndMag select 1;
    AirdropCrate addItemCargoGlobal [_weapon, 1];
    AirdropCrate addMagazineCargoGlobal [_mag, 1 + (round random 1)];
};
systemChat "Test";
_itemArray = [
    "HandGrenade", 1, 
    "optic_Arco_blk_F", 2
    "optic_Hamr", 2];
for "_i" from 1 to 2 do {
    _item = selectRandomWeighted _itemArray;
    if (_item == "HandGrenade") then {
        AirdropCrate addItemCargoGlobal [_item, 1 + (round random 3)];
    }
    else {
        AirdropCrate addItemCargoGlobal [_item, 3 + (round random 2)];
    };
};
systemChat "Test";
still forum
#

So instead of asking "where in these dozens of lines of code could something be broken" you know
"Ah, this works, but this doesn't, so the problem is somewhere inbetween"

#

when I say everything I literally mean everything

#

put a log message everywhere where you want to know whether something happened

past wagon
#

ok

#

@still forum I put in 3 test messages in system chat and I am not getting any messages in system chat

still forum
#

there is no chat in singleplayer, do you have a chat at all?

past wagon
#

no

#

let me test in multiplayer

still forum
#

you can either use local MP preview, or use diag_log.
But diag_log is annoying if you don't have a second monitor and some tool that live-updates your log

past wagon
#

still not getting any messages in system chat

#

even in multiplayer

cosmic lichen
#

give use diag_systemChat please which eats anything ๐Ÿ˜‰

still forum
#

some people use hint for that, but hint only shows a single message

past wagon
#

and i really have no clue what anything youre talking about is

still forum
#

did you check your RPT?

#

did you test your script in debug console?

past wagon
#

no

still forum
#

if you have a syntax error, it won't compile, and nothing will run

past wagon
#

but im not getting any error messages

#

in game

still forum
#

Dunno if compile errors are displayed ingame

past wagon
#

ive always gotten error messages when there is an error in my script

#

what is compile?

still forum
#

in general ingame error messages are basically always sub-par.
Should always check RPT for errors

#

scripts get compiled

past wagon
#

what is RPT?

still forum
#

Arma has a wiki

#

its almost 1 AM I can't explain you the basics of scripting.
See Arma wiki for diag_log, RPT, compile

past wagon
#

ok

polar anchor
#

are mission event handlers not working on multiplayer and vice versa?

cosmic lichen
#

It contains all important links

#

They are working in mp

polar anchor
#

ok ty

analog walrus
#

Quick question, in order to actualise variables/flags/etc. for a new player joining in an MP scenario, is there any other way to do it besides doing getVariable a whole bunch of times?

golden storm
#

Hello everyone, just a quick question, i'm trying to call a code from an SQF in my mission, it is aimed at setting the same animation for certain units, at the current time it is not working but i don't know why:

animation.sqf:

_unit = _this select 0;

[] spawn {
  waitUntil {time > 0};
  while {true} do {
    _unit switchMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    sleep 16;
  };
}; 

On unit's init:

test1 = [this] execVM "scripts\animation.sqf";

But it says: _unit is not defined

analog walrus
#
_this select X

is only used when dealing with params of a function. If that's all the code you have in animation.sqf, there's no need to declare _unit. You can replace _unit with _this and it should work.

golden storm
#

oh, ok thanks, but ai'nt "switchMove" a function?

fair drum
#

you can just send it right into the sleep scope is what he means

fair drum
#

so it will auto pull from the server when a new player joins

#

or did i just misread your question

analog walrus
#

_this select X is used after calling the function, kinda. To give an example, addAction has a number of params for the script part:

unit addAction ["Test", {
  params ["_target", "_caller", "_actionId", "_arguments"];
}];

If want to declare a variable as _target or _caller you do

unit addAction ["Test", {
  variable1 = _this select 0;
  variable2 = _this select 1;

so now variable1 is _target and variable2 is _caller. In this case, _this refers to the "params" array, "_this select 0" simply means you're choosing the first item of the array.

#

It's a bit difficult to explain in words exactly, but some of the functions will have a "params" array that you can then select from, it's best to check the wiki

golden storm
#

Oh ok, so for it to work it needs multiple parameters