#arma3_scripting

1 messages · Page 674 of 1

little raptor
#

yes

#

you shouldn't put the filename there

heady quiver
#

oh.

little raptor
#
class CfgFunctions
{
  class bsTag {
        class buyShop {
            file = "functions";
            class vehicleIsBuyable {};
      };
  };
};
#

looks for functions\fn_vehicleIsBuyable.sqf

heady quiver
#

you mean functions/bsTag_vehicleIsBuyable.sqf ?

#

whats bsTag for ?

little raptor
#

bsTag_fnc_vehicleIsBuyable

heady quiver
#

Aah

grave thistle
# little raptor you shouldn't put the filename there

I'm pretty sure you can also do that if you only "add one function at the time". I saw sth like that in a description.ext anyway, and the function worked just fine. But yeah, I think what Leo suggested is definitely easier & clearer

heady quiver
#

And the code can just be in that file without wrapping it ye ?

little raptor
#

not the category

heady quiver
#

weird, it says: script functions not found meowsweats

little raptor
#

it shouldn't say that

#

is that what you put in description.ext

heady quiver
#

description.ext

    class CfgFunctions {
        class bsTag {
              class buyShop {
                  file = "functions";
                  class vehicleIsBuyable {};
            };
        };
    };
grave thistle
#

you have "functions" folder in the mission folder?

heady quiver
#

OHH.

#

wait i know why

little raptor
heady quiver
#

Maybeeeeeeeeeeee

#

hahah

#

woopsie

#

brb.

#

ty for help

fair drum
#

No that's sarcasm lol, keep trying.

signal bolt
#

A while back ago i was searching a script to make the scope more "Realistic" on RHS scopes but now i wanna put it back to normal and i have no idea how?
and its getting annoying. Some scopes doesnt work at all anymore. It more like zoom out, most SU230 scopes i think was is called are fucked

heady quiver
#

@little raptor one more thing, _price is not reachable so i need t opass a variable to that object right? like this:

params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction['Unlock', {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    if([player] call HALs_money_fnc_getFunds >= _price) then {
        [player, -_price] call HALs_money_fnc_addFunds;
        _target setVehicleLock "UNLOCKED";
        _target removeAction 0;
         { [west, 'HQ'] sideChat format['%1 just purchased a car for €%2', name player, _price]; } remoteExec['call'];
    }
}];
#

Well, just tested it and seems to be working meowcamera

#

or not notlikemeow

#

{ [west, 'HQ'] sideChat format['%1 just purchased a car for € %2', name player, _price]; } remoteExec['call']; everything works expect the fact that it outputs: BlackShadow just purchased a car for €any 🤔

winter rose
#

yeah, because… suspense

#

_price does not exist there

heady quiver
#

so i need to pass it on again?

winter rose
#

pass it on?

heady quiver
#

so { [west, 'HQ'] sideChat format['%1 just purchased a car for €%2', name player, _price]; } remoteExec['call']; this can reach it? or need to make it global?

#

_price to price

winter rose
#

urgh, no

#

not global

#
[[west, "HQ"], format ["%1 paid %2€", name player, _price]] remoteExec ["sideChat"];
#

what you are saying here is "create the string locally, and send it to be sideChatted there"

heady quiver
#

aah

#

Yea that entire remoteExec format is so weird to me.

#

Dunno why

winter rose
#

[leftArgumentIfAny, rightArgumentIfAny] remoteExec ["command"]

it's only that really 🙂

heady quiver
#

It looks so difficult x)

winter rose
#

how so? 😄

#

if you want to hint something where player_1 is local, do```sqf
["Hello"] remoteExec ["hint", player_1];

#
[thatGuy, 1] remoteExec ["setDamage", thatGuy];
```(ok here it does not make sense since it is a global command, but you get the idea)
heady quiver
#

thatGuy twice ?

winter rose
#

the second thatGuy means "exec this on the machine where thatGuy is local"

heady quiver
#

aah oke

winter rose
#

it can be the server if a unit is playable but not played, or on the player's machine

heady quiver
#

ty

viral wasp
#

it gifs error plz help

#

File C:\Users\dylan\Documents\Arma 3 - Othet Profiles\falcon\mpmissions\warlort%20v8.takistan\description.ext, line0: '.Class': 'C' encounterd instead op '='

warm hedge
#

Did you followed some tutorials?

oblique arrow
#

Hm peeps what'd be the right way to add an ace self interaction to ever player inside a trigger area?

little raptor
#

also is it a "dynamic" trigger?

#

as in can people enter later on?

viral wasp
oblique arrow
#

and then the base is just contained in a trigger

#

but if you have a better idea I'm open to suggestions 👀

little raptor
#

🤔

#

why not some local triggers

#

that run for each client

#

when they get in they get the action

#

when they get out it's removed

dusty whale
#

cameraEffect

#

or what it was

warm hedge
# viral wasp yes

Well, you better to read the tutorial again... this time, carefully

oblique arrow
robust tiger
dusty whale
#

i had to override and re-write the entire Arma 3 movement system

little raptor
#
_trigger = createTrigger ["EmptyDetector", _pos, true];
_trigger setTriggerActivation ["ANYPLAYER", "PRESENT", true];
_trigger setTriggerStatements ["this", "thisList call some_fnc_addAceAction", "thisList call some_fnc_removeAceAction"]
oblique arrow
#

Oh wait I could props also just throw the ace interaction code into the triggers activation/deactivation fiels, no?

little raptor
little raptor
warm hedge
little raptor
#

if player A gets in, trigger won't activate for player B

viral wasp
#

tanks

dusty whale
#

is there an eventhandler i can use to hook into the player tabbing in/out of arma

warm hedge
#

Alt+Tab you meant?

cosmic lichen
#

isGamePaused

warm hedge
#

If so, isGameFocused is the getter command. No EH, tho

oblique arrow
oblique arrow
little raptor
#

which is why I suggested local triggers

oblique arrow
#

I wish stuff was just easy ablobderpy

little raptor
#

just use a loop! 😄

oblique arrow
#

Eh I'll throw it on the to-do list and pick it up again at some point I guess, not feeling like spending my evening on it now

little raptor
#
while {true} do {
  waitUntil {
    sleep 1;
    player inArea _trigger;
  };
  call some_fnc_addAction;
  waitUntil {
    sleep 1;
    !(player inArea _trigger);
  };
  call some_fnc_removeAction;

};
#

_trigger can just be an area, not necessarily a trigger

#

(^ goes in initPlayerLocal.sqf)

oblique arrow
#

How would I define _trigger, public variable it or?

little raptor
oblique arrow
#

Ye I know

little raptor
#

you can just use some trigger you defined in the mission

#

_trigger = my_mission_trigger

oblique arrow
#

ah 👍

little raptor
#

(and put it outside the loop)

oblique arrow
#

Ye ye

viral wasp
#

this better

warm hedge
#

Read what I wrote again, please

viral wasp
#

yes I dit but its stil not wurking

warm hedge
#

CAREFULLY this time. No workaround, no ignore something. Read what I wrote, follow what I wrote, carefully

viral wasp
#

oke

#

[]={}; like tihs or [] = {}; like tihs wits space or not

cosmic lichen
#
requirments[] = {};
little raptor
dusty whale
#

if they have pause on lose focus

warm hedge
#

Yes you can use. Scripts will run even if you don't focus on it

dusty whale
#

nice

heady quiver
#

@little raptor remember my code with buyingVehicle, my mate bought a vehicle and it unlocked but he cant get out x)

#

You know why by any chance?

little raptor
#

or maybe for gas meowsweats

heady quiver
#

x)

heady quiver
#

Thats what i got right

little raptor
torpid quartz
#

Is there a way to emulate the same black bar effect of BIS_fnc_cinemaBorder without using it?

I want the players to still be able to run around when the effect plays and not stop them in their tracks.

little raptor
heady quiver
#

but its one the car right

little raptor
#

also I have no idea what you just said meowsweats

final storm
heady quiver
#

Sorry x), I mean the action is on the car right.

little raptor
#

it is

#

but that's not the issue

heady quiver
#

_caller removeAction _actionId; changed it do this now.

little raptor
#

second of all, setVehicleLock requires the arg to be local

little raptor
#

change player -> _caller

#

not _target -> caller

heady quiver
#

oh

#

oke did that 🤔

little raptor
heady quiver
#

_target setVehicleLock "UNLOCKED";

#

still same

winter rose
#

@heady quiver locaaal, so remoteExec!!

heady quiver
#

but _target is localvar right x)

winter rose
#

of course, if you don't change the code it won't change the effect 😄

heady quiver
#

i know i was just looking

winter rose
#

NOOO

heady quiver
little raptor
heady quiver
#

i dont know

#

x)

little raptor
#

just remoteExec setVehicleLock where _Target is local

#

is that clear now?

winter rose
#

Apply what I told you earlier ;-)

heady quiver
#

IM TRYING

#

LOL

#

my brain very small peanut

little raptor
#

just read the wiki meowsweats

#

for remoteExec

heady quiver
#

[_target, _actionId] call ['removeAction', _target];

little raptor
#

also Lou told you some comments ago

heady quiver
#

sigh.

little raptor
#

why _actionid?

heady quiver
#

woops

#

removeAction *

#

[_target] remoteExec['setVehicleLock', _target];
[_target, _actionId] remoteExec['removeAction', _target];

little raptor
heady quiver
#
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        _target setVehicleLock "UNLOCKED";
        _target removeAction _actionId;
        [_target] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];
heady quiver
#

Yes, but it needs to be unlocked for all players.

little raptor
#

it will be

#

first of all

_target setVehicleLock "UNLOCKED";

#

second of all

[_target] remoteExec ['setVehicleLock', _target];

#

I mean correct those

winter rose
hearty loom
#

is there anyway i can return or calculate the inventory level on armor?

#

like the level 1

