#arma3_scripting

1 messages ยท Page 24 of 1

copper raven
#

yes

tulip ridge
#

Gotcha, thank you!

copper raven
#

you also want to setVehicleAmmo where the object is local (i'm not sure where that event is fired)

tulip ridge
copper raven
#

objectPlaced should work

tulip ridge
#

Do I have to do anything with the parameters?

_whenPlaced = ["acex_fortify_objectPlaced", {
    deleteVehicle test;
}] call CBA_fnc_addEventHandler;

I tried doing this just to see if it would delete a rock when placed, but nothing happens

copper raven
#

well for parameters, no

#

if test is not getting deleted then either you probably didn't add the event or idk

sullen sigil
#

Anyone know if there's a way to return when CONTINUE has been pressed on a hintC hint? Wiki says game pauses in SP but script keeps running ๐Ÿ˜…

copper raven
#

did you try sleep after it?

sullen sigil
#

not yet but scheduling the script every time its run probably isnt a good idea meowsweats

#

wait it already schedules

#

i shall try that

#

works, thanks lol -- dont think ive ever seen hintc used so wasnt sure wtf to do

copper raven
#

it probably suspends the entire scheduler, that's why it works

#

(my guess)

#

according to the note

sullen sigil
#

ah, makes sense

copper raven
#

or actually no, hintC stops the simulation, sleep is simulation, uiSleep isn't, so yeah

sullen sigil
#

oh right, gotchu - im pretty oblivious when it comes to scheduling, i just know it make the sleep

copper raven
#

same thing when you pause the game in sp, if you sleep, it just suspends until you unpause the game, then the delay happens

sullen sigil
#

ahh right -- thanks ๐Ÿ™‚

jovial robin
#

hello whats the trigger script i need to use so when a VIP is in a trigger area the mission is done

jovial robin
#

i want the mission to be finshed when this AI VIP is on the trigger

jovial robin
#

i don't know what to do i use normal trigger connected to task state and put trigger activation on indeprent the VIP but it still don't say completed

proven charm
willow hound
tulip ridge
copper raven
#

are you executing test.sqf?

tulip ridge
#

Y'know, you think I would've realized that...
Could I just add nul = execVM "test.sqf" in the initServer?

copper raven
#

just move the code into initServer.sqf

tulip ridge
#

Yep, worked fine
Perhaps I should not always be scripting at like 5 am lmao

#

Thank you for putting up with my idiot self twice now lol

#

Setting the ammo doesn't seam to be working though

// Set up ACE Fortify
[west, 5000, [
    ["3AS_HeavyRepeater_Armoured", 0]
]] call ace_fortify_fnc_registerObjects;

// Delete ammo from objects when placed
_whenPlaced = ["acex_fortify_objectPlaced", {
    objectPlaced setVehicleAmmo 0;
}] call CBA_fnc_addEventHandler;
copper raven
#

remoteExec it

tulip ridge
#

[objectPlaced, 0] remoteExec ["setVehicleAmmo"]; like this?
It didn't seem to work, but this is my first time using remoteExec, so I was looking at the wiki for it

#

Oh wait they do have a case where they set the ammo
{objectPlaced setVehicleAmmo 0;} remoteExec ["call"];

#

Wait no

winter rose
#
[objectPlaced, 0] remoteExec ["setVehicleAmmo", objectPlaced];
jovial robin
exotic flame
#

Can anyone give me a water jet example using particle effects ?

tulip ridge
#

I commented out the previous line, added that, and it now no longer appears. Changing back to the old line causes it load fine

tulip ridge
#

Oh it might've just been a weird hiccup (might not have fully reloaded the mission or something like that), but it gives the same error, that it was expecting a Group, Side, Object, etc.

winter rose
#

then objectPlaced is undefined or something like that

#

or rather, it's something entirely different that is causing the issue

tulip ridge
#

It's in an event handler, is there maybe something else I need to set up?

// Configure ACE Fortify
// Set Budget for Bluefor to 5000
[west, 5000, [
    ["3AS_HeavyRepeater_Armoured", 0]    // E-Web Turret
]] call ace_fortify_fnc_registerObjects;


// Delete ammo when placed
_whenPlaced = ["acex_fortify_objectPlaced", {
    // {_this setVehicleAmmo 0;} remoteExec ["call", objectPlaced];
    [objectPlaced, 0] remoteExec ["setVehicleAmmo", objectPlaced];
}] call CBA_fnc_addEventHandler;
winter rose
#

where is "objectPlaced" defined?

#

are you sure it is not _objectPlaced? see ACE doc

#

or you are missing a params somewhere

tulip ridge
#

Oooh wait, there's two different CBA event handlers, CBA_fnc_addEventHandler and CBA_fnc_addEventHandlerArgs

#

Maybe that's it?

winter rose
#

again, no idea

sudden yacht
#

Anyway to set an Object hostile? Without it being manned by AI?

tulip ridge
winter rose
copper raven
#

(and use local variables)

sudden yacht
#

@winter rose Essentially yes.

tulip ridge
#

Adding the params causes some issue
Did I just put the params in the wrong place?

_whenPlaced = ["acex_fortify_objectPlaced", {
    params ["_player", "_side", "_objectPlaced"];
    [_objectPlaced, 0] remoteExec ["setVehicleAmmo", _objectPlaced];
}] call CBA_fnc_addEventHandler;
#

I might actually take a break from this for a little bit, do something else for a bit and come back

copper raven
#

that looks fine

copper raven
sudden yacht
tulip ridge
#

It's not one that's displaying in-game, just the fortify menu doesn't appear
So it's probably in a log file

sullen sigil
#

i am 90% sure this is a stupid question but ive been trying to do this for half an hour now

how do i detect if an object is in the area of a trigger to use as a condition? i.e i want a specific classname of object to be in the area of a trigger and that fires the condition

stable dune
sullen sigil
#

ah, i was looking at inArea, didn't see inAreaArray :p thanks :)

#
this AND (count (vehicles select {_x isKindOf "ace_envelope_small"} inAreaArray thisTrigger) > 0);```
using this but it's not returning true when digging a trench ;-;
#

i think my brain could be frazzled or im not doing it right

#

this is blufor present in the trigger area

granite sky
#

Are you sure those trenches are in vehicles?

sullen sigil
#

What else would they be?

#

That sounds passive aggressive its not meant to sorry

granite sky
#

Beats me. I never figured what exactly counts as an entity or vehicle in Arma.

#

It feels like a critical missing part of the wiki.

sullen sigil
#

i assume its not as simple as just being in cfgvehicles or not?

#

I presume that should work then if ace_envelope_small is a member of vehicles then?

granite sky
#

Can't see anything wrong with it. From an optimisation perspective you'd normally want the select after the inAreaArray.

sullen sigil
#

roger, i'll ask in grad trenches then -- thanks ๐Ÿ™‚

granite sky
#

yeah they're not in vehicles.

#

Looks like it's only physX objects.

sullen sigil
#

ah

#

any idea for a different approach then?

open hollow
#

entites ?

granite sky
#

(nope)

sullen sigil
#

i mean i could just change the activation to anybody so thisList becomes all objects, right..?

#

and then modify script accordingly

hallow mortar
#

Yes, and that would probably be better because iterating through vehicles is not necessarily fast

granite sky
#

nearObjects works.

sullen sigil
#

I tried something with that before and it didn't work either ;-;

hallow mortar
#
count (thisList select {typeOf _x == "ace_envelope_small"}) > 0```
sullen sigil
#

one mo lemme change vehicles to thisList

#

ya

granite sky
#

getPosATL player nearObjects ["ace_envelope_small", 10] is picking up this stupid trench :P

sullen sigil
#

is that editor placed or dug with etool?

granite sky
#

Dug with etool.

#

Haven't checked the type inheritance though.

sullen sigil
#

thats working for me in debug console too so i presume i could just make that equal a bool or some shit..?

hallow mortar
#

Don't forget you can use lazy evaluation to save performance:

if (condition1 && {condition2}) then { ...
// condition2 will only be evaluated at all if condition1 returns true```
sullen sigil
#

oh i thought they (&&, AND) meant the same thing

#

or is that what the {} is for

#

let me test without GRAD trenches but it should work the same

south swan
#

a && {b} means "don't bother to run b if a is false already"

sullen sigil
#

ah gotchu

hallow mortar
#

&& and and are the same. {} in an and construct controls lazy evaluation.

sullen sigil
#

i should probably go back and change a fair bit of my code then ๐Ÿ˜…

#

going to try without grad trenches but i dont see why it wouldnt work with them ๐Ÿคท

#

wait what

#

@granite sky you werent using grad trenches were you? the small envelope one doesnt show up with regular etool thonk

granite sky
#

plain ACE + small trench

sullen sigil
#

ignore me, grad changes it so its not as high :p

#

ok so its not working without grad trenches either thonk

#

thats the trigger stuff

#

c (size) is set to -1 so not an issue with that

granite sky
#

I would be quite surprised if triggers activated on stuff you can only find with nearObjects.

sullen sigil
#
count (getPosATL player nearObjects ["ace_envelope_small", 10]) > 0``` should accomplish the same thing for the sake of testing, right?
granite sky
#

well no, because one's checking the trigger area and one's checking 10m from the local player.

sullen sigil
#

basically accomplishes the same thing for my use case so not a huge deal

granite sky
#

At least check a radius from thisTrigger :P

copper raven
#

why not use thisList?

sullen sigil
#

because thisList is only condition objects and i cannot for the life of me make the trench show up in it no matter what i do

#

aha

sullen sigil
#

i'll try it with thisTrigger instead shortly

copper raven
#

you can probably go with a much cleaner way by using trench ehs

#

im sure they have some for when you place them or whatever

sullen sigil
#

almost certainly but everything is contained within object inits atm

#

ok so that works with thisTrigger so ๐Ÿคท

#

will try reintroduce grad trenches and see if that breaks anything but unlikely

granite sky
#

uh, check the inheritance of the trench objects.

sullen sigil
#

i dont think it was an issue with grad trenches per se but just extra complexity on top of standard ace

granite sky
#

I have a note here that all the GRAD trenches individually inherit from "Base_Bag_F", so you have to search for each type separately.

sullen sigil
#

ah, its fine as player gets to told to dig one specific type of trench

granite sky
#

Just assume that every Arma modder hates missions and it works out.

sullen sigil
#

failure shall result in pulverisation

#

so far i only have like 2/5 sections for this mission done and each one has taken literal hours

#

cool, still works with GRAD trenches -- thanks for help all ๐Ÿ™‚

sullen sigil
#

not quite the thing i was looking for :p

#

but working all good now anyways ๐Ÿ™‚

#

...now doors arent disabling simulation properly

#

why can this never go right

south swan
#

well, then sqf ["ace_fortify_deployFinished", { (_this#0) params ["_player", "_side", "_configName", "_posASL", "_vectorDir", "_vectorUp"]; if (_configName == "Land_BagFence_01_long_green_F" && {asltoagl _posASL inArea tttt}) exitWith {hint "WOOO3"}; }] call CBA_fnc_addEventHandler;

#

"i want to rune some code as soon as X happens" is a good indicator that EH may help ๐Ÿคทโ€โ™‚๏ธ

south swan
hallow mortar
south swan
#

setting it to CIV (which matches the side cursorObject when i look at the stuff) doesn't help as well. I guess triggers don't check for the object with simulation = "house"; or something

hallow mortar
#

Try it with Anybody

south swan
#

still nope

tulip ridge
south swan
#

look up?

tulip ridge
#

It just stays snapped to the ground

#

Maybe it's just because I'm in VR, but it just stays halfway in the ground no matter where I look

south swan
#

are you "looking" or "aiming" up then?

tulip ridge
#

Like if I'm using freelook with alt?

south swan
#

ah, i guess i'm mixing things. VR map doesn't seem to break stuff for me. When i aim up - i get things floating above the ground ๐Ÿค”

tulip ridge
#

I think it might just be with how tall the ladders are, it works with other objects

torpid pewter
#

That seems to be working thank you so much, I can't believe I never tried this earlier, finally get to play an old mission that's been broken for so long.

#

I have another scripting question, not necessarily for the same person, but the mission also has a crate full of specific weapons with the variable name "a1", that unfortunately for whatever reason glitches out and doesn't spawn properly, and I'm wondering if it's possible to spawn it in game with the debug console. I've tried a few variations of script commands but I don't think they were designed for this.

Is this possible?

open fractal
torpid pewter
#

Yeah I figured that would be one way, but I mean to spawn that specific crate that's already defined by the mission. This way would be a bit more tedious, but could still work if the way I want is not possible.

south swan
#

i can think of one or two ways of getting the data of that crate to replicate it with script. But it would be kinda involved. As in: either "dig through the debinarized version of mission.sqm" or "copy-paste the crate into a separate mission, save, export to SQF, dig through the exported code and only leave the relevant parts" involved

sullen sigil
#

me again ๐Ÿ˜ƒ

this addEventHandler ["Hit", {
Six12th_Targets = Six12th_Targets + 1;
systemChat str Six12th_Targets;
this removeEventHandler [_thisEvent, _thisEventHandler];
}];``` seems to never remove and eventhandler stays, meaning target gets hit and `Six12th_Targets` increases every time its hit
#

(it should only increase once per target ever)

south swan
#

"this" isn't defined inside the EH

sullen sigil
#

ah

south swan
#

_this#0 should be used instead

sullen sigil
#

within the EH or overall?

south swan
#

within the EH

sullen sigil
#

gotchu -- what does the #0 bit mean?

hallow mortar
#

it's an abbreviated form of select 0, selecting the 0th element in the array

sullen sigil
#

Ah, thanks ๐Ÿ™‚

#

Works fine, time to copy paste tons

torpid pewter
#

Hmm, well the crate issue isn't too big of a deal I can just circumvent it and it's a rare issue. The more important issue I've found is that the mission seems to restart for all players if someone joins in progress. I know typically when a mission isn't designed for JIP that person spawns at the beginning, but it seems to restart the whole mission.

What would be the cause of this? I can send the mission in the DM if anyone wants to look.

hallow mortar
#

That would have to be something that's scripted that way. Could be a playerConnected EH, something in init.sqf...there are a few ways it could be done so without knowing the mission (don't send it to me, I don't have time to dissect it) it's not really possible to go "oh yeah, that's definitely caused by x"

torpid pewter
#

Ok I see, there script that moves the players at spawn was in initlocalplayer.sqf which I didn't know until now executes locally for all players during start and join in progress. That would make sense.

#

Moving it to init.sq seems to have fixed it, but still need to figure out a way to move the player, but I think I can do that.

sullen sigil
#

are there any requirements mission-side for playMission? I'm getting an A3 loading screen then returning to main menu a few moments later with the right terrain loaded but judging by the rpt no attempt to load it

sullen sigil
#

changing to config pathing has fixed it for some reason

torpid pewter
#

So what I'm trying to do now is execute a script only when a player joins in progress. The script's function is to spawn the player near other players already in game and I know it works

However, I can't seem to find a way to execute it only on join in progress. It works if I put it in initplayerlocal.sqf but that breaks another script in init.sqf that only when the mission starts, spawns the players at a specific marker.

I tried putting the script in init.sqf and using the onplayerconnected command but that didn't seem to work.

How do I run this script only on players that are trying to JIP?

granite sky
#

probably broken though :P

gray anvil
#

22:20:37 Error GIF pre stack size violation
the fuck is this

sullen sigil
#

did you try write a different language in sqf

pseudo ridge
#

There is a way to make AI land vehicles don't go into an map area? The only way i know is put many PhysicX small objects on this area. Any better way? ๐Ÿ˜”

copper raven
warm hedge
#

I recently have that thing, I forgot what it was... something related to an array I recall

cosmic lichen
#

I think this happens if you have a very large , nested array with a missing bracket

copper raven
#

so weird meowsweats

#

if anything i just get a crash ๐Ÿ˜„

tender fossil
#

Note: Arma 2 OA!

What on earth is happening here? ๐Ÿ˜…

"WFBE_Server_PV_SupplyMissionCompletedMessage" addPublicVariableEventHandler {
    
    private ["_message", "_side"];

    _message = _this select 0;
    _side = _this select 1;

    // This throws an error
    if ((side player) == _side) then {
        _message call CommandChatMessage;
    };
};
String STR_EVAL_TYPENAN not found
Error in expression <de = _this select 1;

if ((side player) == _side) then {
_message call CommandCh>
  Error position: <== _side) then {
_message call CommandCh>
  Error ==: Type Array, expected Number,String,Object,Side,Group,Text,Config entry,Display (dialog),Control,Team member,Task,Location
tender fossil
gray anvil
tough abyss
#

is there a way to get cordinates and add a certain amount to a certain axis?

#

like getpos then add something to the position

winter rose
#

yes

#
private _newPos = getPosATL player vectorAdd [0,0,1]; // 1m above
tough abyss
#

thanks lou

#

how would you determine if a player is heading towards the x or y axis?

winter rose
#

getDir, sin and cos
but you might prefer getRelPos

copper raven
#

check their velocity?

winter rose
#

or modelToWorld commands

#

modelToWorld
modelToWorldWorld
modelToWorldVisual
modelToWorldVisualWorld
๐Ÿ˜„

tough abyss
#

thanks

#

what do you use to get a vehicle weapon? other than cfgvehicles?

#

and a magazine?

winter rose
#

depends on the use case

tough abyss
#

air vehicle but i think i can find it in config

spiral temple
#

When I change the owner of a object via setOwner (server-side) the object vanishes... is there something I need to know?

winter rose
spiral temple
#

it's a crate

copper raven
#

are you the one creating the crate?

spiral temple
#

no, the crate is created server-side

copper raven
#

with createVehicle?

spiral temple
#

yes

copper raven
#

what kinda crate? (classname)

spiral temple
#

well, at least all vanilla crates I tried - as example: Box_NATO_Support_F

copper raven
#

cannot reproduce

#

alias to select with higher precedence

#

its all you need

wind hedge
#

Guys, I have some markers named "INFO_01", "INFO_02", "INFO_03" etc etc... and then I have other markers which are "CIVCAR_01", "CIVCAR_02", "CIVCAR_03". Then a script creates Agent NPCs at the locations of the INFO markers. Finally I need to create a vehicle at the CIVCAR marker location but to do so correctly in need to get the last two numbers on the INFO marker name so I can create the right vehicle for each agent at the right CIVCAR marker. How do I do that?

#

In short, which command do I use to get the last two numebers in a string (the marker name)

copper raven
south swan
copper raven
#

no need

#

private _mkr = format ["CIVCAR_%1", _infoMkr select [5, 1e6]]

tough abyss
#

how would i go about adding items to a backpack

tough abyss
#

that is in the inventory of a weaponholder?

tough abyss
south swan
tough abyss
#

thanks

copper raven
#

not sure though

sullen sigil
#

Is there any way to play a video on the player's screen?

#

i.e if i have a gif/mp4/whatever format, is it possible to shove it onto the players screen in the top left

copper raven
sullen sigil
#

and here i was about to make it frame by frame, thanks ๐Ÿ™‚

south swan
#

inb4 drone and r2t :3

sullen sigil
#

nein is just for "narrator" most likely

copper raven
sullen sigil
copper raven
#

actual id?

south swan
#

O_o

copper raven
#
private _data = _playerDataArray select _index;
_data pushBack format ["Data A-%1", parseNumber (_data select -1 select [7, 1e6]) + 1]
#

that?

#

it adds string "Data A-(+1 from last)" to the array everytime you run it

hallow mortar
#

This feels like it should be a hashmap so you can get by player ID properly.

south swan
#

or parallel arrays + find

copper raven
#

that was the goto way before hashmaps ๐Ÿ˜„

sullen sigil
#

...wait i have to create this video frame by frame anyway meowsweats

#

unless theres a fade imagine in command ๐Ÿ˜‚

sullen sigil
#

image

#

not imagine

#

im just trying to fade an image into the top left of the players screen while narrator talks

copper raven
#

oh, so that's totally different from what you were asking ๐Ÿ˜„

#

use hashmaps

sullen sigil
#

wait i dont want BIS_fnc_playVideo either way that covers the entire screen

south swan
#

to play the video on an object, e.g an in-game screen, see Example 3
doesn't sound fullscreen

sullen sigil
#

in game as in on object

#

is what thats referring to as far as i can tell

copper raven
#
private _uid = getPlayerUID player;
private _hashmap = [_uid] createHashMapFromArray [[0, "blabla"]];
_hashmap get _uid set [0, 1000];
systemChat str (_hashmap get _uid); // [1000,"blabla"]
sullen sigil
#

oh thats easy

#

thanks, think its an image display in that case then

copper raven
#

don't use an array

#

use a hashmap like in my example

#

where key is the player uid

#

no, it's some dummy data (as an example)

south swan
dreamy kestrel
#

Hello, trying to get a handle on appropriate remoteExec (or remoteExecCall) vis-a-vis JIP.

Writing a multiplayer mission, have the units down as 'slots', but have found that the slot unit may not be the same object as the unit on "redeploy". So any actions, etc, I expected were not there.

Question is, does any of that snafu matter when the object in question is not a player (slot or deployed) object? JIP executes on joining, actions may be applied appropriately, and so on.

Thanks...

winter rose
#

if you wonder "will an addAction added in initPlayerLocal.sqf work on a non-player object", the answer is yes

granite sky
#

More generally, slot -> object mappings in MP are temporary, but objects are persistent.

#

You can JIP an addaction on an object, and as long as that object still exists then the addaction will work for newly connected players.

dreamy kestrel
#

okay so if I follow correctly, player is not necessarily the "same" player OBJECT depending on 'when' you find him re: the slot...
but any other target object should be fine for JIP purposes...

winter rose
#

yep, they are hopefully synchronised
just the "player" character object can be deleted/created on leaving/join

dreamy kestrel
#

cool, seems consistent experientially as well. thank you.

granite sky
#

Players are a different object after respawning too, although some stuff is moved over.

winter rose
#

(some?) Event Handlers

warm coral
#

is there a way to delay a module activating?

#

a way that doesnt use triggers

#

because im trying to use the ace ambient sounds module and a trigger doesnt seem to delay the activation

#

dug into ace github and found this

LOGIC, [bob, kevin], true] call ace_missionmodules_fnc_moduleAmbianceSound
#

but that misses the option of the sounds following the players

granite sky
#

So random 1000 occasionally returns 1000.

#

this is not good

#

Like 1 in a few million calls.

winter rose
#

or at least, it shouldn't?

granite sky
#

It certainly fucking shouldn't, yes.

#

But it does.

winter rose
granite sky
#

Had an "impossible" error in some code so I did a check.

winter rose
#

hmmmmmm

viral basin
#

Hey there, does createSimpleObjcet also respect Named Properties of the p3d? I created a flat object with a texture and used class=land_decal but it still floated above the surface and the lighting was strange.

south swan
winter rose
#

uuuuuuffโ€ฆ @still forum ๐Ÿ˜ƒ

granite sky
#

Couldn't get selectRandom to break, but that probably doesn't have the int->float conversion.

still forum
winter rose
#

random 1000 can return 1000

#

rarely, but it can

still forum
#
Number from 0 (included) to x (excluded)

Guess wiki is wrong then

#

are you sure that its 1000, and not 1000-epsilon?

#

make ticket then and don't ping

#

bye

winter rose
#

โค๏ธ ๐Ÿ˜„

south swan
#

random 1000 == 1000 returned true ๐Ÿคทโ€โ™‚๏ธ

dreamy kestrel
south swan
#

sigh

dreamy kestrel
#

are you sure it was not evaluated random (1000 == 1000). which is stronger from precedence?

south swan
#

precedence going wrong 40M times and then correct once would be an even better bug ๐Ÿคฃ

copper raven
knotty crow
#

I'm trying to get a brighter mortar flare script to function in multiplayer, what commands would have to be executed with remoteExec?

this addEventHandler ["Fired", 
{ 
if ((_this select 4) isEqualTo "Flare_82mm_AMOS_White") then { 
 _firedObj = (_this select 6);
 _light = "#lightpoint" createVehicle ( getPosATL _firedObj ) ;
 _light setLightBrightness 5.0; 
 _light setLightAmbient [1, 1, 1]; 
 _light setLightUseFlare true; 
 _light setLightFlareSize 5; 
 _light setLightFlareMaxDistance 500; 
 _light setLightColor [1, 1, 1]; 
 _light lightAttachObject [_firedObj, [ 0, 0, 0 ]];
_thread = [_firedObj, _light] spawn { 
    _obj = _this select 0;
    _light = _this select 1;
    
    waitUntil {isNull _obj};
    deleteVehicle _light;
    };
}; 
}];```
copper raven
#

all of them

#

make a function

#

or add event handler on every machine

knotty crow
#

I've been told createVehicle is global

copper raven
#

lightpoints are local no matter what you use

#

you should be using createVehicleLocal for them

knotty crow
#

gotcha

#

and I'd have to use remoteExecCall since it's unscheduled, right?

copper raven
#

waitUntil {isNull _obj}; use ammo event handlers btw

copper raven
#

try adding EH on every machine first, it might work fine

#

i know though that sometimes it doesn't fire on remote machines (don't remember the reason)

knotty crow
#

I think the wiki said it's better practice to use remoteExecCall and make it a function instead of putting spawn in a normal remoteExec

copper raven
#

it's best to stay unscheduled when you can

knotty crow
#

but then again you said something about ammo remote handlers

#

so if I can just do it with remote handlers that'd be fine

knotty crow
#

yeah i guess i could try that?

#

so if I just remoteExec the event handlers it might work

#

I'll try that

copper raven
#

don't remoteExec, try with remote ehs first

copper raven
#

it already runs on every pc, so you don't need to do anything additionally

knotty crow
#

yeah running it from an init

#

oh so I shouldn't need to event handler it

copper raven
#

the deletion part?

#

if yes, then yes you do, it's better

knotty crow
#

oh I mean remote exec not event handler

copper raven
#

no need yes

knotty crow
#

ok

copper raven
granite sky
#

IIRC on the server, Fired always triggers.

#

but clients and HCs have the camera restriction for remote units.

#

HC object location counts as the camera :P

knotty crow
#

so wait, if the player isn't looking at the mortar that fires the flare it won't run on their client so they won't see the light?

granite sky
#

I don't think it's directional.

#

Just radius around camera position.

knotty crow
#

that's annoying

granite sky
#

Your best bet for this stuff is probably to install the Fired handler only on the server, and then remoteExec the contents.

copper raven
#

mortar should be fine i imagine

knotty crow
#

alright I'll probably put it all in a function and remoteExec the function when the Fired handler fires

#

multiplayer scripting makes my brain hurt

slender olive
#

Hey, I need some help
I'm trying to set up a PvP Battlefield Breakthrough-style gamemode and I'm having trouble making it so that once the first sector is captured Opfor, the next sector opens up for capture by Opfor. I have this right now (variable name secn is a sector)
Trigger condition: Sec1 getVariable "owner" == EAST
Trigger OnActivation: Sec2 setVariable ["taskOwner",Everyone];
I'm sure that "everyone" isn't the correct thing to put where it is, but how would I change the task owner to make it capturable by everyone? Sec2's "trigger owners" variable is set to Nobody at mission start btw

#

I also know that the trigger is activating properly because a hint pops up that I made to test it

#

Nevermind, it being a task in the first place doesn't change weather or not it's capturable. In that case, how would I make any of that happen? Lol

#

Also, if anyone does come up with an answer please @ me

copper raven
slender olive
copper raven
#

yes

slender olive
#

Didn't seem to work, something else is wrong too

tough abyss
#

is there any way to detect when a player is in the water?

#

like animstate etc?

copper raven
#

animstate event handlers probably

#

if you want to check if they currently are underwater, eyePos player select 2 < 0

copper raven
#

might want to look into the function itself

winter rose
slender olive
copper raven
slender olive
#

I don't see anywhere in the attributes anything about simulation

copper raven
#

_logic enableSimulation false

tough abyss
#

or swimming

slender olive
winter rose
winter rose
tough abyss
slender olive
copper raven
#

execute it where the logic is local

slender olive
#

I'm gonna try this enableSimulation false

copper raven
#

no

slender olive
copper raven
#

give the logic a name

slender olive
#

U want me to place a "game logic" object and name it?

copper raven
#

no i mean the sector logic

slender olive
#

Oh, the "sector control" gamemode logic or the sector itself? Cuz the sector I already have named

copper raven
#

the latter

slender olive
copper raven
#

not really, i'll explain this again, you give the sector logic a name (you already did you said), then, you disable it's simulation, via enableSimulation

#

you should make your trigger server only aswell

slender olive
#

Ok

cold mica
#

Anyone have an idea on how to get a random name?
I tried

_unit setName (configFile >> "CfgWorlds" >> "GenericNames" >> "SahraniNames");

But that was not correct.

copper raven
cold mica
#

Any way to convert values of a config to an array?

copper raven
#
private _cfg = configFile >> "CfgWorlds" >> "GenericNames" >> "SahraniNames";
_unit setName configName (_cfg select floor random count _cfg);
#

should work

#

or perhaps

private _cfg = configFile >> "CfgWorlds" >> "GenericNames" >> "SahraniNames";
_unit setName getText (_cfg select floor random count _cfg >> "FillThisIn");
cold mica
#

I'll try either

copper raven
#

classname sounds incorrect, so the second, i think there should be a "pretty name" in the class, check the config

cold mica
#

I tried the following:

private _cfg = configFile >> "CfgWorlds" >> "GenericNames" >> "SahraniNames" >> "FirstNames"
_unit setName configName (_cfg select floor random count _cfg);

Which works, however it assigns names of variables to the units rather than the values. (For example, instead of David, a unit is named DAVID1, DAVID2, etc.)

copper raven
#

replace configName with getText

cold mica
#
private _cfg = configFile >> "CfgWorlds" >> "GenericNames" >> "SahraniNames" >> "FirstNames"
_unit setName getText (_cfg select floor random count _cfg);

Yep, this works. Thanks!

granite sky
#

Turns out that this will give around 1 in 50 million of your units a blank name :P

copper raven
#

huh

granite sky
#

_cfg select floor random count _cfg is busted because random doesn't 100% guarantee that it will roll below the input value.

#

In this case you can just replace with selectRandom _cfg which probably doesn't have the same issue.

copper raven
#

selectRandom does not take config

#

well then subtract a small amount i guess ๐Ÿ˜…

#

or min _cnt - 1

granite sky
#

oh, this is working directly with config. Fun.

copper raven
#

i never knew that ๐Ÿ˜„

#

always been using it like that

granite sky
#

Yeah I was until it threw an impossible error at me yesterday :P

copper raven
#

so wiki is wrong?

granite sky
#

Arma is wrong :P

#

Like random is clearly supposed to work as the wiki says.

#

Probably an int->float conversion glitch.

copper raven
#
[] spawn {
    private _attempt = 0;
    while {true} do {
        if (_attempt % 50000 == 0) then {
            systemChat str (_attempt toFixed 0);
        };
        if (random 10 == 10) exitWith {
            systemChat str ["hit", _attempt toFixed 0];
        };
        _attempt = _attempt + 1;
    };
};
#

kek

#

ticket worthy perhaps

sullen sigil
#

What file formats are accepted by playsound3d? .wss doesn't seem to be working thonk

copper raven
#

should work, you probably converted it wrong

#

or perhaps you aren't passing the full mission path

sullen sigil
#

playSound3D [getMissionPath "myaudio.wss", player, true]; is what im doing thonk

#

wiki uses getmissionpath in its example

#

and myaudio.wss is in an audio folder in the scenario folder

#

oh wait you need that

#

brug

copper raven
#

yeah? ๐Ÿ˜„

sullen sigil
#

getMissionPath implied otherwise to me but i think i am just smooth brain

#

wait, ignore me

#

there is an issue it just wasnt a pathing one

#

playSound3D [getMissionPath "audio\myaudio.wss", player, true, [0,0,0], 2, 1, 0]; isn't playing anything now that ive added the bits onto the end thonk

copper raven
#

if it's true, then the format must be wrong/encoding or whatever

#

actually, no

#

and you're passing [0,0,0] as position

#

pass nil

sullen sigil
#

aaaah right i thought it meant offset ๐Ÿคฆ

#

(as the default was 0,0,0)

#

thank you ๐Ÿ™‚

unique cypress
#

Sorry noob question ahead: why does this event handler ignore my sleep command? ๐Ÿ˜ฆ

#

this addEventHandler ["FiredMan", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
sleep (1 + random 1);
[ATLoader, player] say3D [
selectRandom [
"aaa_reloading1","aaa_reloading1","aaa_reloading1",
"aaa_reloading1","aaa_reloading1","aaa_reloading1",
"aaa_reloading1","aaa_reloading1","aaa_reloading1"], 100]; }];

copper raven
#

you cannot suspend in unscheduled

unique cypress
#

Is there any "easy" work around?

open fractal
#
selectRandom [
                "aaa_reloading1","aaa_reloading1","aaa_reloading1",
                "aaa_reloading1","aaa_reloading1","aaa_reloading1",
                "aaa_reloading1","aaa_reloading1","aaa_reloading1"]
``` uhhh
unique cypress
#

Havent found anything on google why sleep does not work with EH

copper raven
unique cypress
unique cypress
unique cypress
#

I just want a simple "Reloading" shout after i shot the AT Gun, followed by a "reloaded"

granite sky
#
this addEventHandler ["FiredMan", {
    params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
    [] spawn {  
        sleep (1 + random 1); 
        [ATLoader, player] say3D [
        selectRandom [
                "aaa_reloading1","aaa_reloading1","aaa_reloading1",
                "aaa_reloading1","aaa_reloading1","aaa_reloading1",
               "aaa_reloading1","aaa_reloading1","aaa_reloading1"], 100];  
    };
}];
unique cypress
#

Works like a charm!

#

thank you so much!

runic edge
warm hedge
#

A spawn in an EH is sleep-able. More like spawn makes it sleep-able

runic edge
#

oh ok, and is this warning from the wiki spawn page still true : "When multiple Code is spawned in an order, there is no guarantee that the spawned Code will execute in the same order (see Example 2). If the order is important, use BIS_fnc_spawnOrdered." ?

warm hedge
#

Yes

runic edge
#

I'll go read this ! Thank you ๐Ÿ™‚

unique cypress
#

So it seems that the AT guns from IronFront somehow have just HE loaded - which is a problem as i am not able to destroy tanks with it.
Iยดve tried to by pass that with a EventHandler HandleDamage + setdamage on the tanks, which works. The Problem is, that even a indirect hit (for example 3m in front of the tank) will destroy the tank.

Would anyone happen to know how to script that a direct hit is necessary? Or "apply" a required damage threshold?

drowsy geyser
#

If I define a global variable inside init.sqf, is it the same as doing: publicVariable ?

#

I mean does the global variable update on all pcs or do I need to remoteExec the variable for everyone if the the variable changes?

copper raven
copper raven
drowsy geyser
#

Thank you

hallow mortar
unique cypress
#

lol... to remove the current magazine i found out, the gun uses "FakeWeapon" ammo...

#

Thanks, much appreciated - will give feedback if i get it to work with the right ammo

pseudo ridge
#

Waypoints: What is the difference from types "UNLOAD" and "TR UNLOAD"?

winter rose
#

it might be "unload everyone but vehicle crew"

granite sky
#

yeah, TR UNLOAD is a waypoint you give to the vehicle crew group to offload the vehicle cargo group. It's surprisingly reliable as waypoints go.

#

I think UNLOAD is the vehicle-in-vehicle one, which is poorly supported.

#

GET OUT is for getting the crew group out of a vehicle.

pseudo ridge
#

Thanks!

cyan dust
#

Is there any way to open inventory other than

player action ["Gear", _someCrate]

?
I want to allow player to open certain crate even if it is far away from them

winter rose
#

I want to allow player to open certain crate even if it is far away from them
no can do I believe
create an invisible crate and move it near the player?

cyan dust
rocky basin
hallow mortar
tender fossil
#

Arma 2 OA! How to get a remote unit to which an object is local (the script is executed on server)? objectFromNetId seems to return the original owner of the object which is exactly what I'm not looking for ๐Ÿ˜›

south swan
tender fossil
south swan
#

extra oof

#

and it is (at least in 3) just an iteration over allUnits meowsweats

hallow mortar
#

Could you have a local script that runs on mission start/respawn that makes each client report its player unit as a variable the server can access?

tender fossil
frank sonnet
#

Hey, just begining with most of eden scripting, and I'm coming across a couple issues with my script.

This is the init:

Protaganist diableAI "MOVE";
Protaganist switchMove "ActsPercMrunSlowWrflDf_FlipFlopPara";
Protaganist switchMove "";
Protaganist switchMove "AmovPercMrunSlowWrflDf";
Protaganist switchMove "";
Protaganist switchMove "HaloFreeFall_non";
animationState Protaganist;
#

Just for note, two main issues. The first, none of the animations will play. The unit will just begin to run off.
Secondly, whenever attempting to add the disableAI line, it'll prompt me with an error specifically ";" was missing.

hallow mortar
#

Well, step 1, disableAI is spelled wrong.
Secondly, switchMove has instant effect and you're running all those commands immediately after each other, so the unit has no time to play any of them before being put into the next (last one being a freefall state which it presumably immediately recovers from).
You may also need to disableAI "ANIM" to prevent it doing whatever it wants.

frank sonnet
#

Haha, it is! That's why is worked the first time, but not after a retype.
How should I space out animations, I've tried the sleep command but it doesn't have any change at the moment?

hallow mortar
#

sleep doesn't work in init fields because they're unscheduled and sleep requires a scheduled environment (https://community.bistudio.com/wiki/Scheduler). You'll need to create a scheduled environment, for example by using spawn.

frank sonnet
#

How do I use spawn?

hallow mortar
frank sonnet
#

Okay, and this method doesn't require writing anything outside of the eden editor?

hallow mortar
#

It does not

frank sonnet
#

Awesome, the animations are back!

#

Sorry to berate you with questions, but do you have any ideas on how I can keep the freefall animation playing? Do I just need to throw them into the air?

hallow mortar
#

You could write a loop that repeatedly runs the animation, or you could adjust the height at which the freefall animation automatically triggers (https://community.bistudio.com/wiki/setUnitFreefallHeight) to something super low. Kind of depends on where you need the unit to be and what you need it to do.

jade acorn
#

how can I place that Laws of War campaign particle-orb-thing? I wanted to create a scenario with similar system of memory points/places, just can't find any info or a solution on whether it is an object or a particle spawned or what

unique cypress
#

I dont know which orb you mean, but if thats kind of an anomaly thingy you could try out one of aliascartoons scripts as an alternative maybe?

jade acorn
unique cypress
#

oh ok, thats quite subltle

#

grab the link, give me a sign and then lets delete the last messages so your question does not get lost

jade acorn
#

nah no need to delete, if I don't manage to get that effect in few days I'll just ask again, thx for the link

unique cypress
#

Noob question, but not sure what to google for an answer..

Can i go with: if then <do code> else <no code> to have code only fired when the unit is still alive?

copper raven
unique cypress
#

Oh cool, so i would just skip the else. Thanks for your answer!

fervent halo
#

What kind of a script should I use to automatically disable AI moving after they have respawned, and only allowing them to move after I have activated a trigger or so?

#

I hate to see the AI going on a 10km run to regroup with me after they have respawned

copper raven
#

ai cannot respawn though?

fervent halo
#

When they respawn on "respawn_x", they go on a long hike to regroup with me

#

I would like to prevent that from happening

copper raven
#

are you using some mod that does that?

fervent halo
#

Also, how can I make that the AI can respawn from player placed respawn points such as sleeping bags?

#

Lambs danger but it is disabled for the player group

copper raven
#

no i mean the respawning

fervent halo
#

Ah

#

No I do not use any mods which affect AI respawning afaik

#

Multiplayer tab has custom respawning enabled

#

And I have a "respawn_independent" there too

#

I also noticed that the AI takes and does move orders after respawning or parting ways with me, but returning to formation doesn't do a thing

#

So I can't really proceed forward with them unless I issue them a move command separately

copper raven
#

i've never heard of vanilla AI being able to respawn, as in true respawn (like the player unit)

fervent halo
#

Isn't AI respawning on "respawn_side" vanilla behaviour?

#

If thats not the case then I have some mod interfering

#

Definitely

copper raven
#

is the AI playable?

fervent halo
#

Yeah

copper raven
#

ah that's probably why it works

#

i mean you can try respawn eh maybe?

fervent halo
#

Whats that

copper raven
fervent halo
#

Oh I have no idea how to create that or where to put the script into

copper raven
#

init box should work

fervent halo
#

My scripting skills are very limited

#

init.sqf?

#

Or

copper raven
#

the init box of the unit

fervent halo
#

Ah

sullen sigil
#

i think this should be fairly easy but i just cannot figure it out
i want to generate a number with BIS_fnc_randomInt, but make sure i dont get the same number twice in a row. ive managed to work out i want to generate a new number if i get the same one twice, but dont know how to check if that number is the same number again without just if statementing for all eternity

copper raven
#

twice or more than that?

#

if twice, just keep a variable of the previous value

sullen sigil
#
_idleLineOld = 0;
_idleLine = [1,3] call BIS_fnc_randomInt;
if (_idleLine == _idleLineOld) then {
//generate random number again
};```
#

but i do not know what to do if the random number generated again is the same again

copper raven
#

you can use recursion

sullen sigil
#

i am small brain person please explain

#

wait i think i have figured it out

unique cypress
#

GerTank3 addEventHandler ["Hit", {
params ["_unit", "_source", "_damage", "_instigator"];

Where would i define _instigator = player?

Can i do this in the init.sqf and it will be registered in any EventHandler which contains "_instigator"? Or would i define that in every unit init where the EH gets fired?

open fractal
#

you're already defining _instigator with the params line

#

_instigator will be whatever fired the round that hit the tank

hallow mortar
#

The params available in the EH are special variables that read the properties of that specific event. Each instance only exists in, and only contains the information for, that specific hit event.
They can't be globally changed.

What you can do, if you need the instigator to always be the player, is use https://community.bistudio.com/wiki/setShotParents to set the properties of the projectile involved in the hit event. You would do this at the time it's fired using a Fired EH.

That being said, if the instigator is always going to be the local player, you may as well just use player and not try to screw around with the _instigator param at all.

unique cypress
#

Thanks so much for that detailed explanation! So i would just replace _instigator with player and will be fine?

tough abyss
#

how does one define a variable as code? is it like a function? im more so looking for documentation on syntax

#

cant find any examples

copper raven
copper raven
tough abyss
#

thanks just checking it is how i imagine it would be

#

couldnt run it as i am on bad pc

copper raven
#

{} represents a code constant in sqf, cfgfunctions doesn't do anything special other than assigning a code value to a variable

granite sky
#

well, it also blocks overwriting the variable, like compileFinal.

copper raven
#

it does use compileFinal to do that, you can do that manually aswell

leaden ibex
#

Hello there, is it possible to add a key event handler, that will execute a function every time that key is pressed - in mission, no mods
I am looking at CBA function cba_fnc_addKeybind, which even adds they keybind into the Configure addons in settings.

The line I am using right now

["IMF", "ViewDistanceLong", ["Set view distance to long", "Set view distance to long"], {
    call IMF_fnc_setViewDistance;
}, {
    call IMF_fnc_setViewDistance;
}, [DIK_F1, [false, false, false]]] call CBA_fnc_addKeybind;

But the function IMF_fnc_setViewDistance is never called, any ideas why that would be?

Is it a problem, that this is in mission files, or can it be there?
If so, is there any other way to achieve something similar?

open fractal
leaden ibex
open fractal
#

systemChat str _this to determine if the event handler is firing

leaden ibex
#

monkaHmm it is, give me a second

#

Ok, managed to get it working with the "vanilla" way, but weirdly it doesn't work with CBA way.
If anyone has any idea, let me know!

leaden ibex
velvet merlin
#

setAnimSpeedCoef has local effect

#

does it mean you need to apply it on all machines?

#

or does the position sync handle that itself

open hollow
#

according the comments on the wiki:

nomisum
Must be executed on all clients to work properly in MP (otherwise only movement speed is adjusted, not animation itself)
Waffle SS.

For animation speed to control unit speed, this must be executed on the local client. Non-local clients can set a speed less than the local client's. Non-local clients using an animation speed greater than the local client's may result in the animation freezing.

proven charm
winter rose
proven charm
winter rose
#

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

#

I have as much information as you provided

proven charm
#

I'm using BIS_fnc_addRespawnPosition

winter rose
#

ok

proven charm
#

but it doesn't take picture, maybe marker though

tender fossil
#

Arma 2: OA!

            if (_friendlyCommandCenterInProximity) exitWith {
                {
                    _iteratedPlayerUID = _x select 1;
                    diag_log format ["_associatedSupplyTruck: %1, leader group: %2, getPlayerUID leader group _associatedSupplyTruck: %3, _iteratedPlayerUID: %4, _playerObject: %5", _associatedSupplyTruck, leader group _associatedSupplyTruck, getPlayerUID leader group _associatedSupplyTruck, _iteratedPlayerUID, _playerObject];
                    if ((getPlayerUID (leader group _associatedSupplyTruck)) == _iteratedPlayerUID) then {
                        _playerObject = _x select 0;
                        _match = true;
                    };
                } forEach (WFBE_SE_PLAYERLIST);

                _currentSupplyTruckDriverLeader = _playerObject;

                diag_log format ["_playerObject/_currentSupplyTruckDriverLeader: %1, _match: %2", _playerObject, _match];

playerObject doesn't get updated if there is more than one player on the server. What might cause it?

#

RPT print (hid some details): ```
2022/10/11, 4:51:12 "_associatedSupplyTruck: O 1-1-C:1 (somePlayer) REMOTE, leader group: O 1-1-C:1 (somePlayer) REMOTE, getPlayerUID leader group _associatedSupplyTruck: 76561198108738xxx, _iteratedPlayerUID: 0, _playerObject: <NULL-object>"
2022/10/11, 4:51:12 "_associatedSupplyTruck: O 1-1-C:1 (somePlayer) REMOTE, leader group: O 1-1-C:1 (somePlayer) REMOTE, getPlayerUID leader group _associatedSupplyTruck: 76561198108738xxx, _iteratedPlayerUID: 76561198053533xxx, _playerObject: <NULL-object>"
2022/10/11, 4:51:12 "_associatedSupplyTruck: O 1-1-C:1 (somePlayer) REMOTE, leader group: O 1-1-C:1 (somePlayer) REMOTE, getPlayerUID leader group _associatedSupplyTruck: 76561198108738xx, _iteratedPlayerUID: 76561198108738xxx, _playerObject: <NULL-object>"
2022/10/11, 4:51:12 "_playerObject/_currentSupplyTruckDriverLeader: <NULL-object>, _match: true"

#

The _match does change to true but _playerObject stays <NULL-object>

#

2022/10/11, 4:44:04 "WFBE_SE_PLAYERLIST after iterating: [[<NULL-object>,"0"],[O 1-1-H:1 (somePlayer) REMOTE,"76561198053533xxx"],[O 1-1-C:1 (anotherPlayer) REMOTE,"76561198108738xxx"]]"

#

(The first null object is intentionally added there)

tender fossil
winter rose
#

you declare it somewhere before?

tender fossil
winter rose
#

_playerObject

#

also debug _x select 0 while you're at it

tender fossil
#

Yes, it's defined in upper scope with private variable

#

Hmm true, will do

copper raven
#

_x select 0 is null obj from what it looks like

open hollow
tender fossil
# winter rose `_playerObject`

It was caused by uninitialized variable on server, the error messages were just a bit confusing. Got it fixed, but thanks in any case! And same to @copper raven ๐Ÿ™‚

Quick question since my buddy who I'm testing with is apparently in bit of a hurry, is there a quick way to limit marker visibility (to given side only) apart from PV'ing it and making it local?

tender fossil
# winter rose `setMarkerAlphaLocal`?

The code spawning the marker is client side, and thanks to the famous rubber duck I realized that I need to make it server side (I guess?) ๐Ÿ˜„

winter rose
#

either
create it locally if the player is of the correct side
or
create it global server-side and setMarkerAlphaLocal on the client

your call

frigid oracle
#

How do I check which Respawn Module a player is spawning at? I wish to have a respawn event handler preform different actions depending on the selected respawn location.

jade acorn
#

I'm trying to make player do some animations during cutscene, one of which is "Acts_trailer_campCommander" however everytime this one ends, player immediately goes into that lying down dead/unconscious state. I do it as follows:

player playMoveNow "acts_trailer_campCommander"; 
player playMove "AmovPercMstpSnonWnonDnon";```

so last move should cause the campCommander animation to change into the standing anim, but unit still goes on the ground
is it just because it shouldn't be used on playable units? How am I supposed to know which one I can use and which ones I can't? Or how to set these animations so the campCommander one doesn't end with my unit on the ground?
proven charm
#

and then check where the _unit is closest to, and run your actions

frigid oracle
frigid oracle
#

Oh wait closest to check? does near entitles work on modules?

proven charm
frigid oracle
#

Good idea, will look into it

proven charm
#

i was thinking of something like: if(_unit distance2D (markerpos "respawn1") < 50) then { do stuff };

frigid oracle
#

Gotcha

hasty frigate
#

hey guys, I'm looking for a scripting command to get the player camera position (visual), currently the only command to get true eye position (including head tracking offsets) is with positionCameraToWorld which is simulation and so doesn't work in vehicles.
There also doesn't appear to be any way to pull current 6dof headtracking offsets independently

hasty frigate
winter rose
hallow mortar
winter rose
#

then nothing else is available

copper raven
knotty crow
#

Keep getting Error reserved variable in expression when I run this, dunno why. I've tried switching variable names around and it doesn't seem to work.

fnc_mortarFlare = {
    params = ["_obj"];
    _light = "#lightpoint" createVehicleLocal (getPosATL _obj);
    _light setLightBrightness 5.0; 
    _light setLightAmbient [1, 1, 1]; 
    _light setLightUseFlare true; 
    _light setLightFlareSize 5; 
    _light setLightFlareMaxDistance 500; 
    _light setLightColor [1, 1, 1]; 
    _light lightAttachObject [_obj, [ 0, 0, 0 ]];
    waitUntil{isNull _obj};
    deleteVehicle _light;
};
this addEventHandler ["Fired", 
{ 
if ((_this select 4) isEqualTo "Flare_82mm_AMOS_White") then {
    _firedObj = (_this select 6);
    [_firedObj] remoteExecCall ["fnc_mortarFlare", 0];
    };
}];
knotty crow
#

yeah, just fixed it by switching that to _obj = _this select 0;

proven charm
#

or just remove the =

knotty crow
#

now i'm getting Error cannot suspend in this context which is weird because I thought remoteExecCall ran the function in a scheduled environment

#

oh wait it's the other way around?

copper raven
#

Call variant executes the function in unscheduled

proven charm
#

yep ๐Ÿ™‚

knotty crow
#

aaa

#

so if i run [[_firedObj], fnc_mortarFlare] remoteExec ["call", 0]; would that work?

#

this hurts my brain

copper raven
#

that would work but that's terrible

knotty crow
#

:)

copper raven
#

you're broadcasting the code value over

#

define the code value on every machine, and pass a string

#

_firedObj remoteExec ["fnc_mortarFlare"]

#

this addEventHandler ["Fired", are you running this code from an initbox?

knotty crow
#

yes

copper raven
#

that's also bad

#

imagine there are 3 players on the server, player x fires, the 3 players tell every player + self to create a flare

knotty crow
#

would adding a condition so the code in the fuction so it only runs on the client be better

copper raven
#

initboxes run on every pc

#

add the EH on the server only

knotty crow
#

so pass a -2 argument on a remote exec

copper raven
#

no

#

add if !isServer exitWith {} before the addEventHandler

tender fossil
#

(With the first option, the server just PV's the needed data to the clients)

knotty crow
copper raven
knotty crow
#

multiplayer scripting is confusing i have no idea what i'm doing

#

alright

copper raven
#

createVehicleLocal (getPosATL _obj) except maybe for this part, createVehicleLocal ASLToAGL getPosASL _obj for the proper position format

#

ah infact you're attaching the light, so you can simply just pass [0, 0, 0]

knotty crow
#

yeah

#

will this only work on a dedicated server? trying to test it on a local mp server, no errors but i'm not getting the behavior I want

copper raven
#

well what's wrong?

south swan
#

are projectiles synced over the net, though?

copper raven
#

the bigger ones are i think

knotty crow
#

I don't see any light attached to the mortar flare

copper raven
#

you're in sp or mp?

knotty crow
#

tried in SP and on a local MP server, non-dedicated

#

just in editor

#

dunno if that makes a difference

#

Here's what i'm using now

fnc_mortarFlare = {
    _obj = _this select 0;
    _light = "#lightpoint" createVehicleLocal (getPosATL _obj);
    _light setLightBrightness 5.0; 
    _light setLightAmbient [1, 1, 1]; 
    _light setLightUseFlare true; 
    _light setLightFlareSize 5; 
    _light setLightFlareMaxDistance 500; 
    _light setLightColor [1, 1, 1]; 
    _light lightAttachObject [_obj, [ 0, 0, 0 ]];
    waitUntil{isNull _obj};
    deleteVehicle _light;
};
if !isServer exitWith {}
this addEventHandler ["Fired", 
{ 
    if ((_this select 4) isEqualTo "Flare_82mm_AMOS_White") then {
        _firedObj = (_this select 6);
        _firedObj remoteExec ["mortarFlare"];
    };
}];
#

wait

#

i'm dumb

#

forgot to add fnc_ in front of mortarFlare

#

hmm still not doing anything

copper raven
#

because you removed params

#

pass an array or put params back

knotty crow
#

shouldn't _this select 0; do the same thing

copper raven
#

partially is same thing

#

if you pass a non array value params will still work

#

[_firedObj] remoteExec or switch back to params ["_obj"]

knotty crow
#

yeah switched back to params

#

no error but still not doing anything

#

it was doing an error earlier but switching to params fixed it

#

might have to add some hints to see if the function

hallow mortar
#

How do artillery flares actually work? i.e. is the burning flare actually the same object as the projectile that's fired, or is it a new object that's created when the projectile fuze triggers?

knotty crow
#

so it's attached from the moment it's created

#

so it looks a little goofy when the light is coming out of the barrel, i could add a delay but i'm lazy

#

works fine in SP without all the remote exec stuff, but now i'm having issues

copper raven
#

if it works without the remoteExec but doesn't otherwise, you're doing something wrong

knotty crow
#

here's the original code

this addEventHandler ["Fired", 
{ 
if ((_this select 4) isEqualTo "Flare_82mm_AMOS_White") then { 
 _firedObj = (_this select 6);
 _light = "#lightpoint" createVehicle ( getPosATL _firedObj ) ;
 _light setLightBrightness 5.0; 
 _light setLightAmbient [1, 1, 1]; 
 _light setLightUseFlare true; 
 _light setLightFlareSize 5; 
 _light setLightFlareMaxDistance 500; 
 _light setLightColor [1, 1, 1]; 
 _light lightAttachObject [_firedObj, [ 0, 0, 0 ]];
_thread = [_firedObj, _light] spawn { 
    _obj = _this select 0;
    _light = _this select 1;
    
    waitUntil {isNull _obj};
    deleteVehicle _light;
    };
}; 
}];
#

for SP

#

here's what i'm using now


fnc_mortarFlare = {
    params ["_obj"];
    hint "ran on client";
    _light = "#lightpoint" createVehicleLocal (getPosATL _obj);
    _light setLightBrightness 5.0; 
    _light setLightAmbient [1, 1, 1]; 
    _light setLightUseFlare true; 
    _light setLightFlareSize 5; 
    _light setLightFlareMaxDistance 500; 
    _light setLightColor [1, 1, 1]; 
    _light lightAttachObject [_obj, [ 0, 0, 0 ]];
    waitUntil{isNull _obj};
    deleteVehicle _light;
};
if !isServer exitWith {};
this addEventHandler ["Fired", 
{ 
    if ((_this select 4) isEqualTo "Flare_82mm_AMOS_White") then {
        _firedObj = (_this select 6);
        _firedObj remoteExec ["fnc_mortarFlare"];
    };
}];
#

function is running when mortar is fired, the hint text shows up

#

next i'll see if the _firedObj var is being passed to the function

#

it's not

#

when using hint str _obj I'm getting <NULL-object>

copper raven
#

still singleplayer?

knotty crow
#

this is in a local multiplayer server

#

the kind you get when you run an eden mission in MP

#

dunno if that makes any difference

copper raven
#

what kind of vehicle is firing?

knotty crow
#

mortar

#

firing flare

#

the var somehow isn't being passed from the eventhandler to the function

#

maybe because it's only on the server?

#

and not the client?

#

i'm running this from the init of a mortar vehicle

copper raven
#

nah it's most likely what artemoz said

#

remove if !isServer exitWith {}; and replace _firedObj remoteExec ["fnc_mortarFlare"]; with _firedObj spawn fnc_mortarFlare;

knotty crow
#

now says error spawn: type array, expected code

copper raven
#

wat

#

send the spawn part

knotty crow
#
this addEventHandler ["Fired", 
{ 
    if ((_this select 4) isEqualTo "Flare_82mm_AMOS_White") then {
        _firedObj = (_this select 6);
        _firedObj spawn ["fnc_mortarFlare"];
    };
}];
copper raven
#

with _firedObj spawn fnc_mortarFlare;

knotty crow
#

oh

#

wew

#

works fine now

#

but it's not MP compatible without the remoteExec, no?

copper raven
#

remoteExec will not work

#

just hope that it works the way it is right now, with remote eh

knotty crow
#

but then this code isn't really different to what i was using before, and I'm pretty sure that didn't work on MP

#

i guess I wasn't using createVehicleLocal last time i tested

jade acorn
#

I made a trigger (repeatable, when player is present in area of that trigger) which On Activation creates a holdAction for opening the strategic map.
In On Deactivation I placed [opzone_1_ui,0] call bis_fnc_holdActionRemove; (because creating that holdAction through debug console gave me ID#0) so it removes that holdAction whenever I leave the trigger area, but it does not work. It creates new holdActions whenever I walk into it (but they have no names), but nothing is removed.

#

I assume the ID could be wrong and removal process does not start, but I don't get it why

#

opzone_1_ui is the screen I attached the action to, no typos or anything like that

copper raven
#

ids aren't normalized once you remove

#

they keep incrementing

#

add > 0
remove > 0 // ok
add > 1 // even though 0 is removed
remove > 0 // fail

jade acorn
#

so my first holdAction should be removed, but it isn't and instead I have two there once I activate the trigger

copper raven
#

that means something else added an action beforehand, and the id wasn't 0

#

just store an id

#
//activation
player setVariable ["tag_currentAction", [...] call BIS_fnc_holdActionAdd];
//deactivation
[player, player getVariable "tag_currentAction"] call BIS_fnc_holdActionRemove;
hasty frigate
hasty frigate
#

I just wrote a script that checks for any world position change in every single selection position for every available LOD (and i mean every LOD, even the obscure ones) - the result: not a single player or vehicle player LOD selection position is changed due to headtracking movement (translation). Very sad times.
I'm gonna look into animations and see if maybe there is some animationPhase for the player or vehicle player for headtracking movement but I dont have high hopes ๐Ÿ˜ฆ

tough parrot
#

is there a built in signum or is (x / abs x) the only way?

warm hedge
#

I think that's the only way. You need to take 0 into account as well, though

granite sky
#

[1, -1] select (x < 0) is another slowish option.

jade tendon
#

anyone know of a script i can use to spawn fortification pieces in a specified location, for players to move and use in a custom fob

proven charm
#

still getting this error: https://pastebin.com/0hqfbiBP sometimes. I checked that all parameters passed to BIS_fnc_addRespawnPosition are valid. don't know what else to check?

tender fossil
#

Arma 2: OA! https://sqfbin.com/caloquwimosimuxacede <- player is null object sometimes, why's that? There's a check for null player object in init code: ```sqf
waitUntil {!(isNull player)};

```2022/10/12,  4:17:50 "_associatedSupplyTruck: 148e6080# 1055990: mtvr.p3d REMOTE, leader group: <NULL-object>, getPlayerUID leader group _associatedSupplyTruck: , _iteratedPlayerUID: 76561198021140xxx, _playerObject: <NULL-object>"
winter rose
winter rose
tender fossil
winter rose
#

it is also a terrible way to create/broadcast a mission, just saying o__o

tender fossil
winter rose
#

The code in above message is on server. This is how it's called (from client), and there's the null check before elsewhere in code
ta-daaa - you are sending the server's player as argument

#

oh wait, I read that wrong

tender fossil
#

Yeah ๐Ÿ˜›

#

It works - sometimes, sometimes not

winter rose
#

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

#

anyway, I'd let the server deal the tasks, not the client o_o

tender fossil
#

I'm just wondering how can the player object be null during the code execution because the mission ensures that the client init won't complete until the player object is not null

winter rose
#

no idea
maybe the server didn't connect perfectly at that time, a dirty fix would be to add a static arbitrary sleep 5;

tender fossil
winter rose
#

line 4: _playerObject = objNull; @tender fossil

#

so it's not the object that is null; it is your calculation line 25 that might not return the expected result

tender fossil
# winter rose line 4: `_playerObject = objNull;` <@106336240990707712>

Yes, it's the init for the variable - the RPT shows the following, but only occasionally, it's random: 2022/10/12, 4:54:48 "_associatedSupplyTruck: 16342080# 1055980: kamaz.p3d REMOTE, leader group: <NULL-object>, getPlayerUID leader group _associatedSupplyTruck: , _iteratedPlayerUID: 76561198021140xxx, _playerObject: <NULL-object>" 2022/10/12, 4:54:48 "_playerObject/_currentSupplyTruckDriverLeader: <NULL-object>, _match: false"

#

The debug shows that when the script iterates through the self made player list, it works but the player object somehow becomes null object now and then

winter rose
#

you diag_log before assigning variables e_e

tender fossil
#

Ok, I got more info. The null object error happens only when the PV EH is run instantly after triggering the mission from client. I even added a sleep in the beginning but it still fails

tender fossil
#

2022/10/12, 4:57:21 "_playerObject/_currentSupplyTruckDriverLeader: <NULL-object>, _match: false"

winter rose
#

IDK, you are checking leader id, etc etc
it's illegible
something somewhere is wrong, and it is not the passing of player

#

so check with WFBE_SE_PLAYERLIST that there is the data you want in there, too

tender fossil
#

(The first null object is intended, don't mind that)

winter rose
#

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

tender fossil
#

Should I file a bug report for Arma 2? KEKW

winter rose
#

you mostly should check your code logic

#

I don't see the game failing a == operation ใƒ„

tender fossil
#

2022/10/12, 5:13:43 "_x select 0: <NULL-object>" ```sqf
_playerObject = _x select 0;
diag_log format ["_x select 0: %1", _x select 0];

proven charm
winter rose
tender fossil
#
if ((getPlayerUID (leader group _associatedSupplyTruck)) == _iteratedPlayerUID) then {
    _playerObject = _x select 0;
    diag_log format ["_x select 0: %1", _x select 0];
    _match = true;
};
``` The code is only run if the IDs match
#

(Should've included this initially) ๐Ÿ˜…

#

Also I don't know why the intendation goes crazy like that, it's perfectly fine in my editor ๐Ÿ˜„

winter rose
#

you use spaces and not tabs, that's why

tender fossil
#

I use tabs!

#

Though the codebase is oooold, so it might have spaces in it

hallow mortar
#

There are 2 kinds of whitespace character, one long and one short, and Discord uses the other one when you press tab

#

It's....weird

#

I have the same problem when I copy directly from Notepad++

jade acorn
#

what's the name of default sound for holdAction? I've been going through LoW campaign files for way too long to find it and I can't get either its classname or file name/location

jade acorn
#

whenever you start a memory fragment in LoW it plays a sound, I checked every file that had anything to do with memory fragments and there's nothing

winter rose
#

I did find it and even use it, can't remember though

jade acorn
velvet merlin
#

how to optimize a "what enemies do you have in sight" further as checkVisibility in the end is quite expensive?

  1. targets to limit to known, enemies and within viewdistance
  2. if in FOV
  3. seen already in the last second
  4. not blocked by terrain (terrainIntersect) or another object (lineIntersects)
copper raven
hallow mortar
#

That's a neat trick on the pitch shift, I'll have to remember that

jade acorn
hallow mortar
#

You will also need this:

params ["_target", "_caller", "_actionId", "_arguments", "_progress", "_maxProgress"];```
jade acorn
#

oh, alright

#

thanks

granite sky
#

@velvet merlin Well, the game does a lot of that for you, right? targets etc

#

Those checks run on players, not just AIs.

ocean folio
#

anyone know why script given move waypoints dont have AI get into their vehicles?

velvet merlin
#

checkVisibility is very expensive command

granite sky
#

targets is a cheap command

#

well, not that cheap, but a lot cheaper than DIY

velvet merlin
#

so you want to limit to absolute minimum amount of executions

#
  1. targets to limit to known, enemies and within viewdistance
#

yes i used it already

#

its not that cheap if you work with VD and a good amount of targets either

#

but anyhow its not the problem at hand

granite sky
#

oh, I see.

velvet merlin
#

its to avoid checkVisibility either as you can rule out the unit by other means or you can ensure its visible by other means

granite sky
#

doesn't targetKnowledge lastSeen cover most of this?

#

Or is this some sort of every-frame application?

ocean folio
#
    params["_faction"];

    systemChat str _faction;

    // init stuff
    
    private _motorized = ("true" configClasses (configFile >> "CfgGroups" >> "East" >> _faction >> "Motorized"));
    
    private _spawnpoint = getMarkerPos selectRandom ["spawn_1", "spawn_2", "spawn_3"];
    private _group = [_spawnpoint, east, selectRandom _motorized] call BIS_fnc_spawnGroup;

    _group deleteGroupWhenEmpty true;
    // _group allowFleeing 0;
    // _group setSpeedMode "FULL";

    _wp2 = _group addWaypoint [getmarkerpos "wp", 0];
    _wp2 setWaypointType "MOVE";

When I run this, it spawns the group, gives them a move waypoint, then the vehicle with them takes off and the infantry start running behind it. Even if I start with a get in waypoint and add the move waypoint at index 1, the vehicle just takes off without the infantry.

granite sky
#

What if you give them the get in waypoint but not a move waypoint?

ocean folio
#

the vehicle very slowly drives to the position of the waypoint, with infantry in wedge behind

granite sky
#

Function is bugged, I guess. If it's spawning the right number of units then you could just run moveInAny over the units.

#

If it's not spawning the right number of units then you'll have to DIY.

ocean folio
#

spawns the right number of units, but that number isnt consistent across group types

#

the thing about moveInAny is that it requires a reference to the vehicle

#

assignedVehicles isnt available outside of dev branch according to the wiki

#

ugh I might jsut have to hack together a check for units in vehicles

granite sky
#

probably better off doing it from scratch at this point.

#

createVehicle + createVehicleCrew + fullCrew alt syntax to get cargo seats.

bright robin
#

Just used this code that worked before, but no longer it does
on description.ext

respawnOnStart = 1;
respawn = 3;
respawnDelay = 2;
reviveMode = 0;
respawnTemplates[] = { "Tickets" , "Counter" , "MenuPosition" };

on initPlayerLocal.sqf

  _playerTickets = [player, 3, true] call BIS_fnc_respawnTickets;
#

what is wrong here?

proven charm
bright robin
tender fossil
proven charm
bright robin
proven charm
#

do you see the respawn dialog? or nothing happens?

bright robin
#

it simply doesn't want to work

velvet merlin
velvet merlin
bright robin
#

and doesn't works now

#

wtf

bright robin
#

@proven charm ok, what it happens is that the ticket system for the respawns doesn't want to work

#

wich is really odd

bright robin
#

since it worked las time i've used it

vernal mural
#

What would be the most correct way to attach a player to another one ?

#

I'm experimenting with a perFrameHandler updating the position but so far, it tends to end in blood and broken bones and very messy things

#

attachTo seems to be a better idea

hallow mortar
#

attachTo is usually the best idea for attaching things to other things

#

don't forget about BIS_fnc_attachToRelative, it can be useful for on-the-fly attaching

quaint oyster
#

Someone able to assist me? I'm trying to make an addaciton that only appears when aiming at rocks on the map.

stable dune
# quaint oyster Someone able to assist me? I'm trying to make an addaciton that only appears whe...

Hi,
You can use on AddAction condition to check cursorObject is rock or nearObjects is kind of rock.
https://community.bistudio.com/wiki/cursorObject
https://community.bistudio.com/wiki/nearObjects

I have in tree cut mod where i check is cursorobject kind of tree

{
    !isNull cursorObject && {
        (("SawToolClass" in (items _player)) && ((_player distance2D cursorObject) < 3)) && {
            (((getModelInfo cursorObject) # 1) find "\tree\") != -1
        }
    }
}
tough abyss
violet gull
#

@tough abyss You can try checking that function's code in the Functions Viewer in-game and maybe figure out how it's supposed to be used

#

Advanced Developer Tools mod makes it easier to read

quaint oyster
# stable dune Hi, You can use on AddAction condition to check `cursorObject` is rock or `nearO...

That worked perfectly, thank you, by chance do you know of a way to setvariable on the cursorobject of a rock? It doesn't seem the be as straight forward as I thought.

cursorObject setVariable ["alreadyharvestedstagestone",1,true]; 

Doesn't work for me for some reason, whereas most other objects do.

I'm trying to set that to 1 so the addaction doesn't appear on the thing infinitely, and without deleting the rock from the map, as some rocks of the same classname make up parts of large map pieces.

proven charm
stable dune
bright robin
bright robin
#

i'll recall that the script worked a month ago or so

proven charm
#

ok

bright robin
# proven charm ok

that's the issue i have, i don't understand why, if the scripted worked before, now it doesn't

sturdy sage
#

If i remember correctly you can't set variables on all types of terrain objects, only some depending on simulation type. Workaround for that could be map with the obj as key and whatever data you want to save as value.

bright robin
#

as here

#

here

#

literally same script

bright robin
#

wich makes even less sense

#

because the only part that doesn't seems to work is the tickets

quaint oyster
stable dune
#
cursorObject setVariable ["SNM_harvested",true,true];
cursorObject getVariable "SNM_harvested"
quaint oyster
#

Just doesn't return anything with the getvariable, its a rock on the map, is that why?

stable dune
quaint oyster
#

Trying to make a "mining" system, Goal was to add "harvest stone" to all of the rocks, dice roll the yield of the stones, then set it as already harvested without deleting it, but leaving it unable to be used again by players. I wanted to use the map ones to avoid spawning them across the map

proven charm
#

can't you just add the stone to hashmap?

#

every stone should have unique ID, or am I wrong?

quaint oyster
#

thats above my head sadly

proven charm
#

harvestedStone = createhashmap; harvestedStone set [str cursorObject , true];

#

something like that

quaint oyster
#

I thought about doing somekind of script where it randomly places triggers, the triggers just set a variable to true, if the variable is true, let the player use "dig" which maybe spawns a rock then the rock has options, it being spawned i could make it disappear afterward

#

it wouldn't mess the map up by adding more things to the map aside from triggers, which aren't saved, i could make use a unique rock from the editor for it too since the map ones are causing me problems.

#

doing the digging system I can even adapt it to have random rewards, but then editing the trigger area might be funky, to stop the thing from being abused.

bright robin
#

@proven charm any idea on my problem?

stable dune
proven charm
bright robin
#

still

#

disapointing that the code now decided to not work

proven charm
bright robin
#

as discussed here

#

literally the same

#

copasted

unkempt bay
#

Hello,
I do have a small syntax question with alive

is there a better way to write that condition to check if all vehicles are not alive ?

if ((!alive vhl_1 && !alive vhl_2) && (!alive vhl_3)) exitWith {}

?

Thanks ๐Ÿ˜ฌ

proven charm
bright robin
proven charm
#

and maybe put hint "TEST"; in the sqf file to see its running

bright robin
#

how is that done?

#

Description.ext

#

initPlayerLocal.sqf

#

those are the file names

#

do you see any goof?

proven charm
unkempt bay
bright robin
unkempt bay
#

alright thanks ๐Ÿ™‚

proven charm
bright robin
#

mind if i dm you a thing

bright robin
#

but it shows up that the hint

proven charm
proven charm
bright robin
proven charm
bright robin
#

xd

proven charm
#

@bright robin maybe you had set some respawn setting in the 3den editor before

bright robin
#

sorry for the dms

bright robin
#

but i think they're necesary

proven charm
lavish stream
meager spear
#

Hello! I am novice with sqf. I have some errors with this script I made for a mod.

`private _detonator = _this select 0;
if (typeof _detonator == "EUG_Clacker_4000" OR typeof _detonator == "EUG_Clacker_4000" OR typeof _detonator == "EUG_Clacker_4000" OR typeof _detonator == "EUG_Clacker_5000" OR typeof _detonator == "EUG_Clacker_10000" OR typeof _detonator == "EUG_Clacker_15000" OR typeof _detonator == "EUG_Clacker_20000" ) then
{
private _result= nearObjects [_detonator, ["tfw_rf3080Object"], 6];
if count _result > 0 then
{
_detonator setVariable ['ace_explosives_Range', 99999, true];
hint "Detonator is cable linked to SATCOM. \n Satellite connection: ON.";
}
else
{
_detonator setVariable ['ace_explosives_Range', 1, true];

}
private _result= nearObjects [_detonator, ["tfw_rf3080Object"], 20];
if count _result > 0 then 
{
    hint "Detonator is NOT cable linked to SATCOM. \n Stay max 5 meters from SATCOM \n Satellite connection: OFF.";                
}        

};`

meager spear
hallow mortar
#

That probably means _detonator isn't being passed to the script properly (i.e. _this select 0 isn't returning anything useful)

kindred zephyr
#

Hello collective hivemind blobcloseenjoy

This time I'm not around here to ask how to do X or Y, but to ask how it would be best to iterate through a VERY long array

for "_i" from 0 to _itemCount do
        {
            _verifier = _removedItems pushbackUnique (selectRandom _objectArray);
            
            if (_verifier > 0) then
            {
                (_removedItems #_verifier) hideObjectGlobal true;
            };
        };

The full code contains a known list of A LOT of data (900k+ indexes at maximum) represented by _objectArray. The list is not always the same each time the mission begins, as this is ideally done once per mission due to how long it takes to do it.
_itemCount is a percentage based on the number of entries for the _objectArray.

Is there an effective way to do a looping of that magnitude without taking fucking forever?
The code itself is not complex, and it's very fast in small amounts (i.e < 100k entries) taking around a minute or so to complete, however, after certain threshold I could swear this loop bogs down and become incrementally slower the higher the data amount is. Any suggestion in how to improve this?

meager spear
#

how can I fix it @hallow mortar ?

lavish stream
bright robin
tender fossil
#

How would I refactor this code so that I could put it in addAction condition? ```sqf
{
if (_x isKindOf "Base_WarfareBUAVterminal") then {
_friendlyCommandCenterInProximity = true;
};
} forEach (nearestObjects [(getPos _associatedSupplyTruck), [], 100]);

hallow mortar
# meager spear how can I fix it <@137672072821211136> ?

The problem is likely to be with how you're calling the script - the execVM, call, or spawn that causes the script to run. The detonator object needs to be defined in that context (I don't know what context this is) and passed as an argument, e.g. [_detonator] execVM "your_script.sqf"

meager spear
#

Ok understood, thank you I will check asap

proven charm
#

@tender fossil maybe ```sqf
_friendlyCommandCenterInProximity = false;
{
if (_x isKindOf "Base_WarfareBUAVterminal") then {
_friendlyCommandCenterInProximity = true;
};
} forEach (nearestObjects [(getPos _associatedSupplyTruck), [], 100]);
_friendlyCommandCenterInProximity

tender fossil
#

I mean, I want to add the code directly to addAction parameters to get rid of these annoying bugs that happen otherwise

#

I think I could use count ... > 0 but I can't even think about how to do it anymore because I'm too tired and annoyed ๐Ÿ˜…

hallow mortar
# meager spear Ok understood, thank you I will check asap

Also, instead of using 11 million OR constructs, use this:

_validObjects = ["detonator_class1","detonator_class2",...] apply {toLower _x};
if ((toLower typeOf _detonator) in _validObjects) then { ...```
Much cleaner and makes the classnames not case sensitive
meager spear
#

Have I to write the private _detonator = _this select 0; before your code?

hallow mortar
hallow mortar
meager spear
#

ok thanks

tender fossil
#

Do I need to pass the _associatedSupplyTruck variable in some special way to addAction?

#

Here's how I have it now: ```sqf
player addAction [
"<t color='#00e83e'>" + 'UNLOAD SUPPLIES FROM TRUCK' + "</t>",
'Client\Module\supplyMission\supplyMissionComplete.sqf',
[_associatedSupplyTruck],
70,
false,
true,
"",
"(count (nearestObjects [(getPos _associatedSupplyTruck), ['Base_WarfareBUAVterminal'], 100]) > 0) && (cursorTarget == _associatedSupplyTruck)"
];

hallow mortar
#

The condition code doesn't support passing arguments. You'd have to make it a global variable.

hallow mortar
#

Or add the action to the truck instead of the player so you can use _target

meager spear
#

@hallow mortar I need more info about how to define _detonator in the context. I created a config.cpp with the new detonators (works fine) and now I wanna link the script (the sqf I attached before) to them.

#

I am testing in the editor and so I put in the init of the scenario

if (isServer) then { [_detonator] execVM "satcom.sqf"; minesarray = []; };

hallow mortar
#

You need _detonator to refer to a specific inventory object, presumably of one of those types in your list. The game does not automatically know this or know which detonator you're thinking of; you need to tell it. You need to identify the specific item and define _detonator as a reference to it.

tender fossil
# hallow mortar The condition code doesn't support passing arguments. You'd have to make it a gl...

I have it like this now:

player addAction [
    "<t color='#00e83e'>" + 'UNLOAD SUPPLIES FROM TRUCK' + "</t>",
    'Client\Module\supplyMission\supplyMissionComplete.sqf',
    [WFBE_CL_VAR_ASSOCIATED_SUPPLY_TRUCK],
    70,
    false,
    true,
    "",
    "(count (nearestObjects [(getPos WFBE_CL_VAR_ASSOCIATED_SUPPLY_TRUCK), ['Base_WarfareBUAVterminal'], 100]) > 0) && (cursorTarget == WFBE_CL_VAR_ASSOCIATED_SUPPLY_TRUCK)"
];

supplyMissionComplete.sqf: ```sqf
private ['_associatedSupplyTruck'];

_associatedSupplyTruck = _this select 3 select 0;

diag_log format ["SupplyMissionComplete.sqf: _associatedSupplyTruck: %1", _associatedSupplyTruck];

WFBE_Server_PV_SupplyMissionCompleted = [player, _associatedSupplyTruck, side player];
publicVariableServer "WFBE_Server_PV_SupplyMissionCompleted";

RPT (supplyMissionComplete.sqf): ```"SupplyMissionComplete.sqf: _associatedSupplyTruck: <NULL-object>"```
...
#

Both files are being executed on client

#

So again a mysterious null object error

#

The added action also appears twice in the action menu ๐Ÿ˜‚

meager spear
hallow mortar
#

I don't know what that means so almost certainly no

meager spear
#

class CfgWeapons { class ACE_Clacker; class EUG_Clacker_500: ACE_Clacker { author="[EUG] Eughenos"; displayName="Detonator M57 500m"; ace_explosives_Range=500; };

#

here is the config.cpp

hallow mortar
hallow mortar
# meager spear `class CfgWeapons { class ACE_Clacker; class EUG_Clacker_500: ACE_Cl...

This is a cfgWeapons, which means it defines a type of weapon that can exist. It does not define a specific instance of that weapon, it only defines that a weapon of this type is possible.
I'm not certain that cfgWeapons works in mission config, and I'm not certain that setVariable works on weapons properly - I don't think they exist as true unique objects with persistent properties

hallow mortar
granite sky
#

@meager spear What do you need to do in your satcom.sqf?

meager spear
#

Have you a better idea of how to realize this concept?

granite sky
#

shrugs

#

The problem's what Nikko said. Weapons aren't objects so you can't store variables on them.

#

In this case I'd have thought that storing the var on the player would be fine.

copper raven
brazen lagoon
#

hey, how do supports work? like how do I add them to the command menu