#arma3_scripting

1 messages Β· Page 635 of 1

little raptor
#

setDir
setVectorDirAndUp should work too

#

let me test

still forum
#

maybe andUp works but normal setVectorDir doesn't, mh

sage dawn
#

I've had issues with setting rotation of attached objects

little raptor
#

@still forum confirmed, and up works

#

setVectorDir doesn't

still forum
#

can you send me a example line?

spark turret
little raptor
#

@still forum

_unit = typeOf player createVehicleLocal [0,0,0];
_unit attachTo [player, [0,0,0]];
_unit setVectorDirAndUp [[0,-1,0],[0,0,1]]
still forum
#

I attached to a memory point, and setVectorDirAndUp just does nothing for me 🀣

#

whai

#
_unit = typeOf player createVehicleLocal [0,0,0];
_unit attachTo [player, [0,0,0], "launcher"];
_unit setVectorDirAndUp [[0,-1,0],[0,0,1]];
little raptor
#

hold on it does

#

"launcher" doesn't exist

#

try rightHandMiddle1

still forum
#

launcher does exist

little raptor
#

maybe in some other lod

still forum
#

memory lod

#

mem points are in memory lod

little raptor
#

my bad

#

and it works for me

still forum
#

That's the script I posted above πŸ€”

little raptor
still forum
#

A bollard

#

I'm trying to attach a thing to my launcher position, but doesn't work without rotation :/
I shouldn't have broken it PikaThink

spark turret
#

a literal "manpad"

winter rose
#

oooh size factor!

#

can we get that so we have soldiers of different sizes as well? πŸ˜„
you opened the Pandora's box now

#

or RC tanks πŸ˜„

little raptor
#

yes please!

winter rose
#

oh my, the possibilities!

spark turret
#

child soldiers

#

or even better:
MEGA GOATS

#

Goatzilla

winter rose
#

@jade abyss ↑ !!!

still forum
#

still can't really get the setVectorDirAndUp working right :/

#

attached objects have a relative orientation to parent, but that command doesn't modify it.
Maybe we need seperate command to do that then.. with MP sync notlikemeow

little raptor
#

that command doesn't modify it
what do you mean?

#

that it should be absolute?

still forum
#

setVectorDirAndUp doesn't seem to modify the attached object orientation, atleast not when attached to a mempoint πŸ€”

little raptor
#

it does on my build!

#

you broke things again?! πŸ˜„

still forum
#

hmpf

#

can you send screenshot of how your script looks for you?

#

There surely is a BIS function that turns euler angles into VectorDirAndUp right?

little raptor
#

dunno

winter rose
still forum
#

eeeee

little raptor
#

if it's "polar" its a bit different

#

no, it's not. it's in spherical coordinates

#

so yeah that's the one

little raptor
#

is that lagrangian or eulerian transform?

#

I think it's Eulerian

spark turret
#

note to self:
the amount of light flares (tracers) you can display at once is around 40/50

#

it will just render the closest 50 ones

#

when do bullets get deleted by the garbage collector?

winter rose
#

when they hit for sure
BIG MAYBE after 8s of lifetime?

winter rose
spark turret
#

bullets themselves

little raptor
#

BIG MAYBE after 8s of lifetime?
they have a life time in their config

spark turret
#

yeah seems about right with the 8s

little raptor
#

timeToLive

spark turret
#

sounds like a feel-good song

#

whats a good eventhandler to detect if the bullet is no more to delete its lgiht?

#

i used waitUntil isNull but uh thats not that performance friendly πŸ˜„

winter rose
#

isNull, unfortunately

#

maybe we will get a deleted EH

spark turret
#

so.. ill have to run a coroutine for every fired bullet?

little raptor
#

none of them work work on bullets

little raptor
vestal field
#

Is it possible to make a 'force push' script? Bascially when i hit a key it would just apply x amount of force to a object

warm hedge
#

addForce?

vestal field
#

Yea like that but

little raptor
#

forces are only possible with PhysX objects

winter rose
#

I tried git addForce, it didn't work

vestal field
#

Yea that's the goal really

little raptor
#

the alternative is velocity

vestal field
#

Just push physx objects around abit like a gravity gun

#

I know zombies and demons manages to give their units alot of force in their hits but that would be config related i guess

little raptor
#

you can do it with event handlers

#

plus it's not force

#

it's velocity

#

any way, if you want force addForce is your only choice

#

maybe addTorque too

queen cargo
# little raptor we don't have "coroutines" in arma

Well ... technically, spawn is indeed a coroutine. It runs on the same thread afterall. However, you barely have any control about the scheduler indeed, which means you cannot pause a spawned script or resume it

ebon citrus
#

Hi everyone

#

What are all of you up to lately?

#

Any cool bugs in 2.0?

still forum
ebon citrus
#

Was there a signed vector rotation function in Sqf?

little raptor
#

@vestal field

findDisplay 46 displayAddEventHandler  ["KeyDown", {
 params ["", "_key"];
 if (_key == 33) then { //F
  _obj = cursorObject;
  _mass = getMass _obj max 1;
  _obj addForce [player weaponDirection "" vectorMultiply _mass*2,[0,0,0]];
 };
}]
tough abyss
#

Wondering if anyone can help me, as I can't really find much documentation on the wiki, I'm trying to add a new radio channel just for map markers, and only for specific players. I have the following code in init.sqf

// Air Radio
if (isServer) then {
    _unitList = [S001,S002,S003...];
    _radioIndex = radioChannelCreate [[255,0,0,0.8], "Custom Radio", "%UNIT_NAME", _unitList]; // Create radio channel
    _radioIndex enableChannel [false,false]; // Disalllow text/voice messages
};

But I'm seeing the following error in the server RPT log

