#arma3_scripting

1 messages · Page 133 of 1

errant iron
#

_unit setUnitLoadout getUnitLoadout _unit seems like a pretty easy workaround actually

gentle zenith
#

Is anybody aware of a way that somebody's scope sway could end up being zero? Without mission-side scripts or hacks?

#

To be clear getCustomAimCoef player equals zero

meager granite
#

Unless you have a script somewhere, sounds like a hack to me

sharp grotto
#

Repeated use of setunitloadout in a short time on the same player can also cause the sound to go quiet.

bleak mural
#

I had an idea concerning vehicle AI and being stuck... first off...is there any type of EH that is sort of like "istouchingobject"? i know theres condition IsTouching ground. But i had the idea,that if i vehicle is touching an object A) destructable, then check with a timeout of 60 seconds if its still touching it(stuck on destructable road barricade as in this example) or B) Is touching non dextructable object like rock or low wall(common map objects that they stuck on alot) if so: for A, setdamage1 to object or if B: hide object.

#

is this something that could work,without perfomance impact checking regularly?

#

it could cut in half how often vehicles get stuck indefinetly. the check could ignore buildings,just focus on certain object classes

proven charm
bleak mural
proven charm
#

check if its have move WP

bleak mural
#

your saying ONLY if it had move?

proven charm
#

then thats same as not moving

bleak mural
#

gotchya

proven charm
#

check for MOVE WP

#

or SAD etc

bleak mural
#

still wouldnt work though. as vehicles WILL stop to engage and continue wp after known threats are dead

#

it would end up deleting alot of walls and rocks around the area perhaps

#

imagine your bipoded on a wall,and a AAPC drives next to you,stops to engage,then a minute later your wall dissapears

proven charm
#

check that there is no enemies near before trying to unstuck, but I wouldnt go about deleting stuff but rather use script to move the vehicle to nearest road or something

#

I actually do that in my mission

bleak mural
#

yes setpos is a common usage

#

i do it too

#

but in my mind i was considering vehicles i dont have current eyes on

#

more dynamic

#

do you use it in a dynamic way or on your group?

proven charm
#

I move the vehicles

bleak mural
#

automatically/autonomously or a function you need to call?

proven charm
#

not sure what you mean, there is script running on each group that moves the stuck vehicles

bleak mural
#

can you share it? i meant was it used on demand,or constantly checking

#

so constantly checking right?

proven charm
#

yes constantly checking, I can share the script but its not standalone but depends on other functions

bleak mural
#

thanks man id appreciate it

proven charm
#

ill dm it to you

meager mist
#

Hey! I'm working on the AI Sector Searchlight script by ALIAScartoons but I didn't get it to work on a MP scenario, but not sure why. I keep getting a "Undefined Variable in expression: _v_chek" error on line 36 when loading it but from what I can tell , _v_chek is defined on line 10? The script is working in terms of its making the unit move the searchlight. But obviously this error is quite annoying. WHat am I doing wrong?

// nul = [this,100,3,"scan_1",true] execvm "AL_AI_scan\al_scan.sqf";

private ["_vik","_ai_scan","_alt","_ini_dir","_ini_poz","_alt","_rnd_fct","_delay","_v_chek","_fire_y","_v_chk"];
sleep 10;
if (!isServer) exitwith {};

_vik    = _this select 0;
_alt     = _this select 1;
_delay    = _this select 2;
_v_chk    = _this select 3;
_fire_y = _this select 4;

_ai_scan = gunner _vik;
_v_chek = missionNamespace getVariable _v_chk;

if (!isNil{_vik getVariable "activ"}) exitWith {};
_vik setVariable ["activ",true,true];

if (_delay < 1) exitWith {"I recommend using a higher delay than 1 sec"};

_ini_dir = getdir _ai_scan;
_ini_poz = getposASL _ai_scan;

if (_alt>0) then {_rnd_fct = 50} else {_rnd_fct=0};
if (_fire_y) then {_tur_lans = (_vik weaponsTurret [0] select 0);[_vik,_tur_lans,_v_chk] execvm "AL_AI_scan\start_fire.sqf"};

_obiect_comp = createSimpleObject ["A3\data_f\VolumeLight_searchLight.p3d",[0,0,0]];
_obiect_comp hideObjectGlobal true; 

[[_vik,_obiect_comp],"AL_searchlight\al_search_light_effect.sqf"] remoteExec ["execvm",0,true];
_obiect_comp hideObjectGlobal false;

while {alive _ai_scan} do 
{
    _v_chek = missionNamespace getVariable _v_chk;
    if (!_v_chek) then {
        _ai_scan enableAI "move";
        _ai_scan enableAI "target";
        _ai_scan enableAI "autotarget"; 
        waitUntil {_v_chek = missionNamespace getVariable _v_chk}; // Wait until _v_chek becomes true
        _ai_scan disableAI "move";
        _ai_scan disableAI "target";
        _ai_scan disableAI "autotarget";   
    };

    _angle = [(random 30),(random 30)*(-1)] call BIS_fnc_selectRandom;
    _watchpos = _ini_poz getPos [20+(random 100),_ini_dir+_angle];
    _watchpos set [2, (_watchpos select 2) + _alt + (random _rnd_fct)];
    _ai_scan doWatch _watchpos;

    sleep _delay + (random 3);
};
deleteVehicle _obiect_comp;
_ai_scan enableAI "move";
_ai_scan enableAI "target";
_ai_scan enableAI "autotarget";

link to demo scenario: https://steamcommunity.com/sharedfiles/filedetails/?id=1481699891

hallow mortar
#

_v_chek is defined by reference to another variable. If that variable doesn't exist, then _v_chek will also not exist. Trace the logic backwards.

#
_v_chek = missionNamespace getVariable _v_chk; // looks for a global variable with the name defined in _v_chk
_v_chk = _this select 3; // looks for the fourth (zero-indexed) parameter passed to the function

[this, 100, 3, "scan_1", true] execVM "..."; // that parameter is "scan_1"```
So it's looking for a global variable named `scan_1`, which must be defined as a Boolean (true/false) before the script runs.
#

This is a bit of a clumsy implementation on the script's part. Firstly...use params, man :U
Secondly, a syntax exists for getVariable that can assume a default value for the variable if it doesn't exist. Using that syntax would save the missionmaker having to define the variable ahead of time.

meager mist
#

I have this one in the init.sqf, I wondered if that's enough.

scan_1 = true; publicVariable "scan_1";

And then on the entity in the Editor it's called like this

nul = [this,5,3,"scan_1",true] execvm "AL_AI_scan\al_scan.sqf";

But would that mean that it's looking for the scan_1 parameters in the script sqf and not the init.sqf?

hallow mortar
#

Although the script has a 10-second sleep which should avoid that 🤔 but hey ho

#

However, the init.sqf thing is wrong in a different way. init.sqf runs on all machines, so the variable is defined on all machines, so publicVariable is not needed. And...init.sqf is run on all machines including JIP clients when they JIP. So if someone joins after the variable is set false to stop the script, their init.sqf will set it true again. Won't start the script again but it's dangerous.

#

I would suggest removing the pre-definition of scan_1 and just changing the script to use the other syntax of getVariable. Then you won't have to think about these problems at all.

#
_v_chek = missionNamespace getVariable [_v_chk, true];```
#

You can remove the null = from the start of your execVM calls btw. That's a workaround for an old problem with the Editor which no longer exists.

meager mist
#

I've been alt-tabbing like mayhem to understand it all ... But it's slowly getting there.
The getVariable pre-definition is mentioned twice, but I guess it's only needed in the while {alive _ai_scan} do part of the script? Because the first one is just defining it, and then the second one is to actually set the parameters of the syntax?

#

And regarding the null = It would then just become

execvm "AL_AI_scan\al_scan.sqf";
warm hedge
#

null = execVM "something.sqf" syntax was a workaround to long-term issue we had like 15 or so years. The null = part is not necessary right now, AFAIK

hallow mortar
meager mist
#

Oh yea, you're right.. I missed the 3rd. I'll comment out the first one for now.. Then the other two should look like something like this? (added a comment on the first one, to understand if I was correct)

while {alive _ai_scan} do // Script will change something defined below
{
    _v_chek = missionNamespace getVariable [_v_chk, true]; // Changes _v_chk to true 
    if (!_v_chek) then { // Script will then proceed with the following 
        _ai_scan enableAI "move";
        _ai_scan enableAI "target";
        _ai_scan enableAI "autotarget"; 
        waitUntil {_v_chek = missionNamespace getVariable [_v_chk, true]}; // Wait until _v_chek becomes true then does the following below.
        _ai_scan disableAI "move";
        _ai_scan disableAI "target";
        _ai_scan disableAI "autotarget";   
    };

    _angle = [(random 30),(random 30)*(-1)] call BIS_fnc_selectRandom;
    _watchpos = _ini_poz getPos [20+(random 100),_ini_dir+_angle];
    _watchpos set [2, (_watchpos select 2) + _alt + (random _rnd_fct)];
    _ai_scan doWatch _watchpos;

    sleep _delay + (random 3);
};```
#

Then in the units init I would put this line to make it run

execvm "AL_AI_scan\al_scan.sqf";
hallow mortar
meager mist
#

Is it as simple as just removing null = ?

[this,5,3,"scan_1",true] execvm "AL_AI_scan\al_scan.sqf";
#

I sometimes think WAY to hard about these :p

#

What about the scan_1 though? Because you mentioned that it won't be needed because we have defined it in the script itself now right?

hallow mortar
hallow mortar
#

I'm not totally sure what the expected behaviour of the script is, so you might need to change the default value to false rather than true.
I think it's true to stop the scanner where it is, and false to let it move. So the default value you need depends on whether you want it to move by default, or be stopped by default.

meager mist
#

The way the script is set up is that you can set up a trigger and if, for example in my mission, BLUFOR steps into that trigger, it'll stop the script. I assume it's for that purpose. The onActivation is set for

scan_1 = false; publicVariable "scan_1";

It has these parameters lined out in another .sqf

nul = [vehicle_name,watch_altitude,delay_scan,"control_variable",enable_random_fire] execvm "AL_AI_scan\al_scan.sqf";

vehicle_name        - string, name of the vehicle you want to simulate sweep scan and or fire
watch_altitude        - number, altitude in meters, useful if you want the AI to look upwards and simulate AAA scan or shooting, 
                        set it to zero if you want to keep AI watch direction more or less horizontal
delay_scan            - number, delay in seconds before AI selects another position/direction to watch at
"control_variable"    - string, is the name of a boolean variable you link the object to, it has to be between quotes "" to work, 
                        is a variable that allows you to control de script,
                        it needs to be defined when mission starts as true and before running the "AI Sector Scan script"
                        As long the variable is true the script will keep running, make it false via trigger or another script to stop the script
                        See the DEMO mission to see how you can use it
enable_random_fire    - boolean, if is true AI will shoot while scanning the area, if is false AI will only scan the sector
hallow mortar
#

Right, so I think its description of how the control variable operates is slightly wrong, because it doesn't match the actual code

#

It says setting the variable to false stops the script, but that's not the case; the loop's only exit condition is the scanner AI being dead

meager mist
#

And that's defined with this right? It kinda literally says whats it's supposed to do.. if the gunner of the vic (searchlight in this case) is alive... just loop

while {alive _ai_scan} do
hallow mortar
#

Yep. There's no other way of fully stopping the script.
I've figured out the way the toggle variable works. While it's true, the AI scans randomly. When it's false, the AI stops scanning and is allowed to turn and track targets.

#

So the comment is almost correct, setting it to false stops the AI from scanning. But it doesn't stop the script; if you set it to true again later, the loop is still running and will detect that and make the AI go back to scanning.

#

That's a reasonable design in itself, but it's not what the documentation says, and it's another reason not to define the variable in init.sqf (if someone JIPs while the AI is in shoot mode, their init.sqf will put it back into scan mode!)

exotic flame
#

Can i use onEachFrame on server side ?

#

I mean doesn't it require a graphical interface ?

fair drum
exotic flame
meager mist
#

It all works now flawlessy, also on dedicated 😄 So thanks so much for the help.. I understand it more now 🙂

drowsy geyser
#

having trouble with playSound3D command on a hosted server if i execute this example via debug consol it is hearable for everyone but if i use a custom sound the sound only plays for the executing player
wiki example:

playSound3D ["A3\Sounds_F\sfx\blip1.wss", player, false, getPosASL player, 1, 1, 100];

my sound:

playSound3D [getMissionPath "sounds\test1.ogg", player, false, getPosASL player, 1, 1, 100];
hallow mortar
#