torpid quartz
# heady quiver `_caller removeAction _actionId;` changed it do this now.

awesome didn't know about this. still a bit confused about getting titleRSC and cutRsc to work together, titleRSC just seems to stay there and cut can't effect it, cut's effects are instant and over before i can do anything but I think i get what i need to muck around with from the wiki. Found a steam thread though that's got what I needed so don't worry, I'll figure out cutRsc in time.

https://steamcommunity.com/app/107410/discussions/17/1729837292638666076/

hearty loom
#

you know when you hover over it in your inventory and it gives you the Armour level

winter rose
torpid quartz
# little raptor what level?!

hovering over clothing items ingame that offer protection give you "armor levels" in the hover text. that's what they're probably referring to

little raptor
#

oh that

#

ok

#

@hearty loom ```sqf
getText (configFile >> "CfgWeapons" >> vest _unit >> "descriptionShort")

#

it's a text

#

not number

hearty loom
#

that fine tho

#

thanks sm

little raptor
#

that's it

heady quiver
#

['UNLOCKED'] remoteExec ["setVehicleLock", _target]; this is what i had

#

x)

winter rose
#

remember: leftArg, rightArg

little raptor
#

and remove the duplicate

#

_target setVehicleLock "UNLOCKED";

#

it will ruin everything

heady quiver
#
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        _target removeAction _actionId;
        [_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];
little raptor
#

give it a go

little raptor
# heady quiver `['UNLOCKED'] remoteExec ["setVehicleLock", _target];` this is what i had

Here is an example of an SQF command that we want to write a remoteExec for:

_target setVehicleLock "UNLOCKED"
```     ^1                 ^2                               ^3
1: `leftArg` (what's on the left of the command)
2: `command`
3: `rightArg` (what's on the right of the command)

`remoteExec` template:
```sqf
[leftArg, rightArg] remoteExec ["command", ...];
``` Just copy paste the `leftArg`, `rightArg` and `command` into the template. You can add the `remoteExec` target and the rest of the parameters (such as JIP, see the wiki) in the `...` area.

so it becomes:
```sqf
[_target, "UNLOCKED"] remoteExec ["setVehicleLock", _target]; //setVehicleLock must be executed where _target is local, so we put _target in the ... area

Another Example: unary command (no leftArg)

hint "hello"
```   ^2            ^3
(no `leftArg`, so skip)
```sqf
["hello"] remoteExec ["hint", 0]; //show the hint to every client

Another Example: a binary command with multiple arguments in the rightArg array

_unit addAction ["hello", {code}]
```    ^1            ^2                          ^3
```sqf
[_unit, ["hello", {code}] ] remoteExec ["addAction", 0]; //add the action to _unit for every client

A tricky one: unary command with array rightArg:

createSimpleObject ["Land_Wrench_F", _pos, true];
``````sqf
[["Land_Wrench_F", _pos, true]] remoteExec ["createSimpleObject", _player]; //creating a simple object locally on another machine (_player's)

**Functions: ** This is how you remoteExec a function:

[_arg1, _arg2, _arg3] call My_fnc_function
``````sqf
[_arg1, _arg2, _arg3] remoteExec ["My_fnc_function", ...];

the function only needs to be defined on the target machine(s)

Nular commands or functions with no parameters:

remoteExec ["My_fnc_function", ...]
heady quiver
#

Only thing is that the buy option stays for everyone else.

little raptor
#

note that actionID may not be the same for everyone

#

you'll have to store it

tidal ferry
#

Any way to make an 'on salute' event handler?

little raptor
#

use animStateChanged EH

tidal ferry
#

Gotcha, thanks!

#

Another question- is it possible to add event handlers to certain uniforms, vests etc.?

#

Via config, that is

#

And is there any way to create 3D text within the world, using whatever principle setPlateNumber uses?

tidal ferry
#

Well yes, but I mean to specifically create 3D text from a string input

#

In the same way that you could with setPlateNumber

#

Like, a jank solution would be to find an object I could modify with setPlateNumber, attach it, and just remove all its textures, but that's a rather inelegant solution

winter rose
#

I mean, there is a 4×4 "user texture" object

#

but nothing where you can set "use this text plox kthxbai"

hallow mortar
#

Someone could make [as a mod] an object that's nothing but a holder for a setPlateNumber display, but there's not one in the base game

warm hedge
#

Made before. It didn't satisfied me

young current
#

@tidal ferry what kind of usecase do you have?

tidal ferry
#

Just looking to try and add nametags to some uniforms

#

Would save a lot of data to have a function that could do that instead of a bunch of individual name tag textures

young current
#

Id say if you are going through the trouble of adding name tags that are quite hard to see anyway, do it with textured tag object and the textures.

#

if you want it to look anyway nice

craggy lagoon
#

I've attempted to modify a Getin event handler that I had to a WeaponAssembled event handler, but it's not working. Anyone willing to take a look at it and tell me what I'm doing wrong?

["I_HMG_02_high_F", "WeaponAssembled", {
    params ["_unit", ""];
    if !(_unit getVariable ["WeaponSP", false]) then {
        playSound "Denied";
        ["<t color='#FFBB00' size = '.5'>You're not a Weapon Specialist.</t>",-1,0.8,5,0.5,0,789] spawn BIS_fnc_dynamicText;
    };
}] call CBA_fnc_addClassEventHandler;
copper raven
#

you're supposed to add the event handler to the unit, not the weapon

#

so, add to CAManBase class instead

opal turret
#

Hoping one of you folks can give me a hand. I'm creating dynamic patrol groups but, as you can see from the code, each one is given a private variable name that is the same as the previous group.

It works fine but I don't think it's best practice and I'd also imagine the previous group variable would no longer exist.

So, does anyone have a suggestion on how I can give each group a unique private variable as they are spawned in?

//Spawn patrol groups
_smlGroups = [];

for "_i" from 1 to 5 do 
{
    private _patrolPos_01 = [_trigPos, 0, 100, 0, 0, -1, 0, [], [[0,0,0],[0,0,0]]] call BIS_fnc_findSafePos;
    private _patrolGroup_01 = createGroup [TPHSide, true];

    for "_i" from 1 to floor (random [4,4,6]) do {
        _patrolUnit_01 = _patrolGroup_01 createUnit [selectRandom TPHUnits, _patrolPos_01, [], 0, "NONE"];                                                                    
    };

    [_patrolGroup_01, _patrolPos_01, 150] call bis_fnc_taskPatrol;
    _patrolGroup_01 enableDynamicSimulation true;
    _smlGroups pushback _patrolGroup_01;

    sleep 0.15;
};
copper raven
#

why would you want to do that

#

the ideal way would be to use an array, like you're doing it right now(neat if you need to do something with those groups later)

craggy lagoon
#

@copper raven Ok now it registers that I don't have the correct Variable, plays the sound and gives error notice. But it still builds the static. I'm not sure what to add to stop the build process.

copper raven
opal turret
copper raven
#

not sure what you mean by that

#

the group still exists

craggy lagoon
#

@copper raven Thank you, I'll look into that.

opal turret
# copper raven the group still exists

I'm running this on a server, together with LAMBS_danger, and each time a firefight kicks off the rpt is spammed with Ref to nonnetwork object and I'm wondering if it's looking for a group name that no longer exists. I could be waaaaay off, and probably am, but if there is a way that I can rule it out by assigning unique variable names it'd help.

copper raven
#

that message is w/e seen it a lot of times for a long time now, nothing to do with that

opal turret
#

It only pops up when I'm running LAMBS though, so it got me thinking.

copper raven
#

maybe something's broken

#

in the mod

#

some people verify cache and it fixes it blobdoggoshruggoogly wouldn't worry about that log message though

opal turret
#

Righto, cheers for the assistance.

timber bear
#

anyone have a script for teleport on mission start? My mission is teleporting me way the heck out in the middle of no where under water so i need a script that runs on mission start to teleport players to where they are supposed to start.

timber bear
craggy lagoon
#

I would like to write something that would run a script every time a player added a UAV terminal to their loadout. But i'm not sure what function I should be looking at. Any suggestions?

opal turret
#

Containerclosed event handler, then check assigneditems is a solid start.

buoyant hare
#

Anyone have any tips on how to time-effectively make a small model scale of a compound/HQ/village with setObjectScale?

still forum
#

There is already a script/mod that does that on the workshop

buoyant hare
#

@still forum Mind sharing the name of that mod?

still forum
#

Don't remember

sharp grotto
#

@buoyant hare

buoyant hare
#

@sharp grotto cheers big ears!

wispy pond
#

So is there a script to force a type of glasses onto a character and still have the glasses slot freed up?

#

like a way to force it onto the character model itself like adding a flag to a vehicle?

fair drum
#

when I'm looking through functions say on CBA/ZEN/ACE github etc, when you are reading the file description and they do the name, arguments, usage, and stuff, and they list Public, does that usually refer to public as in, open to everyone to look at on github, or do they mean a function that is known by every client?

robust hollow
#

could you send an example?

fair drum
#

this particular one I'm looking on ZEN's github...

/*
 * Author: Kex
 * Makes the given VLS unit fire on the given position.
 *
 * Arguments:
 * 0: VLS Unit <OBJECT>
 * 1: Position <ARRAY|OBJECT|STRING>
 *   - in AGL format, or a Map Grid when STRING
 * 2: Spread <NUMBER>
 * 3: Magazine <STRING>
 * 4: Number of Rounds <NUMBER>
 *
 * Return Value:
 * None
 *
 * Example:
 * [_unit, _position, 0, _magazine, 1] call zen_common_fnc_fireVLS
 *
 * Public: No
 */
wispy pond
#

@little raptor attach it meaning?

little raptor
robust hollow
wispy pond
#

I didnt know you could do that with characters and gear items i will give it a shot

fair drum
little raptor
#

you just create it and attach it

wispy pond
#

can that be done through config files for a custom character? thats ultimately my goal

#

Not working

little raptor
wispy pond
#

might i also add there isnt a placeable model for the glasses item im wanting to use

little raptor
wispy pond
#

ok that answers my question then

little raptor
sand rune
#

hello, does anyone know if you can set the playback speed for a pre-recorded unitCapture script?

#

e.g. if I wanted it to go faster than was recorded

little raptor
#

unless you make your own function

sand rune
#

a shame! I thought there'd be some remnant of that feature in A3 since I've seen a similar thing be available in VBS so I assumed it was reused haha

fleet hazel
#

Hey guys. How can I prevent editing in my profile fovTop and fovLeft

hallow mortar
fair drum
#

since I can't send args to a onEachFrame handler, and I can't use a missionnamespace variable as its has the potential of being overwritten by another instance of the script, should I just use a really small sleep on a while loop? how small for a frame?

#

i'm trying to avoid CBA to keep no mods. But I know they have a perFrameHandler function that allows for args.

little raptor
#

I normally design my each frame loops like this:

var_scheduler = [];
onEachFrame {
  {
    _x#0 call _x#1;
    var_scheduler set [_forEachIndex, 0];
  } forEach var_scheduler;
  var_scheduler = var_scheduler - [0];
};
var_scheduler pushBack [nil, {hint "hello"}];
```(I use a bit more complicated version, but that's the gist of it)
little raptor
fair drum
little raptor
#

also don't use onEachFrame notlikemeow

fair drum
#

I'm looking at doing some VLS missile tracking a target since the target would move (have to move a static laserTargetW). I could probably sacrifice some accuracy for a lower refresh time and performance and just do a loop every .2 sec or something

little raptor
fair drum
#

oh did you mean don't use the onEachFrame command or the event handler then?

little raptor
#

scheduled

#

I mean the loop with sleep

fair drum
#

oh I get that. I was referring to your dont use onEachFrame after you just posted a work around for onEachFrame lol

little raptor
dreamy kestrel
#

Q: how robust is BIS_fnc_sortBy when the thing being sorted is 0- or 1- elements?

#

Q: how robust is BIS_fnc_sortBy when the thing being sorted is 0- or 1- elements? i.e. do I need to include any special wrapper logic around that? like a count-oriented switch ... do, let's say?
Of course, responding accordingly to arrays of different sizes, would not want to _array#0 a 0-element array due to DBZ errors.

little raptor
#

if you mean the original array, then it's empty

#

what's there to sort?

dreamy kestrel
#

@little raptor well, that's my question. if I approached it "ignorant" of the size, 0- or 1- element arrays do not need to be sorted, but can I feed that through the sortBy algo anyway? is it robust enough to handle that? or am I right to wrap that in a switch or other construct?

little raptor
#

yes

dreamy kestrel
#

I'm just looking for ways to potentially clean up my code without this pattern cropping up

little raptor
dreamy kestrel
#

or said, could consider count _x > 1 gets sorted?

little raptor
#

no need

#

there's virtually no performance penalty

dreamy kestrel
#

in terms of gauging sortBy robustness I mean

little raptor
# dreamy kestrel in terms of gauging `sortBy` robustness I mean

I have no idea what kind of "robustness" you're going for
but here's the sortBy function

#include "..\paramsCheck.inc"
#define arr1 [_inputArray,_inputParams,_algorithmFnc,_sortDirection,_filterFnc]
#define arr2 [[],[],{},"",{}]
paramsCheck(arr1,isEqualTypeParams,arr2)

_inputParams params ["_input0", "_input1", "_input2", "_input3", "_input4", "_input5", "_input6", "_input7", "_input8", "_input9"];

// filter is specified
if !(_filterFnc isEqualTo {}) then 
{
    _inputArray = _inputArray select _filterFnc;
};

// alternative sorting algorithm is specified
if !(_algorithmFnc isEqualTo {}) exitWith
{
    _cnt = 0;
    _inputArray = _inputArray apply 
    {
        _cnt = _cnt + 1; 
        [_x call _algorithmFnc, _cnt, _x]
    };

    _inputArray sort (_sortDirection == "ASCEND");
    _inputArray apply {_x select 2}
};

_inputArray =+ _inputArray;
_inputArray sort (_sortDirection == "ASCEND");
_inputArray
dreamy kestrel
#

okay, so practically speaking,

private _ranges = _units apply { (getPos _x) distance2D _markerPos; };
private _sorted = [_ranges, [], { _x; }] call BIS_fnc_sortBy;
_sorted params [
    [Q(_range), -1, [0]]
];
_range;

There may be no units, one unit, or how ever many units.

little raptor
#

yes

little raptor
#

just sort

little raptor
dreamy kestrel
#

in this instance, sure, good point. for those times when may be dealing with arrays of a different shape.

#

I can just use the unit itself? i.e. _x distance2D _markerPos (?)

little raptor
dreamy kestrel
#

oh I see, is there a better one? that plays well with markerPos?

little raptor
#

in this case it's 2D

#

so it won't matter

#

getPosWorld/getPosASL/getPosATL are the fastest

#

but they are different in 3D

dreamy kestrel
#

yes oc

#

if I wanted basically "on the ground" reference?

#

guessing that's getPosATL

little raptor
#

on the ground or from the ground?

dreamy kestrel
#

"terrain" as the docs suggest

little raptor
#

I mean 0 height from the ground?
or the actual unit height (e.g when in building)

dreamy kestrel
#

but as you said, 2D, so likely a wash, but for performance gains

little raptor
#

but getPosWorld is the fastest

#

by a small margin

dreamy kestrel
#

okay dokay, thanks. appreciate it.

thorn saffron
#

Is there a way to add decimal numbers to round numbers? Like I want to turn 75 into 75.0000

thorn saffron
#

thanks, the explenation got me confused

fair drum
#

Curious to what you want to use 4 decimal accuracy for.

little raptor
#

that's just useful for string representation

#

(also floats have only up to 7 significant digits afaik)

fair drum
#

Ah so probably useful for UI for say a countdown as returning a countdown directly would give all the decimals of time.

#

Instead of doing the math directly with a round or something then showing that.

valid abyss
#

Does the init.sqf get executed for every person on a server?

winter rose
cosmic lichen
#

it does on mission start

valid abyss
#

Thanks

cosmic lichen
#

biki -> Event Scripts

winter rose
valid abyss
#

So what would happen if I executed an entitykilled eventhandler in the init.sqf?

winter rose
#

it would fire for every computer

cosmic lichen
#

it would execute it for the server and every player 😄

valid abyss
#

Right just making sure, thanks a lot!

night storm
#

hi, im new to this (very), and im trying to make a mission that has two objectives-
1 - Kill a target
2 - Extract the three Hostages

the second objective needs to be triggered by the first one being completed, and once the second one is completed, the mission is complete.
Fail condition is if all three hostages are killed.

ive got the entities sorted out but now i need to work on the actual guts of the mission - the objs and pass/fail conditions. TIA

fair drum
#

why is CBA's wait and execute preferred over using waituntil?

robust hollow
#

because it runs in an unscheduled environment

hallow mortar
# night storm hi, im new to this (very), and im trying to make a mission that has two objectiv...

Target's death: give the target unit a variable name, create a trigger with !alive your_target_name as the activation condition.
Hostage extraction: well....this is more complicated and depends on how you want the extraction to work.
Hostages dead: trigger with (!alive your_hostage1_name) && (!alive your_hostage2_name) && ...
For sequential objectives you can sync Tasks modules to the triggers (though my personal preference would not be a hard requirement to do them in order, just give them the objectives and the freedom to choose the order), and use triggerActivated target_dead_trigger as part of the hostage extraction's conditions

fair drum
#

... pain... i just overwrote my scenario attempting to load it from a blank map...

#

good thing most of it is scripts but man is that annoying

ripe sapphire
#

thats why i always make backups lol

#

i also just lost most of my profile data because of a power outage

#

arsenal loadouts, settings, addon settings etc are gone

fair drum
#

paaaaainnn

ripe sapphire
#

and my last backup is from january OOF

#

well at least i still have most of the settings and loadouts

hallow mortar
fair drum
#

i've come to collect them now

torpid quartz
#

how would i remoteExec this?

MAN4 setGroupID ["Blue Boy"]; 
MAN4 sideChat "Test Text Hello!";
#

or more so make it so when a trigger goes off with server only ticket that it this side chat text appears for all players

fair drum
#
//Normally
A command B

//RemoteExec
[A, B] remoteExec ["command", whereTO]
#

try that and i'll check it

torpid quartz
#
[MAN4 ["Blue Boy"]] remoteExec [setGroupID, 0];
[MAN4 "Test Text Hello!"] remoteExec [sideChat, 0];

can't test right this second because i need players so i'm making as many versions as possible of things to test atm, but is this looking right?

#

ah no getting a "missing ]" error. hang on let me try fix this

robust hollow
#

[MAN4 missing , on both lines

torpid quartz
#

ah right, thought because you didn't need comers in the original you could get away with spaces. now i think about it probably not lol

#

yeah there we go, thanks Connor

hallow mortar
torpid quartz
#

oh right no haven't will do thank you

#

also for [sideChat, 0] @hallow mortar ?

hallow mortar
#

Yes, always for the command name in a remoteExec

torpid quartz
#

excellent thank you. that's what might have been causing me other problems too

#
missionNamespace  setVariable ["PART10", true, true]

[setVariable ["PART10", true, true]] remoteExec ["missionNamespace", 0]

due to how the command is structured I have no idea, but how would i do it with this, can't get it not to spit errors right now

fair drum
torpid quartz
#

oh nice

fair drum
#

or you can remote exec to just the clients of a particular group

#

etc etc

torpid quartz
#

good to know that helps a lot thanks

fair drum
#

so on your missionname space thing

#

that second "true" makes it public

#

so you dont have to remote exec it at all

#

just be careful. its the same as using publicVariable and if you over use it, you can clog the network

torpid quartz
#

ah, right. gotcha.

setting up a large test mission to see what things work so i wanted to see if a remote version would work. makes sense though thanks.

fair drum
#

if you don't need to send it to every client, then don't. keep it on the server

torpid quartz
#
[  
this,             
 "Turn on table",            
 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",   
 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",   
 "_this distance _target < 3",        
 "_caller distance _target < 3",        
 {},               
 {},               
 { missionNamespace setVariable ["PART3", true, true] },      
 {},               
 [],               
 3,               
 0,               
 true,              
 false              
] call bis_fnc_holdActionAdd;

main thing i've been trying to do is this, which i think will work now hopefully lol because I've been having hell with hold actions due to trying to remote execute the whole thing lol.

fair drum
#

yes, that would be an instance where you would make it public. I had to do that recently as well

#

just remember, if that code is only firing on the server, you still need to send the whole handler to the clients as well

#

example of what I had to do recently

torpid quartz
#

oh damn this is some good stuff thanks for sharing that

#
"_this distance _target < 3 && !PART1", 
 "_caller distance _target < 3 && !PART1",

if you where going to have this for the requirement stuff for a MP game, would having PART1=FALSE in init.sqf be the right move? Or would having it in initServer.sqf?

fair drum
#

well what is part1? object? bool? number?

torpid quartz
#

bool

fair drum
#

you could forget having to define part1 earlier and instead use `!(isNil "PART1") which will return true once PART1 becomes anything but non existent. or you could define before. its up to you.

torpid quartz
#

oh no nice i didn't think checking it was nill was a thing, only true and false. that works great.

fair drum
#

does "Put" fire when a unit drops an item as well? cause isn't the ground considered a "container"?

copper raven
#

should fire yes

fair drum
#

performance question. is there significant overhead with stacking if thens vs one long liner if statements?

#

i know that sqf doesn't short circuit unless using lazy evaluation but how does stacking if thens do?

copper raven
#

more commands = slower

#

no reason to stack if then, when you can use lazy evaluation

#

faster, cleaner

hallow mortar
# fair drum does "Put" fire when a unit drops an item as well? cause isn't the ground consid...

From the perspective of your question, yes. But the ground isn't considered a container. In fact, when you "put something on the ground" you're actually creating an invisible holder object and putting the items into its inventory; "the ground" isn't an inventory space that exists. These invisible containers are how nearby items are grouped (and why they sometimes aren't). You can even see them in Zeus if you add all objects after one has been created.

#

Or to phrase it better, the ground isn't considered a container; there are invisible containers that are considered the ground.

torpid quartz
#
[  
this,             
 "Turn on table",            
 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",   
 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",   
 "_this distance _target < 3",        
 "_caller distance _target < 3",        
 {},               
 {},               
 { missionNamespace setVariable ["PART1", true, true] },      
 {},               
 [],               
 3,               
 0,               
 true,              
 false              
] call bis_fnc_holdActionAdd;

So i've got this which works.
But when someone does the action, the option is still there for all the other players (not that it really matters since it's just setting a bool to true)
I wanted to remove this issue with !(isNil "PART1") but i'm getting a error for missing "]", modified code below with the !(isNil "PART1")
any ideas?

[  
 this,             
 "Turn on table",            
 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",   
 "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",   
"_this distance _target < 3 && !(isNil "PART1")",  
"_caller distance _target < 3 && !(isNil "PART1")",        
 {},               
 {},               
 { missionNamespace setVariable ["PART1", true, true] },      
 {},               
 [],               
 3,               
 0,               
 true,              
 false              
] call bis_fnc_holdActionAdd;
hallow mortar
#

Quotes inside strings

copper raven
#

use single quote or escape with 2x " e.g " ""hi"" "

hallow mortar
#

The parser thinks the quote before "PART1" is the quote at the end of the string, so you have to do that ^

torpid quartz
#

the mission space one for the is nill one?

#

or both?

copper raven
#

nothing to do with spaces

hallow mortar
#

Only for the ones that are inside another set of quotes

copper raven
#

"isNil "var"" bad
"isNil ""var""" good

torpid quartz
#

whoop, must have done a bad copy paste, removing the IsNill ones did work

#

excellent, thanks as always gents

hallow mortar
#

No, that's not right

#

Don't remove them, double them

warm hedge
#

I prefer to use ' instead of "" FYI

hallow mortar
#

You still need quotes, you just need to show the parser that they're quotes within the string and not the quotes delineating the string

warm hedge
#

Basically: You can't use " inside "

copper raven
#

you can, you just need to escape it properly

#

instead of backslash you use the quote type that was in the beginning of the string twice

hallow mortar
#

In sqf, anything wrapped in " is a string (text value). For reasons unknown, the addAction command needs you to pass code as a string for some of its parameters, so if your code itself contains a string, you have to escape the quotes

warm hedge
#
"One says: "This is a illegal string!""```This is considered as three parts:
`"One says: "`, `This is a illegal string!`, `""`. Obviously the middle part is illegal while others technically aren't, so this is a illegal code
torpid quartz
#

uh how would you get to work on a server? I've tried remote executive it but yeah neither of these pops up for other people.
Both work for me, but yeah.

MAN1 setGroupID ["Blue Boy"]; 
MAN1 sideChat "Hello ladies!";
[MAN5, ["purple Boy Man5"]] remoteExec ["setGroupID", 0]; 
[MAN5, "Test Text Hello! for man5"] remoteExec ["sideChat", 0];
hallow mortar
#

In theory the remoteExec'd version looks fine to me (barring the potential to duplicate it if all clients broadcast the remoteExec, but one thing at a time)

#

Are you sure this code is actually being executed?

torpid quartz
#

it's just in a trigger with a activation of any player present

#

with the MAN1 unit standing beside it and so on

#

would having "server only" ticked on the trigger probably breaking this?

cosmic lichen
torpid quartz
#

that might do it, didn't know about that

#

MAN1 setGroupIdGlobal ["Blue Boy"]; ?

winter rose
#

at least, that's what the doc says 😊

supple cove
#

anybody had success creating actions with ace and applying colors to them? been trying

_action = ["kisk_example_class", "<t color='#ff0000'>fancy red option</t>", "", kisk_example_action, _condition] call ace_interact_menu_fnc_createAction;

Welp, looks like it doesn't accept structured text or I'm doing this wrong

little raptor
#

requires string

#

(and what you put is a string, not structured text)

#

also I've never seen the ACE interact menu with custom colors

supple cove
#

welp, sad, but it does make sense.
I think it is possible due to the medical options

#

they do change colors based on the wound type/severity

little raptor
cerulean locust
#

ace medical only colours the icon as far as I can see. which can be done by setting the icon parameter to something like ["path/to/icon.paa", "#FF0000"]

supple cove
#

Oh, well, thats actually nice

#

was taking a while to index the whole code to search for this

#

Yup! works perfectly! thank you a lot

tough abyss
#

Think this is probably a better place to post than before

#

https://steamcommunity.com/sharedfiles/filedetails/?id=1129927793 trying to get this to work for when i do mini ops with friends so it doesnt need TS, but for some reason it wont work. I don't get an error message or anything. I made sure to transfer the AFAR folder into my mission folder, make 2 notepad files and put the right code in each before saving them as init.sqf and Description.ext but it does nothing. Any ideas as to what I'm doing wrong? Ive tested in multiplayer and singleplayer.

little raptor
tough abyss
little raptor
#

where did you put init.sqf and description.ext?

tough abyss
#

C:\Users\James\Documents\Arma 3\mpmissions\Tropic%20Osram.psyfx_pht

#

Same place the mission.sqm is

#

Is that the wrong place?

little raptor
#

no

#

paste this in it:

systemChat "working!";
#

see it you see a message when the mission starts

#

also you shouldn't just restart the mission when you edit those files

#

you should close the mission, go back to eden and start again

tough abyss
#

Should I put it into the init.sqf? The system chat thing

#

I've been restarting my whole game to try and fix it

tough abyss
tough abyss
#

Didnt change anything unfortunately

#

I didnt get a message or anything

little raptor
little raptor
willow hound
#

init.sqf might run too early to see systemChat expressions, not sure though.

little raptor
#

@tough abyss
what about this:

[] spawn {sleep 1; systemChat "working!";};
#

(altho your file seems ok to me)

hallow mortar
#

Do you have file extensions turned on in Windows Explorer?
I mention this because init.sqf is described as a "text document" in the type column, whereas for me a correct init.sqf is described as "SQF file". So I wonder if you actually have a file named "init.sqf.txt"

little raptor
hallow mortar
#

Windows always displays extensions for files not associated with any program. In the screenshot, init.sqf is associated with Notepad but the other two are not associated

little raptor
#

maybe that too

#

@tough abyss make sure file extensions are enabled then

hallow mortar
#

(View tab -> file name extensions checkbox)

tough abyss
#

@little raptor @hallow mortar Thanks both, turning on the file extensions and I saw the init was actually named init.sqf.txt
Getting rid of the .txt seems to have fixed it thanks both

wind hedge
#

Guys, the "U_I_OfficerUniform" cannot be re textured by using setObjectTextureGlobal?

#

I've tried this in the unit's unit but does not work: SQF this setObjectTextureGlobal [0,"textures\uniforms\AAF_Officer\AAF_Officer_Green.paa"]; this setObjectTextureGlobal [1,"textures\uniforms\AAF_Officer\AAF_Officer_Green.paa"]; this setObjectTextureGlobal [2,"textures\uniforms\AAF_Officer\AAF_Officer_Green.paa"];

sharp grotto
#

Might try
(uniform player) setObjectTextureGlobal....

little raptor
sharp grotto
#

Uff true. I didn't say anything

little raptor
#

it's uniformContainer
and afaik it should work the same as setObjectTexture on the unit

wind hedge
#

uniformContainer did not work eighter 😦

little raptor
#

and afaik it should work the same as setObjectTexture on the unit

#

I didn't expect it to

wind hedge
#

Nothing works on U_I_OfficerUniform, just tried SQF this setObjectTextureGlobal [0, "\A3\Characters_F\Common\Data\basicbody_black_co.paa"];

#

and that one works on every other uniform I've tried on

#

So... why is U_I_OfficerUniform protected?

little raptor
#

maybe it doesn't have any hidden selection textures 🤷

wind hedge
#

So if all other uniforms have Hidden Selections and U_I_OfficerUniform doesn't, does that means that it was an oversight by the devs and needs fixing?

little raptor
wind hedge
#

I have just spent two hours doing a texture I cannot apply, so I will try all the channels to get this fixed 🙂

plucky nimbus
#

hello can you script a unite to arrive at a specific time for example to sync an attack between multipl groups in arma 2 co

little raptor
#

nvm

#

well you can add the waypoints to both groups once they have both completed a waypoint

wind hedge
little raptor
#

@dim terrace is that a bug? ☝️ or is it intended?

#

I just did a quick check and it seems the U_I_OfficerUniform uniform does indeed have hiddenSelectionTextures, but it cannot be changed with setObjectTextureGlobal

#

if it's a bug please let me know to open a ticket.

dim terrace
little raptor
dim terrace
#

I'm pretty sure it works on B_soldier_f

plucky nimbus
little raptor
little raptor
dim terrace
#

perhaps someone else could try it?

little raptor
#

here's the script I use in case someone wants to try ☝️ :

[] spawn {
  u = createGroup west createUnit ["b_soldier_f", getPosATL player, [], 0, "NONE"];
  _u = uniform u;
  for "_i" from 1 to 10 do {
    sleep 3;
    u setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"]; //works
    sleep 3;
    u forceAddUniform "U_I_OfficerUniform";
    u setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"]; //doesn't work
    sleep 3;
    u forceAddUniform _u; //readd default uniform
  }
}
dim terrace
#

there is no need for ticket for that one

wind hedge
knotty aspen
#

just curious, is there a work-around for placing multiple custom vehicles that have attach scripts on them? as in, do i have to change variable names every single time i want multiple custom-comp vehicles?

#

i assume i could technically group it all into one model, but i'm not quite sure how to do that, since i'm still sorta new to the whole custom-composition thing, and i think i'd need to physically model the vehicle with all the parts on it to do that.

valid abyss
knotty aspen
#

i'll try that out, thanks

knotty aspen
valid abyss
#

Attach scripts?

knotty aspen
#

the main issue im having is when the variable names switch and then i have to individually go into the car's init

#

and start switching variable names around

#

to match the new ones

#

placing one normally is fine, but if i place a second one, it'll break unless i switch the variable names.

valid abyss
#

Could you send me the script?

knotty aspen
#

yeah

novel shuttle
tidal ferry
#

Is there any way to suspend script inside a forEach loop?

little raptor
tidal ferry
#

Worked, thanks!

manic sigil
#

What is Solomon Maru's face? I need a unit to look like him without the 'Solomon Maru' tag popping up.

#

Nevermind, think I got it

tidal ferry
#

What is an exception, exactly?

little raptor
tidal ferry
tidal ferry
#

Is SQF Object Oriented?

copper raven
#

what makes you think that?

light shale
#

hey guys I have a question that i can not find the answer for on google. I have a script that takes some time to get through do to it having a progress bar. It can be called many times within a couple seconds but i need it to queue the script to be ready to be called again once the script is done. do you guys have any suggestions?

#

I can share the script with you if you so desire

tribal lark
#

How does SQF view 6am? on the 'date' wiki page it uses 3 >= 19 for 7pm, but idk how to change that to 6am if you know what i mean

warm hedge
#

You're comparing what with what?

tribal lark
#

Thank you

pliant stream
#

there is no way to perform a reference comparison of arrays, is there?

warm hedge
#

isEqualTo or arrayIntersect?

winter rose
#

that would work with value or reference @warm hedge

#
private _array1 = [];
private _array2 = +_array1;
private _array2ref = _array1;

// how to get _array2ref isRefTo _array1
pliant stream
#

i suspect it's not possible

#

i don't actually need it either, just curious

limber stump
#

How to make friendly fire messages (push notification before he got killed) and not make it spam the chat?

#
{ if (side _x isEqualTo WEST) then
    {
        _x addEventHandler
        [
            "HandleDamage",
            {
                _returnDamage = (_this select 2);
                if ((side (_this select 0)) isEqualTo (side (_this select 3))) then
                {
                    _returnDamage = 0;
                    _string = str text format ["%2 has friendly fired %1.", (name (_this select 0)), (name (_this select 3))];
                    [_string] remoteExec ["systemChat", 0, false];
                };
                _returnDamage;
            }
        ];
    };
} forEach allUnits;
sharp grotto
#
{ if (side _x isEqualTo WEST) then
    {
        _x addEventHandler
        [
            "HandleDamage",
            {
                _returnDamage = (_this select 2);
                if ((side (_this select 0)) isEqualTo (side (_this select 3))) then
                {
                    _returnDamage = 0;
                    if ((diag_tickTime - LastFriendlyFireNotif) >= 10) then
                    {
                        _string = str text format ["%2 has friendly fired %1.", (name (_this select 0)), (name (_this select 3))];
                        [_string] remoteExec ["systemChat", 0, false];
                        LastFriendlyFireNotif = diag_tickTime;
                    };
                };
                _returnDamage;
            }
        ];
    };
} forEach allUnits;

Add to initplayerlocal.sqf

LastFriendlyFireNotif = diag_ticktime;

Maybe like that , untested tho ^^

winter rose
#

units west instead of allUnits 😉

peak snow
#

hello, not sure if this is the right place to ask but is there a way to "connect" states so that lets say a building is destroyed a vehicle destroys itself as well?

#

Or lets say a generator is destroyed the things connected to it by script "turns off" or gets destroyed as well?

willow hound
peak snow
#

so I'll need something along those lines, and then some other line of code to "kill" the other things? sorry for stupid quesiton but I've never done any scripting in arma XD

willow hound
#

For the first example (building gets destroyed --> vehicle gets destroyed) you could use the Killed EH like so:

MyBuilding addEventHandler ["Killed", {
  MyVehicle setDamage 1;
}];
peak snow
#

hmm, alright and MyBuilding would be changed to whatever the variable name I set it to. Could it also be used to kill multiple vehicles at the same time?

willow hound
#

Of course it could, yes. You can place any valid code you like within the curly brackets {}.

peak snow
#

alright, just wanted to check. Thank you very much!

pliant stream
# pliant stream i suspect it's not possible

wrt. reference equality of arrays, i realise that it is possible by observing mutation of the array. insert an element via one reference, observe the mutation via the other, then roll back the mutation. a bit dirty for sure though

#
referenceEquals =
{
    local _0 = _this select 0;
    local _1 = _this select 1;
    local _s = count _0;
    if (_s != count _1) exitWith { false };

    _0 set [_s, 0];
    local _r = count _1 != _s;
    _0 resize _s;

    _r
};
winter rose
#

you would want to use isNil to ensure it is unscheduled then 😄

pliant stream
#

yes, either that or name unscheduled execution as part of the contract

limber stump
copper raven
pliant stream
#

determining reference equality can be very useful

copper raven
#

there are many ways, calling pushBack on same arrays will print -1 etc

copper raven
#

oh yeah

heady quiver
#

Hey, how can i _target removeAction _actionId; remoteExec this again for all players 🤔

#

Thats within addAction btw

little raptor
#

then remote exec a function that gets the action id on their system and removes the action

heady quiver
little raptor
#

do it in reverse order in a separate function (remoteExec this):

#
params ["_target"];
private _id = _target getVariable ["my_action_id", -1];
_target removeAction _id;
_target setVariable ["my_action_id", -1];
copper raven
sharp grotto
#

Iam lazy and just do this

RemoveActionByName = {
    params ["_object", "_name"];
     {if (_object actionParams _x select 0 == _name) exitWith {_object removeAction _x}} forEach actionIDs _object; 
};
[_playerObject, '[Stand up]'] call RemoveActionByName;
#

works great 😛

heady quiver
#

_target setVariable ["my_action_id", _actionId];
{
_id = _target getVariable ['my_action_id', ''];
_target removeAction _id;
} remoteExec['call'];

@little raptor something like this?

copper raven
#

it does nothing

copper raven
#

when you're adding the action to clients, save the action id to the namespace of the object you're adding the action to

#

then when you want to remove it, get the id from the object and remove the action

little raptor
#
  • remove the saved id
#

(like set it to -1, or nil)

heady quiver
#
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    _target setVariable ["my_action_id", _actionId];
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        _target removeAction _id;
        [_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];

This the entire function, it works but when i (me) unlock it, my buddy still has the option to unlock it.

little raptor
#

I already said what to do

#

and save the action id in the above function

heady quiver
#
deleteAction = {
    params ["_target"];
    _id = _target getVariable ["my_action_id", -1];
    _target removeAction _id;
    _target setVariable ["my_action_id", -1];
}
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    _target setVariable ["my_action_id", _actionId];
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        _target removeAction _id;
        [_target] call deleteAction;
        [_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];
#

BUT

#

Remote exec it

little raptor
#

I said make it a function

#

deleteAction = {...} is not a real function

heady quiver
#

i know

#

x)

winter rose
#

make it a CfgFunctions function

heady quiver
#

ok 😦

little raptor
#

so it does nothing

#

and you're still keeping removeAction

#

remove it

heady quiver
#
class bsTag {
        class buyShop {
              file = "functions";
              class vehicleIsBuyable {};
        };
        class removeActions {
              file = "functions";
              class removeActionFromVehicle {};
        };
    };

inside: fn_removeActionFromVehicle.sqf

params ["_target"];
_id = _target getVariable ["my_action_id", -1];
_target removeAction _id;
_target setVariable ["my_action_id", -1];

action:

params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    _target setVariable ["my_action_id", _actionId];
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        _target removeAction _id;
        [_target] call bsTag_fnc_removeActionFromVehicle;
        [_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];
little raptor
heady quiver
#

i give up

little raptor
heady quiver
#

i am doing _target setVariable ["my_action_id", _actionId]; right

#

........

little raptor
#

you have to save it when you add it

heady quiver
#

Mmm

#

Brb, small break..

heady quiver
#

hi

#

@little raptor so what didnt i do? You pointing to that setVariable part but i dont understand meowsweats

#
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    _target setVariable ["my_action_id", _actionId]; <---------------------- RIGHT HERE NO?
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        _target removeAction _id;
        [_target] call bsTag_fnc_removeActionFromVehicle;
        [_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];

Because i am setting it ?

copper raven
#

addAction returns the action id

#

save the result into a variable, and use setvariable

heady quiver
#
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        {[_target] call bsTag_fnc_removeActionFromVehicle;} remoteExec['call'];
        [_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];
_car setVariable ["my_action_id", _car];
copper raven
#

nope

#

read again

heady quiver
#

addAction returns the action id

cosmic lichen
#

_id = _target addAction ...

heady quiver
#

ooooooooooh

#
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_id = _car addAction[_description, {
    params ["_target", "_caller", "_actionId", "_arguments"];
    _price = _target getVariable ['price', ''];
    if([_caller] call HALs_money_fnc_getFunds >= _price) then {
        [_caller, -_price] call HALs_money_fnc_addFunds;
        {[_target] call bsTag_fnc_removeActionFromVehicle;} remoteExec['call'];
        [_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
         [[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
    }
}];
_car setVariable ["my_action_id", _id];
little raptor
copper raven
#

now in the part where you call removeaction, remoteexec some removeaction function(the one you were given)

little raptor
#

(and even if you wanted to that's invalid)

copper raven
#

ah wait you changed the code to something invalid again

heady quiver
copper raven
#

removeActionFromVehicle, what does that even do? or is that the function leopard gave u?

heady quiver
#
params ["_target"];
_id = _target getVariable ["my_action_id", -1];
_target removeAction _id;
_target setVariable ["my_action_id", -1];
#

Thats the function

cosmic lichen
#

why

copper raven
#

yeh, ok, but your remoteexec is bad, won't work

#

_target is undefined

little raptor
copper raven
#

why remoteexec call? just remoteexec the function instead, no need to do such wrapping

heady quiver
#

yea i need to learn that.

#

but lets ignore that ugly part, whats not working now?

little raptor
#

you were taught a million times meowsweats

copper raven
#

_target is undefined like i told you

#

local variables don't carry over like that, the target machines won't magically know what _target is inside the code, either pass it properly, or remoteexec the function, and not do that wrapper stuff

heady quiver
#

[_target] remoteExec ['bsTag_fnc_removeActionFromVehicle'];

#

now _target

#

but _target isnt local right

#

i mean it is.

#

but

cosmic lichen
#

_target will be resolved first. Eg. remoteExec will send the object stored in _target instead of the _target variable

loud python
#

does anybody know how exactly setMissileTarget works?

cosmic lichen
#

What is not working?

loud python
#

I'm trying to get a Mk41 VLS to fire at some random position

#

but I just can't find a way to have the missiles actually do anything other than fly up

#

not even fireAtTarget with laserTarget player works

cosmic lichen
#

Is that a modded missile?

heady quiver
loud python
#

neither works

#

I'm trying to use a game logic object for the target

little raptor
#

how do you use it?

loud python
#

but that also doesn't work

loud python
heady quiver
#
whatEverFunctionYouWannCallIt = {
    [] spawn {
            _sendPos = if (isNull cursorObject) then {AGLtoASL screenToWorld [0.5,0.5]} else {aimPos cursorObject};
            _spawnPos = player modelToWorldWorld [0,-500,200];
            sleep 5;
            _missile = createVehicle ["M_Jian_AT", ASLtoAGL _spawnPos, [], 0,"CAN_COLLIDE"]; 
            _missile setMissileTargetPos ASLtoAGL _sendPos;
            _missile setVectorDir (_spawnPos vectorFromTo _sendPos);
    }
};

This is what i use... i aim at something and call that function maybe with radio and it fires a rocket.

little raptor
loud python
#
launcher fire "weapon_VLS_01";
launcher getVariable ["missile", objNull] setMissileTargetPos position target;

This doesn't work (setMissileTargetPos just returns false)

loud python
#
launcher fireAtTarget [target, "weapon_VLS_01"]

This returns true and the missile just goes up

loud python
loud python
#

does that make a difference?

little raptor
loud python
#

ah

#

yes it does

#

mainly because I ran the code, waited for a second, then ran the code again

#

the missile was definitely already flying at that point

little raptor
loud python
#

yea, still doesn't work though

little raptor
#

does the missile face the target?

loud python
#

nope, still goes straight up

little raptor
#

it needs to be in its targeting cone to lock

loud python
#

those missiles never spawn looking at the target though

#

hmmm...

#

I'll try pointing the missile straight at the target I guess, maybe that helps 🤷

#

nope, pointing the missile right at the target object (setVectorDir to vectorFromTo) and then calling setMissileTarget also just fails

fair drum
#

@loud python just hopped on discord so i haven't read through everything yet but i see you are talking about VLS?

#

and targetting? cause I just was working through something with that this week

loud python
#

VLS Indeed!

fair drum
#

may be relavent, but I use fireAtTarget and remoteReportTarget

loud python
#

remoteReportTarget?

fair drum
#

and if you want it follow things, you create a "laserTargetW" or "laserTargetE" and attach it to an object

loud python
#

I tried launcher fireAtTarget ["...", laserTarget player] and it didn't work

fair drum
#

hopefully you are in a singleplayer environment when doing that?

loud python
#

yea

#

for now just playing around

#

later on I'll switch to laserTargetW if that works

fair drum
#

try using remoteReportTarget

loud python
#

oh...

#

yea

#

just did that

#

remoteReportTarget works flawlessly, even when the target is a game logic object 😄

#

Thanks a lot for that tip ❤️

fair drum
#

yuppers

#

if you set the time too low, it will stop being broadcast and the missile will lose lock and crash to ground

#

so I get the artillery ETA and add a little bit extra

#

and use that as the time for the remote broadcast

loud python
#

nah, I mostly want this for very precisely scripted situations

#

like firing a missile at a target that won't move near the AO

#

for the cool effect

#

so I can just figure out a number that works 😄

#

if 30 is too low, I'll take 60 xD

fair drum
#

and if you don't want to go through the hassle of making units and stuff for just a scripted sequence that the player won't see the launch, just use BIS_fnc_EXP_camp_guidedProjectile

loud python
#

hmmmmm...

#

that sounds super useful as well 😄

#

I'll have a look at this function, thanks for that as well

fair drum
#

thats how you like shoot helicopters out the sky for scripted sequences easily, or top down attacks on tanks and stuff

#

where the player doesn't need to see the launch

#

cause it will spawn the missile out of thin air

loud python
#

I'll see if I can get setMissileTarget to work as well

#

but yea...

call { private _missile = "ammo_Missile_Cruise_01" createVehicle position this; missile setVectorDir [0, 0, 1] }

one would expect that code to spawn a missile that points up, but one would be mistaken

#

ah never mind, I'm dumb

fair drum
#

vectors have magnitude though, not just direction

loud python
#

wait what coordinates does setVectorDir use?

little raptor
little raptor
loud python
#

what space I mean

little raptor
#

world

loud python
#

then [0, 0, 1] should be up

#

which it isn't

little raptor
#

it is up

#

the question is what is the direction of your model

#

createSimpleObject ["ammo_Missile_Cruise_01", eyePos player];

loud python
#

ugh... it seems the problem was I needed to setVectorDirAndUp for it to work

little raptor
#

if your missile is horizontal yes

loud python
#

oooooh wait I'm even dumber than I thought nvm

#

my missile was in the _missile variable but I was calling setVectorDir on missile

fair drum
#

also, that won't create the cool particles I think. its just a naked missile

loud python
#

doesn't matter if the missile spawns half a map away 😉

#

buuuuut... setMissileTarget still won't work, even after reportRemoteTarget 😭

fair drum
#

the reportRemoteTarget is if a launcher actually exists as it needs a data network

loud python
#

yea, it seems setMissileTarget is just black magic and doesn't work

fair drum
#

try using the example on the wiki page or a different missile

#

since it mentions that not all missiles work

loud python
#

ah, yes, "Missile_AGM_01_F" seems to actually work

#

guess it's just that it doesn't work with cruise missiles then

#

dumbest thing I could think of is spawn a VLS, have it shoot a missile and instantly delete it again xD

fair drum
#

nah you want it there until impact

#

then you can delete it

loud python
#

then I'll just make it invisible I guess xD

fair drum
#

is there a way to rotate which teams are available in the lobby at start? cause I guess the mission init hasn't started then yet which means you couldn't use any commands like changing the unit to playable.

willow hound
#

Nope

hallow mortar
grim ravine
#

Hi all - I'm scratching my head trying to get an event handler to fire from a mine when it's triggered by a player walking over it at the moment i'm trying to add;

_unit addEventHandler ["Deleted",{(_this) execVM "\RW_zeus\functions\CleanObject.sqf";}];

as the EH "Killed" doesn't fire

#

The addEventHandler is being added to an ACE IED which has the same functionality as the base game AP mines

little raptor
grim ravine
#

I have a module that "buries" the IED using setPos and then adds an oil stain on the top with createVehicle

#

The oil stain is then stored as a variable in the IEDs namespace and picked up by the script to clean itself up

little raptor
#

ok

grim ravine
#

I.E

_unit setVariable ["RW_oil_1", _oil_1];
// Get object references to indicators.

private _oil_1 = _unit getVariable "RW_oil_1";
// Delete oil stains.
if !(isNil "_oil_1") then { deleteVehicle _oil_1; };```
little raptor
#
  1. you might want to turn that code into a function for improved performance
  2. did you try fired event handler?
grim ravine
#

(in different scripts)

#
  1. yes on my todo meowsweats
  2. I will try that now
little raptor
#

the object doesn't accept any event handlers it seems

proper sail
#

where do i find the stuff again on the wiki from a config sensor like rectangular=1 or angle=-150

#

i cant find it in sensors or im blind

grim ravine
little raptor
grim ravine
#

The same cleanup script fires when a curator/zeus hits "end"

little raptor
#

when you try to add it it just returns -1

#

aka failed

grim ravine
#
_unit addEventHandler ["Killed",{(_this select 0) execVM "\RW_zeus\functions\CleanObject.sqf";}];``` has been working for me
little raptor
#

not a mine

#

(ammo)

grim ravine
#

_unit is the object that I drop my zeus module onto

little raptor
grim ravine
#

That works when a Zeus presses "End" on the object, it does not work if a player triggers it by stepping on it

#

I tried Fired and that doesn't do it either 😦

#

I'll try adding a Hit EH to the object I spawn ontop of the buried mine and see if I can remove it that way

hallow mortar
#

bold idea: killed EH on the player, uses the killer information to determine if it was a mine and if so delete any nearby oil stains

little raptor
grim ravine
#

It's being dropped on IEDLandBig_F

loud python
#

Can I change the buoyancy of a static trawler to make it sink?

hallow mortar
#

buoyancy probably not, but you could try changing its mass and seeing if that overcomes the buoyancy

#

also, I'm not 100% sure, but I think the trawler will sink if it's "destroyed", so trawler_name setDamage 1 might work

loud python
#

nope, tried that already

#

trawler can't be "destroyed" xD

#

how would I change its mass?

hallow mortar
#

setMass

loud python
#

I'll try 😄

#

also, how did I turn a vehicle invisible?

#

I see the option in the editor, but I think it could be scripted as well

hallow mortar
#

hideObjectGlobal

#

be advised that this can make the object intangible as well as invisible

loud python
#

hmmm...

#

dammit I want the object to still take damage xD

fair drum
#

are setVariables transferred from corpses to units when they are respawned?

willow hound
#

The respawn system is supposed to do that, yes.

tribal lark
#
if (date select 3 >= 6) then{ 
nul = [this] spawn {   
  while {true} do { (_this select 0) say3D ["Reveille", 500, 1, false, 0]; sleep 30; };   
}; 
};```
Trying to make something play at 6am, doesn't work for some reason
winter rose
tribal lark
#

so waitUntil would work better

still forum
#

nul = you don't need that btw

#

use isNil

#

correctly

#

Or read this page

#

"What's the easiest way to check if nothing has been selected in a list box?"

cold pebble
static roost
#

who is good with initial setup for the description.ext

grave thistle
#

What in your opinion would be the best way to get the position of a bullet (in Fired EH) at the first impact? What I have right now works well enough but I was wondering if there was a better way to do it that utilized the impact somehow instead of looping. Apparently the bullet momentarily teleports to [0,0,0] before being deleted from what I heard. Hence _projectile select 0

// inside FIRED-EH
waitUntil {
    // updating the pos
    if (getPos _projectile select 0 != 0) then {
        _impact_pos = getPosASL _projectile;
    };
    _min_ratio = (speed _projectile)/_previous_speed;
    _previous_speed = speed _projectile;
    // If the bullet velocity decreases more than to 0.99 during an iteration (from the looks of it), it impacted something -> the loop is over
    getPos _projectile select 0 == 0 || (_min_ratio < 0.99);
};```

I tried to get EpeContactStart-EH working here but with no luck. It didn't seem to execute at all.  biki says` It can be assigned to a remote vehicle but will only fire on the PC where the actual addEventHandler command was executed. `.I'm not that familiar with EHs yet, but I thought this wouldn't be an issue as I thought I needed it to "fire on the bullet". What I tried:
```sqf
// inside FIRED-EH
_projectile addEventHandler ["EpeContactStart", {
    params ["_object1", "_object2", "_selection1", "_selection2", "_force"];
    
    _impact_pos = getPosASL _object1;
}];
little raptor
fair drum
#

fsm condition priority, lower number is higher priority right?

#

also, can you terminate a FSM externally with terminate?

pulsar bluff
#

isnt there a terminateFSM command?

fair drum
#

not on scripting commands or functions page

tender fossil
#
_resultArrived = missionNamespace getVariable format ["WFBE_JOIN_RESULT_ARRIVED_%1", getPlayerUID player];    

waitUntil {
  _resultArrived;    
};

Can I do this a.k.a. is _resultArrived passed as reference?

robust hollow
#

not entirely sure what you are trying to achieve there, but what ever it is, you're doing it wrong.

fair drum
#

yeah i was confused too... that doesn't do anything he probably wants

winter rose
#

You get it once, then expect it to change - never going to happen

little raptor
#

Only arrays, structured text and hashmaps can be passed by ref

robust hollow
#

i imagine you're after waitUntil {!isNil format ["WFBE_JOIN_RESULT_ARRIVED_%1", getPlayerUID player]} perhaps?

tender fossil
tender fossil
#

It's funny, I can create relatively complex scripts but I keep making stupid mistakes like this 😄 😄

#

(To clarify: the variable is being initialized and assigned a value in another thread in parallel)

little raptor
#

There's no "pararell thread" in sqf

tender fossil
#

@little raptor Well, in practice

#

As in "within the scheduler"

little raptor
#

If you're the one assigning it why do you wait for it?

#

Just make an "event handler"

tender fossil
#

I just hacked it together 😄

#

Hmm, need to check something

little raptor
#

Scheduled (as in "wait for something") loops are bad. Unless you have to, don't use them

tender fossil
#

Yes - the value is being publicVariable'd by server once it has gathered the required data from other clients

little raptor
#

No

robust hollow
#

so to do that without a loop you'd use remoteexec

tender fossil
#

@robust hollow Not in Arma 2 😛

robust hollow
#

oh dear 🤢

little raptor
#

BIS_fnc_MP 🤷

cosmic lichen
#

Arma 3 0.5 😛

little raptor
#

How did you do it in older armas then? meowsweats

cosmic lichen
#

There was a system for that, dont remember the name

little raptor
#

I think publicVar event handler?

tender fossil
#

@little raptor Yes, I use publicVariable EHs otherwise but in this case it's simpler to just use waitUntil (because I'm being lazy and don't want to refactor the whole code) 😄

winter rose
#

call RE

#

see Arma 2 Multiplayer Framework on the wiki

#

@little raptor

tender fossil
#
_skillPlayer = profileNamespace getVariable "WFBE_CL_VAR_SKILLPLAYER";
        
if (isNil _skillPlayer) then {   // <<--- FAIL
  _skillPlayer = 100;
};

The above code fails with "Undefined variable in expression: _skillPlayer"

robust hollow
#

isNil "_skillPlayer"

tender fossil
#

...

#

Hahaha 😄

#

See, I'm dumb

cosmic lichen
#

Saving that in profile? Nice 😄

robust hollow
#

does a2 not have the alt syntax where you define a default value?

tender fossil
#

Nope

robust hollow
#

you sure? the wiki has notes specifically for getVariable in a2

tender fossil
#

I think the alt syntax applies to Arma 3 only, no?

robust hollow
#

i dont think so

#

try it

austere granite
#

It was only defaults for specific namespaces

fair drum
#

if I do this function add method,

class CfgFunctions
{
    class myTag
    {
        class myCategory
        {
            file = "myPath";
            class myFunction {};
        };
    };
};

can I still do a preInit by placing it in class myFunction {preInit = 1};

robust hollow
#

yea

distant oyster
cosmic lichen
#

You pinged a green boi 😮 joke

cold pebble
#

@distant oyster I tested it this morning with someone sitting in a heli with slingload assistant open

#

I did cursorObject enableRopeAttach false and it was no longer on his assistant, then true gave back same functionality

#

Granted, the crate was local to me

distant oyster
#

hm yeah actually the arguments might need to be local

#

then the effect is global

torpid quartz
#

so i've got this code I got from a steam forum.
When i'm hosting a server and it's just me it runs fine. and in singleplayer too it also runs fine.

But how would i run this so everyone can see it when other people join the server? I tried executing it globally with the run code module but nothing happened for anyone.
Any ideas?

https://pastebin.com/wnMByJez

distant oyster
distant oyster
#

from initPlayerLocal.sqf if you want it to run every time someone joins

torpid quartz
#

was going to run during the mission at a half way point.
and uh, put it in a function? Not quite sure and I'm sure you don't mean just put [ all the code] remoteExce

Could i stick all the cod in a sqf file and remoteExce it? would that do it?

cold pebble
distant oyster
distant oyster
# cold pebble How confident are we the object needs to be local? 🤔

i tested it on a hosted server with another client running. when executing it on the hosting client (server which is the owner of the vehicle) it had an effect on all clients, when i executed it on the connected client it only had an effect on the hosting client / server / owner

torpid quartz
#

I'm just hosting stuff on my own PC at the moment for friends so it should be good, I guess?

distant oyster
#

yeah

torpid quartz
#

sick i'll try and text it in the next few days when i can get people on

distant oyster
#

you can also launch multiple arma 3 instances via command line / batch file

#

and test with yourself as host and client

torpid quartz
#

oh? wow I didn't know that I'll look into that it'll help a lot thanks!

distant oyster
torpid quartz
#

Thanks a bunch i'll have a good read of it

tender root
#

Okay I have a really dumb question:
What happens if I execute setPos / setDir on objects with createVehicleLocal?
Does this cause any issues, because setPos / setDir have global effect, but the object exists only locally or does it just work fine and Arma is smart enough to not broadcast the changes to other clients? 🤔

little raptor
tender root
#

Yeah obviously. I wouldn't have a reference to the object if I would execute on another machine 😄

#

Thanks a lot ❤️

#

tbh I didn't expect anything else but just wanted to make sure because it's Arma... 😄

quasi sedge
#

I want user "Saved_Loadout" in profile folder, not in mission, so each time when player connected to server mission, he already receives his loadout automatically.
How to rewrite this code?

[missionNamespace, "arsenalClosed", {
    profileNamespace setVariable ["Saved_Loadout",getUnitLoadout player];
    hint "Selected gear saved!"
    }] call BIS_fnc_addScriptedEventHandler;
player addEventHandler ["Respawn",{

        0 = [_this select 0] spawn {
        
            params [["_player",objNull,[objNull]]];
                waitUntil {sleep .2; alive _player};
                _player setUnitLoadout (profileNamespace getVariable ["Saved_Loadout",[]]);         
        };
}];
fair drum
#

will local variables be shared between codeStart/codeProgress/codeCompleted in holdaddaction if say the local variable was created in the codeStart scope? or do I have to use a set/get variable as a work around.

    {
        //codeStart
        params ["_target", "_caller", "_actionId", "_arguments"];
        private _nearUnits = allUnits select {_x distance _target >= 100};
        if !(_target getVariable "launcher_team" isEqualTo resistance) then {
            [server, [missionnamespace getVariable "server_channel", format ["%1 is now neutral and is being captured!", _launcher getVariable "launcher_name"]]] remoteExec ["customChat", allplayers];
        };
        _target setVariable ["launcher_team", resistance];
    },
    {
        //codeProgress
        params ["_target", "_caller", "_actionID", "_arguments"];
        private _handle = [
            {
                playSound "readOutClick";
            }, 1
        ] call hyp_fnc_addperframehandler;
    },
    {
        //codeCompleted
        params ["_target", "_caller", "_actionID", "_arguments"];
        _handle call hyp_fnc_removeperframehandler;
    }

looking specifically at _handle

willow hound
quasi sedge
#

@willow hound simple as that?

[missionNamespace, "arsenalClosed", {
profileNamespace setVariable ["Saved_Loadout123",getUnitLoadout player];
saveProfileNamespace;
    hint "Selected gear saved!"
    }] call BIS_fnc_addScriptedEventHandler;
player addEventHandler ["Respawn",{

        0 = [_this select 0] spawn {
        
            params [["_player",objNull,[objNull]]];
                waitUntil {sleep .2; alive _player};
                _player setUnitLoadout (profileNamespace getVariable ["Saved_Loadout123",[]]);
                
        };
}];
willow hound
#

Yes.

little raptor
#

you can use the argument I believe

#

it's passed as reference (if array)

dusky wolf
#

Been working on a freeze/unfreeze AI script for use in training environments. It's basically an add action to disable/enable simulation on all opfor. The addaction itself is added locally to the intructors but I've been having trouble setting up the remoteExec.

            params ["_target", "_caller", "_actionId", "_arguments"];
            missionNamespace setVariable ["ai_freeze", true];
            ((allUnits select {side group _x == east}) + (vehicles select {side group _x == east}) - (allPlayers)) apply {_x enableSimulationGlobal false;};
        },
        nil,        // arguments
        0,        // priority
        true,        // showWindow
        false,        // hideOnUse
        "",            // shortcut
        "!(missionNamespace getVariable ['ai_freeze',true])"     // condition
    ];```
#

I attempted to save the array to a variable to pass to the remoteExec but no dice

#
_eastAI = ((allUnits select {side group _x == east}) + (vehicles select {side group _x == east}) - (allPlayers));

{[_x, false] remoteExec ["enableSimulationGlobal", 2]} forEach units group _eastAI;
willow hound
#

While it is far more efficient to make a function that runs on the server to collect all the OPFOR units and disable their simulation, I can't see a reason why...

{
  [_x, false] remoteExec ["enableSimulationGlobal", 2];
} forEach (units east);
```... shouldn't work.
little raptor
#

allUnits select {side group _x == east}

#

units east

willow hound
#

What certainly won't work for multiple instructors is the addAction condition with ai_freeze, but that's a different topic.

fair drum
#

well I wanted to avoid having to load CBA up but its unscheduled framehandlers are too good. I wanted the mp mode to be available to the public without mods. Guess I'll have to be super careful and see if I can make it so only the server needs it.

little raptor
fair drum
#

i tried, but stuff gets pretty messy. they worked but the organization is garbage that I'm doing lol

willow hound
#

But what good does a PF EH do on the server?

fair drum
#

its just timings and everything is remotely executed from the server. I'm just trying to avoid waitUntils and sleeps

#

what I have currently. trying to have a loop on 120 seconds, with a waitUntil for the firing sequence to start. before it was a while loop with 120 sec sleep and a waituntil at the beginning. still trying to figure it out.

params [["_launcher", objNull, [objNull]]];

private _handle = [
    {
        [
            {
                _this getVariable "launcher_captured";
            },
            {
                private _team = _this getVariable "launcher_team";
                private ["_target"];

                switch _team do {
                    case west : {
                        _target = missionNamespace getVariable "westTarget";
                        [_target, "alarm_blufor"] remoteExec ["say3d", allPlayers];
                        [_this, _target] call hyp_fnc_launcherFire; 
                    };
                    case east : {
                        _target = missionNamespace getVariable "eastTarget";
                        [_target, "alarm_opfor"] remoteExec ["say3d", allPlayers];
                        [_this, _target] call hyp_fnc_launcherFire;
                    };
                };
            },
            _this
        ] call cba_fnc_waituntilandexecute;
    },
    120, _launcher
] call cba_fnc_addperframehandler;
#

i think I'm messing up arguments somewhere

willow hound
#

Was there something wrong with the while-loop?

fair drum
#

just trying to keep things out of scheduled environment for accuracy and lag.

little raptor
willow hound
#

Yes, I can't follow the rationale behind that either redchain

fair drum
#

you're right, it doesn't. but, I'm trying to learn a different way in the process which gives me more stuff in my brain bank to work with in the future. I'm trying to learn the CBA and ACE coding rules as well.

#

many of these things never get finished. I just like learning a new thing and figuring it out lol

willow hound
#

Well this right here certainly is an overcomplicated and erroneous approach if you ask me

fair drum
#

your not wrong. and part of the process is banging your head against the wall until you go... man, this really ain't worth it in the long run haha

#

which I'm about at

willow hound
#

This adds the same code to waitUntilAndExecute every 120 seconds by the way, so whenever launcher_captured finally returns true, all the accumulated instances of that code run.

fair drum
#

yeah, I see that now. I'll probably just go back to my original.

params [["_launcher", objNull, [objNull]]];

while {true} do {
    waitUntil {
        _launcher getVariable ["launcher_captured", false];
    };
    
    private _team = _launcher getVariable "launcher_team";
    private ["_target"];
    
    switch _team do {
        case west : {
            _target = missionnamespace getVariable "westTarget";
            [_launcher, "alarm_blufor"] remoteExec ["say3D", allplayers];
            [_launcher, _target] call hyp_fnc_launcherfire;
        };
        case east : {
            _target = missionnamespace getVariable "eastTarget";
            [_launcher, "alarm_opfor"] remoteExec ["say3D", allplayers];
            [_launcher, _target] call hyp_fnc_launcherfire;
        };
    };
    uiSleep 120;
};
willow hound
#

You can pull [_launcher, _target] call hyp_fnc_launcherfire; (and in theory also remoteExec) out of the switch and uiSleep is probably not what you actually want here, but other than that this looks pretty good.

little raptor
#

something like that needs sleep

#

(it's not UI related)

fair drum
#

already fixed

fair drum
#

so all of a sudden my custom chat channels just stopped working...
my customchannelID is 2.

radioChannelInfo 2 states it exists, and that my character is added, yet I cannot access the channel. direct commands to the channel do not show up either. I didn't change anything when it was working...

fair drum
#

i switched my editor to SP and it worked, then switched it back to MP and its now working... weird. I didn't change anything and no it wasn't disabled

#

sounds like i may have a editor mod conflict somewhere

#

hmm and few seconds later it stopped working again... interesting

#

so this is my creation function

if isServer then {
    private _channelname = "SERVER MSG";
    private _channelID = radioChannelCreate [[0.85, 0.4, 0, 1], _channelname, "GAME", [server]];
    if (_channelID == 0) exitwith {
        systemChat format ["Custom channel '%1' creation failed!", _channelname]
    };
    [_channelID] remoteExec ["hyp_fnc_radioChannelAdd", [0, -2] select isDedicated, _channelname];
    missionnamespace setVariable ["server_channel", _channelID, true];
};

and this is the player add function

params ["_channel"];
_channel radioChannelAdd [player];

it appears that it is creating the same channel on both indexes of 0 and 1, but it shouldn't ever return 0 because that means it failed.

#

as radiochannelinfo 0 and radiochannelinfo 1 return the same thing

little raptor
#

custom channels are in the range 6-15

#

you should add 5 to _channelID to get the actual channel

fair drum
#

yes, but when created they are the lower range. i believe only for things like enablechannel do you have to add 5

#

we don't even get that far anyways because even with the create channel, it doesn't let me access it with channel switch keys, even though my character shows its added to that channel

little raptor
fair drum
#

but I haven't given any enableChannel commands lol

fair drum
#

all channels 0-15 are [true, true]

little raptor
#

does it work then?

fair drum
#

let me try

#

returns false for that particular channel. all others are true

little raptor
#

either it's not added or not enabled 🤷

fair drum
#

radiochannelinfo returns [[0.85098,0.4,0,1],"SERVER MSG","GAME",[server,p1],false,true] which is my channel, and p1 my character is added