if (isServer) then {
_jhcUnitList = [S001,S002,S003,S004,S005,P001,P002,P003,>
14:58:03   Error position: <S001,S002,S003,S004,S005,P001,P002,P003,>
14:58:03   Error Undefined variable in expression: s001
14:58:03 File mpmissions\__cur_mp.Altis\init.sqf..., line 35
ebon citrus
#

There is no unit/object named S001

tough abyss
#

Those are the names we've set for playable units

ebon citrus
#

Obviously not, as they dont exist

tough abyss
#

Works when I host a LAN server, just not on dedicated

ebon citrus
#

Ahhh, MP environment

#

I see

#

Have fun! See you guys kater

little raptor
tough abyss
#

They're set in mission.sqm

worn forge
#

is this a case issue? s001 vs S001?

little raptor
#

SQF is case insensitive

still forum
#

its a player slot thats empty, no AI no unit

tough abyss
#

Ahhh, that would make sense

#

What would be the best way to add on a player-by-player basis then? I've tried doing the radioChannelCreate in init.sqf and then radioChannelAdd in initPlayerLocal.sqf but it didn't work.

still forum
#

?

tough abyss
#

My problem is I only want units in that list to use the radio.

ebon citrus
#

Onjoin?

still forum
#

store them as strings, get them via getVariable with objNull as default value

ebon citrus
#

Through playerconnected ir similar

#

If the unit needs to exist when the script runs, then run the script as the unit is created

tough abyss
#

But if I run it every time a unit is created, won't it create multiple channels?

ebon citrus
#

Cant you create the channel in init and join players to it as they connect?

languid oyster
#

Anyone knows a way to change a CBA setting externally? What I mean is following: A checkbox setting value is stored in the variable XX_var1. Can be true or false, dependent on the checkbox setting.
Now, I change this variable externally, for example if I set in the debug console
XX_var1 = true;
But when I open cba settings, respective checkbox will stay unchecked, though the variable was set to true. How do I manage to have that CBA checkbox set external?

tough abyss
#

Makes sense, so something like

init.sqf

if (isServer) then {
    _radioIndex = radioChannelCreate [[255,0,0,0.8], "Custom Radio", "%UNIT_NAME", []]; // Create radio channel
    _radioIndex enableChannel [false,false]; // Disalllow text/voice messages
};

initPlayerLocal.sqf

if (_playername in _unitList) then 
{
    CHVD_maxView = 10000;
    CHVD_maxObj = 10000;
    _radioIndex radioChannelAdd [player];
}
worn forge
#

Not tested -

init.sqf or initServer.sqf

if (isServer) then {
    myCustomRadioChannel = radioChannelCreate [[255,0,0,0.8], "Custom Radio", "%UNIT_NAME", []]; // Create radio channel
    myCustomRadioChannel enableChannel [false,false]; // Disalllow text/voice messages
};

onPlayerRespawn.sqf

if ( str player in ["s001", "s002", ...] ) then {
   ["myCustomRadioChannel", player] remoteExecCall ["publicVariableClient", 2];
   waitUntil {!(isNil "myCustomRadioChannel")};
   myCustomRadioChannel radioChannelAdd [player];
};
ebon citrus
#

You could use missioneventhandlers. I dont remember the soecifics, but make sure that the unit is alive/created before you try to join it

#

The initPlayerLocal might run befire the unit even exists

tough abyss
#

where can i send pictures to get help with a error i have

#

Ahh OK

ebon citrus
#

@tough abyss imgr link

worn forge
#

problem is server creates the radio channel id# but I don't think that # is broadcasted / synced to players? Could be wrong

serene quiver
#

Howdy folks...
...so I want to put a cooldown time for a repetable radio trigger that executes a .sqf script. Not a problem with a true; false; variable at the beginning and end of the script:

support = false;
//stuff
sleep 60;
support = true;
playSound3D ["A3\dubbing_f\modules\supports\misc_new_available.ogg", player];```

What I would like is a hint that comes up if the player calls the support with the radio trigger that says: "support will be available in: countdown time"...any suggestion?
ebon citrus
#

So a scheduled task with "waitUntil alive player" (pseudocode)

#

Only 2 months and im already getting rusty to the degree i dont remember the syntax of these commands

winter rose
#
waitUntil { not isNull player };
```…or use `initPlayerLocal.sqf`
grim ravine
#

Oop, wrong reply

ebon citrus
#

@winter rose is initPlayerLocal good for this?

#

Does init after the unit is created?

#

Well, i usppose so

#

It comes after init.sqf, right?

#

So after the mission.sqm aswell

winter rose
#

I believe so yes

tough abyss
#

@ebon citrus I cant even take a screenshot

#

can I go live in call?

#

really fast

little raptor
tough abyss
#

I unloaded all my mods but still cant play official servers

#

I get a error with something with "addons"

#

and key

little raptor
#

what does it have to do with scripting?

winter rose
tough abyss
serene quiver
#

Not good?

little raptor
#

what trigger?

serene quiver
worn forge
#

Fisher I've implemented publicvariableclient wrong, wait one

tough abyss
#

Thank you

worn forge
#

onPlayerRespawn.sqf

if ( str player in ["s001", "s002", ...] ) then {
   [clientOwner, "myCustomRadioChannel"] remoteExecCall ["publicVariableClient", 2];
   waitUntil {!(isNil "myCustomRadioChannel")};
   myCustomRadioChannel radioChannelAdd [player];
};```
little raptor
serene quiver
#

Trigger activated by radio channel: "alpha","bravo"....πŸ˜‹

#

R you trolling me???

#

πŸ˜‚

little raptor
#

no I don't know what they are. I'm not a mission maker

#

anyway, you can just put the code in the activation code

winter rose
#

it's a trigger that triggers when you press 0-0-1 (Alpha) to 0-0-9 (…other letter)

spark turret
#

the time has come.
i am willing to learn how to differnetiate between reference and value clone

#

anyone able to explain how to do the two things?

little raptor
#

you're referring to arrays?

spark turret
#

i am willing to reward that person up to 1 virtual cookie πŸͺ

tough abyss
#

Thanks Ryko, I'll try that now

spark turret
#

yes arrays

little raptor
#

what do you mean differentiate?

#

you want to have two separate variables?

spark turret
#

well, how to i make a reference and how do i make a value clones

little raptor
#

one a reference, one a clone?

spark turret
#

yeah

serene quiver
little raptor
#

@spark turret

_array = [];
_ref = _array;
_copy1 = _array + []; //shallow copy
_copy2 = +_array; //deep copy
little raptor
serene quiver
little raptor
#

ok. but if it's a one time thing why not just delete it afterwards?

serene quiver
#

need a cooldown time in essence..

#

no repetable trigger

little raptor
#

ok. so what you wrote should be fine...almost

spark turret
#

thanks will read up

serene quiver
little raptor
#

well I mean did you define that variable?

#

support

serene quiver
#

in the trigger condition

#

with this && support;

little raptor
#

you can't define (initialize) it there

serene quiver
little raptor
#

triggers don't have init

serene quiver
little raptor
#

no not that

#

maybe this

#
if (time < missionNamespace getVariable ["nextSupport", 0]) exitWith {
  systemChat format ["Support will be available in %1 seconds", round(-time + (missionNamespace getVariable ["nextSupport", 0]))];
};

nextSupport = time + 60;
[] spawn {
  sleep 60;
  playSound3D ["A3\dubbing_f\modules\supports\misc_new_available.ogg", player];
};
#

try that in your trigger activation code

serene quiver
#

thank you

little raptor
#

hold on

#

let me correct one thing

#

ok now it's good

serene quiver
little raptor
#

@serene quiver also don't forget to set your trigger condition to this

ebon citrus
#

@tough abyss ctrl+alt+prtscr on windows to copy current active window

little raptor
#

@serene quiver I think I misunderstood what you wanted.

#

or maybe I didn't

#

let me know if it does what you want

tough abyss
#

Im doing it rn but its loading forever

#

he didnt see my error btw

little raptor
#

well the validation told you it couldn't validate 2 files

#

so that was your issue

tough abyss
#

I know

#

Thanks btw

serene quiver
tough abyss
#

can i put my pc on sleep while its validating @little raptor

little raptor
#

no!

#

it should've been done by now if it was just two files

#

did you click on ok?

spark turret
#

ive had that before, forgot why and how to fix. according to biki my code is correct?

                //define parameters for the sound (playSound3d)
                _left = [
                    _sound,
                    objNull,
                    false,
                    _position,
                    _volume,
                    _pitch,
                    0
                ];

                [_left,_shots,_id, _fireRate] spawn {
                    params ["_left","_shots","_id","_fireRate"];
                    for "_i" from 0 to _shots do {
                        _left remoteExec ["playSound3D",_id];
                        sleep _fireRate;
                    };
                };

error:
17:26:55 Error when remotely executing 'playsound3d' - wrong number of arguments (7) passed, must be either 0, 1 or 2

#

playSound3d takes 7 arguments, so i dont get why it doesnt want them now

winter rose
#

[[]]

tough abyss
little raptor
#

[_left] @spark turret

tough abyss
#

Only thing is

16:24:56 Server: Object 7:6 not found (message Type_120)
16:24:56 Server: Object 7:7 not found (message Type_92)

but I have no idea what that is

worn forge
#

are your units named s001 or S001? because converting it to strings will probably make it a case issue... ie., try changing it to str player in ["S001", ... if your unit variables are S001

worn forge
#

you could do that, or you can be consistent with your variables

little raptor
#

variables are not case sensitive

worn forge
#

...

#

if you convert it with str then it will be a factor

winter rose
#

in is case-sensitive yes

tough abyss
#

I'm using code that was already there and working in onPlayerRespawn to set viewdistance

#

Unit names are definitely capitalised

little raptor
#
(toLower str player) in (_array apply {toLower _x})
#

now it's not

winter rose
#

anyway, str in is an awful way to do so πŸ˜„

little raptor
#

or you could use findIf

worn forge
#

Hey, I'm not saying it's perfect, I'm just saying it's a means to an end when you can't ensure the variable is there or not

#

@tough abyss change it to str player in ["S001" and see if that works, if it does then you can either keep on rollin' with that or find a prettier way to do it

little raptor
#

when you can't ensure the variable is there or not

isNil
isNull
spark turret
#

only check isNull if its not isNil

worn forge
#

Sure, add an extra step

tough abyss
#
_playername = str player;
if (_playername in _unitList) then  {
#

Has worked for us before

#

Just adding your code inside the if statement

#

It works!

spark turret
#

why string? doesnt your unitList hold objects?

tough abyss
#

Added to onPlayerRespawn.sqf

customRadio enableChannel false;
worn forge
#

It's player objects, so if the slot isn't filled, the variable doesn't exist

spark turret
#

also a guess, but str player will not catch respawned players bc their object changes iirc. could use name player

winter rose
#

respawned players keep their vehvarname I believe

worn forge
#

yeah, that's my experience

tough abyss
#

For anyone else - or myself when I forget, below now working

init.sqf

if (isServer) then {
    customRadioChannel = radioChannelCreate [[255,0,0,0.8], "Custom Radio", "%UNIT_NAME", []]; // Create radio channel
    customRadioChannel enableChannel false; // Disalllow text/voice messages
};

onPlayerRespawn.sqf

if (str player in ["Unit1", "Unit2"...]) then 
{
    [clientOwner, "customRadioChannel"] remoteExecCall ["publicVariableClient", 2];
    waitUntil {!(isNil "customRadioChannel")};
      customRadioChannel radioChannelAdd [player];
    customRadioChannel enableChannel false;
}
worn forge
#

So you've got specific units which are tied to air channel - are they also units of the same class? Or rank? I'm just trying to imagine a better identifier to when they get added to a channel rather than a specific unit variable name, so Leopard20 can be happy

tough abyss
#

The reason we have it like that is because we're a Milsim, so it's to separate out the different roles

worn forge
#

Could you use rank as a differentiator? If the player is a certain rank, they get added to the channel?

fading tiger
#

Hi everyone, I have a problem with the addon compiler.

I am calling a file for a function class testFunction {file = "test.sqf";};
It compiles the folder and Arma 3 detects the category, but can't find the file test.sqf.
The sqf and the config.cpp are in the same folder.

little raptor
#

post your cfgFunctions

hazy juniper
#

hy, I created a bear for arma 3 named Brownbear_F. I added the bear to the automated spawned Species on my map. how can i find one with script command in editor debug console?

fading tiger
#

`class CfgFunctions
{
class blue_mind
{
class Test
{

            tag = "testtag";
            postInit = 1;
            class testFunction {file = "test.sqf";};
    
        
    };
};

};`

little raptor
little raptor
#

Have you made it into an addon?

#

or is that in the mission folder?

#

if it's an addon, you must add the addon path too

fading tiger
#

I made it to an addon, but I didn't knoe, that I needed to add the path. I will try it.

little raptor
#

@fading tiger something like "MyAddon\test.sqf"

hazy juniper
#

@little raptor It give back many of this values under the debug execute window: 0x2cbe4180,Agent.

fading tiger
#

@little raptor That's it, thank you very much. I appreciate it.

little raptor
#

@hazy juniper yes, that's your animal

#

how did you want to find it then?

hazy juniper
#

@little raptor no i have too much trees, is there a possible setpos player command to see it?

little raptor
#
My_Animals = nearestObjects [player, ["Brownbear_F"], 1000];
onEachFrame
{
{
  drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\CrewAimIndicator\gunnerAuto_ca.paa", [1,1,0,1], ASLToAGL aimPos _x, 0.5, 0.5, 0, str _forEachIndex];
} forEach My_Animals;
};

to setpos:

player setPosASL getPosASL (My_Animals#0);
#

get the index from the icons, and use it like (My_Animals#index)

hazy juniper
#

nice! thx a lot @little raptor

idle jungle
#

hey guys ive put

//--- Control Chat - Format: {channelID<number>, disableChat<bool>, disableVoice<bool>}
disableChannels[] = {
    {0, true, true}, //--- Global Chat
    {1, true, true}, //--- Side Chat
    {2, true, true}, //--- Command Chat
    {3, false, false}, //--- Group Chat
    {4, false, false}, //--- Vehicle Chat
    {5, false, false}, //--- Direct Chat
    {6, true, true} //--- System Chat
};``` into my description.ext 

however i can still manage to type in chat, does it not necessarily mean i cant type but others just wont see it?
worn forge
#

This is in your description.ext?

idle jungle
#

yeah should it be in a init.sqf?

worn forge
#

I think it's not working properly there - surest way is to put

2 enableChannel [false, false];
``` in your `initPlayerLocal.sqf`
#

(Obviously one statement for each of the channels you want to affect)

idle jungle
#

ahhh because enablechannel is a local command IIRC

worn forge
#

Yup

idle jungle
#

thanks ill give it a go

worn forge
#

πŸ‘

idle jungle
#

it worked but global channel was still there :/

0 enableChannel [false, false];
1 enableChannel [false, false];
2 enableChannel [false, false];
3 enableChannel [false, false];
4 enableChannel [false, false];
5 enableChannel [false, false];
6 enableChannel [false, false];```
#

unless global cannot be stopped

worn forge
#

You can't remove that channel, or direct channel. But only a logged-in admin can use global anyway

idle jungle
#

ohhh

#

makes sense that im seeing it appear as im testing on lan quickly

worn forge
#

yup

idle jungle
#

last quick question
if lets say on a dedi i would want to login as the admin how would i do it with every channel disabled haha

#

unless i keep direct open maybe

worn forge
#

I think when you're in the lobby screen the sqf isn't run yet, so group channel isn't yet disabled, and further, since direct can't be disabled, you'll always have a channel to type in

idle jungle
#

ohh okay makes sense thanks for the help bud

finite sail
#

you could remove their radio

oblique arrow
finite sail
#

iirc, it takes away all the chat channels,

#

i dropped my radio, i still had global channel, but that might be because I'm host/client in my test serevr

oblique arrow
#

Huh, I didnt think it actually did anything

#

I'll have to test that at some point, thanks bongocat

finite sail
#

πŸ™‚

serene quiver
#

Hello..
would createTrigger be more performance-friendly/efficient than a regular trigger? Let me explain: I have 9 composition (bandits camps) that spawns randomly on 36 markers scattered around Altis. To have guards patrolling the camps I set up triggers (BLUFOR present) so they spawn once the player gets near them. As you can imagine, there're a LOT of triggers around the map. I thought that maybe get the trigger to spawn JUST where they're needed would be better. Is it? And how?
I looked up the https://community.bistudio.com/wiki/createTrigger page...
Something like this?

_trg = createTrigger ["EmptyDetector", getPos ???]; 
_trg setTriggerArea [400, 400, 0, false];
_trg setTriggerActivation ["WEST", "PRESENT", true];
_trg setTriggerStatements ["this", "execVM "spawn_guard.sqf";"];```
Thank you

NOTE the ```sqf
setPos ???``` that because is unclear to me what to put here. I could use setMarkerPos "marker" but then I have to create 36 of themm.I'm confused.
worn forge
#

Lots of triggers isn't a good idea. I'd run something a bit differently; a single routine which checks every X seconds to see if your player is in the vicinity of, say, a marker. And if so, then you run your spawn_guard.sqf script

worn forge
#

untested -

myFancyDetector = [] spawn
{  while ({alive _x} count allPlayers > 0) do
   { sleep 20;
     {  if (  [allPlayers select {alive _x}, getMarkerPos _x] call BIS_fnc_nearestPosition < 400 ) exitWith
        { (getMarkerPos _x) execVM "spawn_guard.sqf"; };
     } forEach myMapMarkers; // predefined array of your markers
   }
};
#

I assume you'd need to pass a position to spawn_guard.sqf

serene quiver
#

I'm gonna test that script now..report back asap

serene quiver
#

Doesn't seem to work...mmm..just to be clear, this is how I tested it:
VR map,
1 player.
3 markers: "marker_0","marker_1","marker_2"
In the init.sqf:

private myMapMarkers = ["marker_0","marker_1","marker_2"];


myFancyDetector = [] spawn
{  while ({alive _x} count allPlayers > 0) do
   { sleep 5;
     {  if (  [allPlayers select {alive _x}, getMarkerPos _x] call BIS_fnc_nearestPosition < 5 ) exitWith
        { (getMarkerPos _x) execVM "spawn_guard.sqf"; };
     } forEach myMapMarkers; // predefined array of your markers
   }
};```

spawn_guards.sqf: `hint "activated";
`
worn forge
#

would need to see the errors produced in your rpt

#

I kind of whipped that up quickly, no idea if the format is 100% correct

serene quiver
#

no errors..just nothing happened

robust hollow
#

private myMapMarkers = ["marker_0","marker_1","marker_2"];
thats wrong, you dont private global variables.

worn forge
#

they're strings

serene quiver
#

correct form?

robust hollow
# worn forge they're strings

what do you mean? unless myMapMarkers had an underscore at the start, it is a global variable, which you dont private

worn forge
#

I assume you popped the player within 5m of your map marker?

#

Oh duh, yeah he's right

#

Just do myMapMarkers = ["marker_0","marker_1","marker_2"];

serene quiver
#

nope..I walked there if it's what you mean

worn forge
#

I was confusing that with private ["marker_0", "marker_1"]

#

well the BIS_fnc_nearestPosition command is comparing all the players to each map marker one at a time and seeing if a player is within 5 meters of the iterated markers

#

but start by removing that private statement πŸ˜›

serene quiver
#

still no joy

robust hollow
#

im not sure i understand this either
[allPlayers select {alive _x}, getMarkerPos _x] call BIS_fnc_nearestPosition < 5
the way i read it, that checks if an object is less than 5

worn forge
#

yeah, your original trigger specified 400m radius, which is why I had used < 400 instead of the < 5 you put in

#

oh man I'm quite tired it seems

robust hollow
#

either way, an object isnt a number so you're not comparing it correctly

worn forge
#

That'll just return the closest object

serene quiver
worn forge
#

Well it's a farther walk unless your marker is 5m away from you

serene quiver
#

it's way more than 5 meters, tha's for sure..

worn forge
#
myFancyDetector = [] spawn
{  while {alive player} do
   { sleep 5;
     { if (  player distance2d getMarkerPos _x < 400 ) exitWith
        { (getMarkerPos _x) execVM "spawn_guard.sqf"; };
     } forEach myMapMarkers; // predefined array of your markers
   };
};
#

The 400 is specific, it means if a player comes to within 400m of the map marker, it'll launch your script. If you make it 5m, the player will have to come to within 5m of the map marker.

robust hollow
#

can optimize that with findIf instead of count (both for the while and if conditions)

worn forge
#

Sure could, I'm whipping this out pretty rough

#

Frankly I wouldn't use {alive _x} count allPlayers > 0 as a while condition anyway, I'd just use while {true}... in fact that's probably another reason it isn't working

serene quiver
#

Forgot to say: it's SP mission..if that make a difference

worn forge
#

It certainly does

serene quiver
worn forge
#

that feels about right

serene quiver
#

Still no joy though..even If I move the markers further away....

spark turret
#

Even simpler with a SP mission. Attach ellipse marker to player, make marker invisible, check inArea _myMobileMarker

serene quiver
#

Furthermore, I have to do that for every playable unit, right?

spark turret
#

well im not sure if you can move the normal, blue triggers. but the next best and very similar thing is an area marker. it can do 95% of the things a real trigger can

#

yeah for every unit that should trigger the camps

#

ah wait, you cant attach markers. only loop their position

serene quiver
#

Hold on....thought of something..

spark turret
#

yeah sure

#

it might be easier to write yourself a loop that gets the distance for every player to every camp, and triggers if the distance is smaller than 2km or sth

#
while {Run_Loop} do {
    {
        _player = _x;
        {
            _distanceToCamp = _player distance _x;
            if (_distanceToCamp < 2000) then {
                systemChat str ["player",_player,"triggered",_x];
            };
        } foreach [_camp1Pos,_camp2Pos,_camp_n+1Pos];
    } foreach allPlayers
    sleep 2;
}

something along these lines

serene quiver
spark turret
#

you will have to modify it first

#

you need to define run_loop and also the camp positions

serene quiver
#

I'm gonna try the attach-trigger also.You CAN attach the normal "blue" trigger to a player..

spark turret
#

Triggers check for their condition much more often, so i would guess they are more performance costly

serene quiver
spark turret
#

Lol yeah that might be the case

#

The advantage the loop has, is that you can control how long it sleeps.

serene quiver
#

ok..how you define the run_loop? and as far as the camp positions, is the markerPos enough ?

#

or the name of the marker?

spark turret
#

Yeah "x distance y" can take objects or 3d positions.
Run_loop is just a global boolean so you can kill the loop from outside.
Just define it as true above

spark turret
#

Its a variable that is true or false = boolean and can be accessed from outside the script = global

#

Just put "true" as the while condition, you dont really need the run_loop

serene quiver
#
while {true} do {
    {
        _player = _x;
        {
            _distanceToCamp = _player distance _x;
            if (_distanceToCamp < 2000) then {
                systemChat str ["player",_player,"triggered",_x];
            };
        } foreach ["marker_0","marker_1","marker_2"];
    } foreach allPlayers
    sleep 2;
}```
spark turret
#

Hm does "distance" allow markers as input?

winter rose
#

getMarkerPos I believe

#

yup

Location or Array in format Position or Position2D

spark turret
#

Zagor you are trying to feed it a marker, but it only takes positions. So you have to get the markers positio first and feed it that.

spark turret
serene quiver
#
while {true} do {
    {
        _player = _x;
        {
            _distanceToCamp = _player distance _x;
            if (_distanceToCamp < 2000) then {
                systemChat str ["player",_player,"triggered",_x];
            };
        } foreach [getMarkerPos ["marker_0","marker_1","marker_2"];];
    } foreach allPlayers
    sleep 2;
}```
spark turret
#
while {true} do {
    { //player forloop _x = player here
        _player = _x;
        {  //marker forloop _x = marker_n here
            _distanceToCamp = _player distance (getMarkerPos _x);
            if (_distanceToCamp < 2000) then {
                systemChat str ["player",_player,"triggered",_x];
            };
        } foreach ["marker_0","marker_1","marker_2"];
    } foreach allPlayers
    sleep 2;
}
exotic flax
#

I've got an interesting question;
I have an array with an undefined amount of values, and I would like to return a random selection from it based on a given percentage.

eg. An array with 100 values, and a percentage of 30% should give 30 random values.

serene quiver
#

hold on..I'm getting this..lol

#
while {true} do {
    { //player forloop _x = player here
        _player = _x;
        {  //marker forloop _x = marker_n here
            _distanceToCamp = _player distance (getMarkerPos _x);
            if (_distanceToCamp < 2000) then {
                execVM "spawn_guards.sqf";
            };
        } foreach ["marker_0","marker_1","marker_2"];
    } foreach allPlayers;
    sleep 2;
};```
spark turret
#

sth like that? not sure i get the prblem

spark turret
#

i would make a second array that stores all active camps. once the players activate one, it gets added to the _activeCamps array and the loop will see that and not run the script a second time

robust hollow
serene quiver
#

"" i would make a second array that stores all active camps"" ....how do I do that since the camps are compositions that spawn randomly?

#

maybe an array of objects contained in the camps?

#

i/e: myCampObjects = ["box1","box2","box3"]; ?

#

and "activeCamps array" where it goes inside your previous script?

exotic flax
#

I would say that 99.9% of modern keyboards have the Win key (or similar), so that shouldn't be an issue.
Although I wouldn't use it since ACE uses it by default and will cause more complaining from people who want to use your mod/script in combination with ACE.

#

as long as people can rebind it, nobody will really complain πŸ˜‰

exotic flax
#

variables can be integers as well

missionNamespace setVariable ["money", 100000000];
cosmic lichen
#

money == STRING

#

missionNamespace setVariable ["money", "100000000"]; isEqualTo money = "100000000000"

#

so you are checking if a string (money) is greater than a number.

#

missionNamespace setVariable ["money", 100000000]; ?!?

#

now it's a number

#

We all do.

#

But then there's arma πŸ™‚

spark turret
#

That way you can check before you activate it on player proximity. Otherwise you get new guards every 2 seconds

serene quiver
#

I'm sorry..but how to "insert" that in the script you wrote above? I wouldn't now how..sorry mate

spark turret
#

np

serene quiver
spark turret
#
//empty list that will hold all already active camSetPos
_activatedCamps = [];

//loop that checks for player proximity to non-active camps every 2 seconds
while {true} do {
    _inactiveCamps = ["marker_0","marker_1","marker_2"] select {
        //filter out already active camps from this array
            !(_x in _activatedCamps)
        };

    { //player forloop _x = player here
        _player = _x;
        {  //marker forloop _x = marker_n here
            _distanceToCamp = _player distance (getMarkerPos _x);
            if (_distanceToCamp < 2000) then {
                _activatedCamps pushBack _x;
                execVM "spawn_guards.sqf";
            };
        } foreach _inactiveCamps;
    } foreach allPlayers;
    sleep 2;
};
#

its pretty dirty code

#

sorry kinda burned out for today πŸ˜›

serene quiver
spark turret
#

A prettier version would be to start with an array of inactive camps and delete each camp from it when its activated.
"Find" and "deleteat" are the methods you could use for that

serene quiver
#

EDIT: WORKS!!! Thank you @spark turret

//empty list that will hold all already active camSetPos
_activatedCamps = [];

//loop that checks for player proximity to non-active camps every 2 seconds
while {true} do {
    _inactiveCamps = ["marker_0","marker_1","marker_2"] select {
        //filter out already active camps from this array
            !(_x in _activatedCamps)
        };

    { //player forloop _x = player here
        _player = _x;
        {  //marker forloop _x = marker_n here
            _distanceToCamp = _player distance (getMarkerPos _x);
            if (_distanceToCamp < 50) then {
                _activatedCamps pushBack _x;
                execVM "spawn_guard.sqf";
            };
        } foreach _inactiveCamps;
    } foreach allPlayers;
    sleep 2;
};```
serene quiver
#

@spark turret Now how I can get a group spawn only at active markers?

guardGroup= [getPos ???, EAST, (configfile >> "CfgGroups" >> "East" >> "CFP_O_WAGNER" >> "Infantry" >> "cfp_o_wagner_infantry_security_detail")] call BIS_fnc_spawnGroup; 
wp1 = guardGroup addWaypoint [getPos ???, 0];  
    wp1 setWaypointType "GUARD";   
    wp1 setWaypointSpeed "FULL";  
    wp1 setWaypointBehaviour "AWARE";  
    wp1 setWaypointFormation "DIAMOND";```
Something on the line of:
```sqf
if (player = <500 _activatedCamp ) then {
guardGroup= [getPos ???, EAST, (configfile >> "CfgGroups" >> "East" >> "CFP_O_WAGNER" >> "Infantry" >> "cfp_o_wagner_infantry_security_detail")] call BIS_fnc_spawnGroup; 
wp1 = guardGroup addWaypoint [getPos ???, 0];  
    wp1 setWaypointType "GUARD";   
    wp1 setWaypointSpeed "FULL";  
    wp1 setWaypointBehaviour "AWARE";  
    wp1 setWaypointFormation "DIAMOND";} else {exitWith {}};```
???
tough abyss
#
call compile format["%1", cursorObject]
 4:22:01 Error in expression <2ab29410080# 1779940: hatchback_01_f.p3d>
 4:22:01   Error position: <ab29410080# 1779940: hatchback_01_f.p3d>
 4:22:01   Error Missing ;

Hello, has anyone got this problem nowadays? I'm stuck with this (the only way I found to solve this problem is to not parse the object in a local variable and do everything I want inside the call compile, but it's really ugly)

robust hollow
#

objects dont work in strings like that

#

you may want to try this
object to string -> netID cursorObject
string to object -> objectFromNetID _netID
(BIS_fnc_netID if SP)

tough abyss
#

oh, nice one

#

thanks a lot @robust hollow

#

didnt thought of that

little raptor
#

_inactiveCamps = ["marker_0","marker_1","marker_2"] select {
//filter out already active camps from this array
!(_x in _activatedCamps)
};

_inactiveCamps = ["marker_0","marker_1","marker_2"] - _activatedCamps;
#

if (player = <500 _activatedCamp ) then {
wat?

#

getPos ???
don't use getPos for waypoints and stuff. (positioning where height is important)

lucid shale
#

this started poping up in my rpt logs today. maybe even there yesterday. im not sure. can someone tell me what this means. Yes we have made changes to our framework but dont know when this started.

Ref to nonnetwork object <No group>:0 (Logic)
Ref to nonnetwork object 1821648: <no shape>
languid oyster
#

@lucid shale got those log entries too. Plenty of them. Would like to know too where they come from. Had no time to investigate yet.

#

Another question: I would like to get direction and position of a fired weapon. Could be an infantry held weapon or some vehicle weapon. I tried to get _muzzle from fired event, but no luck

#

And another question πŸ™ˆ
I want to addForce to an object 90Β° from it's current direction. Any math crack here?

vague geode
#

@little raptor First of all again, thanks a lot for your help. I have implemented your system to detect glitched units now and it works for 95% of them but there are still a few units glitched into certain buildings that don't seem to get detected. Do you have any suggestion for a backup system?

proper sail
#

@languid oyster getdir - 90?

#

oh sorry i misread the addforce

languid oyster
#

@proper sail yes, I need vector in format [x,y,z]

#

Isn't there a nice function for that?

winter rose
#

modelToWorld πŸ™‚

#

(setVelocityModelSpace for only velocity)

little raptor
still forum
little raptor
#

it compiles:

#

<2ab29410080# 1779940: hatchback_01_f.p3d

#

which is not a valid expression in SQF

#

hence the error

#

if you compiled: "cursorObject" it would work (call compile "cursorObject")

#

but as Dedmen said, I'm not sure why you're compiling that in the first place

vague geode
little raptor
#

getPos select 2 returns the height above surface

#

not ground

languid oyster
#

Thanks for advice, Lou

vague geode
#

I know, I tested it but it doesn't work. As long as you are above a surface (e.g. ontop of a building) it works but if you glitch through the roof it doesn't calculate the height below the roof but above the next surface below.

little raptor
#

there's another way you can do this too:

#
_testObj setPosASL (getPosASL _unit vectorAdd [0,0,2]);
getPos _testObj select 2 < 2 - _error;
#

_error is up to you

#

you need a testObj that has to be created only once

serene quiver
serene quiver
spark turret
#

_x is the camps marker in that case so you can call getMarkerPos _x to get its position and feed that to the groups spawn and waypoint

little raptor
#

but you only had 3 elements there so it wouldn't metter much

serene quiver
# spark turret _x is the camps marker in that case so you can call getMarkerPos _x to get its p...

Yeah...I got this working with:

while {true} do {
    _inactiveCamps = ["marker_0","marker_1","marker_2"] - _activatedCamps;

    { //player forloop _x = player here
        _player = _x;
        {  //marker forloop _x = marker_n here
            _distanceToCamp = _player distance (getMarkerPos _x);
            if (_distanceToCamp < 500) then {
                _activatedCamps pushBack _x;
                //execVM "spawn_guard.sqf";
                
guardGroup= [getMarkerPos _x, EAST, (configfile >> "CfgGroups" >> "East" >> "CFP_O_WAGNER" >> "Infantry" >> "cfp_o_wagner_infantry_security_detail")] call BIS_fnc_spawnGroup; 
wp1 = guardGroup addWaypoint [getMarkerPos _x, 0];  
    wp1 setWaypointType "GUARD";   
    wp1 setWaypointSpeed "FULL";  
    wp1 setWaypointBehaviour "AWARE";  
    wp1 setWaypointFormation "DIAMOND";                
      };
        } foreach _inactiveCamps;
    } foreach allPlayers;
    sleep 2;
};```
serene quiver
little raptor
#

yes

#

but it's better to save that as a global array

#

those 36 markers

serene quiver
#

What's the difference between the "normal" array in the script and a "global" one?

little raptor
spark turret
#

I recommend watching a youtube tutorial on "access modifiers". Programming language doesnt matter, its a Universal concept and very important

#

Uh ib4 dedmen corrects me saying "private" isnt an access modifier.

serene quiver
winter rose
#

yes, global variables means global scope variable

not public (aka on every machine)

spark turret
#

Very important difference, especially in multiplayer

still forum
spark turret
#

Whats the correct term then?

still forum
#

technically, private is a "keyword"

#

the universal concept of "access modifiers" probably doesn't really apply to SQF

#

you are talking about variable scoping here, access modifiers is usually referring to classes in object oriented programming, which SQF doesn't have

spark turret
#

Yeah okay thats fair.
I use variable scoping and access modifiers as the same thing bc its essentially the same for everything i have worked on so far

serene quiver
#

This is getting deeper than I wanted..lol....
NOW... how do I convert this

[ [[6907.65,22232.2,4.0887],[5402.73,21881.2,4.27298],[3608.01,20017.2,4.27237],[3795.7,17489.6,4.27268]] call BIS_fnc_selectRandom, random 360, drugComposition ] call BIS_fnc_objectsMapper;```

in this? (using markers instead of X,Y,Z)

`[getMarkerPos "myBase", 0, _objectsArray, 0.5] call BIS_fnc_objectsMapper;`
little raptor
#
_markers apply {getMarkerPos [_x, true]}
#

returns an array of positions

#

drugComposition
?!

serene quiver
#

LOL....I'm making a "narcos" hunt mission..LOLLLLL

little raptor
#

call BIS_fnc_selectRandom

#

selectRandom

#

the fastest way to do what you want:

getMarkerPos [selectRandom _markerArray, true];
serene quiver
#

Basically I have 12 "hideouts" house composition that randomly get positioned on the map among 36 markers....

serene quiver
tough abyss
serene quiver
#
_MyCompositionArray = ["camp1","camp2","camp3"];

[ getMarkerPos [selectRandom _MyCompositionArray, true],random 360, drugComposition ] call BIS_fnc_objectsMapper;```
#

ok ??

little raptor
#

_MyComposionArray
are those markers?

serene quiver
little raptor
#

getMarkerPos [selectRandom _MyComposionArray, true]]
the last ] is redundant