That should work fine (source: I've done it)

drowsy geyser
#

i played the same sound with say3D and it worked without issues but playSound3D not

#

the problem with say3D is that the sound can hardly be heard as soon as you turn away from the sound source even though you are standing right next to it, idk if it is intended or a bug

hallow mortar
#

The only reason (that I can think of) why playSound3D might not be audible for everyone with that example is if the clients somehow had different versions of the mission file, one with the sound and one without. But I don't know how that would happen and that would break say3D as well.

It should work perfectly with your code, and I've done exactly that myself many times without problems.

drowsy geyser
hallow mortar
#

I've never noticed that myself

drowsy geyser
#

please test it xD

hallow mortar
drowsy geyser
#

no it is the actual code and the sound is defined in description.ext and plays for the host but not for the client but im executing it via debug consol idk if this could be the issue but the same sound plays for everyone if played with say3D

hallow mortar
#

Description.ext definition doesn't matter for playSound3D. It doesn't use config classes, it goes off the actual file path.
Debug console or not doesn't matter. playSound3D has global effect.

river sundial
#

Any scripted that could help me create a game mode? I am not much on arma 3 scripting so I figured I would try to find someone that can actually script lol

meager mist
#

Second scripting question of the day, after trying to figure it out for an hour .. I managed to find a script that downloads data from someone else, changed it to a HUD element and managed to change code so that it only adds the addAction if that player has a certain item in it's items.. But, it only checks on script load and nothing after that.. I tried while {true} do but obviously.. that just checks it every milisecond and overwhelms the server.. And I could not find any proper solutions online. This is the code:

T8L_fnc_addActionLaptop =
{
    {
        _items = items player;
            if !( _x getVariable [ "T8L_pvar_dataDownloaded", false ] && ("ItemcTab" in _items)) then
            {
                _x addAction [ T8L_var_TLine05, { call T8L_fnc_ActionLaptop; }, [], 10, false, false ];
            };
        } forEach allUnits;    
    }
};```
#

Im guessing there is a better way then just doing while {true} do and then sleep for a minute.. ?

#

Not sure if another/better way is to do is the findIf paramater..

waitUntil { { alive _x } count [unit1, unit2, unit3] == 0 } // slow, always goes through all array elements
granite sky
#

Depends what the methods are by which a player might acquire that item.

#

I don't think there's a general EH that fires whenever an item is changed in a unit's inventory.

hallow mortar
#

https://community.bistudio.com/wiki/addAction
addAction and BIS_fnc_holdActionAdd support conditions - code that must return true for the action to display. You can add the action freely and let the condition decide when it's displayed.

meager mist
granite sky
#

In this case I think the addAction condition is best, because it'll only be evaluated if the unit is in front of you.

meager mist
#

Ah, so if I set the radius to 2m or something, the item (the laptop) that gets the addAction will check within 2m if there is someone with that item?

granite sky
#

I mean addActions are only considered for the cursorObject.

#

So you add the action to everyone, and then it's only doing at most one "classname" in items _target per frame.

meager mist
#

I'll dive deeper into this at some point. I tried to convert this into something useful for me, but didn't have any luck. So maybe a break is needed..

player addAction ["Test Action","test_action.sqf",[],-1,false,true,"","((unitBackpack _this isKindof 'tfw_ilbe_a_gr') && ('tfw_rf3080Item' in (items _this + assignedItems _this)))"];
#

Obviously, this one check if the player has a backpack + an item in that.. and I'd only need 1.. but I kept getting errors :/

hallow mortar
#

What kind of errors?

meager mist
#

yea.. breaks help.

#

This is what I used. It calls this line for the action text: T8L_var_TLine05 = "Start Data Transfer"; THis is what I just used. and it just works flawlessy..

_x addAction [ T8L_var_TLine05, { call T8L_fnc_ActionLaptop; }, [], 10, false, false,"","('ItemcTab' in (items _this + assignedItems _this))"];
#

I think what I did was use && in between the call action and checking if the items is in the inventory... which obviously doesn't work.

bleak mural
#

can someone clarify the trigger interval for me?

#

quote BIKI: However, when trigger is attached to some object, the trigger will inherit the simulation frequency of the object it is attached to.

#

Does this mean interval setting is useless when attached to say a module from editor?

#

such as a show/hide module?

#

essentially i do not need my triggers checking every 0.5 seconds,and want to use many. so i want to put them on 5 seconds or so interval to play it safe performance wise

meager granite
#

Not sure exactly but it means trigger wont do a check more frequently than your module does its simulation (probably rarely)

#

Btw attached means attachTo command

bleak mural
#

some reason i thought of synced to

#

nice one

analog mulch
#

hello,
how do i make a custom song play for the player on the mission end screen, and instead of "Mission Completed" to show a custom text instead

#

song is in .ogg format in mission folder under "music"

hallow mortar
analog mulch
#

so i set playmusic part to false to stop the default arma music?

#

how will put the custom song instead then?

hallow mortar
analog mulch
#

so in the end trigger it will be:

[End1, true, true, false, false] call BIS_fnc_endMission;
playMusic "end1";

in description.txt:

class CfgMusic
{
tracks[] = {};
class end1
{
// display name
name = "ending";

    // filename, volume, pitch
    sound[]    = { "\music\ending", db + 0, 1.0 };

};

#

is this correct?

winter rose
analog mulch
#

.ext ofcourse

#

ty

winter rose
analog mulch
#

oh yeah tell me about it

cosmic lichen
winter rose
#

a Dragon - I don't want him to steal muh gold

abstract bay
#
     params ['_pos','_radius'];
     private _array_roadListFiltered = [];
     {
          if ((typeName _x) isEqualTo 'OBJECT') then {

_bbox = boundingboxReal _x;
_bbox params ["_a","_b"];
_size = _a distance _b;
if (_size < 25) then {_array_roadListFiltered pushBack _x};

          };
     } forEach (_pos nearRoads _radius);
     _array_roadListFiltered;
};

// usage

_array_roadSegments = [(position player),500] call TAG_fnc_filterJungleRoads;``` Where I should put this code, in init.sqf or? I don't understand what is usage
winter rose
#

if you don't need it, don't use it

abstract bay
#

I don't want AI vehicles to use footpaths because they will get stuck in jungles, I need it, so where to put?

oblique arrow
#

to provide an explanation of the code

abstract bay
oblique arrow
abstract bay
#

Third post

oblique arrow
#

Ah, that code is just to get all the big/small roads, its not actually to limit AI or anything

abstract bay
#

is there a way to block AI vehicles from using footpaths?

glossy pike
#

im making a drone view to screen script and ive got it working but how do i make it so that the place its viewing is loaded as its not close to any player at the start of the mission so all that loads is terrain how do i force load any objects and buildings there without having a player in the area?

#

also including the buildings included in the map

#

im also using a invisible target as the target if that helps so the drone view is always going to be stationary

solid ocean
#

so im making a vehicle spawn script and want to add a cool down on it so people cant spam spawn and create chaos with it this is what ive got so far but i get an error in game when i do it so what am i doing wrong here?

this addAction ["Create Vehicle", { 
    private _veh = createVehicle ["55th_Aslung_pattern_fuel_olive", getMarkerPos "pad1",[],0,"None"]; 
},nil,1.5,true,true,"","true",10,false,"",""];
sleep 90; 
patent goblet
delicate cedar
#

Hi @winter rose the other day you gave a script to hide editor placed markers for an specific side. I have a problem when i host the map on a dedicated server. I have mobile markers attached to vehicles using a script and those markers doesn't hide when players join the server. Is there anything i can do to hide them?

meager granite
#

Interesting observation about REing a data structure to same client twice:

arr = []; f = {arr pushBack _this}; [1,2,3] remoteExecCall ["f", [player, player]];
```, then
```sqf
[arr, (arr select 0) isEqualRef (arr select 1)]
```=>`[[[1,2,3],[1,2,3]],true]`
#

engine doesn't copy it twice and properly passes same object into RE function twice

#

same with hash maps

#

same with remote client

delicate cedar
#

I'll try with initPlayerServer

#

It doesn't work

meager granite
frosty barn
summer coral
#

howdy i have started making a optre mission where each player is supposed to spawn in their own cryopod before dropping in a drop pod, i have done some digging and found that the best way to do this is through an event handler. i have made an attempt at it and since this is my first time actually scripting i am likely making errors and not knowing what i am doing wrong so im hoping that somebody here can help me in the right direction. My current code is this sqf scrub1 addMPEventHandler ["MPRespawn", { scrub1 moveInCargo pod1 }]; however its not working and im not sure what it is im doing wrong plan is that when a player respawns it moves them to their own cryopod, this is to eliminate people attempting to spawn in the same pod. Any help would be much appreciated

warm hedge
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
summer coral
meager granite
#

Where do you have this code?

summer coral
#

i had it on the player itself, i tried it first with respawn instead of mprespawn but that didnt change it. do i need to put it in a SQF file

meager granite
#

What is pod1? Same object that is always present on the map for players to spawn in?

#

If you want to have it as Init field in editor, try something like:

this addMPEventHandler ["Respawn", { params ["_unit", "_body"]; _unit moveInCargo pod1; }];
summer coral
#

yes my apologies i should have specified. pod1 is the variable name for the cryopod which is always present, scrub1 is the variable name of the unit for that pod

meager granite
#

Add my line to each player, change pod1 to other pods as needed

#

Can pods be occupied later? What if player respawns and there is already somebody in the pod?

summer coral
#

i could have used a module but i dont trust the people i play with to spawn one at a time

summer coral
meager granite
#

What happened and what did you expect?

summer coral
#

what i expected was to be teleported into the pod upon spawning, what happened was that i still spawned on the respawn marker

meager granite
#

spawning the first time or respawning?

summer coral
#

both

meager granite
#

Respawn only handles next spawns

#

Where did you add this line to? Your playable unit init line?

#

In 3DEN or Zeus?

summer coral
#

added it to the playable unit in the 3DEN editor

meager granite
#

Try respawning and see if it works

summer coral
meager granite
#

Change moveInCargo to moveInAny

#

Add logging inside Respawn code to see that it runs

#

diag_log str ["Respawn just ran!", _unit, pod1];

#

check RPT what it logs

rich falcon
#

I'm using DSA and the enemies appear in the form of a civilian, but a hostile one (Friendly units also fire at them), and I want to have an objective to survive, with the win condition being all the spooks are gone, but I can't use a simple civilian presence otherwise dead bodies would be counted, so I'm wondering if it's possible to check if a specific infantry role is present in a given area?

summer coral
meager granite
#

Try more basic setup, change pod1 to some random car

cobalt path
#

I am wondering, is there a way to spawn IR laser. Like the one on your gun, but spawn it and point it into the sky?

#

One way I can think is maybe spawning a civ unit with a laser and forcing it to look up and hiding it. But I am prettu sure, hiding the model will hide the laser

hallow mortar
#

drawLaser

cobalt path
# hallow mortar `drawLaser`

Thanks!
Altho I am having some isses, any ideas why this doesnt seem to work?

addMissionEventHandler ["Draw3D", { 
 drawLaser [ 
  getpos mfbeacon1, 
  [0,0,1], 
  [1000, 0, 0],  [], 
  5, 
  20, 
  -1, 
  false 
 ]; 
}];
warm hedge
#

Doesn't work how

cobalt path
#

as in nothing happens

warm hedge
#

Are you sure? drawLaser takes a positionASL

cobalt path
#

I mean the vector should be going up and it should be a thick ass laser coming from the mfbeacon1 object, I would see it

still forum
still forum
meager granite
#

remote player also got it twice and it was same array and hashmap

#

So it is reliable

still forum
#

What if you locally set into the first array, so modify it.
Then the second remoteExec being received creates a new copy?

#

remoteExec doesn't have any history about what it created in the past, that doesn't make sense

meager granite
#

It is new copy on each RE receiving, but engine unserializes it only once, then feeds into REd function however many times that target was specified

cobalt path
meager granite
#

Nothing wrong or broken here, it was just interesting to know that unserialized data is built just once

meager granite
#

All good, I was just checking if deserealized data was built once more if you RE it to same client by listing their entity twice. It doesn't and its good.

still forum
#

Oh so you are doing ONE remoteExec. And one remoteExec passes only one variable. yeah
You said "REing a data structure to same client twice" But you only do it once

meager granite
#

Was looking for a way to prevent second execution and thankfully data is the same and isEqualRef check solves it

#

Was using crew _vehicle as RE targets and there is no way to only select unique RE targets from client side

brave venture
#

I have ran into a wall I can not overcome. I am trying to make a script to attach one object to another object's selection and follow the selection's movement. Basically the attachto function but for a selection. Is there a way to do it? I could not figure out a way to track pitch, roll, and yaw.

proven charm
brave venture
#

I wish. If it was for only attaching to one specific object, sure, but not for attaching it to any object. I could not find a way to find the mempoint for a random object I want to attach to short of getselectionbones and that is still in dev build. I also question how useful it will be since the attachto biwiki says:

hallow mortar
#

That's specific to triggers. If you're using anything other than a trigger, that note doesn't apply

proven charm
#

im not expert in attachTo but the example 5 shows drill on the hand

brave venture
#

ok so it will work with getselectionbones then.

brave venture
hallow mortar
#

That's not an attachTo problem, it's a problem with the design that has led to the selection being completely unknown

#

Attaching objects to an arbitrary selection with rotation following is completely possible: _object attachTo [_otherObject, [0,0,0], _selectionName, true];
The problem you seem to have is with finding the name of the selection you want to use. The solution to that depends hugely on what exactly the script is meant to do.

still forum
#

How do I find out if player is currently aiming down weapon sights?

meager granite
#

cameraView == "GUNNER"

sullen sigil
#

theres still not a getter for if the gun is able to be fired on the next fire command

brave venture
#

Thnak you. You made me realize I was being a massive idiot and missed the obvious answer staring me in the face since day 1.

tepid notch
#

The new arma update sees double damage to the one unit. Is there a way to disable this?

"HandleDamage" can trigger "twice" per damage event. Once for direct damage, once for indirect damage (explosive damage). This can happen even in the same frame, but is unlikely.

^^ here is the wiki on the new eventhandler: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage

I run escape servers that see players unconscious but not dead. The double deaths bug out the player & they get revived into a locked camera view. I tried entering this code when they are revived, but it didnt work:

// Start Arma3 player bugged fix     
    private _display = findDisplay 46;
    if (!isNull _display) then {
        (_display) displayRemoveAllEventHandlers ["KeyDown", "MouseMoving", "mouseZChanged"];
    }

    _unit switchCamera "Internal";
    [] _unit call ATHSC_fnc_exit;
// End Arma3 player bugged fix     
hallow mortar
#

handleDamage is not a new event handler and it firing multiple times per damage event isn't new

slender beacon
#

Hey! I'm working on a custom background scene, but I can't get the camera to work! It spawns its own player unit in the sky instead of mine in a hidden place, and the view doesn't switch to the camera. Any common mistakes I might be making?
here's my init.sqf

player enableSimulation false;
player hideObject true;
enableEnvironment false;
showCinemaBorder true;

_camera = "camera" camCreate getPosATL campos;
_camera cameraEffect ["internal", "back"];
_tar=selectRandom [phen,airfield,sovi];
_fov=0.7;
if (_tar==phen) then {_fov=selectRandom [0.25];};
_camera camPrepareTarget (_tar);
_camera camPrepareFOV _fov;
_camera camCommitPrepared 5;
_camera spawn {_camera=_this;
    while {sleep 20; true;} do {
        _tar=selectRandom [phen,airfield,sovi];
        _fov=0.7;
        if (_tar==phen) then {_fov=selectRandom [0.25,0.25,0.25,0.7];};
        _camera camPrepareTarget (_tar);
        _camera camPrepareFOV _fov;
        _camera camCommitPrepared 5;
    };
};
bleak mural
#

Not sure if this is more an editor or scripting Q: But what im trying to do is something a little dynamic. drawing a blank on a dynamic way to achieve it. I want to have a small regroup or rally point area, so a trigger. and in it,there will be a group(could be any) and i need the next group to enter it,all of them to join group of the first group.

#

is this possible? without waypoints or variable names?

meager granite
bleak mural
#

variable names can work,its just theres gona be 10 or more groups

meager granite
#

Engine does two fake-y HandleDamage fires, one for bleeding, another for some head damage that it doesn't apply unless its a fatal hit

#

You can skip these out of your calculations with _context > 2 check

#

new parameter in 2.16

#

This line about direct and indirect damage is also false and needs to be removed from the wiki

#

🤓

#
"HandleDamage" is persistent. If you add it to the player object, it will continue to exist after player respawned.
```This is true for all entity event handlers
frigid spade
#