little raptor
tough abyss
#

right

#

thanks for all the answers guys

serene quiver
little raptor
#

@tough abyss example:

_variables = [];
_lb setVariable ["variables", _variables];
lbClear _lb;
{
  _lb lbAdd _x;
  _variables pushBack _something;
} forEach _data;
#

now to fetch the data:

(_lb getVariable ["variables", []]) select lbCurSel _lb; //get data attached to the current lb selection
serene quiver
tough abyss
#

I thought we just could compile vehicles like players

little raptor
#

you can, in a way

#

if you use vehicle var names

#

but the variable name must also match the vehicle var name

serene quiver
#

Thank you

still forum
#

And yes I reply before I read further messages :U

tough abyss
#

^^

serene quiver
#

ps:units do spawn..just the composition is M.I.A.

little raptor
#

@serene quiver missing the azimuth

cosmic lichen
#

it's optional

little raptor
#

it is, but he's providing the units array

#

[ getMarkerPos [selectRandom _MyCompositionArray, true], drugComposition ]

#

wrong params

#

@serene quiver what you wrote here was already correct:

#

I don't know why you changed it

serene quiver
cosmic lichen
#

it is

#

I just tested it

#

Just replace [ getMarkerPos [selectRandom _MyCompositionArray, true], drugComposition ] call BIS_fnc_objectsMapper;
With [ getMarkerPos [selectRandom _MyCompositionArray, true],random 360, drugComposition ] call BIS_fnc_objectsMapper;

#

See the syntax. You are providing the composition in place of the azimute

spark turret
#

= you give 2 input parameters, but Bis_fnc_objectsMapper wants 3.

little raptor
#

to be fair, the function params is not written properly

cosmic lichen
#

yeah

little raptor
#
[position, azimuth, objectsArray, badChance] call BIS_fnc_ObjectsMapper 

Parameters:
position: Position - (Optional, default [0,0])
azimuth: Number - (Optional, default 0) the template orientation
objectsArray: Array - created with BIS_fnc_objectsGrabber

cosmic lichen
#

param in the middle is optional which doesn't make much sense

little raptor
#

even the first one is!

cosmic lichen
#

xD

serene quiver
#

Thank you all..got this working with:

_MyCompositionArray = ["marker_0","marker_1","marker_2"];
[ getMarkerPos [selectRandom _MyCompositionArray, true],random 360, drugComposition ] call BIS_fnc_objectsMapper;```
spark turret
#

Youre building a singleplayer map with 40 bandit camps? OldMan 2.0?

serene quiver
spark turret
#

You could enhance variation by selecting the guard groups randomly from multiple different groups

serene quiver
#

btw...how do you post images/screenshots here, not just the links...?

spark turret
#

Cant. Gotta upload to a Host and link

serene quiver
#

Can you embed it?

spark turret
#

12 FPS? πŸ˜„

serene quiver
#

lol...almost

cosmic lichen
#

Make sure to use layers

#

Makes editing much easier.

serene quiver
cosmic lichen
#

There is nothing to it.

#

For example

#

That boat in the middle with all those waypoints

#

Select it and add it to it's own layer

#

Then just hide the layer.

serene quiver
#

I see..just like when you edit a texture file with GIMP...shows and hide layers..

spark turret
#

reminder to myself that i have like 6 attempts of makinf dynamic occupation systems where points of interests are dynamically selected and patrols randomly visit them, and none of these attempts was ever finished

cosmic lichen
#

yes

serene quiver
#

and it doesn't effect the way the mission i launched, right?

cosmic lichen
#

nope

#

Layers are just for the editor, however, you can get all objects assign to a layer during the mission, which would allow you to show hide all entities of a layer

serene quiver
# cosmic lichen nope

mmmm...interesting..so for instance...if the mission tasks don't allow you to "see" a certain part of the mission, you could hide them and call them once it's the right time?

cosmic lichen
#

Yes

serene quiver
#

awesome...and how would you call the layer mid-game?

serene quiver
#

i/e: I have an HVT..to find him you have to collect various intel to reveal his position...

#

so to avoid stumbling upon him before collecting the intel, you could "hide" the layer that has him with his waypoint and all..correct?

cosmic lichen
#

You cannot hide the layer but the objects it contains

serene quiver
#

well let me rephrase that: you "hide" the HVT and his waypoints, and "call" it later on?

cosmic lichen
#

yes

serene quiver
#

I guess that if the engine doesn't have to render them, it will save performance...right?

spark turret
#

Yeah

#

Not just rendering, but their AI calculations, physics etx

serene quiver
#

I guess on a mission like the one above it will have a significant impact..

spark turret
#

im no expert on performance, (in fact most of my works are super unperformant πŸ‘€ ) but theres more mechanics that help save performance.
disable simulation is one, and the vanilla, built in dynamic simulation mechanic. it freezes far away units to save up their AI (and collision?) calculations

spark turret
#

Any suggestions on how to test a script for its performance in multiplayer?

serene quiver
#

Hey, what's wrong with this? can't get to work....
I hide the layer "civis" with this in a gamelogic: (and it works):

[] spawn {
{ _x enableSimulation true;  
  _x hideObject true;  
  } forEach (getMissionLayerEntities "civis" select 0);```