does "break;" kill all loops everywhere or just any loop it's inside of

meager granite
slender beacon
#

got it!

delicate cedar
#

Sorry, i add the markers in the editor and the script executed in the init of the vehicle/heli relocate and attach them to the vehicle

winter rose
granite sky
#

allMapMarkers

frigid spade
granite sky
#

It'll break the inside one.

frigid spade
#
_posFound = false;
_randomPos = [];
for "_i" from 1 to 6 do{
        while {!_posFound} do
        {
            _randomPos = [_first_objective,100,300,0,2] call BIS_fnc_findSafePos;
            if (_randomPos = [0,0,0]) then 
            {
                break
            } else {
                _posFound = true;
            };
        };
    _waypoint = _grp addWaypoint [_randomPos, 1];
    _waypoint setWayPointType "SAD";
};

trying to get this to find random waypoints near a position for boats to attack and if it can't find one just break out of it
but i'm getting "error missing '('" on the if statement line

delicate cedar
granite sky
#

if (_randomPos = [0,0,0])

#

should be isEqualTo

frigid spade
#

thank you, i forget that I have to use that
which makes me feel even dumber because in other languages it wouldve been "==" so i was wrong twice lol

granite sky
#

nods

granite sky
#

Also you're probably doing it wrong with findSafePos. That thing does something like 1000 attempts itself, so wrapping it like that is... odd.

#

Actually the while just doesn't do anything?

bleak mural
# fair drum repeatable or just once?

repeatable. the idea: 10 squads start the scenario. over time they will dwindle down from 8 strong to X strong. i want to essentially,at any point ,merge two or three squads together. i would like to do this in a particular area such as a custom retreat point to

stable dune
bleak mural
# fair drum standby

if you can can create a solution youll have saved me tonnes of time, was about to give up on this. each group also has a variable name and same callsign,id need to keep at least one of the groups variable names as all groups in OP have wp's and events based on name happen

fair drum
# bleak mural if you can can create a solution youll have saved me tonnes of time, was about t...
// --------------------
// Type: None
// Activation: Anybody
// Activation Type: Present
// Repeatable: True
// Server Only: True
// --------------------

// Condition
private _units = thisList select {_x isKindOf "CAManBase"};
private _groups = [];
_units apply {_groups pushBackUnique (group _x)};

count _groups >= 2;

// Activation
private _units = thisList select {_x isKindOf "CAManBase"};
private _groups = [];
_units apply {_groups pushBackUnique (group _x)};
if (count _groups < 2) exitWith {false};

diag_log format ["Trigger %1:: More than 2 groups detected... merging...", thisTrigger];

while {count _groups > 1} do {
    private _parent = _groups select 0;
    private _toMerge = _groups select (count _groups - 1);

    diag_log format ["Trigger %3:: Group %1 merged to %2", _toMerge, _parent, thisTrigger];

    units _toMerge join _parent;
    _groups = _groups - [_toMerge];
};

have fun

frigid spade
bleak mural
#

gona fire it up

#

server only? false is ok? its SP

fair drum
frigid spade
fair drum
#

@bleak mural updated

bleak mural
#

it works perfectly.

#

my idea for a use for it in a SP mission was related to giving player pilots more tasks...if groups out in the field get dwindled down,theyll pick up weakened squads,exfil back to a FOB,then go get another diminished squad,do same,and get em to full strength with your code here, then fly em back to the front. Thanks so much

winter rose
delicate cedar
#

Thank you lou! ill try it just now

abstract bay
winter rose
#

vehicles drive where they can

delicate cedar
abstract bay
#

how can they? AI vehicles use the footpaths in the jungle, vehicles often end up there deep in the jungle and get stuck. their suffering should be alleviated

little raptor
#
{
  _x setDamage 1
} forEach (vehicles inAreaArray jungle)

no more suffering

#

but to answer seriously, which terrain are you using? footpaths should use the "trail" (iirc) road type. if they don't the vehicles will use them too
if you're using a vanilla map you can report it in #arma3_feedback_tracker and it might get fixed

granite sky
#

It is normal behaviour on Tanoa, I guess because the jungle tracks are marked as TRACK rather than TRAIL.

coarse dragon
#

is there a script that can remove all Nades from the AI?

#

even ones from mods?

#

nvm found it lol

tribal lark
#

Is there a known workaround for GetIn/GetOut event handlers not firing for seat changes? I have script that gives the driver of a vehicle a couple actions, but I can't figure out how to add them from a seat change vs. getting in the vehicle normally

fair drum
tribal lark
summer coral
terse tinsel
#

Is there any way to make a vehicle invisible but still move?

languid vapor
terse tinsel
summer coral
# meager granite post your final EH code

here it is sqf scrub1 addEventHandler ["Respawn", { scrub1 moveInAny pod1;}]; I also want to not that i also ran the event handler seperately and it worked ```sqf
scrub1 addEventHandler ["Respawn", { scrub1 sideChat "respawned";}];

#

maybe im just thick and im missing something

meager granite
#

You can't use scrub1 inside event handler, I posted you a version with params and _unit

#

Because it still points to old dead unit at this point during respawn

summer coral
#

so this ```sqf
_unit addEventHandler ["Respawn", { _unit moveInAny pod1;}];

meager granite
#

No, use the code I gave you

#

_unit is undefined on yours

#

you need to get it from EH with params first

summer coral
#
this addMPEventHandler ["Respawn", { params ["_unit", "_body"]; _unit moveInAny pod1; }]; 
meager granite
#

Yes

#

Add this to the unit's init field

summer coral
# meager granite Add this to the unit's init field

unfortunately same as before and im starting to think that while it should work in theory that it just wont work ive been at this for three days now to no avail, i thank you for trying to help me i will continue to research and make attempts at it but it may be frivilous.

meager granite
#

Try having it in most simple setup

#

New mission, one respawning player, some vehicle as pod1

#

see if it works there

summer coral
#

will do

meager granite
#

Vanilla assets too

summer coral
#

ok that worked so perhaps its the mods?

#

or the mission maybe?

#

well its not the mods

meager granite
#

Other scripts messing something up maybe

#

Try your mission but haave some vanilla vehicle for pod1

summer coral
#

didnt work in that mission, fortunately it was a mission made for the purpose of testing the spawn thing

#

it was just a vr with a spawn point and somecryobays

grizzled cliff
summer coral
#

maybe it was my previous event handler messing it up

#

found the issue

#

it was the humble respawn timer, appearently it only works when there is no delay

summer coral
mystic scarab
#

Hello, can anyone help me disable curator features for a specific curator through sqf? I'm trying to enable Zeus for a platoon leader so they can order units inside vehicles and I need them to not be able to change unit skill or health.
This is my code so far:

[alpha_1_actual_curator, "object", ["UnitPos", "Exec"]] call BIS_fnc_setCuratorAttributes; //set attributes

alpha_1_actual_curator addCuratorEditingArea [1, [0,0,0], 0];
removeAllCuratorAddons alpha_1_actual_curator;
while {true} do {
    _cameraLimit = ((getPos curatorDrone)#2)+5;
    alpha_1_actual_curator addCuratorCameraArea [1, getPos curatorDrone, 10];
    alpha_1_actual_curator setCuratorCameraAreaCeiling _cameraLimit;
  sleep 1;
};

I plan to add handling for designating a drone and change the while to while the unit is alive, but first I want to check if using Zeus for this is possible.

tepid notch
#

@meager granite Thanks for the info. I think you are right, the new _context parameter has broken co10 Escape game mode, causing multiple deaths.

Just wondering how to turn _context off so it defaults to handling damage like it was before update 2.16?
Changelog states: Tweaked: "HandleDamage" event was extended with additional context.

I tried adding this into initplayerlocal.sqf but it didnt work:

player addEventHandler ["HandleDamage", {
    private _context = 0;
    params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
    if (_context > 0) exitWith {}; 
}];

This is what each value in _context relates to:
context:

0 : TotalDamage - total damage adjusted before iteration through hitpoints
1 : HitPoint - some hit point processed during iteration
2 : LastHitPoint - the last hitpoint from iteration is processed
3 : FakeHeadHit - head hit that is added/adjusted
4 : TotalDamageBeforeBleeding - total damage is adjusted before calculating bleeding

Love your work on KOH & wasteland. I have had hours of fun playing those.

meager granite
#

As for fixing it, you'll need to find HandleDamage in mission itself and make it ignore EH calls with _context > 2

tepid notch
#

@meager granite ok thanks. In the escape game mode you go unconscious after being hit and the player goes into a 3rd person camera mode. After the update you get two kill messages and get stuck in the camera view after a revive 😞

meager granite
#

Update shouldn't have changed anything about HandleDamage 🤔

grizzled cliff
#
        object create_vehicle(std::string type_, vector3 pos_, std::vector<marker> markers_ = {}, float placement_ = 0.0f, std::string special_ = "NONE")
        {
            game_value_array<5> args({
                game_value_string(type_),
                game_value_vector3(pos_),
                game_value_array_dynamic<marker, game_value_string>(markers_),
                game_value_number(placement_),
                game_value_string(special_)
            });

            return std::make_shared<object_ptr>(host::functions.invoke_raw_unary(__sqf::unary__createvehicle__array__ret__object, args));
        }
#

C++11/14 ftw

calm ruin
#

What do I need to enter into my server's difficulty settings to disable the shift+click marker on the map. Trying to teach my guys legit land nav and be sure they arent cheating lol

hallow mortar
#

I believe it's the waypoints difficulty option

timber bison
#

How can i show a german Ü in the strings of a script?

winter rose
#

typing it?

#

and save the script file as UTF-8

meager granite
#

Yeah, its about saving in proper encoding

#

Otherwise you can do toString [220]

timber bison
#

okey thanks

meager granite
#

Wishing for something like setNoNil to skip setting the value if its nil:

hs = createHashMap;
private _value = player getVariable "var";
if(!isNil"_value") then {
    hs set ["var", _value];
};
```=>
```sqf
hs = createHashMap;
hs setNoNil ["var", player getVariable "var"];
tepid notch
#

@meager granite thanks so much for your help. I added an ignore above _context 2 in the HandleDamage event handler & everything seems to be back to normal.

if (_context > 2) exitWith {};

🍺

jaunty ravine
#

Hello, I am wondering if there's any way to fetch the "eyePos" of an elevated commander turret (Strider/Fennek) for use in scripts.

winter rose
#

does eyePos commander _theTank work?

jaunty ravine
#

That seems to just register the eyepos of the actual commander unit inside the vehicle as opposed to the actual turret "eye"

winter rose
#

oh, then config browsing will tell you

jaunty ravine
jaunty ravine
drifting dome
#

I'm trying to make a static detonator for some explosives, and am having issues.

/*Code for creation of "TNTarray". Done with "Game Logic" module in 3DEN. This, as far as I can tell works.*/
private _TNTarray = ["tnt1", "tnt2", "tnt3", "tnt4", "tnt5", "tnt6", "tnt7", "tnt8", "tnt9", "tnt10", "tnt11", "tnt12"];
/*Code for the detonator. Placed in the items init. This throws the error "Missing ;" for some reason I can't seem to spot.*/
this addAction ["Detonate TNT", {setDamage 1} forEach _TNTarray];

Thanks for any help!

jaunty ravine
winter rose
#

yes, this addAction code is an entirely different script, so it doesn't know about _TNTarray

drifting dome
#

wait is the "_x" serving as a sort of proxy object here? then the "forEach" command defines the x?

jaunty ravine
drifting dome
#

for some reason the "addAction" doesn't seem to work, it isn't adding any action I can perform on the object

jaunty ravine
#

Make sure the entire forEach is enclosed by { }

drifting dome
#

it is yeah

#

I just dumped what you wrote into the object 😅

jaunty ravine
#

Then I haven't a clue, unfortunately.

#

Make sure you read what Lou said as well, he's probably forgotten more about SQF than I know.

drifting dome
#

I have a suspicion it's the object itself being weird, trying with one I know has worked with "addAction" before

#

yeah it is lol, guess I'll have to find another detonator prop

#

it's now throwing an error saying _TNTarray is an undefined variable, I suppose that indicates that the array hasn't been made successfully?

drifting dome
#

sadly I don't understand what that means lol, I'm not very good at this stuff 😅

jaunty ravine
drifting dome
#

I suppose I could just define every single explosive like this?

forEach "TNT1, TNT2, TNT3, etc.";
jaunty ravine
#

You'd have to format it as an array.

#
forEach ["tnt1", "tnt2", "tnt3", "tnt4", "tnt5", "tnt6", "tnt7", "tnt8", "tnt9", "tnt10", "tnt11", "tnt12"];
drifting dome
#

ooh yess thank you, I forgot how to 😅

jaunty ravine
#

No worries! I wish you good luck on your journey.

hallow mortar
#

Although the action code is a separate scope to the script that created the action, addAction supports arguments - information passed from the creating scope into the code scope

#

You could also make your array a global variable (no _ prefix), which can be accessed by any script on the machine where it was created

bleak mural
#
0 setOvercast selectRandom [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
#

isnt this syntax correct?

#

entering it via mission init

#

no error,just isnt picking a random overcast setting

#

oh i got it nvmind

#
[selectRandom [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1]] call BIS_fnc_setOvercast;
clear leaf
#

Is there a Way on How i can get my Ai to go to the waypoint exact location without like stoping a little bit away or something like that. Like when there is a car i front of him he keeps distance even when he is in careless mode Can i script it somehow to make hem go realy close op to it?

bleak mural
#

if you want,you can give a wp to where u want vehicle to go,then another final wp right next to it

#

that way it "should" go to exactly where the 2nd last wp was

frozen seal
#

Hello! Question to sqf experts. Why does this code return false? Aren't _a and _b referencing the same object? Or is something different understood in sqf by "reference"? (I'm coming from C# background where similar code would return true)

_a = zeus_indfor;
_b = missionNamespace getVariable "zeus_indfor";
hint(str(_a isEqualRef _b));
drifting spire
#

What are all the possible damage types for ace_medical_fnc_addDamageToUnit?

winter rose
#

or (round random 10) * 0.1 😄

hallow mortar
granite sky
#

(floor random 11) * 0.1 nearly works except it can roll 11 occasionally (until 2.18 hopefully)

granite sky
frozen seal
granite sky
#

Most things in SQF are peculiar :P

frozen seal
#

haha true

sullen sigil
#

is there an equivalent to bis_fnc_exporteditorpreviews for weapons?

granite sky
#

isEqualRef is only relevant for arrays and hashmaps, I guess.

frozen seal
#

Ok I'm about to go insane, what the hell is happening? This code works fine in SP/Local MP:

fn_GetTellArrayLocal = {
    params ["_receiver", "_fileName", "_subtitle"];
    _array = [_receiver, "Say", "radio", ["1", {}, _subtitle, [_fileName]], "DIRECT"];
    _array
};

zeus_indfor kbAddTopic ["Say", "radio.bikb"];
_tellSub = "Cut the bullshit, Petrovich. You know exactly why we're here.";  
_tellArr = [Petrovich, "\rs\petro_j2_real.ogg", _tellSub] call fn_GetTellArrayLocal; 
zeus_indfor kbTell _tellArr;

However, on Dedicated Server it only works if zeus_indfor is an AI. It does **not **work if zeus_indfor is a player 😭
This code returns true so the player has the topic:

hint(str(zeus_indfor kbHasTopic "Say"));
#

Do I need some special magic to call kbTell on players on DS? Players do speak in local MP.

faint oasis
#

Hi, i have a question ? how can i know the damage that will be applied in the event "HandleDamage" ? Because i tried to put

this addEventHandler ["HandleDamage", {
    params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
    
    if ((damage _unit) >= 0.9) then
    {
        hint "Avoided !";
        0
    };
}];

but it's not working, the unit can still die, i'm not sure if the (damage _unit) is the damage before or after but i think it's before since it's not working. now the "_damage" parameter of this event seems to give a value according to all hitpoints so i'm not sure what i should do with that one.

fleet sand
faint oasis
# fleet sand Something like this myb: ```sqf this addEventHandler ["HandleDamage", { para...

Yeah i made something really similar to you so thank you because it's working

this addEventHandler ["HandleDamage", {
    params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
    
    private _damage_to_deal = _damage;
    
    if (_damage >= 0.95) then {
        _can_pass = false;
        _damage_to_deal = 0.99;
    };
    
    _damage_to_deal;
}];
#

but it's just that except the "hitHead" and "hitBody" on 1, the rest won't kill the unit but strangely, when there is a hit on "hitAbdomen" it seems to change the "hitBody" too so i don't really know. Btw atm i'm using the damage parameter no matter of what has been hit, it seems to work perfectly.

fleet sand
faint oasis
#

but since i'm not sure what could lead to that, i will keep disabling damage

fleet sand
faint oasis
#

i will try to play around with that event and see what i cando

faint oasis
drifting spire
#

What are all the possible damage types for ace_medical_fnc_addDamageToUnit?

faint oasis
fleet sand
stable dune
# faint oasis no why ?

Just for if legion example doesn't work. Because ace uses its own damage Handling and you need to do that differently

#

And usually ppl doesn't tell are they using ace or not

drifting spire
#

are you not able to assign variables in switch cases?

#
_damageLevel = "light";
switch _damageLevel do { 
 case "light": { //0.3 
  _spot = "medical_spot_1"; 
  _min = 0.0; 
  _mid = 0.3; 
  _max = 0.6; 
 }; 
 case "medium": {//0.5 
  _spot = "medical_spot_2"; 
  _min = 0.1; 
  _mid = 0.5; 
  _max = 0.7; 
 }; 
 case "heavy": {//0.7 
  _spot = "medical_spot_3"; 
  _min = 0.3; 
  _mid = 0.7; 
  _max = 0.9; 
 }; 
 case "random": {//0.5 
  _spot = "medical_spot_4"; 
  _min = 0.0; 
  _mid = 0.5; 
  _max = 0.9; 
 }; 
}; 

in this case, _min, _mid, and _max never changes.
I have to assign the switch to a variable and add a return to get any information out.

#
_damageLevel = "light";
_info = switch _damageLevel do { 
 case "light": { //0.3 
  _spot = "medical_spot_1"; 
  _min = 0.0; 
  _mid = 0.3; 
  _max = 0.6; 
  [_spot, _min, _mid, _max]; 
 }; 
 case "medium": {//0.5 
  _spot = "medical_spot_2"; 
  _min = 0.1; 
  _mid = 0.5; 
  _max = 0.7; 
 }; 
 case "heavy": {//0.7 
  _spot = "medical_spot_3"; 
  _min = 0.3; 
  _mid = 0.7; 
  _max = 0.9; 
 }; 
 case "random": {//0.5 
  _spot = "medical_spot_4"; 
  _min = 0.0; 
  _mid = 0.5; 
  _max = 0.9; 
 }; 
}; 
_info

like so

#

(only tested for light)

delicate cedar
#

Hi guys, im using the incontinentia's undercover script. I dont know if anyone is familiar with it. Im tryng to figure out if there is a function to make AI spawned by, zeus or using a recruit module like SpyderAddons one go undercover too

hallow mortar
drifting spire
#

oh, that's pretty nuts weird

#

The wiki doesn't mention this, I don't believe

hallow mortar
drifting spire
#

You CAN create variables in If statements, though, right?

hallow mortar
#

You can create them but they'll be destroyed when the scope ends

drifting spire
#

huh, neat.

#

I guess I've never noticed it

hallow mortar
#

(note: all this only applies to local variables, global variables persist regardless)

fair drum
drifting spire
#

idek what a hashmap is

#

The only thing I might know is linear look up times from a meme I saw years ago

fair drum
#

eh don't worry about it then. its just a key value pair and does really well with stuff like this, especially when you start getting lots of elements

hallow mortar
#

Hashmaps are really good for saving performance with big data sets, but when you have four (4) cases in your switch, it really doesn't matter

sullen sigil
#
private _myvar = 123;
if (true) then {
  // new scope
  private _yeahyeahyeah = 4567;
  _myvar = 343434343434;
};
systemChat str _myvar; // prints 343434343434
systemChat str _yeahyeahyeah; // doesn't print as inner scope killed _yeahyeahyeah when it finished
edgy salmon
#

Hi, i have a problem. I want to loop an alarm sound on a trigger when a player is detected by ai. But it ends before it plays (it starts up like a air raid siren) does any one know how to set it up so it plays the full thing and repeats it?

drifting spire
fair drum
edgy salmon
#

Well, a trigger and the base alarm sound under the effect tab. It's set to if blufor detected by opfor. Nothing more

fair drum
edgy salmon
#

G, thanks

manic flame
manic flame
#
private _timeline = [
    [
        0, {
            [markerSize "start", markerPos "start", 0] spawn BIS_fnc_zoomOnArea;
        }
    ],
    [
        5, {
            [markerSize "adv_1", markerPos "adv_1", 5] spawn BIS_fnc_zoomOnArea;
        }
    ]
];

[_timeline, 0, nil, allMapMarkers, "start"] spawn BIS_fnc_animatedBriefing;

// timeline, index, hide, show, end, code

waitUntil {
    !(missionNamespace getVariable ["BIS_fnc_eventTimeline_playing", true]);
};

Is this okay? I keep getting a params error in the file

versed belfry
#

Is there a way to check if a unit is a "drone" or "drone unit"?

I am working on a script that triggers on the initialization of any unit and it seems to even affect units inside drones which it shouldn't.

drifting spire
#

I have no clue about drones, but maybe check if the unit is "inside" of a vehicle that is a drone

#

but tbh I don't know how drones work

fair drum
versed belfry
fair drum
#

you could possibly check for the existance of a config property "uavCameraDriverDir" or "uavCameraDriverPos"

versed belfry
#

I need the script to work regardless of what mod the drone is from, hence why that'd be problematic.

versed belfry
warm hedge
#

getNumber (configOf _uav >> "isUAV") == 1 to detect if it is an UAV
getText (configOf _unit >> "simulation") == "UAVPilot" to detect if it is an UAV Pilot

fair drum
#

even better

drifting spire
#

probably best solution

#

SQF wizards reside in this chat.

#

uhh

#

Not sure I'd call em that.

versed belfry
#

Just googled it, Jesus, apologies.

drifting spire
#

LMAOOO

manic flame
# fair drum whats the error?

It errors on the BIS_fnc_animatedBriefing file, gives me param Errors

[
[ "_timeline", [], [ [] ] ],
[ >
 0:31:23   Error position: <params
[
[ "_timeline", [], [ [] ] ],
[ >
 0:31:23   Error Params: Type String, expected Array
 0:31:23 File A3\Functions_F_Tacops\Systems\fn_animatedBriefing.sqf, line 22
fair drum
versed belfry
# drifting spire LMAOOO

Moment you said "Not sure I'd call em that" my brain went "I feel like I am missing something"

versed belfry
fair drum
manic flame
#

I thought so as well!!! But i wasnt too sure

fair drum
#

you actually need:

[<2DArray>, <number>, <string>, <array>, <array>, <string>, <bool>, <code>] spawn BIS_fnc_animatedBriefing

manic flame
#

yeeeea

fair drum
#

I'll change the wiki page

manic flame
#

👍 ty man, just wasnt too sure if it was a me issue or a general issue lolz

fair drum
#

good find

#

fixed

delicate cedar
delicate cedar
#

Anyone knows how to use the garage feature of jeroen arsenal?

somber radish
sturdy basalt
#

hi all, im using some coding to spawn ai on a trigger set to Any player - present / call{this}

ive set the trigger zone, named the game logic "spwn1" where the ai is supposed to spawn, and used empty markers named "wypt1" and "wypt2" where they should travel after spawning but when i enter the trigger zone i get this warning: any clue?

call{_ambush1 = [getPos spwn1, east, (configfile >> "CfgGroups" >> "East" >> "VN_PAVN" >> "vn_o_group_men_nva_field")] call BIS_fnc_spawnGroup;
_wp1 = _ambush1 addWaypoint [position wypt1 , 0];
_wp2 = _ambush1 addWaypoint [position wypt2 , 0];
_wp2 setWayPointType "SAD";}

cosmic lichen
#

wYpt1 is undefined.

#

2 as well

#

Ah these are markers
Use markerPos "wYpt1"

sturdy basalt
cosmic lichen
#

You don't. See what I wrote

sturdy basalt
#

ill give it a try 🙂

#

call{_ambush1 = [getPos spwn1, east, (configfile >> "CfgGroups" >> "East" >> "VN_PAVN" >> "vn_o_group_men_nva_field")] call BIS_fnc_spawnGroup;
_wp1 = _ambush1 addWaypoint [markerPos "wypt1" , 0];
_wp2 = _ambush1 addWaypoint [markerPos "wypt2 ", 0];
_wp2 setWayPointType "SAD";}

meager granite
#

you have extra space in second marker name

sturdy basalt
#

call{_ambush1 = [getPos spwn1, east, (configfile >> "CfgGroups" >> "East" >> "VN_PAVN" >> "vn_o_group_men_nva_field")] call BIS_fnc_spawnGroup;
_wp1 = _ambush1 addWaypoint [markerPos "wypt1" , 0];
_wp2 = _ambush1 addWaypoint [markerPos "wypt2", 0];
_wp2 setWayPointType "SAD";}

thanks!!

sturdy basalt
#

@cosmic lichen @meager granite now im getting a different error and they arent spawning...

#

hmmm

meager granite
#

what is _pos ?

sturdy basalt
#

no clue... im using gePos for a game logic as the spawn location

polar belfry
#

Can I post the pastebin of a script of mine. I want to make sure if that script if run from a composition by the zeus all players get its effect

meager granite
#

You're passing wrong stuff into what should be a position

sturdy basalt
meager granite
#

Post code

polar belfry
#

Will this script if run from the zeus locally as a composition take data about all players and try to run?

sturdy basalt
#

did not think spawning AI on a trigger would be so challenging 😅

cosmic lichen
#

Learn to debug your script in Debug Console

#

What does getPos spawn1 return?

fleet sand
polar belfry
#

this script when placed by the game master locally as part of a composition it will check the player plane altitude and spawn several missiles at the altitude of players + 1000m and those missiles will track the player planes. My question is will this version of the script where the whole code block is encapsulated with the "forEach playableUnits" will run the commands for all players. without it last time it only took data locally from the game master about himself and not about the other players. the deletevehicle p1 line is to delete the object that makes the is part of the composition and has the code in it in order to save power on the server and to avoid junk

exotic flame
#

Is there a proper way to calculate the elevation of an artillery turret for a given target ?

fleet sand
# polar belfry this script when placed by the game master locally as part of a composition it w...

try this your code in that pastebin was all over.

0 spawn {
    private _players =  allPlayers - entities "HeadlessClient_F";
    {
        if(isnull objectParent _x) then {continue;};
        private _veh = vehicle _x;
        if(_veh isKindOf "Air" && (side _x == west)) then {
                
            for "_i" from 0 to 4 do {
                private _zAxis = (getposATL _veh) select 2;
                if(_zAxis > 200) then {
                    private _pos = _veh getRelPos [900,180];
                    private _newPos =_pos vectorAdd [0,0,_zAxis+1000];
                    
                    private _missileDir = _newPos vectorFromTo getposATL _veh;
                    private _missile = createVehicle ["ammo_Missile_rim162", _newpos, [], 0, "CAN_COLLIDE"];     
                    _missile setVectorDirAndUp [_missileDir, [0,0,-1]];
                    _missile setMissileTarget _veh;
                    sleep 4;
                };
            };
        };
        
    }foreach _players;
};
deletevehicle p1;
fleet sand
exotic flame
#

Thank you 🙂

fleet sand
nocturne bluff
#

niiice

exotic flame
#

I have another question: if i use player setVariable ["test", [], true] the variable will be broadcasted on every computer. But if i use (player getVariable "test") pushBack 1; the variable will not be broadcasted. How do i share the variable ?

meager granite
#
(player getVariable "test") pushBack 1;
player setVariable ["test", player getVariable "test", true];
#

Or a cleaner version:

private _array = player getVariable "test";
_array pushBack 1;
_array pushBack 2;
_array pushBack 3;
player setVariable ["test", _array, true];
#

Keep in mind that two clients broadcasting same thing could overwrite each other, sort of a race condition

exotic flame
meager granite
#

Its a barebones tool, you can make your own solution

#

instead of broadcasting the whole thing, make a RE function that will have each client do the pushBack themselves to their own local array

#

It gets complicated with JIPs though

#

Still unless you're sending megabytes, its all a drop in the ocean

polar belfry
#

I also have one more code similar to this but instead of missiles spawning it's a bomb at player level can you help me make it optimal as well

#

to simulate the ace combat burst missiles

granite sky
#

spawn needs a preceding parameter, even if you don't use it. 0 is just a cheap parameter.

polar belfry
#

ok

polar belfry
#

the way it works is that it checks for the players altitude. Under a certain altitude spawns a bomb in the plane killing the player and over a certain altitude it spawns it at a fixed altitude below the player

#

I will try myself first to see what I can do

granite sky
#

What's the most correct way of detecting whether a particular object is a unit? Definition of unit for this purpose is "capable of crewing a vehicle".

granite sky
#

Seriously?

polar belfry
proven charm
polar belfry
#

I already check the side

granite sky
#

hmm, maybe configOf >> "isMan"

#

I wonder if goats can technically crew a vehicle.

proven charm
#

animals derive from the "Man" class so you cant use that for iskindof hence "CAManBase" works better

granite sky
#

Yeah, the engine surely isn't using config parentage for this stuff though.

hallow mortar
proven charm
#

maybe faster to get it from config though

hallow mortar
#

Multiple SQF commands is usually slower than a single SQF command that does all its operations engineside

zenith stump
#

Been trying to find a way to disable pre placed fuel pumps on the map, but haven't found any solutions I've managed to get to work.

Any suggestions on how to do it?

granite sky
#

Hide them, replace with simple object?

proven charm
#

ah nice didnt notice the alt syntax first

granite sky
#

setFuelCargo 0 on the pumps seems to work fine though. I'm not sure what you tried that didn't work.

zenith stump
#

I know FuelCargo 0 works, but since I can't edit the pre placed ones,I can't do that to them.

Though hiding and replacing them with editable pumps could be a solution.

winter rose
hallow mortar
#
private _nearFuel = nearestTerrainObjects [_somePosition, ["FUELSTATION"],500,false];
{
  _x setFuelCargo 0;
} forEach _nearFuel;```
zenith stump
#

If I understand correctly, that sets fuel of each fuel station within 500 meters to 0?

hallow mortar
#

Each fuel station that is a terrain object. It doesn't do mission-placed objects.

zenith stump
#

I see. Well those aren't what I was going for, so this is perfect. Thanks.

magic sundial
#

what does this error mean? This is the code im trying to use

_randomElement = selectRandom [
    "AidlPercMstpSnonWnonDnon_G01",
    "AidlPercMstpSnonWnonDnon_G02",
    "AidlPercMstpSnonWnonDnon_G03",
    "AidlPercMstpSnonWnonDnon_G04",
    "AidlPercMstpSnonWnonDnon_G05",
    "AidlPercMstpSnonWnonDnon_G06",
    "AidlPercMstpSnonWnonDnon_G0S",
    "Acts_CivilIdle_1",
    "Acts_CivilIdle_2",
    "Acts_CivilListening_1",
    "Acts_CivilListening_2",
    "Acts_CivilStand_Default"
];
_randomTest = selectRandom [
    "work1",
    "work2",
    "work3",
    "work4",
    "work5",
    "work6",
];
hint _randomTest;
//_unit playMove _randomElement;
warm hedge
#

Invalid comma at last element there

magic sundial
#

o htrue

#

sweet thanks lol, im still learning

tough abyss
#

Thanks Verox that does give me an approach to finding the offending scripts, not a profiler but I can try it and if the scripts are amenable I cut the problem down. Will put something together and see what the data says.

#

@grizzled cliff Would using lineIntersects be faster and have a smaller performance hit with this?

polar belfry
# proven charm ```_unit isKindOf "CAManBase"```

by the way how do I implement it in something like this

0 spawn {
    private _players =  allPlayers - entities "HeadlessClient_F" ;
    {
        if(isnull objectParent _x) then {continue;};
        private _veh = vehicle _x;
        if(_veh isKindOf "Air" && (side _x == west)) then {
                
            for "_i" from 0 to 4 do {
                private _zAxis = (getposATL _veh) select 2;
                if(_zAxis > 200) then {
                    private _pos = _veh getRelPos [900,180];
                    private _newPos =_pos vectorAdd [0,0,_zAxis+1000];
                    
                    private _missileDir = _newPos vectorFromTo getposATL _veh;
                    private _missile = createVehicle ["ammo_Missile_rim162", _newpos, [], 0, "CAN_COLLIDE"];     
                    _missile setVectorDirAndUp [_missileDir, [0,0,-1]];
                    _missile setMissileTarget _veh;
                    sleep 4;
                };
            };
        };
        
    }foreach _players;
};
deletevehicle p1;
#

cause I thought if I can make it work then the code will also kill blufor AI which will make it look cool

#

I thought at one point to use allunits

#

would it work?

lime rapids
#

cameras made by camcreate automatically replace the camera of all players correct? or is there a command like camswitch? cant find anything on biki and havent touched cameras in a long while

hallow mortar
#

No, the camera view does not automatically switch to newly-created cameras. That would be terrible. Certainly not for all players, since camCreate is Local Effect.
Use cameraEffect or switchCamera to select cameras or objects to follow.

lime rapids
fair drum
polar belfry
#

are addaction commands of compositions global or local

fair drum
polar belfry
#

I encapsulated the commands in foreach _players

#

_players is allplayers - the headless clients

fair drum
#

thats's not how locality works

polar belfry
#

It's to visually spawn a missile

#

that fires from the rear of a submarine so the players see it

fair drum
#

and its started by an add action?

polar belfry
#

yes the zeus goes in said submarine and there's an action to fire the missile

#

the missile spawns off a prop in the back of the sub

fair drum
#

anything that happens inside of the add action's script is local to the machine that pressed the action. so when you write your script that is called from it, you need to write it so that you take that into account.

polar belfry
#
this addAction ["<t color='#FF0000'>Launch Missile</t>", { 
private _players =  allPlayers - entities "HeadlessClient_F" ;
{   
private _pos = launch modelToWorld [0, 2, 1.6];    
private _missile = createVehicle ["ammo_Missile_Cruise_01", [0, 0, 0], [], 0, "none"];      
  if ((getPosASL launch) select 2 > 0) then   
  {   
    _missile setPosASL _pos;      
   
  };   
  if ((getPosASL launch) select 2 < 0) then{   
    _pos = getposASL launch;   
    _dist = abs (((getPosASL launch) select 2) - 0 );   
    _missile setPosASLW AGLtoASL (_pos vectorAdd [0, 0, _dist+ 4]);   
  };   
   
   _missile enableSimulation true;   
  _missile setVectorDirAndUp [[0, 0, 1], [1, 0, 0]];    
}forEach _players; 
}        
];  ```
#

here's the action

fair drum
#

this will create n number of missles where n = playercount. createVehicle is a global effect command so every client will see every one of them. You do this, stuff goes boom and your players are dead probably.

#

you don't have to iterate through players at all. just make one missile.

polar belfry
#

I tried without the foreach and none saw it

#

this action is in a composition zeus will spawn later in battle

proven charm
fair drum
polar belfry
#

no one saw the missile

fair drum
polar belfry
#

the prop the missiles come from

fair drum
#

so give me the whole story. you got a prop attached to the sub or something in the composition?

#

I'm trying to replicate so I can work it out for you

polar belfry
#

I have a submarine from hafm. I attached on it a prop. With the add action the missile comes from the prop if prop above water or from the surface of the water if prop is underwater

#

I didn't use the sub itself as refernce cause it's z position is broken

fair drum
#

so i'm assuming in the init of the prop you are just assigning a global variable as itself? launch = this?

polar belfry
#

so the only thing in the prop is the variable name launch

#

in the submarine there's the add action I posted

fair drum
# polar belfry so the only thing in the prop is the variable name launch

so I don't have that mod, but I just used a invisible helipad instead above the sub. and it works fine for me.

https://streamable.com/w0fgys

// sub init
// variable name: sub
this addAction [
    "<t color='#FF0000'>Launch Missile</t>",
    {
        private _pos = launch modelToWorld [0, 2, 1.6];
        private _missile = createVehicle ["ammo_Missile_Cruise_01", [0, 0, 0], [], 0, "none"];
        if ((getPosASL launch) select 2 > 0) then {
            _missile setPosASL _pos;
        };
        if ((getPosASL launch) select 2 < 0) then {
            _pos = getposASL launch;
            _dist = abs (((getPosASL launch) select 2) - 0 );
            _missile setPosASLW AGLtoASL (_pos vectorAdd [0, 0, _dist+ 4]);
        };
        _missile setVectorDirAndUp [[0, 0, 1], [1, 0, 0]];
    }
];

// pad init
// variable name: launch
[this, sub] call BIS_fnc_attachtorelative;

keep in mind, the way you have it right now, only the zeus that placed down this sub will see the launch action

you also need zeusCompositionScriptLevel = 2; in your description.ext file btw

drowsy geyser
#

Is it possible to dynamically change the duration of a BIS_fnc_holdActionAdd and increase or decrease the duration while its being used?

faint oasis
#

Hi, i have a question ? Is it possible to ragdoll an AI ?

cosmic lichen
#

You can pause it

polar belfry
drowsy geyser
hallow mortar
#

Through the power of variables, yes

#
// other script:
myHoldActionPause = false;
sleep 5;
myHoldActionPause = true;

// progress condition
{ myHoldActionPause }```
drowsy geyser
#

Thank you

fair drum
faint oasis
# little raptor addForce

Oh ok i didn't know that, it's working perfectly but the unit is always set unconscious, is there a way to avoid that ?

little raptor
#

no

faint oasis
winter rose
#
_unit setUnconscious true;
sleep 1;
_unit setUnconscious false;
wild canyon
#

Hi got a database running but still getting:
extDB3: Error with Database Connection

winter rose
#

hi, see their doc

wild canyon
#

Just not connecting :/

abstract bay
winter rose
polar belfry
#

I have a question will playsound sound the same throughout the map?

#

I want to use it for an explosion sound and want it to be heard far away

abstract bay
gentle zenith
#

Hey all, a quick maybe simple issue here.
A few years back my vehicle clean up script would kick dead players from their vehicles once the vehicle was deleted nothing special was run to do this, it just used deleteVehicle _vehicle

Since last year when my server reopened, however, when the vehicles clean up the corpse no longer pops out and is also deleted, did something change within Arma, or is it more likely that I goofed somewhere?

manic kettle
#

if i use publicVariable "blah", does it update the JIP queue of variable blah, or does it add to the queue?
So if i ran the function 3 times does it run 3 times for JIP players?

warm hedge
#

AFAIK update/overwrite

granite sky
#

Update IIRC, but anyone currently connected will get sent the thing three times.

drifting spire
#

How would one remove dead bodies from a vehicle

fair drum
drifting spire
#
_crew = fullCrew _vehicle;
{
    if !(alive _x) then {
        deleteVehicle _x;
        }
} forEach _crew;

I tried this, but it doesn't seem to work.

fleet sand
gentle zenith
fleet sand
meager granite
#

Anybody else would find HASHMAP select ARRAY useful?

createHashMapFromArray [
     ["a", 123]
    ,["b", 321]
    ,["c", 111]
    ,["d", 222]
    ,["e", 333]
] select ["a","c","e"]
```=>`[123,111,333]`
#

actually ARRAY select ARRAY can be useful too, so you can for example select needed values out of large EH arrays

flint topaz
#

Like I can see it could be useful but a loop could accomplish the same thing

#

and it’s niche so not sure if you’d get Bohemia to add it

meager granite
flint topaz
#

Ehh we can’t test it but I doubt the improvement would be as much as you think

#

Have you tested the performance of a looped approach?

meager granite
#

No but I can estimate it will be several times slower than having it in-engine

flint topaz
#

Get from a hashmap is consistent regardless of map size so it should be easily mathematically calculable

#

I think the main cost will be creating of the new array

meager granite
#

The issue is number of commands, the less you have the better

#

I'm doing inside Fired event handler, added to every single unit in the game so I'm trying to squeeze it as much as possible.

flint topaz
#

Mind explaining your use case a bit more

meager granite
#

Tracking every single projectile for detailed damage tracking

flint topaz
#

So you are adding to the map per Fired

meager granite
#

Building hashmaps and brief arrays of useful data out of event data

#

then sending summaries to server so its tracked there

#

In some cases I need to compact larger hashmaps into smaller arrays, thus HASHMAP select ARRAY idea

fair drum
drifting spire
#

It's an array of the crew members, no

fair drum
#
[
  [R Alpha 1-1:1, "driver", -1, [], false, R Alpha 1-1:1, "$STR_POSITION_DRIVER"],
  [R Alpha 1-1:2, "turret", -1, [0], false, R Alpha 1-1:2, "$STR_A3_COPILOT"]
]
drifting spire
#

ahh, got it

gentle zenith
deft zealot
#

@grizzled cliff "probably because of Eastern Europe and their crappy computers" :D

granite sky
meager granite
granite sky
#

I lost track of where and how to test simpleVM

still forum
#

it would

granite sky
#

Is it usable anywhere atm? Curious how much faster it is on these tiny loops.

still forum
#

its enabled on profiling branch and dev branch

open hollow
#

is the hasmap limited to 10k params?

#

i used a loop to create dict with 20k params and it worked then i used arr = dict apply {_x} an now arr is 20k parameters

#

wait, arrays are no longer limited to 10k ?

#

i guess not, i almost crashed arma but i created a 1M params array, this is a bug or a feature? blobcloseenjoy

hallow mortar
#

The 10k limit is for iterations of a while loop in an unscheduled context

open hollow
hallow mortar
#

Any of them, but step 0 is probably learning to read channel names

open hollow
#

well hasmaps are not limited to 10M :p

still forum
#

😠

wind hedge
#
if (
    _hitPoint isEqualTo "#structural" &&
    {!isNull _vehicle} &&
    {_ammo isNotEqualTo ""} &&
    {
        private _ammoCfg = configFile >> "CfgAmmo" >> _ammo;
        GET_NUMBER(_ammoCfg >> "explosive",0) > 0 ||
        {GET_NUMBER(_ammoCfg >> "indirectHit",0) > 0}
    }
) exitwith {

};
#

☝️ Ace 3 uses this in their handleDamageEH to detect explosion damage... how can I get a vanilla GET_NUMBER alternative?

#
    private _mitigate = true;
    private _vehicle = objectParent _unit;
    if (
        _point isEqualTo "#structural" &&
        {!isNull _vehicle} &&
        {_projectile isNotEqualTo ""} &&
        {
            private _ammoCfg = configFile >> "CfgAmmo" >> _projectile;
            getNumber ((_ammoCfg >> "explosive",0) > 0) ||
            {getNumber ((_ammoCfg >> "indirectHit",0) > 0)}
        }
    ) then {
        // Explosion damage is not mitigated, do nothing.
        _mitigate = false;
    };
#

☝️ getNumber doesn't work for me, gives me a missing "(" error

little raptor
#

remove the ,0

wind hedge
little raptor
#
getNumber (_ammoCfg >> "explosive") > 0 ||
            {getNumber (_ammoCfg >> "indirectHit") > 0}
little raptor
wind hedge
hallow mortar
#

GET_NUMBER is a macro. Whatever's in the macro will still be vanilla script commands, they're just using it like a function (why not an actual function? 🤷). The ,0 is a second parameter being passed to the macro, like a function, and it's probably the default value to use if the config property isn't defined, like with getVariable.

little raptor
#

why not an actual function?
function call is a bit slow

#

there's the call command, plus passing the parameters, plus maybe doing a params or select to extract stuff

#

macros are expanded inline by the preprocessor, so there's no call overhead

tidal aurora
#

If on a script executing on server I run something like: "remoteExec ["fnc_long_cinematic", -2]", what is a sensible way to wait for all clients to have executed "fnc_long_cinematic" ?

#

so the server side script can continue to do something after that

#

I guess have server wait for the fastest client to set some public variable and hope shit wont get too out of sync

little raptor
# tidal aurora If on a script executing on server I run something like: "`remoteExec ["fnc_long...

it's a bit tricky
you have to use a callback by the clients to tell the server that the script is done
if instead of -2 you specify the clientIDs as an array, you can count how many of them have called the callback
you also have to take into account that a client may never finish the cinematic (e.g. they get disconnected)

imo you can do something like this:

playedCinematics = [];
remoteExec ["fnc_long_cinematic", -2];
sleep CinematicDuration;
waitUntil {playedCinematics findIf {time < _x#1} < 0};
// continue with the rest

fnc_long_cinematic

// report to the server that the client has started the cinematic
remoteExecCall ["fnc_cinematicStarted", 2];

// cinematic stuff
...
// report to the server that the client has finished the cinematic
remoteExecCall ["fnc_cinematicFinished", 2];

fnc_cinematicStarted

private _clientID = remoteExecutedOwner;
private _playID = playedCinematics findIf {_x#0 == _clientID};
if (_playID < 0) then {_playID = playedCinematics pushBack [_clientID, 0]};
playedCinematics#_playID set [1, time + CinematicDuration + _someDelay]; // add a few seconds of delay, in case the client has performance issues

fnc_cinematicFinished

private _clientID = remoteExecutedOwner;
private _playID = playedCinematics findIf {_x#0 == _clientID};
if (_playID < 0) exitWith {};
playedCinematics#_playID set [1, 0]; // complete the cinematic
#

you can also use a hashmap instead of playedCinematics = []; but it's not really important

tidal aurora
#

nvm found it "_myArray # 2; // returns "third item" - Arma 3 only"

sturdy basalt
#

hey guys! does the setDamage command work in decimals like: setDamage 0.05;

winter rose
cosmic lichen
sturdy basalt
#

thank you! i need to figure out how much i need to reduce the damage of APERS tripwire as i dont want it to kill a player outright but have them badly wounded

tidal aurora
sturdy basalt
#

now im confused haha

hallow mortar
#

setDamage sets the amount that the unit is damaged

#

it's like inverse HP

sturdy basalt
#

no matter how much i lowered it xD

#

is there a script that lowers how much damage it does?

hallow mortar
oblique arrow
#

Helloh I need help again 😄
I'm currently working on a script for a mission, the mission has 3 transformer switches and the players have to use ace interactions to set the 3 switches to the correct settings so that the generator is overloaded and blows up
I dont want to write the script 3 times, so I was hoping to use one file with parameters
I've got the ace interactions working thus far, except that I need to somehow publicise the current state of the transformer switches so that I can use a trigger to make the generator go boom when all 3 are correct
I tried using

params ["_switch_object"] //pp_switch_1
_action_name_switch_generator = format ["Pie_%1_generator", _switch_object_text];
// set switch to generator
_action = [_action_name_switch_generator, "Set switch to 'Generator'", "", 
{
_target animateSource ["switchposition",-1]; 
hint "Switch set to generator";
_temp_pp_switchPos = "Generator";
_variableNameSwitchPos = format ["%1_switchPos_",_switch_object];
missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
}, 
{true}] call ace_interact_menu_fnc_createAction;
[_switch_object, 0, ["ACE_MainActions", _action_name_base], _action] call ace_interact_menu_fnc_addActionToObject;

However that always gives me an error that the setvariable got an Any instead of a string

#

Anybody got any smart thoughts blep ?

#

(note I left some formatting stuff that works out of the script so its a bit shorter)

fair drum
little raptor
#

the code is correct as it is

tidal aurora
little raptor
#
params ["_switch_object"] //pp_switch_1
_action_name_switch_generator = format ["Pie_%1_generator", _switch_object_text];
// set switch to generator
_action = [_action_name_switch_generator, "Set switch to 'Generator'", "", 
{
  _target animateSource ["switchposition",-1]; 
  hint "Switch set to generator";
  _temp_pp_switchPos = "Generator";
  _variableNameSwitchPos = format ["%1_switchPos_", _target];
  missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
}, 
{true}] call ace_interact_menu_fnc_createAction;
[_switch_object, 0, ["ACE_MainActions", _action_name_base], _action] call ace_interact_menu_fnc_addActionToObject;
oblique arrow
#

The _variableNameSwitchPos is so that I can use the script for multiple transformers and set a missionNamespace variable for each one respectively, or does that not make sense blep ?

little raptor
#

I know but I don't understand the word "pos" there (it's a string, "Generator")

oblique arrow
little raptor
#

as in selection pos? (which is a string)

oblique arrow
#

the switch on these can be animated, so thats where 'position' came into my head from

#

but yeah from a purely code perspective it doesnt make sense you're right 😅

sharp grotto
sharp grotto
# oblique arrow

For the lights

_switch setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"];
oblique arrow
#

and then go back to normal if the settings are changed again

#

which would put me at 2 triggers each so 6 triggers just for the lights, at my current knowledge level at least

fleet sand
still forum
#

There shouldn't be need for trigger, you can just call a script function after your "action" script that checks if all switches are set right?

Though then multiplayer shenanigans

oblique arrow
#

that sounds smarter than my current knowledge level 😄

still forum
#

Do you use init.sqf, or do you have all code in init scripts in editor?

#

Like something like this

Pie_fnc_CheckSwitches = {

  if (switch1_switchPos_ == "Generator")
  {
    switch1 setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch 1
  };
// Test other things, set other things for other switches
};

and then in all your actions

_action = [_action_name_switch_generator, "Set switch to 'Generator'", "", 
{
  _target animateSource ["switchposition",-1]; 
  hint "Switch set to generator";
  _temp_pp_switchPos = "Generator";
  _variableNameSwitchPos = format ["%1_switchPos_", _target];
  missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
call Pie_fnc_CheckSwitches;
}, 

When any switch changes, you update all switches lights and stuff

oblique arrow
still forum
#

then you can easily add a global function like that

oblique arrow
#

I shall try it, thank you peeps bongocat

fleet sand
still forum
#

obj init runs on every player that has the object. Which is usually every player.
thus global, everyone will have it

fleet sand
hallow mortar
#

The init field for compositions placed in Zeus is only executed on the machine of the Zeus that placed it

#

(and only if the server/mission has the config setting to allow init field execution for compositions)

still forum
hallow mortar
#

I don't know why it be like that, only that it do be like that

drowsy geyser
#

The lever only goes down one step

hallow mortar
#

It's not a problem with the switches. The issue is that your code is basically saying:

switch1 animateSource ["switchposition", -0.1];``` every time you do it. So every time the code runs, it sets the animation position to `-0.1`, which is...the same position every time.
oblique arrow
hallow mortar
#
private _currentState = switch1 animationSourcePhase "switchposition";
switch1 animateSource ["switchposition", _currentState - 0.1];```
fleet sand
# drowsy geyser Does anyone know why the following doesn't work with these switches? I want to l...

Myb something like this not tested :

[
    switch1,
    "Raise switch",
    "\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",
    {systemChat format ["Starting"];},
    {
        params ["_target", "_caller", "_actionId", "_arguments", "_frame", "_maxFrame"];
        private _relProgress = _frame / _maxFrame;
        _target animateSource ["switchposition", ((2*_relProgress)-1)];        
    },
    { 
    systemChat format ["Finished"]; 
    },
    {
   params ["_target"];
    systemChat format ["Interupted"];
    _target animateSource ["switchposition", 0];
    },
    [], 10, nil, true, false
] call BIS_fnc_holdActionAdd;
drowsy geyser
#

thank you both

oblique arrow
# still forum Like something like this ``` Pie_fnc_CheckSwitches = { if (switch1_switchPos...

Hm ok trying out the function thing at the moment, however I'm encountering the same problem with my params not being transmitted correctly 🤔

//Switch ace action
_action = [_action_name_switch_generator, "Set switch to 'Generator'", "", 
{
_target animateSource ["switchposition",-1]; 
hint "Switch set to generator";
_temp_pp_switchPos = "Generator";
_variableNameSwitchPos = format ["Pie_%1_switchPos",_target];
missionNamespace setVariable [_variableNameSwitchPos,_temp_pp_switchPos];
[_switch_object, _target]call Pie_fnc_setSwitchLights;
}, 
{true}] call ace_interact_menu_fnc_createAction;
[_switch_object, 0, ["ACE_MainActions", _action_name_base], _action] call ace_interact_menu_fnc_addActionToObject;

//Pie_fnc_setSwitchLights
Pie_fnc_setSwitchLights =
{
    params ["_switch_object_text","_target"];
    _switch_object_test = param [0];
    hint _switch_object_test;
    //hint "pie fnc executed";
    hint format ["pie fnc executed %1 %1",_switch_object_test, _target];
    _variableNameSwitchPos = format ["Pie_%1_switchPos",_target];
    _variableNamePowerLvl = format ["Pie_%1_powerLvl",_target];
    _switch_switchpos = missionNamespace getVariable _variableNamePowerLvl;
    _switch_powerLvl = missionNamespace getVariable _variableNamePowerLvl;
    switch (_switch_object) do
{
    case pp_switch_1: 
    { 
        if( _switch_switchpos == "Generator" || _switch_powerLvl == "80") then 
        {
            _switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch
            hint " red light";
        } else {
            _switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,1,1,1,ca)"]; // not red light on switch
            hint " not red light";
        };
    };
    case pp_switch_2: 
    { 
        if( _switch_switchpos == "Generator" || _switch_powerLvl == "80") then 
        {
            _switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch
            hint " red light";
        } else {
            _switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,1,1,1,ca)"]; // not red light on switch
            hint " not red light";
        };
    };
    case pp_switch_3: 
    { 
        if( _switch_switchpos == "Generator" || _switch_powerLvl == "80") then 
        {
            _switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,0,0,1,ca)"]; // Red light on switch
            hint " red light";
        } else {
            _switch_object setObjectTextureGlobal [1, "#(argb,8,8,3)color(1,1,1,1,ca)"]; // not red light on switch
            hint " not red light";
        };
    };
    default { hint "zero, three or four" };
};
    //hint "Function was executed!"; // Function will show a hint when executed
};

#

That code then just generates the same old any for both params

#

what am I doing wrong with my parameters 😄

winter rose
#

too much code

oblique arrow
winter rose
#

you never params'ed _target

#

(unless ACE does it itself, idk)

oblique arrow
#

_target comes from the ace action, I input it in the original fnc call
[_switch_object, _target]call Pie_fnc_setSwitchLights;
I dont use it in the fnc yet other than it being in the format since I'm trying to just get the first param to be transmitted correctly

winter rose
#

yeah but ```sqf
_target animateSource ["switchposition",-1]; // where is _target defined?

oblique arrow
#

🤔 good question, it definetly works at the moment so I guess its ace already doing it somehow?

hallow mortar
#

ACE doesn't use addAction for its actions

#

It does look like _switch_object is not defined in the action code, yet you pass it to the function:

[_switch_object, _target] call Pie_fnc_setSwitchLights;```
oblique arrow
hallow mortar
#

Maybe™

#

That's not a locality problem btw. Locality is when you're on the wrong machine. This is a scope problem.

oblique arrow
#

ah yes, wrong words 😄

#

I have clearly been looking at code too long today

hallow mortar
#

Your switch (code structure) has switch (_switch_object), which is not defined

#

You could probably save some effort by saving the missionNamespace variables in the switch object's namespace instead. Don't need to worry about format-generating unique names then.

meager granite
#

Still wish there was publicVariableJIP STRING or something like that, so you can make a variable to be broadcasted to JIP

#

Could be useful for large data structures, you update small bit of the structure on all clients through a function while make the whole structure to be sent whole to JIP

#

Sure it can also be scripted, but having engine handle it would make it more convenient

#

Now contemplating whether I should script such system myself or say fuck it and just publicVariable the whole thing on each small change

velvet knoll
#
/* rhsusf_m1240a1_m240_usmc_d addWeaponTurret ["rhs_weap_TOW_Launcher_Static", [0,0]]; */
hint "good!";
#

hmm....

brave venture
#

I'm currently try to attach objects to an arbitrary selection that will follow rotation. This is what I currently have: _object attachTo [_otherObject, [0,0,0], _memorybone, true]; This works well when the _memorybone for the object is the same between lods (i.e. spine, head, hand, etc). I find component from fire geo and use that, no issue.

Any idea how to find the controlling _memorybone when it is a different name from the selection? Say door_5 & door_5_axis? wheel & wheel axis? Obviously for more broadly than _memorybone = selection + _axis/_X.

#

If you got an alternative to using attachto that works, that works as well.

bleak mural
#

just had a quick question: "While true" in the past dropped my system to its knees, couldnt tell why. i avoided since. It is generally safe and performance friendly to use correct?

#

as an example, this checks for player in vehicle every minute. should be lightweight right? since its just player?

#
while {true} do
{
if (player != vehicle player) then 
    {
    playmusic format ["RadioAmbient%1",floor (random 31)];
    };
sleep random 60;
};
fair drum
fair drum
bleak mural
#

and yeah maybe i had the sleep wrong or not atall, i see what you mean

fair drum
#

challenge: once your music starts, make the loop wait for the music to end, then do its random wait time. I'll give hints if you get stuck.

meager granite
fair drum
bleak mural
fair drum
#

nonono, that wasn't for you to use

#

( means exclusive, [ means inclusive in math notation

bleak mural
#

oh i just checked yeah i see, i thought that was odd lol

fair drum
#

i mean to say, its 0 to <60

bleak mural
#

i actually had that issue a while ago with music

fair drum
bleak mural
#

thats a new EH to me.

drifting spire
#
_isEmpty = true;
if (!isNull _vehicle) then {
    {
        if(!alive _x) then {
            deleteVehicle _x;
        };
    }foreach crew _vehicle;
    _crew = crew _vehicle;
    if (count _crew == 0) then {
        deleteVehicle _vehicle;
        missionNameSpace setVariable [_variable,objNull];
    }else {
        "Vehicle is not empty!" remoteExec ["hint",_caller];
        _isEmpty = false;
    };
};

Is there ANY reason this isn't deleting dead players from the crew of the vehicle?
Works fine for dead NPCs, but player bodies won't get deleted and _isEmpty is always false.

bleak mural
#

EH's are game changing

fair drum
meager granite
#

Worth a ticket

fair drum
meager granite
#

So you can get the duration out of the file's header

meager granite
fair drum
drifting spire
#

By the time this script is run, the player has respawned

meager granite
fair drum
#

On other notes, I think the IDC syntax of lbSetPictureRightColorSelected is broken. It gives the missing ; error that happens when the command syntax isn't recognized. The alternative control object syntax works fine.

meager granite
drifting spire
#

It's part of an addAction on a sign.

#

so, idk

meager granite
fair drum
meager granite
#

=>
["b:CONTROL lbsetpicturerightcolorselected ARRAY"]

#

only alt syntax in the engine

#

considering that 1.20 was like 10 years ago I doubt anyone cares about main syntax anymore, just remove it from there

fair drum
#

kk

meager granite
drifting spire
#

lotta words, I'm not understanding them

meager granite
#

Instead of fixing deleteVehicle to properly work on dead bodies they added a new command which has 2 syntaxes that work differently

#

And I think also still bugged, I had an issue with it recently

drifting spire
#

You reckon that'll work better in this usecase?

meager granite
#

So just play around with stuff until its sort of working

drifting spire
#

I'll give it a shot

meager granite
#

I think dead bodies also break if they're controlled by player for too long

#

Then they are never properly deleted and that seat is no longer script usable (normal gameplay get in works)

drifting spire
#

well what'ya know

meager granite
#

all in all, its all fucked with dead bodies in vehicles, try stuff until something works

drifting spire
#

It happened to work, thanks for the quick fix!

#

Been trying to debug this for the past day

#

I thought it was working, as I was testing with dead AI, and then I tried as a player, then it stopped working.
Why do they act differently?

meager granite
#

That's why

drifting spire
#

Do issues like this occur in reforger, with the new engine?

meager granite
#

Not that I know of, but its completely new from A3 engine

#

Probably has its own troubles, nothing is perfect

sharp grotto
# meager granite Probably has its own troubles, nothing is perfect

I used Exile and it ejected players inside vehicles on death via Killed EH, always worked.
Not perfect for immersion but #Arma

if !((vehicle player) isEqualTo player) then
{
    unassignVehicle player;
    moveOut player;
};

That's the code i used before stopping, and never saw it not working.
A bit annoying when you get killed in a air vehicle because sometimes the body went underground, but again #Arma blobdoggoshruggoogly

meager granite
#

I like dead players inside vehicles because it opens gameplay opportunities in KotH

#

For example you can revive dead units while also inside the vehicle, including mid-flight

fleet sand
meager granite
#

How much crap is stored for a single hit on a vehicle

proven charm
#

it stores your DNA

unborn rivet
native oracle
#

Anyone able to help me out with a hiddenselection problem I've been having? I'm trying to change the texture of a shirt, and this is how I thought you'd write the code into the init box, but nothing works. Example: this setobjecttexture [0,texture_name]

warm hedge
#

First off

#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
warm hedge
#

Also texture_name is not a string but a variable/identifier

tldr: it's not a valid texture

still forum
native oracle
warm hedge
#

Same answer

still forum
native oracle
# warm hedge Same answer

So, this would then be the correct way to write it then? in theory? ***this setobjecttexture [0, "\modname\texturename.paa"] ***

warm hedge
#

In theory yes

native oracle
#

cheers mate, I'll give it a try

warm hedge
native oracle
#

I'll try that sqf thing, I just didn't quite understand the format of it.

I get an error when trying this setobjecttexture [0, "\modname\texturename.paa"] stating that the picture is not found

warm hedge
#

Which means the file is not there

#

Do you know what is the file you want to put there

native oracle
warm hedge
#

Well read the guide carefully then. You've pretty skipped into the conclusion

native oracle
#

well, this is how he explains the process of changing the texture of the shirt In the unit's init: this setobjecttexture [0,texture_name] to change the shirt textures And at the top of his guide, he has the classnames of the textures simply listed as such Replace * with one of: ABSTRACT, ADPM, AMCU, AMCUF, ARID, ARMATA, ATACS, BCD, BCG_AM, BCG_AN, BCG_BR, BCG_BRSA, BCG_DG, BCG_R, BCG_T, BCG_U, BCG_WD, BCG_WL, BCG_WW, BCM, BCP, BDC, BLC, BME, BROWN, CADPAT, CDW, CHIP, DARK, DCCU, DPCU, DPDU, DPM, EMR, ESE, FLECK, GLC, GRANITE, GZONE, ICAM, IDPM, IDT, ITMP, JEITAI, JIGSAW, KA2, KDC, KILO, M05, M09, M09D, M14, M2011, M2015, M81, M90, M98, MAD21, MANDRAKE, MARPAT, MARPATD, MCAM, MCAMF, MCAMD, MCAMT, MLAND, MTARN, MTP, MWC, NFP, NZMCU, NZMTP, OBH, OCP, OCPF, OD, PAP, PSDC, RCAM, SLOCAM, SURPAT, T07D, TAC, TAN, TAT, TAZ90, TCAM, TCAMF, TE3, TIGER, TIGERAT, TUNPAT, UNIPAT, US4CES, VEG, VSR, VZ2007, WLP, XINGKONG, Z93

warm hedge
#

You're reading it entirely wrong

#

More like you don't really seem to have a need of setObjectTexture but just have tpw_g3_g3_rs_ng_uniform_* uniform class

native oracle
#

would you be able to nudge me into the general area as to what I need to be doing?

warm hedge
#

Replace * with one of: [...]
This explains well. Which means, * in these guides have to be renamed into one of them

native oracle
warm hedge
#

"tpw_*_uniforms\data\g3_shirt_co.paa" this is the texture name I guess

native oracle
native oracle
granite sky
meager granite
#

Can try making a repro out of it

faint oasis
#

I have a question ? Is there a command to see what are the dlcs loaded on the server or the mission ? Because the command "getMissionDLCs" only check the dlcs units in the mission, nothing else and i wanted to know if it was possible to know if a CDLC is enabled or not.

hallow mortar
#

I don't think there's a specific command for it, but checking for the DLC addons in CfgPatches should do what you need

faint oasis
#

oh i didn't think about that, because when you see the latest changelog of the dlc "reaction forces" they said "If the Western Sahara CDLC is enabled, some of its vehicles are added into the randomized vehicle spawn and motor pool" so i think they are checking the config, so i will try that then, thank you 😄

hallow mortar
faint oasis
scarlet tree
#

Hi, I'm a beginner, bit stumped with variable scopes here. Can local variables in an .sqf be passed onto event handlers in that same .sqf?
I'm trying to use the task framework to create a few tasks with a local effect (eg, "Mount vehicle"), so each player gets it completed independently before moving on to other tasks. To this end, correct me if I'm wrong, each player needs to have this task with a unique task ID. I did this by adding [this, "av6_taskMount_01"] execVM "scripts\AV6_taskMount.sqf";with a different ID to each playable unit, and then start the .sqf with private _soldier = _this select 0; private _taskID = _this select 1; These variables are undefined in any EH I create. Can I change that?

meager granite
#

For your case it could be something like:

_soldier setVariable ["my_task_id", _taskID];
_soldier addEventHandler ["Killed", {
    params ["_unit"];
    private _taskID = _unit getVariable "my_task_id";
    // Fail the task here
}];
#

Also tasks are local, they're nothing more than an UI effect, you probably don't need a unique ID for each player because essentially each player only has to care and know about their own task

#

Task framework is used to ease things when you want tasks to be synced over the network

scarlet tree
#

I tried using a single ID to create a simple "mount vehicle" task for all players locally, which worked fine until I used BIS_fnc_taskSetState to complete it - then it got completed for everyone, even those who hadn't gone near the vehicle. createSimpleTask and its associated commands worked as needed, but didn't display any task notifications.

meager granite
#

Task Framework is for making tasks MP-synced, thus your completion was synced to everyone

#

To change task state locally

#

There is isGlobal flag to not broadcast task state to others

#

BIS_fnc_taskSetState is a wrapper for BIS_fnc_setTask pretty much

scarlet tree
#

Of course... thank you! You've been very helpful

meager granite
#
private ["_taskID","_state","_hint"];
_taskID = param [0,"",[""]];
_state     = param [1,"",[""]];
_hint     = param [2,true,[true]];

[_taskID,nil,nil,nil,_state,nil,_hint] call bis_fnc_setTask;
#

All that it does

#

You sent nil's to BIS_fnc_setTask to not to do anything with arguments you don't want to change

scarlet tree
#

Oh cool, I can use that.

meager granite
#

Don't feed nils into other functions, unless you're sure they can deal with it

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
surreal horizon
#

Hi, im creating my first mission in arma 3 and want to add a function when looting dead ai, limit the total items in the inventory to only 3, but didnt manage so far, anyone can help?

_unit = _this select 0;

if (isPlayer _unit) then {
    if ((player distance _unit) < 3) then {
        _fullInventory = getUnitLoadout _unit;

        if (isNil "_fullInventory") exitWith {
            hint "The inventory is empty!";
        };

        _totalItems = count magazines _unit + count uniformItems _unit + count backpackItems _unit;

        if (_totalItems > 3) then {
            while {_totalItems > 3} do {
                {
                    _subInventory = _x;
                    while {count _subInventory > 3} do {
                        _unit removeItem (_subInventory select 0);
                        _subInventory = _subInventory - [_subInventory select 0];
                    };
                } forEach [magazines _unit, uniformItems _unit, backpackItems _unit];
                
                _totalItems = count magazines _unit + count uniformItems _unit + count backpackItems _unit;
            };

            hint "Excess items removed from inventory!";
        } else {
            hint "The inventory already has 3 items or less!";
        }
    } else {
        hint "You are too far to loot!";
    }
} else {
    hint "Only players can loot!";
};```
little raptor
#
_fullInventory = getUnitLoadout _unit;
_uniformItems = _fullInventory#3#1;
_vestItems = _fullInventory#4#1;
_backItems = _fullInventory#5#1;

_changed = false;
while {count _uniformItems + count _vestItems + count _backItems > 3} do
{
  _changed = true;
  if (count _backItems > 0) then {_backItems resize (count _backItems - 1); continue};
  if (count _vestItems > 0) then {_vestItems resize (count _vestItems - 1); continue};
  if (count _uniformItems > 0) then {_uniformItems resize (count _uniformItems - 1); continue};
};

if (_changed) then
{
  _unit setUnitLoadout _fullInventory;
}
#

tho I don't really recommend doing that

#

because, e.g. if the player places something in his vest and he already has 3 items, something will be removed from his backpack

little raptor
#

because I just corrected his script to make it work

surreal horizon
#

Which would be a better way?

#

Have 0 sqf knowledge

#

trying to make something of a random loot using the ai body as loot table

little raptor
#

actually nvm

#

also I think when you use getUnitLoadout on a dead unit you won't get his backpack items

surreal horizon
#

tried the code, no success

surreal horizon
#

Nvm, figured out a way, just not 100% if it will work rn, but really interesting, although not realistc

#
[_this] spawn
{
params["_unit"];
addMissionEventHandler ["EntityKilled", 
    {
            params["_unit"];
            if (_unit isKindOf "Man") then {
            private _box = createVehicle ["Box_NATO_Wps_F", getPosATL _unit, [], 0, "CAN_COLLIDE"];
            private _tomb = createVehicle ["Land_Tombstone_04_F", getPosATL _unit, [], 0, "CAN_COLLIDE"];
            clearWeaponCargo _box;
            clearMagazineCargo _box;
            clearItemCargo _box;
            clearBackpackCargo _box;
            {_box addItemCargo[_x,1];} forEach (assignedItems _unit);
            {_box addWeaponCargo[_x,1];} forEach (weapons _unit);
            {_box addItemCargo[_x,1];} forEach (vestItems _unit);
            {_box addItemCargo[_x,1];} forEach (uniformItems _unit);
            _box addItemCargo[(uniform _unit),1];
            _box addItemCargo[(vest _unit),1];
            _box addItemCargo[(headgear _unit),1];
            _box addBackpackCargo[(Backpack _unit),1];
            deleteVehicle _unit;
            hideObjectGlobal _box;
            _tomb addAction ["Loot",{_this select 1 action ["Gear",_this select 3]},_box];
            };
        }];
    };

For future reference if anyone needs to create a custom crate after a unit dies, you can add this to their init, with this setup it creates a tombstone, did by digging on forums(For selecting which object to spawn: https://forums.bohemia.net/forums/topic/177963-make-an-object-appear-as-another/; For creating the crate: https://forums.bohemia.net/forums/topic/211102-put-player-gear-in-ammo-box-on-death/)

#

Now the question is how performance is going to be when ai start dying left and right

oblique arrow
#

Thank you for your help everyone <3

bleak mural
#

im quite curious to understand this feature in High command: Create Task Spawns code saved to High Command - Commander module's namespace _logic getVariable "onTaskCreated"

#

from what i understand, i can, on a waypoint of a unit,run a line of code for them?

#

a modifier to a waypoint called "create task" is present on high command. it should execute a line of code,but im not sure where "commander modules namespace " is. never heard of it.

#

or what "_logic getVariable "onTaskCreated" /how its supposed to be run. i never used logics before

#

essentially i want to run a code on a group on a wp by using "createtask" via the wp modifier

#
[this,def,25,3,false,true] call CBA_fnc_taskDefend
oblique arrow
bleak mural
#

im also looking at "radios = <array>; - Radio channels reserved for radio triggered waypoints." i think this is more of what im trying to do. im calling it but the hroup isnt carrying out the CBA function once reaching the waypoint

oblique arrow
#

Next points of the to-do list is looking for more fitting sounds to use, preferrably looking for some kind of generator+generator winding down noise, gonna take a bit to check the vanilla sounds 😄

#

And also possibly custom explosion effects, which someone mentioned would be cool

bleak mural
#

ok so i must be misinterperating this or it doesnt actually work

#
BIS_HC_1 setVariable ["onTaskCreated", Code, true];
#

when this is called on a groups wp via High command,it should run the code on them correct?

#

to that end i have a syntax as follows:

#
BIS_HC_1 setVariable ["onTaskCreated", [_this] call CBA_fnc_taskDefend, true];
#

i get no errors,but the group dont follow the CBA defend script

bleak mural
bleak mural
#

should be nothing to worry about right? i think its referencing group this

winter rose
#

always fix errors

bleak mural
#

however if i change"_this" to "_group this" the syntax throws error

winter rose
#

see what arguments are provided to this onTaskCreated event

rich frost
#

anyone here worked with hashMapObjects before?

Im woundering the following: If i create a hashmap Object, for example, on the server, have itself being setup with all the internal stuff and create and whatelse, if I then publicVar it all clients, will it re-run the create method?

bleak mural
#

... " /x/cba/addons/ai/fnc...taskdefend.sqf
|#|params [
["group", grpNull, [grpNull...'
ERROR params: type number,expected array,object,group,location....

#

so location of defense/module etc

#

because im doing this on the fly,there is no exact location,other than the groups pos

winter rose
#

then get the group's pos?

bleak mural
#

"def" is referencing an object pos

#

how to get group pos?

winter rose
#

getPosATL leader myGroup

bleak mural
#

actually with that syntax i think it wont throw errors and group will carry out script on pos

#

il tidy it up thank you

hallow mortar
# bleak mural however if i change"_this" to "_group this" the syntax throws error

You don't need this specific bit of code any more because you've changed approach, but I want to explain why this was wrong, for future reference.
_ is the prefix for a local scope variable. If you put that in front of a word, the game assumes you're trying to refer to a local scope variable with that name, and goes looking for it. Including if the word would otherwise be a command.
The original code _this is a reference to the Magic Variable _this, which contains some information provided by the scope - arguments passed into the function, or something like that. https://community.bistudio.com/wiki/Magic_Variables The exact contents depends on the context, and _this doesn't exist in all contexts, so watch out for that.
When you change it to _group this, you're not changing it to "get the group of whatever _this is". You're changing it to "the local scope variable called _group, and then the global scope variable called this", which is nonsense syntax. Just two variables one stated after the other.
If _this actually contains a unit in a group, then the correct syntax for getting that group would be group _this. group is a command to return the group of a unit; _group is a local variable.
The _ prefix has a specific meaning in SQF and you can't just move it around at random.

bleak mural
#

its alot of info i cant say i understand it all,but thanks,it gives me a new direction to learn towards

bleak mural
# winter rose getPosATL leader myGroup

If i wanted to reference the current group,how to write this? "leader mygroup" ... myGroup refers to the groups variable but this is run on a random group out of a possible 10

#

"leader groupthis" ?

hallow mortar
#

However you're choosing that random group, just save whichever one was chosen as a variable, instead of hardcoding a reference to a particular group. e.g.

private _selectedGroup = selectRandom [mygroup1, mygroup2, ...];
private _selectedGroupLeader = leader _selectedGroup;```
bleak mural
#

im not choosing a random group

#

i have 10 groups, on a wapoint i issue via high command(could be any group) i need the code to run on that particular group

winter rose
#

see what arguments are provided to this onTaskCreated event
what are the onTaskCreated event's provided arguments?

bleak mural
#

so Alpha1 and alpha 2 have wp's. i may choose to modify Alpha2's move wp with this createtask function

hallow mortar
bleak mural
#

Lou, the error?

hallow mortar
bleak mural
#

this is staright from biki, there is hardly any other info out there BIS_HC_1 setVariable ["onTaskCreated", Code, true];

winter rose
#

let's find out and fill in the blanks then

bleak mural
hallow mortar
#

If it doesn't provide any useful arguments, then you'd have to use hcSelected to get the currently selected groups, which must be the ones the order is being given to

bleak mural
hallow mortar
#

Why would you take that from what I said?

bleak mural
#

because i thought theres no way to get the ones the order is being given to

hallow mortar
#

Please read it again.

bleak mural
#

i think im starting to understand

#

yep

hallow mortar
#

In HC, you can only give orders to groups you have selected. Also, when you have groups selected, any order given is given to all those groups. Therefore, at the moment an order is given, the groups currently selected must be the groups that are being given the order.

#

The onTaskCreated event may turn out to directly provide a reference to the group in question (maybe one day we'll find out!), but if it doesn't, we can use that logic to deduce it ourselves.