...then I want to "show" the units once a task is assigned, with 
```sqf
player addEventHandler[ "TaskSetAsCurrent", {
    params ["_unit", "_task"];
    
    if ( _taskReal isEqualTo ( "task1" call BIS_fnc_taskReal ) ) then {
    _x enableSimulation true; 
    _x hideObject false; 
  } forEach (getMissionLayerEntities "civis" select 0); 
}];```
NOT working...got this error:
`18:58:27 Error in expression <n true;  
    _x hideObject true;  
  } forEach (getMissionLayerEntities "civis">
18:58:27   Error position: <forEach (getMissionLayerEntities "civis">
18:58:27   Error foreach: Type Nothing, expected code`....???
little raptor
#

what does the error tell you?

serene quiver
#

expect code..

#

?

little raptor
#

so do you see it now?!

serene quiver
#

nope..lol..what code is missing?

little raptor
#

what is code?

serene quiver
#

At this point..ain't not sure..

spark turret
#

you are mixing and if statement with a foreach

little raptor
#

jeeze

#

thanks

#

we didn't know

#

(?!)_

spark turret
#

they need their own scopes.
you cant do

if (true) then {
} foreach [1,2,3]
little raptor
#

I'm trying to teach him here

#

any way, that pretyy much explains it now

serene quiver
#

probably to you..still, I wouldn't know how to fix it.

#
player addEventHandler[ "TaskSetAsCurrent", {
    params ["_unit", "_task"];
    
    if ( _taskReal isEqualTo ( "task1" call BIS_fnc_taskReal ) ) then {
    _x enableSimulation true; 
    _x hideObject false; 
  getMissionLayerEntities "civis" select 0);} 
}];```
#

About that?

little raptor
#

and did the forEach just magically disappear?

serene quiver
#

lol....I like you man...

#

Believed or not I'm just like you in my line of work...hahha

little raptor
#

what you were doing

if (something) then {...} forEach [];

the engine executes this first: (according to https://community.bistudio.com/wiki/Operators#Rules_of_Precedence)
if (something) then {...}
then it uses the return value (what is returned by the then, and if condition is false, nothing) as the "code" for forEach

anyway, the answer to this riddle was this:

if (true) then {
{
} foreach [1,2,3]
}
serene quiver
#
player addEventHandler[ "TaskSetAsCurrent", { 
 params ["_unit", "_task"]; 
  
 if ( _task isEqualTo ( "task1" call BIS_fnc_taskReal ) ) then { 
 _x enableSimulation true;  
    _x hideObject false;  
  } forEach [getMissionLayerEntities "civis" select 0]  
}];```
???
#

nope..

spark turret
#
player addEventHandler[ "TaskSetAsCurrent", { 
 params ["_unit", "_task"]; 
  
    if ( _task isEqualTo ( "task1" call BIS_fnc_taskReal ) ) then { 
        {//foreach start
            _x enableSimulation true;  
            _x hideObject true;  
        } forEach [getMissionLayerEntities "civis" select 0]  
    } //end if
}];
#

you need to keep your scopes separate

spark turret
#

foreach needs its own {bla bla } block and so does if (this) then {that}

serene quiver
spark turret
#

what line

serene quiver
#

19:31:34 Error in expression < ) ) then {
{
_x enableSimulation true;
_x>
19:31:34 Error position: <enableSimulation true;
_x>
19:31:34 Error Generic error in expression

proper sail
#

probably because getMissionLayerEntities already returns an array

#

tbh if you are not quite sure what you are doing i would split things up first

#

and not directly execute something for your foreach loop

#

i.e

_mylayer = getMissionLayerEntities "civis" select 0;```
#

but thats just my opinion

serene quiver
#

As long as it gets the job done, it's all good to me...more efficient? prettier? more professional? Doesn't matter to me...even if it's down and dirty, as long as it works..it's GOLD to me..hahahaha

#
player addEventHandler[ "TaskSetAsCurrent", {
    params ["_unit", "_task"];
    _mylayer = getMissionLayerEntities "civis" select 0;
    if ( _taskReal isEqualTo ( "task1" call BIS_fnc_taskReal ) ) then {
    _mylayer enableSimulation true; 
    _mylayer hideObject false; 
  } 
}];```
about this ??? @proper sail
proper sail
#
player addEventHandler[ "TaskSetAsCurrent", { 
 params ["_unit", "_task"]; 
  
    _mylayer = (getMissionLayerEntities "civis") select 0; //now you can diag_log this easily
    _findTask = "task1" call BIS_fnc_taskReal; //now you can diag_log this easily
    
    if (_task isEqualTo _findTask) then { 
        {//foreach start
            _x enableSimulation true;  
            _x hideObject true;  
        } forEach _mylayer; 
    };
    
}];```
#

also the wiki says that bis_fnc_taskReal requires 2 parameters

#

[taskName, owner] call BIS_fnc_taskReal

serene quiver
#

YESSSSSSSSS....thank you a lot,man!!

fiery orbit
#

I'm trying to make a persistent multiplayer mission right now, how would I go about creating and defining variables that I would like to modify further down the line but wont be reset every time the mission is loaded?

spark turret
#

Merlin is right, never try to develop in a whole big script. Make smaller modular parts, test those, then put together

worn forge
#

@fiery orbit search this thread, you'll find some previous discussion on persistent variables

fiery orbit
#

thank you

winter rose
#

@cunning oriole your script seems to run on every machine instead of being centralised on the server

exotic flax
#

Store the queue in missionNamespace or only on the server (remoteExec)

winter rose
#

yes, same, because this remoteExec code means "execute the code here"

#

Server-side:

waitUntil { sleep 1; count allPlayers > 1 };
["go!"] remoteExec ["hint"];
```@cunning oriole
slow cargo
#

@ded would you mind dropping the script you’re using to follow the turrets orientation with attachto? Been racking my brain trying to write one for the last day or so

little raptor
#

it seems you're trying to pair up players.
you can simply do that server side.
why would you need a queue for that?

little raptor
#

but you can do it with onEachFrame

slow cargo
#

I don't need the object scaling - just the script to update the object position relative to the turret

little raptor
#

that too is part of the update

#

I don't follow. Can you explain what you're trying to do in more details?

slow cargo
#

Ah, that's exciting and frustrating - thought they were already using a perframe handler rather than the fancy forbidden magic

#

Much appreciated!

serene quiver
#

Can anyone tell me what's wrong with this?

[] spawn { 
player addEventHandler[ "TaskSetAsCurrent", {    
 params ["_unit", "_task"];    
     
    _mylayerPilot = (getMissionLayerEntities "pilotTaskCustom") select 0;   
    _findTask = "Task04" call BIS_fnc_taskReal;   
       
    if (_task isEqualTo _findTask) then {    
        {   
            _x enableSimulation true;     
            _x hideObject false;     
        } forEach _mylayerPilot;    
    };
    
}];   
};
waitUntil {"Task04", "SUCCEEDED",true};

[] spawn { 
player addEventHandler[ "TaskSetAsCurrent", {    
 params ["_unit", "_task"];    
     
    _mylayerShip = (getMissionLayerEntities "sinkShipCustom") select 0;   
    _findTask = "Task05" call BIS_fnc_taskReal;   
       
    if (_task isEqualTo _findTask) then {    
        {   
            _x enableSimulation true;     
            _x hideObject false;     
        } forEach _mylayerShip;    
    };
    
}];   
};```
Thank you..
#

I'm trying to "reveal" the layers after task is completed, or better assigned..

#

The first layer shows up just fine when the task04 is ASSIGNED, as intended, but then the second layer stay hidden....mmmm...

robust hollow
#

i dont have any experience with tasks, but couldnt you do something like this and forget the waituntil and spawned addEventhandlers?

player addEventHandler ["TaskSetAsCurrent",{    
    params ["_unit","_task"];
    
    private _layers = switch _task do {
        case ("Task04" call BIS_fnc_taskReal):{(getMissionLayerEntities "pilotTaskCustom") select 0};
        case ("Task05" call BIS_fnc_taskReal):{(getMissionLayerEntities "sinkShipCustom") select 0};
        default {[]};
    };    
    
    {
        _x enableSimulation true;     
        _x hideObject false;  
    } forEach _layers;
}];
serene quiver
#

Let me try...

#

thanks

#

YAP..it works like a charm..thank you mate!

languid oyster
#

Am I right assuming addForce does not work with simple objects?

warm hedge
#

Simple Objects can't have any velocity so yes

sage dawn
#

I've been noticing some weird issues with hideObjectGlobal recently, I've had cases where I used that on a vehicle in multiplayer and a few clients are able to still see parts of the vehicle, like the floating crew or helicopter rotors, but that only happens on some players, is there some kinda bug with hideObjectGlobal?

languid oyster
#

thanks for answer @warm hedge. And I made the observation, that disableCollisionWith doesn't seem to work either for those simple objects. Or am I doing something wrong?

little raptor
#

it should work. I've never tested the command on simple objects.
you can just disable simulation

languid oyster
#

I did disable the simu, but it looks crappy having casings floating around in air

warm hedge
#

If it isn't working on Simple Objects, maybe a bug? Honestly the command is really glitchy tho

languid oyster
#

I don't know. Sometimes it seems to work, but when there are loads of objects, things begin to glitch. Maybe a load related problem...

still forum
still forum
#

πŸ‘€

oblique arrow
#

So is that command how its gonna go to retail or πŸ‘€ ? or is that just your private one>
plan setObjectScale [0.2,0.2,0.2];

#

as in xyz factors

#

so a mix of the two options

still forum
#

that's just mine

#

What comes to retail we'll know if and when it arrives

oblique arrow
#

oki

ember path
#

So a few times when just testing stuff, my combatmode == "RED" trigger doesn't trigger despite me shooting all over the place. Ill try adding more squads to the condition maybe

#

Its just not consistent, which is weird

winter rose
#

try detecting behaviour instead

ember path
#

I think it might have to do with ace? Maybe? Because sometimes i just stand Infront of the squad no shooting the trigger triggers, sometimes i kill like 10 people, and nothing, i think i tried it but got some errors, I'll try it again

little raptor
#

and AI never change it

#

if you want the AI to react to you "shooting all over the place", try behaviour (as Lou said)

spark turret
#

i feel like i might have suggested combat mode πŸ‘€ sorry i meant behaviour

ember path
#

i remember trying behaviour after i realized combat mode is not consistent, but i got some error, cant remember it now, ill try it again

#

i put in a group and it says it expect an object

#

i did

#

(behaviour boys == "COMBAT")

#

oh ig it says unit

spark turret
#

i have a script running on a loop and i want to be able to change its parameters during runtime.
i thought about creating a "hashobject", basically a hidden object, which holds the parametres as variables attached to it. script pulls params on each run, if you wanna change it, you can just change the params and the script will use those on the next run.
any other, better idea to achieve that?

ember path
#

so is it just like one.. unit and it doesnt work for the group

spark turret
#

pinky you can use "leader _myGroup" to get a unit (easily)

oblique arrow
#

behaviour
Returns the behaviour of the unit's group. For Arma 3 behaviour explanation see Arma_3_AI_Behavior
? @ember path

ember path
#

no i want to check if the behaviour is something not set it as something

oblique arrow
#

Ooh okay

winter rose
#

setBehaviour on group or unit (and applies to all units anyway)
behaviour on unit only

BI thonk

warm hedge
#

slaps the computer this bad boy can fit some strange behaviour in it

winter rose
#

computer falls to pieces

oblique arrow
#

blobdoggoshruggoogly ^ bi behaviouring weirdly

#

Or should I say

spark turret
#

any better way to modify a public variable and synch it?

_array = missionNamespace getVariable ["IRN_ambient_battle_modules",[]];
_array pushBack ["hello world"];
missionNamespace setVariable ["IRN_ambient_battle_modules",_array,true];
oblique arrow
#
_behaviour = behaviour _bi;
hint _behaviour;

Retuns "Weird" heh

spark turret
#

@serene quiver
might wanna check that out for your random bandits:

markers: Array - (Optional, default []) if the markers array contains any markers, the position is randomly picked from array of given markers plus desired placement position. If any of the markers were given z coordinate with setMarkerPos, the vehicle will also be created at given z coordinate. 

https://community.bistudio.com/wiki/createVehicle

#

can i custom- name vehciles i create by script?

still forum
#

custom name?

#

you mean setVehicleVarName?

spark turret
#

yes thanks

spark turret
#

okay so i built myself a helper object that holds a ton of variables in its namespace, like colors and sounds etc.
how bad is it to pull these variables out of the object, into my script every couple seconds? stays on local machine.

ember path
#

sorry yeah i just set the behaviour to the unit (aka boy) and it worked....but im sure i did this before and it didnt.. oh well

#

now its much more consistent

still forum
cosmic lichen
spark turret
#

well according to your paper object namespace is kind of a hashmap

#

yeah revo, thats what i read and promptly stole the idea πŸ˜„

quartz pebble
#

any builtin commands to get all the muzzles of a weapon?

still forum
#

yes cba os dpong tjat

spark turret
#
    {
        _tmp = _x select 1;
        //update var from hashObject, if undefined use old var
        (_x select 1) = _hashObject getVariable [_x select 0,_x select 1];
        if (_debug && !(_tmp isEqualTo (_x select 1))) then {
            diag_log ["################# VARIABLE CHANGED #####","old",_tmp,"new",_x select 1];
            systemChat str ["################# VARIABLE CHANGED #####","old",_tmp,"new",_x select 1];
        };
    } foreach [
        ["minDistance",_minDistance],
        ["maxDistance",_maxDistance],
        ["salvoFrequency",_salvoFrequency],
        ["salvoAverage",_salvoAverage], //average amount of salvos per "skrimish",
        ["expAverage",_expAverage],
        ["end",_endTime],
        ["tracerEveryX",_everyX],
        ["tracersRndVec",_rndVec],
        ["percentTracers",_percentTracers],
        ["expColor",_expColorPalette],
        ["expSize",_expSize],
        ["expSounds",_expSounds],
        ["shots",_shotSounds],
        ["debug",_debug],
        ["center",_center]
    ];

i wanna update the variable defined in the foreach array, but im a noob concerning references.
it seems (x select 1) cant be set to a different value. any suggestions?

winter rose
#

yes, set

#

_array set [index, value]

#

also, use params ^^

#

@spark turret ↑

exotic flax
#
missionNamespace setVariable [(_x select 0), (_hashObject getVariable [_x select 0, _x select 1]), true];
spark turret
#

@winter rose i think i get what you mean, im not sure how to do it tho.
sth like

{
_this set [_idx,_hashObject getVariable ["nameOfParam",_this select _idx]];
} foreach _this;

?

winter rose
#

my answer to that very intricate question shall be wut

spark turret
#

im trying to update my private variables in my script by pulling values from an object i abuse as a storage container for the variables

#

so i can change the scripts params during runtime

robust brook
#
{
  _x params ["_varName", "_varValue"];

  private _defaultVar = _hashObject getVariable [_varName _varValue];

  if (_debug && !(_tmp isEqualTo _varValue)) then {
      diag_log ["################# VARIABLE CHANGED #####", "old", _tmp, "new", _varValue;
      systemChat str ["################# VARIABLE CHANGED #####", "old", _tmp,"new", _varValue];
  };

} forEach [
  ["minDistance", _minDistance],
  ["maxDistance", _maxDistance],
  ["salvoFrequency", _salvoFrequency],
  ["salvoAverage", _salvoAverage], //average amount of salvos per "skrimish",
  ["expAverage", _expAverage],
  ["end", _endTime],
  ["tracerEveryX", _everyX],
  ["tracersRndVec", _rndVec],
  ["percentTracers", _percentTracers],
  ["expColor", _expColorPalette],
  ["expSize", _expSize],
  ["expSounds", _expSounds],
  ["shots", _shotSounds],
  ["debug", _debug],
  ["center", _center]
];
``` @spark turret something like this for example
winter rose
#

private var = manual change… or an awful usage of call compile

spark turret
#

okay so no foreach here?

#

@robust brook that looks good, but i still need to assign _defaultVar `s value to _minDistance or whichever variabel got updated

#

hm or could i pull every variable, into an array and used "params" on that array right below?

#

ill just bruteforce it with single line commands lol

exotic flax
#
_arr = [
   ["key", "diffval"]
];
_arr = _arr apply {
   _x params ["_key", "_val"];
   _val = _hashObject getVariable [_key, _val];
   [_key, _val];
};

something like this?

spark turret
#

hm yeah i think thats the right direction

#

and the parse that array into the variables so i can use the _keys to get the values

exotic flax
#

it will simply update the _arr with values from _hashObject if it exists.
and using ```sqf
missionNamespace setVariable [_key, _val, true];

#

which also works within a forEach (if you don't need to modify the original array)

spark turret
#

i didnt wanna store the parameters in missionnamespace bc maybe you got multiple instances of the script running

#

ill look into your method later, ill bruteforce for now

winter rose
#

so wait, you simply want to update private _variables?

spark turret
#

yeah from a hashobjects namespace

#

update runs in a loop

winter rose
#

I disagree with such design @spark turret, but I may have some ugly thing

spark turret
#

alright lol

#

touching the outer rims of self modifying code think_turtle

exotic flax
#

inb4 self writing code

spark turret
#

our arma sqf overlords will be gentle

winter rose
#

here:

{
  private _value = _hashObject getVariable [_x, call compile format ["_%1", _x]];
  call compile format ["_%1 = _value", _x];
} forEach ["varname1", "varname2"];
#

that's ugly, that's not performance-friendly, but it works (…or at least, should)

exotic flax
#

Although I agree with Lou here.
I guess it's a system to store settings in variables, which does make sense.
Although in that case I wouldn't use hashmaps... And just use default variables which can be overwritten

still forum
#

call compile format ["_%1 = _value", _x];

winter rose
#

no

still forum
#

local

#

ono

winter rose
#

poopy local var update πŸ˜„

still forum
#

really modifying a variable outside the scope :U

#

ahhhhh

spark turret
#

Lol very strong feelings on me just having a way to change a scripts settings during runtime

#

Is that so bad?

winter rose
#

it's not great, and you compile (twice) every loop

as a debug, sure
as final code, no

#

if I were your employer, I would make you pay me to accept that πŸ˜„

spark turret
#

Well how else could i change setting during runtime?

winter rose
#
_var = _hashObject getVariable ["var", 0];
```or, better, store your variables in an array (if you always get everything) then use `params` on it```sqf
private _array = _hashObject getVariables ["variables", []];
_array params ["_param1", "_param2", "_param3"];
hint str _param1;
spark turret
#

Ill look into only updating on var change later

exotic flax
#

No need for fancy storage when it can't execute code the moment it changed (unless you have a loop somewhere which waits for changes)

idle jungle
#

Hey what file would I need to put
showscoretable 0 would it be a local command or server?

Trying to stop scoreboard coming up during the mission as its causing people to be wreckless to bump up their scores

#

And also showchat false I'm assuming that stops people seeing the chat in game also

little raptor
little raptor
idle jungle
#

Yeah ill try initPlayerLocal.sqf first

idle jungle
#

i cant get showChat false; to work 😦
ive tried the enableChannel script but its not working correctly either

tribal onyx
#

There's allUnits to return an array of all units... what's a way to get all triggers on a map?

#

Alternatively, a way to get all sideLogic, something allUnits explicitly doesn't count?

exotic flax
#

You could check all objects on the map and filter by "EmptyDetector" (= trigger object)

spark turret
#

anyone got a smart idea on a function that randomly selects a point in a circle, and the point is at least x Meters away from each player?

#

i mean i could brute force it in a loop think_turtle

exotic flax
#

???

#

@spark turret BIS_fnc_findSafePos could do the trick

still forum
#

explain like I'm five.

still forum
exotic flax
#

I would say "Ask an adult", but than I still have to explain something which can be found on the wiki or Google

still forum
#

I guess he wants to ask how to do that in script?

#

units sideLogic
but I think that doesn't work yet? Don't remember when I did that.

allUnits select {side _x == sideLogic}?
but that returns modules too, not only triggers
oh allUnits doesn't count sideLogic?
allMissionObjects maybe, but that's bad oof

#

or entities "EmptyDetector" ?

little raptor
#

I don't think empty detectors are "entities"

little raptor
tribal onyx
#

@still forum thanks for trying to help. I think I managed to find a work-around to this. Not the ideal solution and requires some extra prep-work in the editor, but should still work.

still forum
#

allMissionObjects will work, but is performance wise bad

#

but you'll only run it once so its probably fine

still forum
#

correct

green sonnet
#

Alright, waited 10 mins to ask this. In regards to attachTo, I want to attach Zeus editable area to the player character, however, it doesn't update after initialization. I've attempted to correct that with while-do, however it doesn't seem to work. I am a complete novice when it comes to this stuff.

#

Anyone attempt this before?

winter rose
#

you might be trying to attach the module itself, which won't work (the module only triggers a script that takes the position at time T)

green sonnet
#

Yeah, that seems accurate. Is there another way?

winter rose
#

script-wise there may be (but I am not a Zeus expert)

green sonnet
#

Where do i find the script the module executes?

willow hound
#

addCuratorEditingArea returns nothing, it can't be attached.

spark turret
#

script modules are in arma3/addons/ some pbo

winter rose
#

you may not attach the editing area, but you may set it repeatedly

oblique arrow
#

I recommend taking a look at how the official missions do it @green sonnet

willow hound
#

Can't treat it like a marker. Only option is delete and recreate at new position.

#

Maybe there's a BIS function for it, dunno.

green sonnet
#

So, is there some kind of timer/loop I can do to delete the edit area, and recreate it at player position, every second or so?

spark turret
#

some things cant be glued to players (or anything else) and need to be teleported. markers f.e.

willow hound
winter rose
#

@spark turret a Curator area is neither a trigger or a marker or an object (no set(Marker)Pos)
they are areas defined by script to format [centerPosition, radius] (I believe)
and therefore cannot be moved, only created/deleted

spark turret
#

well, shame that this script doesnt have settings which can be changed during runtime πŸ‘€

willow hound
winter rose
#

addCuratorCameraArea
addCuratorEditingArea

removeAllCuratorCameraAreas
removeAllCuratorEditingAreas

unfortunately, no moving anything ^^
not really supposed to be that much either πŸ™‚

winter rose
#

(as shown, I am not a Zeus expert ^^)
well, a server-side loop that edits that area every 2-5s is not going to cost too much either, so why not

willow hound
#

For each player, and you have to remember the IDs for each

winter rose
#

for each player? for each Zeus you mean?

willow hound
winter rose
#

ah yep (well if each player is a Zeus, then we are both right ^^)
if there are only 2-3 Zeus, easily done I think

green sonnet
#

Yes, I am combining warlords, and ZvZ.

#

To create a sudo-RTS game.

willow hound
#

Might be able to circumvent storing the ID using owner.

green sonnet
#

At least, attempting to.

willow hound
#

Problem is new people joining and others leaving

green sonnet
#

Where each player (Edit: a player on each side) is a "commander" that can only build around them, creating tactics while keeping player involvement.

#

I also attempted to sync editable area's around warlords points, but I have no clue what I'm doing, this is just me experimenting. lol.

willow hound
#

Have you scripted before?

green sonnet
#

Nope!

#

πŸ™‚

#

Arma 3's language seems well documented though, so I'm just messing around and seeing what I can learn.

#

The closest I come is a basic knowledge of Unreal engine blueprints, as far as my scripting knowledge goes.

willow hound
#
//Spawn this code on the server!
while {true} do {
  {
    someCurator addCuratorEditingArea [owner _x, getPos _x, 100];
  } forEach (call BIS_fnc_listPlayers); //Don't need HCs
  sleep 5;
};
```This is a rough layout.
It doesn't properly treat players disconnecting, it only works with a single curator and it needs more work before it does what you'd like it to do.
`allCurators` may or may not be useful here, don't know.
green sonnet
#

Alright, gonna treat this as a learning lesson... Couple of questions after trying what I thought to be the answers. (They weren't.)... I'm suppose to replace _x's with obj such as my characters variable name, right?

willow hound
green sonnet
#

So if I execute your code through the debug menu, executing on server side, it should create a edit area around my character?

tribal onyx
#

super quick question:
Does deleting a vehicle also delete the crew?

green sonnet
#

it gives me a generic error after clicking server exec with no modifications.

willow hound
#

Alright, time for me to sleep.
Play around with the code, look up as much as you can in the documentation and ask in here whenever you need more advice or ideas.

green sonnet
#

Thanks for the base guideline!

leaden summit
#

In the description.ext you can name the author of the mission. Can you reference that in other scripts?
Eg I'm working on a simple intro script for our mission makers and would like it to say "<authorname> presents..." and preferably draw the name from the description.ext. is that possible?

robust hollow
#

getMissionConfigValue "author"

leaden summit
#

Oh awesome thank you

green sonnet
#

So uh... What is spawn and how do I get the code executed with it? lol.

exotic flax
robust hollow
#

how do I get the code executed with it
what?

fluid cairn
#

is there a way to force a unit to reload with a script?

exotic flax
robust hollow
past tiger
#

Pico was here! πŸ«–

winter rose
#

@past tiger aaaaaand? πŸ‘€

past tiger
#

Last forum update about new stuff & changes in Arma 3 is from 19 november, i look everyday to see if there is a new update. 14 days with no updates.

#

😟

#

Dedmen is cooking tons of changes and fixes, i'm sure.

unkempt talon
#

Any way to set all Opfor AI sub-skill at scenario?

willow hound
#
{
  _x setSkill [...];
} forEach (units east);
robust hollow
#

(units SIDE since A3 v2.01.146926)

serene quiver
#

I have all this

drugBox addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}];
drugBox1 addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}]; 
drugBox2 addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}]; 
moneyBox addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}]; 
moneyBox1 addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}]; 
moneyBox2 addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}]; 
weaponBox addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}]; 
weaponBox1 addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}]; 
weaponBox2 addEventHandler ["killed", {execVM "Scripts\radiomessage.sqf";}];```
running inside a gamelogic. 
And this in another:
```sqf
null = [] execVM "Scripts\intel\intelDrop1.sqf";   
null = [] execVM "Scripts\intel\intelDrop2.sqf";   
null = [] execVM "Scripts\intel\intelDrop3.sqf";  
null = [] execVM "Scripts\intel\intelDrop4.sqf";   
null = [] execVM "Scripts\intel\intelDrop5.sqf";   
null = [] execVM "Scripts\intel\intelDrop6.sqf";  
null = [] execVM "Scripts\intel\intelDrop7.sqf";   
null = [] execVM "Scripts\intel\intelDrop8.sqf";   
null = [] execVM "Scripts\intel\intelDrop9.sqf"; 
null = [] execVM "Scripts\intel\HVT_intelDrop1.sqf"; 
null = [] execVM "Scripts\intel\HVT_intelDrop2.sqf"; 
null = [] execVM "Scripts\intel\HVT_intelDrop3.sqf";```
It works, BUT...is there a better way to do it? ![salute](https://cdn.discordapp.com/emojis/705048414878040174.webp?size=128 "salute")
winter rose
#

yes 😁

serene quiver
#

LOLLL...I bet!!..HAHAHAHA

little raptor
#

loops and format

serene quiver
little raptor
#

forEach, for and format

#

and there's no need for null =

#

there's no need for anything

#

it fact it's better that way

willow hound
#

Throw it into init.sqf while you're at it

winter rose
#
{
  _x addEventHandler ["killed", { execVM "Scripts\radiomessage.sqf" }];
} forEach [drugBox1, drugBox99];
``````sqf
{
  execVM format ["Scripts\intel\intelDrop%1.sqf", _x];
} forEach [1,2,3,4,5,6];
little raptor
#

forEach [1,2,3,4,5,6];
for "_i" from 1 to 6

winter rose
#

slower iirc

little raptor
#

no

#

faster

winter rose
#

then this ^

little raptor
#

it's not a fair comparison

willow hound
#

Ah guys this does not need optimisation

little raptor
winter rose
little raptor
#

I mean in your forEach example, first you create an array
then loop thru it

#

so it's slower

#

but when you use for, there won't be an array, so it becomes faster

#

otherwise for should never be used instead of forEach

winter rose
#

using for, then from, then to might be slower, no?

winter rose
willow hound
little raptor
#

depends on the number of elements in the array you create

little raptor
winter rose
serene quiver
# willow hound Do your `intelDrop#.sqf` scripts do something different each or do they all do t...

The same stuff indeed
let me check first..hold on..almost the same...

GOM_fnc_intelDrop = {
params [["_side",east]];//defaults to east if no side is given
//you can replace _enemies with an array of units that should drop the intel
//_enemies = allUnits select {alive _x and side _x isEqualTo _side};
_enemies = [intel];
{
_x addAction ["<t size='1.5' shadow='2' color='#ff9900'>SEARCH BODY</t>",{
params ["_object","_caller","_ID","_enemies"];
_object removeAction _ID;
_guaranteedIntel = {alive _x} count _enemies <= 3;//if 3 or less enemies are alive every kill will give intel
if (random 100 < 100) then {
systemchat "You found some intel!";
[] execVM "Scripts\intel\stash_intel_1.sqf";
  } else {
systemchat "You found nothing";
  };
},_enemies,6,true,false,"","!alive _target AND _this isEqualTo vehicle _this AND isPlayer _this",2];
  } forEach _enemies;
};
//init the intel drops
_init = [east] call GOM_fnc_intelDrop;```
Nope, they exec `different stash_intel_1.sqf `
little raptor
#

just a guess

winter rose
#

dunno and will test Β―_(ツ)_/Β―

#

forEach has _forEachIndex and array creation,
for uses string and min two other commands
can be interesting either way

little raptor
#

uses string
they're fast, but compiling them could be slow (but it should happen once)

oblique arrow
little raptor
#

no need to create hundreds of scripts for that

winter rose
oblique arrow
serene quiver
winter rose
#

thanks, will integrate it soon

serene quiver
#

Maybe I should explain better what all those scripts achieve: hold on..

little raptor
winter rose
oblique arrow
winter rose
#

aaaaaall of them, I just didn't want to copy/paste πŸ˜„

#

drugbox, moneybox, pastabox, your call

oblique arrow
#

Ah

serene quiver
#

I have 9 stashes spawning on the map randomly. There are 9 units (defined by the above script _enemies = [intel]; ), that when killed drop this script: https://sqfbin.com/uyepivojijogeguteyom that reveal a location of the randomly placed stashes. The same concept works for HVTs (3) of them...

serene quiver
serene quiver
#

Trust me, I didn't write this (GrumpyOldMan kindly did it for me a few years back) and I wouldn't know how not even if you and I stay here all day long with you trying to teach me. I surely didn't use those scripts in the most efficient way, but back then (I'm overhauling the mission so you know..) "efficiency" came WAY after "it works..who cares".

still forum
# little raptor ok then faster to write

I find a for loop more complicated to write.
you need to know to set the variable name in quotes, and the from and to and whether last value is inclusive or exclusive.
for forEach you simply just list what you want without having to think

#

Btw that will change when script optimizer comes around, the forEach will win

little raptor
#

JIT Compiler?

still forum
#

no assembly optimizer

#

It will turn the forEach array into a constant, instead of rebuilding the array everytime you run that code

little raptor
#

it's outside the loop

still forum
#

its not

#

forEach [1,2,3];
in sqf assembly is

push 1
push 2
push 3
makeArray 3
callOperator forEach

my optimizer turns that into
push [1,2,3]
callOperator forEach

little raptor
still forum
#

If you run ArmaScriptProfiler (which includes SQF-Assembly)
you can do

_code = optimizeCode {{} forEach [1,2,3,4,5]}

#

because when you stop sooner, you stop sooner?

#

thats totally unrelated to what I said

little raptor
#

also exitWith has the same speed for:

{
if (true) exitWith {};
} forEach a;//[1,...1000]
{
if (true) exitWith {};
} forEach b: //[1]
still forum
#

Yes.. Also unrelated to what I said

#

you are iterating over a variable here, you are not creating an array. Which is what i talked about

little raptor
still forum
#

no, it becomes instant, if you only put constants in an array

#

like basically every usage of params will be faster then, and your forEach example

little raptor
still forum
#

Only real constants are string, number, code.
but bool/null types can also be turned into constants instead of calling commands

little raptor
#

I'd really like it if bools were constants too.

still forum
#

my optimizer does that too yeah

little raptor
still forum
#

yeah... I guess

little raptor
#

noice!

serene quiver
#

πŸ‘€ ...cool..(as if I know what the heck you guys were talking aboutπŸ˜‹ ) but exactly how that translates to my original "problem"? (which is how to make it more efficient) Thank you.

little raptor
serene quiver
#

@little raptor ..I know you probably will send me to a Wiki page of some sort (trying to teach how to fish instead of feeding a fish?) but I'm not trying to learn how to fish here...give me the fish and I'll eat it..hahahah

winter rose
#

so. from here.
we won't fish for you, but we can explain how to fish, little by little, and provide fish example to learn by it. now anyone not wanting to follow this is obviously free to not contribute.

serene quiver
spark turret
#

reminds me that i have a poopton of scripts i need to put documentation in and release

winter rose
serene quiver
#

You already took care of the "drugBox" thing...that's done..

#

now I have to work on the "intel" part

winter rose
serene quiver
#

Yep..the eventHandler part, I understood it and already applied in the mission...the second part
{ execVM format ["Scripts\intel\intelDrop%1.sqf", _x]; } forEach [1,2,3,4,5,6];
I don't understand:

#

how the script knows which intelDrop.sqf refer to the right intelFound?

willow hound
#

Make an "init.sqf" file in the mission root folder and put this stuff in there. If it's a multiplayer mission, we need to use a different file though, so just let us know if that's the case.

{
  _x addEventHandler [...];
} forEach MyArrayOfBoxes;
{
  [_x] execVM "...";
} forEach MyArrayOfIntelDrops;
```Now the second loop needs you to alter your `intelDrop.sqf` script slightly and then you're good to go:
The syntax used here passes the value inside the [] left of `execVM` to the script you are executing. You can then use that value inside the script by referencing `_this # 0` or, more elegant and readable, by using `params`.
willow hound
#

If MyArrayOfBoxes and MyArrayOfIntelDrops are the same, you only need one loop with both lines of code.

willow hound
#

It's a file that is executed when the mission starts.

serene quiver
winter rose
#

if MP, it get runs on every client so yep, that's the diff

serene quiver
serene quiver
still forum
#

Hey people.
I planned
_hashMap get _key
_hashMap get [_key, _defaultValue]

but that's not possible because in the first variant _key could also be an array.
So I need to rename the second one.

_hashMap getOr [_key, _defaultValue] (Get value OR default)
_hashMap getDefault [_key, _defaultValue] (Get with possible default value)

or any other ideas? I think getOr is better

winter rose
#

why not make keys only "static" types, string, number, object? would an array be compared by value or reference?

still forum
#

object is impossible.

would an array be compared by value or reference?
both

but that wasn't my question :u Array key support is important removing that is not an option

spark turret
#

If you cant use get for all hashmap uses, wouldbt it be better the rename all? Like "getHash" and then for all cases?

#

Instead of splitting it up into 2 things

still forum
#

That won't help with the problem at all. Still need two command names.

willow hound
#

I'm more in favor of a command name like getValue or something, because just get... don't like that.
How about array syntax only: _hashMap get [_key] and _hashMap get [_key, _default]?

still forum
#

I'm just asking for a oppinion on the name. I'm not asking you about changing fundamentals that were decided weeks ago.

#

Array syntax only could work yeah. But add's performance overhead on every get, but this container is intended to provide high performance, not make you waste performance everytime you want to use it

winter rose
#

if there is a get, there is a set - which is already kind of taken

spark turret
#

Then i choose getOr

little raptor
still forum
#

with the set command. Not related to my question though

#

I just want to get an opinion on the naming so I can continue working on on it..

#

Result:
0.0128 ms
Code:
HashMap get ["test"]

Result:
0.0097 ms
Code:
HashMap get "test"

yeah array is no option. 20% premium just to no have to write the "getOr" instead.

little raptor
#

getOr is simple enough

willow hound
#

getValue and getValueDef for me. Has good readability I think.
I agree with LM, get is too ambiguous.