#arma3_scripting

1 messages · Page 632 of 1

ocean folio
#

according to the mod im trying to work with, I need to define all of the jammers in a script triggered from init.sqf

spark turret
#

Looking in the .rpt is a good way to debug.
Visual studio code has an extension that opens the latest rpt with ctrl shift r. Can recommend

ocean folio
#

I guess I should probably upgrade from notepad lol

spark turret
#

Yeah visual studio code is very nice, poseidon too. Poseidon is less advanced but easier to use for beginner imo

frank ruin
#

If you would want it so people can't get killed if you run over them by a vehicle do you filter on the handledamage eventhandler on _projectile input?

little raptor
#

No

#

Does it even return a _projectile?!

#

It should be objNull

frank ruin
#

Cause if they are driver of vehicle it doesn't kill the player.

#

When they switch to passenger seat and they still drive a player over it kills him.

little raptor
#

When they switch to passenger seat and they still drive a player over it kills him.
How can they drive from the cargo seat?! 🤣

frank ruin
#

Well they speed the vehicle and switch seat, so the vehicle is still moving of the speed.

#

They switch seat right before they want to drive em over with it.

wild prairie
#

is there a case insensitive version of pushBackUnique for strings?

winter rose
#

no, but you can build one

#
private _unique = [];
{
  private _string = _x;
  if (_unique findIf { _x == _string } == -1) then
  {
    _unique pushBack _string;
  };
} forEach _stringArrays;
```@wild prairie (but maybe there is a better solution)
proper sail
#

What is the practical reason for using netId and objectFromNetId? Instead of just using the object itself in the first case?

serene quiver
#

OK...I've got no error, but it isn't working...what's wrong?

uav1 setVariable ["confirm",false];       
player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", {uav1 getVariable ["confirm",true],hint "TARGET CONFIRMED..GOING HOT!";player removeAction (_this select 2);}, [], 4, true, true, "", ""];  
waitUntil{"confirm",true}; 
uav1 fireAtTarget [myNearestEnemy,"PylonMissile_1Rnd_LG_scalpel"];```
queen cargo
#

Just came in my mind, what about scriptResult SCRIPT

#

As a command

#

Anybody suggested that ever?

willow hound
proper sail
#

Right

winter rose
#

y u ping meh :u
this channel is full of capable people too! if I can help, I do help, don't worry

#

@echo yew what are you trying to do here?

#

I want to set a var with random and unique number on 4 different object
oh
but the code is not really related

#

yes, you have to do a random on every line

willow hound
#

Well you only make one random number.

winter rose
#

otherwise you do it once and get… one random number

#

yep

willow hound
#

Does that reply feature ping people? Somebody reply to this so I can see.

winter rose
#

@echo yew btw, your random array should be min, mid, max not mid, min, max

wrong

private _num = round random [600,3000,10400]; // _num = 42 let's say
myobject1 setVariable ["Timer", serverTime + _num, true]; // serverTime + 42
myobject2 setVariable ["Timer", serverTime + _num, true]; // serverTime + 42

right

myobject1 setVariable ["Timer", serverTime + round random [600,3000,10400], true];
myobject2 setVariable ["Timer", serverTime + round random [600,3000,10400], true];
winter rose
willow hound
#

Yea it pretty much pings you, very good.

serene quiver
#

@willow hound is not working in "not" firing the missile...

winter rose
willow hound
#

Ah, I see. Even cooler!

willow hound
serene quiver
#

nope..not doing anything..sorry

willow hound
#
uav1 setVariable ["confirm", false];       
player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", {uav1 setVariable ["confirm", true]; hint "TARGET CONFIRMED..GOING HOT!"; player removeAction (_this select 2);}, [], 4, true, true, "", ""];  
waitUntil {uav1 getVariable ["confirm", false]};
#

That's better.

serene quiver
#

let me test this right now..report back ASAP..

#

@willow hound nope..I got this error:
21:47:33 Suspending not allowed in this context 21:47:33 Error in expression <true, true, "", ""]; waitUntil {uav1 getVariable ["confirm", false]}; uav1 f> 21:47:33 Error position: <getVariable ["confirm", false]}; uav1 f> 21:47:33 Error Generic error in expression

willow hound
#

Uh yea

winter rose
#

Suspending not allowed in this context
means you are using a sleep or waitUntil where you shouldn't

little raptor
#

Just came in my mind, what about scriptResult SCRIPT
@queen cargo
What is it supposed to return?

winter rose
#

correct, it's weird

serene quiver
#

@winter rose I see...and how do I make the uav1 waiting for the addAction to fire?

little raptor
#

Don't wait for it

#

Add a condition

#

Altho I didn't read your previous comments

#

Let me check

serene quiver
#

@little raptor I'm getting lost here..don't think I know how..

little raptor
#

Yep

#

Just put the fireAtTarget in your addAction code

willow hound
#

Aye, smartest solution up there meowthis

serene quiver
#

@little raptor I try with that....no joy!
player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", { uav1 fireAtTarget [myNearestEnemy,"PylonMissile_1Rnd_LG_scalpel"];player removeAction (_this select 2);}, [], 4, true, true, "", ""];

little raptor
#

What's myNearestEnemy

willow hound
#

Maybe waitUntil tried to evaluate uav1, I'm not sure. Won't matter if you do as Leopard20 suggests.

willow hound
serene quiver
#

@little raptor as asin11 sad...

little raptor
#

Does that code work at all?

#

uav1 fireAtTarget [myNearestEnemy,"PylonMissile_1Rnd_LG_scalpel"];

#

Try it in the debug console

serene quiver
#

let me try...

little raptor
#

Because what you wrote is correct

#

Syntax wise

willow hound
#

Can you guarantee that the player has a laser target?
A laser target is created by a laser designator when it's on.

little raptor
#

Also, isn't there a flag for addAction that can remove it automatically after completion? HoldAction has one. addAction must have one too

queen cargo
#

@little raptor would return whatever the spawn returned

little raptor
#

Spawn returns handle

queen cargo
#

No, a new operator that extracts a value out of spawn

little raptor
#

You mean like call?

winter rose
#

holdActionAdd has, not addAction

queen cargo
#
private _handle = [] spawn { 1 };
waitUntil { scriptDone _handle; };
private _value = scriptResult _handle; // Returns 1 once the spawn finished```
This is essentially how it could work
serene quiver
serene quiver
willow hound
#

You are modifying the "DESIGNATE" mode, correct?

serene quiver
#

yap

willow hound
#

What does the DESIGNATE code look like right now?

serene quiver
winter rose
#

zomg the indent

serene quiver
willow hound
#

_drone is undefined inside the addAction scope.

winter rose
#

also your links are content-identical

serene quiver
#

I'm sorry guys..it's my first few posts on discord..I'm trying😋

willow hound
#

Don't worry, the original version of your code is in the very first sqfbin link you posted.

little raptor
#

@queen cargo the handle is null in your example!

#

When a code is done, it's handle is deleted

winter rose
#

that's an example, an idea

little raptor
#

And you can't keep it (and its return value) in memory, because of unnecessary memory usage

winter rose
#

(ofc not doable this way - not without heavy modification at least)

serene quiver
#

I guess this is becoming too hard for my "scripting-ability😂 ....

willow hound
#
player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", {(_this # 3 # 0) fireAtTarget [(_this # 3 # 1), "PylonMissile_1Rnd_LG_scalpel"]; player removeAction (_this select 2);}, [_drone, myNearestEnemy], 4, true, true, "", ""];
```Now this might just work...
serene quiver
willow hound
#

Put only that (no setVariable, no waitUntil, no fireAtTarget) in between the two sleep statements.

queen cargo
#

@little raptor for starters, the handle is not null but a variant of scriptNull (a minor but Important difference)
And what I would like to have is simply a way to Also have an actual value inside of it if it does return a value, suspending the actual deletion of the handle or something like that

serene quiver
#

@willow hound nope..sorry..I got the addaction, but not firing..

little raptor
#

where you put the addAction, add this:

serene quiver
willow hound
#

Because there's no waitUntil it probably fires after the "Missile fired" hint was displayed.

willow hound
little raptor
#

No that's wrong

serene quiver
#

How do you "quote" the messages?

little raptor
#

No that's wrong
Your hint says missile fired when it adds the action

willow hound
#

Next to where you can react to it, the popup at the top right of the message when you hover over it.

serene quiver
willow hound
#

Try again and wait longer, as we said, the hint now comes early.

#

(we can adjust that after we got it working in the first place)

little raptor
#

Try again and wait longer, as we said, the hint now comes early.
@willow hound it doesn't necessarily come early. It's misplaced.

#

But yeah not the issue atm

serene quiver
#

Confirm..not firing

little raptor
#

Are you sure you're using the right type of drone?

#

Maybe it doesn't have that pylon

#

where you put the addAction, add this:
systemChat str [_drone, myNearestEnemy]

#

It's time to debug

willow hound
#

Better put it inside the addAction

little raptor
#

They're not defined there

#

Except for myNearestEnemy

willow hound
#

Yea with (_this # 3 # 0) obviously

serene quiver
willow hound
#
player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", {systemChat str (_this # 3); (_this # 3 # 0) fireAtTarget [(_this # 3 # 1), "PylonMissile_1Rnd_LG_scalpel"]; player removeAction (_this select 2);}, [_drone, myNearestEnemy], 4, true, true, "", ""];
```Could be interesting 🙂
little raptor
#

Yeah

serene quiver
#

systemChat say: [any,1a8df366b00# 178121: lasertgt.p3d]

willow hound
#

Why Arma, why

#

What is the point of letting me pass arguments if they have to be global

serene quiver
willow hound
#

Ah

#

You used the wrong code

little raptor
#

Try what ansin11 wrote

robust hollow
#

the error doesnt match that snippet
ssile_1Rnd_LG_scalpel"];systemChat str [_drone, myNearestEnemy]; player removeAc
vs
ssile_1Rnd_LG_scalpel"]; player removeAc

willow hound
#

ssile_1Rnd_LG_scalpel"];systemChat str [_drone, myNearestEnemy]; player removeAc is not in that code, copy paste my code (again) please.

serene quiver
willow hound
#

It's important to use _this # 3 and stuff in that code, that's why it needs to be exactly that code.

serene quiver
#

this is the code I'm using
https://sqfbin.com/ujikiviqiqekojetuxen

..sorry..no errors, but missile not firing (hint "missile fire" is there though)

systemChat: [uav1,1a74920d600# 1781012:lasertgt.p3d]

willow hound
#

Good, passing the arguments works. I was starting to doubt the fabric of reality.

willow hound
#

Unless something goes wrong with (_this # 3 # 0) fireAtTarget [(_this # 3 # 1), "PylonMissile_1Rnd_LG_scalpel"]; the missile should be fired though. The "Missile fired" hint currently means nothing. How long did you watch and wait?

serene quiver
#

MUCH longer than what it takes normally for the drone to fire with the old code..

willow hound
#

Hmmm

#

Pretty much my last idea: Try this (hopefully fixed) version of your first approach.

_drone setVariable ["confirm", false];       
player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", {(_this # 3) setVariable ["confirm", true]; hint "TARGET CONFIRMED..GOING HOT!"; player removeAction (_this select 2);}, _drone, 4, true, true, "", ""];  
waitUntil {(_drone getVariable ["confirm", false])};
_drone fireAtTarget [myNearestEnemy, "PylonMissile_1Rnd_LG_scalpel"];
serene quiver
#

sorry bud..still not firing. I'm gonna report the drone pilot for desertion...hahahaha

willow hound
#

Ah, unfortunate. And weird. I would have started my own testing by now, but I'm not at home.

serene quiver
#

I'm making a little video to show you what's up...wait..

willow hound
#

In your original original code you were using _weapon instead of "PylonMissile_1Rnd_LG_scalpel", I guess you can try that too, who knows.

serene quiver
#

IT'S FU**ING WORKING!!!!!!!!

willow hound
#

There we go, finally. 🥳

serene quiver
#

AWESOME...it's finally FIRING the missile....now....is keeping firing until I stop lasing..even without me "confirming"😂 ..but that's another story.

#

spoked too soon...it IS firing, but now it doesn't wait for confirm-target. I'm giving up...once solved one problem, a new one pops-up..ARMAAAAA😩

willow hound
#

Hard to tell, might be the AI firing on its own (which could possibly be avoided using setCombatMode or such), but that clip does not show any missile actually reaching its target, sounds like they hit something / explode somewhere else instead...

#

But I've done my duty for today, time to go to bed 😴

serene quiver
little raptor
#

@serene quiver well now that you confirmed that the arguments were ok, you can ditch that command and use something rock solid.
try forceWeaponFire/fire and a fired event handler to setMissileTarget on the projectile.

old sequoia
#

I having trouble finding the correct way to set the mass of a vehicle. Can someone help?

warm hedge
#

What's wrong?

old sequoia
#

Well. I can't find a script that works.

#

To clarify. There's a vehicle that is weighted at 8k and I'm trying to change its weight to 1k.

young current
#

setMass

#

scripting commands wiki page is in pinned messages

old sequoia
#

Setmass doesn't work.

young current
#

well that is the only command to do that.

#

possibly you are using it wrong

old sequoia
#

Well I'm sitting here with 2 other people. One of which is a coder. Used it the way BI instructs and a multitude of different configs.

young current
#

configs?

#

the command is for ingame scripting

#

you can test it with the debug console

turbid zenith
#

Heya everyone, can someone link me to a script that I can use with a trigger to full heal a player? (Locally).
Using ACE3 Medical system as well.
Edit: Found this, can someone confirm this is usable? {_x call ace_medical_treatment_fnc_fullHealLocal} foreach thislist

little raptor
#

it only triggers once. so units entering after the first batch of units (thisList) won't be healed

vague geode
#

Is there any good way to check whether or not an AI is glitched into a bilding or terrain object?

little raptor
#

lineIntersectsSurfaces with GEOM and FIRE lods
But in Arma AI almost never get "glitched" into an object (they usually just walk through the object)

vague geode
compact maple
#

Hi, is someone comfortable with ace3 interaction?

serene quiver
# little raptor <@!493152270549254155> well now that you confirmed that the arguments were ok, y...

Thanks leopard, with this

player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", {(_this # 3) setVariable ["confirm", true]; hint "TARGET CONFIRMED..GOING HOT!"; player removeAction (_this select 2);}, _drone, 4, true, true, "", ""];  
waitUntil {(_drone getVariable ["confirm", false])};
_drone fireAtTarget [myNearestEnemy, "PylonMissile_1Rnd_LG_scalpel"];```

it does fire now...
#

but it keeps on firing after the first strike without waiting for confirmation...
let me make a little video..hold on...
here it is...
https://youtu.be/dI1rIBoZJq4

worn forge
#

@vague geode try for beginPosASL: eyePos _unit (where _unit is what you're testing) and for endPosASL: getPos _unit [getDir _unit, 100]

winter rose
#

(AGLToASL getPos* I believe, but yes)

little raptor
#

no

#

you're both wrong

#

@vague geode

beg: unit modelToWorldWorld [0,0,0.05];
eng: eyePos unit

or the other way around (doesn't make much difference)
you can use modelToWorldWorld for the second one too

#

you can also adjust the front and back (y-coord in model space) a little bit.

#

@serene quiver even if it does, it's wasting performance (waitUntil)
both codes do the exact same thing (logically). so I'm not sure what's wrong.
as for why it keeps firing, that's what the command does. it's similar to the "Fire" command in the engage menu (key 3). the drone sees that target as enemy and won't stop firing until it's dead. so try the other command I mentioned.
also, where are you executing that code again?

serene quiver
little raptor
#

@serene quiver no I mean where do you execute that?

serene quiver
little raptor
#

yeah that

#

like do you execVM it or...?

serene quiver
#

yap..execVm

#

you want me to share the demo folder?

little raptor
#

nope that's fine

light badge
#

Hi all, how can I place a wapon and modify the rotation in x,y,z degrees?
I'm using "setdir" but only it rotates the "z" axis

little raptor
#

@serene quiver try this:

player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", {
_drone = _this#3;
driver _drone forceWeaponFire (weaponState [_drone, [-1], "PylonMissile_1Rnd_LG_scalpel"] select [1,2]);
 hint "TARGET CONFIRMED..GOING HOT!"; player removeAction _this#2
}, 
_drone, 4, true, true, "", ""];

and put this in the init field of the drone:

this addEventHandler ["Fired", {
    _this#6 setMissileTarget myNearestEnemy
}]
little raptor
#

@light badge setVectorDirAndUp

serene quiver
little raptor
#

it shouldn't

#

area you sure it's the same code?

#

Also, remove that waitUntil and fireAtTarget

#

just use that

serene quiver
#

with the
this addEventHandler ["Fired", { _this#6 setMissileTarget myNearestEnemy }] part in the drone init

#

WAIT..I reloaded the demomission...now is not firing at all..the addaction come on, but no joy...and keep circling...ARMAAAAAAAAAAA..

smoky rune
#

is there any multiplayer-friendly way to turn empty vehicle headlights?

little raptor
#

@serene quiver this works for me:

player addAction ["<t size='1.5' shadow='2' color='#00cc00'>CONFIRM TARGET</t>", { 
_drone = _this#3; 
_drone doTarget myNearestEnemy;
_drone fireAtTarget [myNearestEnemy, "missiles_SCALPEL"]; 
hint "TARGET CONFIRMED..GOING HOT!"; player removeAction _this#2;
},
_drone, 4, true, true, "", ""];
serene quiver
#

let me try..

serene quiver
little raptor
#

@serene quiver actually remove the doTarget line from my code because you're already doing it in your code

little raptor
#

also remove that fired EH

#

it's not needed

#

@serene quiver in case you're wondering what was wrong, you were not using the right weapon for the drone

#

as I mentioned the first time I noticed your issue

serene quiver
#

It is a matter of facts, the "PylonMissile_1Rnd_LG_scalpel" instead of the "missiles_SCALPEL" got there because since the type of weapon is declared in the radio trigger with
dronecas=[uav1,60,"missiles_SCALPEL","true"] execVM "dronecas.sqf"; for debug purposes it sneaked his way in.

#

Wrongly so I'll add..

little raptor
#

PylonMissile_1Rnd_LG_scalpel
this is a magazine tho

serene quiver
#

yap..I messed up with the classnames..

little raptor
#

I suspected that when I noticed it (1Rnd)

serene quiver
#

Good job spotting that..now is a beauty

little raptor
#

@cunning oriole that's not a quese

#

you're just changing a variable in a certain player's variable space

#

which is called pvpQueue

sharp grotto
#

I have a weird problem (or iam stupid)

    _cheli = createVehicle ["BlackhawkWreck",_crashpos,[], 0, "can_collide"];
    createSoundSource ["Sound_Fire", position _cheli, [], 0];
    createSoundSource ["Sound_SmokeWreck1", position _cheli, [], 0];

If a move far away from that point and come back the sound is not playing anmyore 🤔

little raptor
#

@cunning oriole I know what you mean

#

but that's not even a "list" (array)

#

anyway you should use an array

#

then use pushBack

#

then count the array

#

it gives the number of players in the queue

#

@cunning oriole something like:

array = [];
array pushBack player;
publicVariable "array"

but note that publicVariable is kind of slow for arrays (depends on the size of the array)

#

it won't be slow if you're dealing with a few players. so it's fine

#

@sharp grotto maybe the game deletes it? I don't see anything wrong

#

also I can't reproduce your problem

sharp grotto
#

Ok. Thanks #mods i guess

idle jungle
#

hey guys what target in remote exec is just that client only? is it i just want that singular person to get that hint message or whatever

astral dawn
#

then you must pass it client's ID or that client's object (his player object typically)

idle jungle
#

ahhh erm ok im not that advanced unfortunately i thought it was just going to be a number like 0 being a server lol

little raptor
#

just use allPlayers as the target

#

unless it's not dedicated

idle jungle
#

its on a dedi thing yea

#

but i dont want all players to get it or im very stupid and overlooking something lol

#

["Message here"] remoteExec ["hint", allPlayers];```

like so?
winter rose
#

if the script is executed on the client, just use the command and not a remoteExec.
if the script is executed on the server, use the targeted player unit as argument

idle jungle
#

i noticed sometimes when using
hint "message"; sometimes it would be broadcasted to other players also

little raptor
#

and if it's not dedicated:

[{if (isServer) exitWith {}; hint "ABC"}] remoteExec ["call", 0];
idle jungle
#

but doesnt 0 execute globally across all clients?

little raptor
idle jungle
#

no no just that 1 person who activated the remote exec

#

like an addaction

#

or trigger area

little raptor
#

remoteExecutedOwner

idle jungle
#

oooo that sounds more like it

copper raven
#

you can use -2 as target in RE to not target server machine "everyone but the server"

winter rose
#

@copper raven never forget that a server can be a player too

copper raven
#

was directed towards the code above, mb

winter rose
#

anyway, a remoteExec 0 for a hint is not what will kill the server, at least I hope ^^

finite sail
#

[0, -2] select isDedicated

#

remoteexec to those clients

#

will cope with player/server

idle jungle
#

thanks guys

little raptor
astral dawn
#

you can to exclude specific client IDs

#

which is also kind of genius btw 😄

cold mica
#
heal_box addAction [
    "<t color='#fb0000'>Heal Self</t>",
    {
    
    {
    [_x] call ace_medical_treatment_fnc_fullHealLocal

    }forEach [call BIS_fnc_listPlayers] select if (_x distance heal_box < 10) then {true}
    
    }
];

This is a script that should heal all players that are 10 meters from the heal_box However, the function ace_medical_treatment_fnc_fullHealLocal is receiving arrays from _x instead of players. Any advice?

little raptor
#

remove the [ ]

#

plus why use the BIS fnc when you have allPlayers?

#
allPlayers select {_x distance heal_box < 10}
#

and I'm not sure if you're providing the right arguments to the ace fnc. that's up to you

#

Heal Self
why does the box say heal self but heals others too?!

still forum
#

fullHealLocal runs locally (as the name says)

#

calling it on remote players won't be right

little raptor
#

@cold mica this means:

[_x] remoteExec ["ace_medical_treatment_fnc_fullHealLocal", _x]
copper raven
little raptor
#

allPlayers select {_x distance heal_box < 10}
or you could put the condition inside the forEach which makes it faster

still forum
#

which makes it faster not if many units get filtered out here, which is probably the case

cold mica
#

yes, most people will be outside the heal_box range. Thank you for the help, I'm gonna try Leopard's suggestions first.

little raptor
still forum
#

no

#

if and then and _forEachIndex overhead

little raptor
#

but you run the loop once

copper raven
#

still more commands to call

little raptor
#

how about count?

still forum
#

select might run the loop only once too

#

still if and then commands overhead

little raptor
#

&& {
}

still forum
#

depends on how much select is filtering out

#

performance really doesn't matter to that level, where such things would make sense to do

cold mica
#

Error Undefined variable in expression: _patient
init.sqf

[] execVM "heal_range.sqf";
#
heal_box addAction [
    "<t color='#fb0000'>Heal Nearby</t>",
    {
    
    {
    [_x] call ace_medical_treatment_fnc_fullHeal

    }forEach allPlayers select {_x distance heal_box < 10}
    
    }
];```
#

Script has been updated, now it has a new error.

cold mica
#

oh, I see. I didn't put anything for cursorObject

little raptor
#

so put [_x, _x] instead

cold mica
#

well, for the Local version of the script, it only needs one item

#

but yes, I will put what you suggested Leopard

little raptor
copper raven
#

RE is fine, but it's not supposed to be executed that way, there might be something else listening on that event for example

cold mica
#

The script works perfectly now! Thank you Leopard, Dedmen, and sharp.!

heal_box addAction [
    "<t color='#fb0000'>Heal Nearby</t>",
    {
    
    {
    [_x,_x] call ace_medical_treatment_fnc_fullHeal

    }forEach (allPlayers select {_x distance heal_box < 10})
    
    }
];

Here is the working version for anyone searching this discord to find a heal script.

copper raven
#

also your select is ran on the result of the forEach, precedence issue

little raptor
#

@cold mica yeah put ( ) around that

#
(allPlayers select {_x distance heal_box < 10})
cold mica
#

woops, thank you

still forum
cold glacier
#

Are there any situations where an object can be removed from the game, and the "Deleted" event handler not called? Or is it safe to clean up resources using it.

winter rose
#

I would say safe, but maybe a dev can confirm

#

which use case?

still forum
#

it should be safe

#

if not, thats bug probably

cold glacier
#

Awesome, thanks guys. Using it to clear JIP queue entries when an object is deleted, because objects can only be used as the JIP ID for a single remoteExec, any subsequent remoteExec calls replace the first in the JIP queue

#

So need to use another style of ID, that gets cleared when the object is deleted. Deleted event handler is the simplest approach I can think of.

astral dawn
#

If it doesn't work due to some arma bug (who knows right?!) then you can check these objects periodically.

#

Like object is nulll - all right let's clear up the JIP queue

cold glacier
#

Yeah, there's a handful of approaches I came up with - a deleted event handler is just the simplest.

#

Next simplest I have is manually storing an array of JIP functions to call, their arguments and the object. When a player joins, custom JIP function fires, and runs all the functions where object isn't null.

astral dawn
#

I've found a bug which triggered the deleted event handler on player when he entered a vehicle for instance. It has been fixed already, but after things like this I'm always skeptical about all other serious event handlers 😄

cold glacier
#

(Bonus fact: 0002:1343:Test, 0002.0:1343:Blarg seem to be the same JIP key - as one overrides the other. Both are valid net IDs according the parser, I think :D)

#

(Both parse to 2:1343)

#

That's good to know - I guess it's safe enough to use in this instance.

#

But yeah, a little caution sounds good.

#

I'll bake in some bug-detection into the wrapper.

smoky verge
#

weird question
I'm using the "copy to SQF" module from achilles on a mission
what can I do to ensure it goes as fast as possible? does stuff like turning down graphics help?

little raptor
#

Well, if it's unscheduled, no. If it's scheduled, it probably could help in the sense that the CPU will probably be doing less work. But I don't think it'll make much difference.

smoky verge
#

wasn't sure where to go
though to post here because I though it was relative to sqfs cpu usage

little raptor
#

well scheduled codes can go faster the fewer other codes are running.

smoky verge
#

does a zeus module count as scheduled?

little raptor
#

The module itself? I don't think so.

#

A module is essentially just a function (or should I say an object+function)

smoky verge
#

I see
then I'll just have to wait for a while
a more relevant question
this function copied an sqf to my clipboard but in a single line
how can I automatically sort every ; to end a line?
was thinking of using the find and replace but how can I replace it with an end of line?

little raptor
#

Use notepad++ or vscode

smoky verge
#

using notepad

little raptor
#

Next line is \n\r

#

Or just \n

#

That gives you the line break char

smoky verge
#

got it, so it will be
;\n replacing every ;
right?

little raptor
#

\n\r is more "windowsy"

#

But yeah

smoky verge
#

it worked thanks

little raptor
#

And ditch notepad for good

exotic flax
#

no, notepad is not able to properly handle linebreaks, so use a proper editor which can, and you shouldn't have to worry about single line stuff anymore

smoky verge
#

sorry meant notepad++

#

forgot there was actually a normal notepad

still forum
#

scheduled code runs faster the higher your fps is, or if you are in a loading screen

little raptor
#

True that too

still forum
little raptor
#

Oh shoot

#

I need some sleep!

still forum
#

I assume they will use scheduled code, as freezing your game for a while in MP is not a good idea

smoky verge
still forum
#

run arma with -noSound and you get higher fps 😄

exotic flax
#

run arma with -server and you'll get even higher FPS 🤦‍♂️

little raptor
#

Wait really?

smoky verge
#

was aware that running stuff on a self hosted server was better than straight singleplayer, I guess server is even better

still forum
#

yeah running the module script on a server with fps limit disabled might be very fast

#

but if you are running the script manually anyway

#

just run it in unscheduled 😄

smoky verge
#

in case it may interest you, its related to that issue I had not a long ago, me and a friend though of using the copy mission SQF module to copy the position of every object in the map, to then swap every createVehicle line with CreateSimpleObject line
so it would work like a replaceWithSimpleObject function but without the deleting part.
so you can cut the network traffic by half

still forum
#

if you want network traffic

#

do local only simple object and run script on every client

smoky verge
#

oh right
shouldnt cause any issue since its just static objects right?

still forum
#

yeah

smoky verge
#

if this whole process were to be made into a mod it would help a lot of people

oblique arrow
#

Hm peeps how do I attach a number to a string?
As in if I have
_itemNr = 4; and _posStr = "spw_item_";
How can I make
spw_item_4
out of that?

cold glacier
#

_posStr + str _itemNr

#

Though you're better doing _posStr + (_itemNr toFixed 0)

#

+ puts two strings together

#

toFixed converts a number into a string, with the specified number of decimal places

#

(See wiki for more info)

oblique arrow
#

yayautism Thank you very much

drifting oasis
#

Aight, this is driving me crazy. I'm trying to get the diwako_dui_special_track variable working, but every time I put it in the init, I get general expression errors in just about everything loaded.

#

The current init line I have set up is missionNamespace setVariable ["diwako_dui_special_track", ["a", "b", "c"]];

#

(I have a, b, and c set as units out of my squad)

robust hollow
#

are you doing it as an array of strings or an array of objects? the github says it should be an array of objects

drifting oasis
#

I'm doing it exactly as seen above

robust hollow
#

ok, well do it as an array of objects, because above you set it as an array of strings

#

which seems to be wrong

drifting oasis
#

This is a bit embarrassing, but can you show me an example?

robust hollow
#

missionNamespace setVariable ["diwako_dui_special_track", [a, b, c]];
where a, b and c are variables referencing objects (which sounds like you have done that already)

#

putting them in "double quotes" or 'single quotes' makes it a string

drifting oasis
#

Ah, that's something I feel like I should have known. Thanks

#

Yup, works as intended now. Thanks!

light badge
#

hi all, i'm trying to use "setVectorDirAndUp" to rotate weaponholder after using a "addWeaponWithAttachmentsCargoGlobal" command but I don't know how exactly works.
I saw community.studio.com page but it is not clear for me, can anyone explain me how the command setVectorDirAndUp works? because y just only want to rotate the weapon x=90º, y=0 and z=180

tough abyss
#
hint parseText "Text<br/><img size= ´10´image= `bild.jpg´ /><br/>Text";
#

I use these to let show an picture as hint, but its shows only the text! I know it had works moanth ago but not anymore! Is there something wrong?

cosmic lichen
#

use ' instead of ´

#

`

drifting oasis
#

Honestly with setVectorDirAndUp I think I just did trial and error until I finally got it the way I wanted. I don't think I ever fully understood it.

@light badge you want to make sure the variables are set between 0.0 and 1.0, lemme find an example where I rotated something 45^o

tough abyss
#

@cosmic lichen Thanks i try it!

cosmic lichen
drifting oasis
#

@light badge
frigpdg1 setVectorDirAndUp [[1,0,0], [0,0,1]];
This rotates something 90 to the right,
frigpdg2 setVectorDirAndUp [[-1,0,0], [0,0,1]];
would be to the left.

To get 90 degrees, try using 0,1,0 or something like that, just mess around with the first 3 numbers.

Those are 90 degrees, actually. 180 would be
frigpdg5 setVectorDirAndUp [[0,-1,0], [0,0,1]];

cosmic lichen
light badge
#

@drifting oasis thak you very much

narrow pollen
#

Are variables set within the missionNameSpace persistent? Do they apply to JIP?

little raptor
#

persistent
no yes
apply to JIP
with public flag yes

narrow pollen
#

missionNameSpace setVariable ["ace_common_allowFadeMusic",false,true]; So this would apply to everyone in the mission, including JIP?

little raptor
#

actually it is also persistent as long as the server (and thus the mission) is up

narrow pollen
#

Alright, thank you

wispy cave
#

When I run sqf private _assembledName = getText(configFile >> "CfgVehicles" >> typeOf _staticWeapon >> "DisplayName"); I get the display name localized in the language of the client it ran on, is there a way for me to get the English name?

winter rose
#

nope afaik

#

why do you need it?

wispy cave
#

logging purposes, I can use the classname then

winter rose
#

it's safer yes

lofty silo
#

what can i make with oop/extensions in arma??

winter rose
#

sorry, what is the question?

lofty silo
#

I'm not a programmer, so i am just curious of all scripts and post which talk about extensions. So, what uses has oop?

#

Also, how hard is it to learn from zero?

copper raven
#

extensions allow you to do stuff that normally wouldn't be possible with plain sqf

willow hound
#

OOP has plenty of "use", read more (or all) about it on https://en.wikipedia.org/wiki/Object-oriented_programming.

Extensions in Arma: https://community.bistudio.com/wiki/Extensions
Extensions are used to achieve things the SQF language itself can't do, prominent examples would be TFAR and ACRE: They need to connect to and exchange data with Teamspeak, which Arma itself does not support.

Hard to learn from zero? Probably. Most people working with Arma extensions likely have a solid understanding of how Arma and programming in general work.

plush breach
#

would anyone happen to know how I can enable simulation on a large group of objects ? I've managed to get a single object to work. However, I don't want to have to go the unoptimized route of having each and every single object have it's own line to enable simulation.

(Essentially is there a way I can get a group of objects all under one variable).

willow hound
#

Do they happen to be close together or of the same type?

plush breach
#

yes

#

they're the same / similar type (same mod) and they're close together

lofty silo
#

Ty for the info! These links help me to understand a little more Arma but for now I'm gonna stick with scripts only.

willow hound
plush breach
#

yep @willow hound thanks it works 😄

serene quiver
#

Ok..I have this
_video = ["Videos\loadin-bar_text.ogv"] spawn BIS_fnc_playVideo;

on top of my init.sqf, followed by
null = [] execVM "Scripts\StoryBoard.sqf";

How do I make the second line wait for the video to be finish?

#

Thanks all

still forum
#

_handle = [] execVM

#

waitUntil {scriptDone _handle}

serene quiver
#

..thanks..so it should be:

_video = ["Videos\loadin-bar_text.ogv"] spawn BIS_fnc_playVideo; _handle = [] execVM waitUntil {scriptDone _handle} null = [] execVM "Scripts\StoryBoard.sqf"; ?

#

please don't 😂 at me..hahah

proper sail
#

your handle is supposed to be tied to the script you are executing

serene quiver
#

ok...but the script is executing AFTER the video call..

#

unless "_video = ["Videos\loadin-bar_text.ogv"] spawn BIS_fnc_playVideo;" is considered a script..

#

in that case, could be:

_handle = ["Videos\loadin-bar_text.ogv"] spawn BIS_fnc_playVideo;
waitUntil {scriptDone _handle}
null = [] execVM "Scripts\StoryBoard.sqf";```
?
proper sail
#

now you are executing it twice

#

_handle is a name just like _video

serene quiver
#

I'm getting lost here..so how that should be?😋

proper sail
#
_handle = ["Videos\loadin-bar_text.ogv"] spawn BIS_fnc_playVideo;
waitUntil {scriptDone _handle}
null = [] execVM "Scripts\StoryBoard.sqf";```
serene quiver
#

works like a charm..really thank you.

still forum
#

Pretty charming blobdance

serene quiver
west grove
#

hm. question. is there a more or less easy way to get the shortest path from point a to point b?

#

taking roads into consideration

#

reason is, i would like to plot a path on the map

winter rose
west grove
#

awesome. this looks good. i'll check it out

tough abyss
#

Evenin' everyone

#

Trying to set up a laptop object with an addaction to view the camera of a pre-placed UAV. What script command send a player directly into the gunner seat of a UAV? Tried assignAsGunner, moveInGunner, moveInTurret; no luck.

crude vigil
#

Dont forget, remoteControl doesnt mean a unit's camera is changed. You need to change it separately which is given in an example.

tough abyss
#

Thanks!

past tiger
#

When you are in first person into a Pawnee helicopter, you can't see lines draw with drawLine3D when looking through the front glass. Anyone also noticed that?

topaz field
#

@little raptor I know this might be 4 days ago but I finally had someone test the sounds for me on a multiplayer server and they could not hear any of them

#

Even with the use of remoteexec

topaz field
#

Do i maybe need to remote exec inside the sqf file h2 say3D ["pickup1", 150, 1]; Which is inside the sqf file which is executed by the AddAction

past tiger
#

@topaz field say3D have local effect, may be if you try:[h2,["pickup1", 150, 1]] remoteExecCall ["say3D",-2];

winter rose
#

@past tiger (again, ) a server can be a player

finite sail
#

[h2,["pickup1", 150, 1]] remoteExecCall ["say3D",[0, -2] select isDedicated];

#

will work if the server is also player

still forum
finite sail
#

oooo

#

[arrayFlatten2, true] getUnitLoadOut Player

#

to remove duplicates?

#

or is it doing that anyway?

compact maple
#

Hi, is there a way to see all the building in a virtual arsenal or something like that ?

winter rose
#

not in vanilla no

compact maple
finite sail
#

in what way do you want to see them? you want to spawn them so you can run around them, or just see a picture?

compact maple
#

Idealy I would have liked to run around to see if this is an open or a closed building, ie... some of the buildings doesn't have doors

#

but I guess the wiki will do

finite sail
#

does the wiki show building insides?

compact maple
#

nope

still forum
#

@finite sail use the existing way to remove duplicates, arrayIntersect

finite sail
#

yep

still forum
#

flattening an array has nothing to do with duplicates, so makes no sense to add it onto there just because you need it for your specific usecase.
A removeDuplicates that doesn't copy the array would be useful though I guess

cosmic lichen
#

It allows you to quickly place all objects of selected category. That way you can quickly find the building you need.

compact maple
#

Thanks! 🙂

dusk gust
#

Might be a strange question, but is there a way to get all variables attached to a display? You can setVariable and getVariable on a display, but you cant just use allVariables.

warm hedge
#

Might worth of a ticket

still forum
#

allVariables should work tho

dusk gust
#

If it should, it doesnt :(

#

Just returns a Generic error

still forum
#

Ah I know why

#

we have it for control but not display :u

dusk gust
#

Unfortunately, yeah lol

still forum
#

I'll fix it

dusk gust
#

Sweet, thank you very much ^^

brave jungle
#

Is it known that "Default" call BIS_fnc_exportGUIBaseClasses causes issues when exporting it directly in a mission? The inherited classes are used before the class is defined.. i.e ctrlDefault is defined almost 500 lines after its already used and so causes an error in the description.ext

#

I mean its an easy fix but others less experienced might not know what to do if its used.

still forum
#

uhm... allVariables control only works on Map display... not general controls 🤔

dusk gust
#

Kinda strange

#

Any control works for me using allVariables. Atleast it doesn't error out ```sqf
allVariables ((findDisplay 46) displayCtrl 114998)

still forum
#

it doesn't error out, but it'll return empty array if your control is not the old mission editor map control

dusk gust
#

Ahh makes more sense then

#

Is there a specific reason for it doing that?

still forum
#

I can't see it.
Actually that specific control seems to have two namespaces on it and some special handling.
I guess I'll just fix the command to work on all controls too

dusk gust
#

That would be amazing. Hopefully it doesn't take too much :)

serene quiver
#

Hi all, would be possible to launch a mission from the strategic map? I meant, starting a new map and everything, not just teleport and giving a task as you do normally...

still forum
#

@brave jungle you can now (maybe 2.02? not sure) use the import command instead of exporting guy classes to description.ext

serene quiver
#

The scenario will be: you're on stratis, go to strategic map, choose mission and mission start on Altis.Once done you go back to Stratis...

still forum
#

you can do that in singleplayer with a campaign

#

campaign of multiple missions.
via script you choose which mission runs next

serene quiver
#

yes sorry I meant in SP

still forum
#

There was this one Arma mod thing, that did Arma in space.
Where you could fly a plane high up and go to space

serene quiver
still forum
#

that actually worked, by being a campaign. If you are high up, the mission just gets ended and you get to the next mission in the campaign.
But the next mission then is on a "space" terrain

#

You need to make a campaign...
That would be as a mod, I don't think you can do it as a workshop mission

#

you need to make a mod campaign pbo

serene quiver
#

Making a campaign is not a problem...my problem would be connecting all the different missions with the strategic map...

still forum
#

this is how you choose which mission runs next, based on edning type

#

Then you just do whatever in your mission, and via script do
https://community.bistudio.com/wiki/endMission
and depending on what end type you pass to endMission, will together with the description.ext above, decide what mission runs next

#

I think there are only the 7 ending types though?

#

but you can have 7 different followup missions, per mission.

brave jungle
bitter magnet
#

nope, what I recall from last editing session its "unlimited".

brave jungle
#

Didn't mean to ping either ^ sry

#

incoming banhammer

serene quiver
#

I got all that,mate. What I really wish was possible was that the player can choose between multiple choices of mission;after he' done with 1 mission, he's teleported back to the board..choose another mission and rinse and repete..

winter rose
still forum
#

What I really wish was possible was that the player can choose between multiple choices of mission;after he' done with 1 mission, he's teleported back to the board..choose another mission and rinse and repete..
yes, thats what i just told you

#

or atleast tried to

serene quiver
dusk gust
#

Thank you for fixing it @still forum Appreciate it immensely :)

still forum
#

yes

serene quiver
tough abyss
#

Hey guys. Apologies if I'm asking in the wrong place. But I'm having trouble with my spaghettis code running fine locally but won't work in a dedicated server environment. I would love to be able to just paste the code up here but well, since it's spaghettis and built base on somebody else's script. I'd be honest I have zero idea where to start debugging.

winter rose
#

ouch 😄

tough abyss
#

Undesrtood 😄 Perharps I'll get back when I managed to pin point the problem 😄 Many thanks for your help 😄

winter rose
#

most of the time, it is because local script (e.g addAction) is added to player, and the script only runs on the server (where there may not be a player)
so, yes a good split between client/server can help 😉

past tiger
#

drawLine3D it's not supposed to be used in a final mission/mod?

warm hedge
#

Why it even is?

finite sail
#

its often used as a debug tool

still forum
#

if you want to use it you can use it just fine

#

it wasn't made to not be used

past tiger
#

ok

#

thanks

#

i mentioned a bug about it, above

little raptor
#

which bug?

winter rose
#

When you are in first person into a Pawnee helicopter, you can't see lines draw with drawLine3D when looking through the front glass. Anyone also noticed that?
#arma3_scripting message

warm hedge
#

If you meant you can't see the line through a glass, it's more like feature/shader issue

little raptor
#

afaik drawLine3D never shows through a view LOD

#

it's not a bug

#

just how it is

tough abyss
#

oh apologies, I didn't meant to get into the middle of the conversation

warm hedge
#

Never mind, that's how the thing goes 🙂

still forum
#

no worries, you forcefully ended the previous conversation and started a new one. So all good

still forum
past tiger
#

@little raptor but the hell cat helicopter don't have this problem, i believe other helis also don't have.

#

It's something that happens with the Pawnee

little raptor
#

maybe it doesn't have a view LOD there at all

#

I don't know

#

Dedmen knows better

compact maple
#

Hi, I would like to search objects on the map using nearestObjects as for center the center of the world, but I don't recall the command to get the center position

little raptor
#

[worldSize/2, worldSize/2]

#

and the radius is worldSize/2*sqrt(2)

compact maple
#

Thanks! 🙂

still forum
#

probably just a glass shader/ layer bug thing. reyhard would know 😄

past tiger
#

@little raptor radius should be worldSize*sqrt(2)/2. You agree?

finite sail
#

_worldCenter = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");

little raptor
#

*sqrt(2)/2

#

to cover the edges

#

yes

past tiger
#

yes

winter rose
#

if it is for a trigger/marker, make it square :p

little raptor
#

no it is for nearestObjects

compact maple
#

its not :b

finite sail
#

or make a location that covers the entire map and use in

compact maple
#

will just use that maths functions!

winter rose
#

quick maffs

#

(BIS_fnc_worldArea is also a thing 😬)

#

@compact maple why nearestObjects btw?

compact maple
#

I want to get any building of a certain classname on the map

winter rose
#

(and not e.g allMissionObjects, nearestTerrainObjects etc)

#

nearestTerrainObjects

little raptor
#

wouldn't nearestTerrainObjects be faster?

finite sail
#

nearestterrainobjects ["house" etc etc

#

yes.. LOADS faster

compact maple
#

Im switching to nearestTerrainObjects then 🙂

finite sail
#

if you want houses, use nearestterrainobjects [["house"]

#

might want to add things like fuelstation and lighthouse to the array

#

when you have that array filter out elements that don't have buildingExit to get actual houses

little raptor
#

I think if you want a certain classname you'd have to use nearestObjects

winter rose
finite sail
#

yes

little raptor
#

I think it might be slower

#

Arma loops are slow

compact maple
#
{
    private _building_classname = _x select 0;
    private _building_buyable     = _x select 1;
    private _center                = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
    private _radius                = worldSize * sqrt(2) / 2; // We also want the objets that are in the edges of the cercle!
    private _buildings            = nearestTerrainObjects [_center, [_building_classname], _radius];
    {
        _x setVariable ["building_buyable", _building_buyable, true];
    } forEach _buildings;
} forEach _buildings_classname;

is what I have rn

#

discord indent is f*cked up lol

finite sail
#

it doesnt take classnames

little raptor
#

_building_classname
won't work

compact maple
#

it takes type ?

finite sail
#

look at the syntax on wiki

#

it has its own hieracrhy

compact maple
#

This command matches objects using isKindOf comparison instead of direct class name == comparison

little raptor
#

?

cosmic lichen
#

Also:
_center = [worldSize / 2, worldSize / 2];
_r = worldSize / sqrt 2;

little raptor
compact maple
compact maple
#

I will just try both, to see which is faster

cosmic lichen
#

This is what you use

little raptor
#

you're using nearestTerrainObjects now

finite sail
#

use nearrestterrainobjects, its way faster unless you want to find buildings placed in editor

compact maple
#

Then I filter it with my own classname ?

finite sail
#

yes

#

typeof

compact maple
#

I know

finite sail
#

or, what i do is filter the returned array to get only those elements that have buildingexits

compact maple
#

But leo/dedmen said it might be slower, I will just try both

finite sail
#

they didn't you misunderstood

compact maple
#

& I did said might

#

lol

cosmic lichen
#

I might be missing something here but wouldn't it be better to execute nearestTerrainObjects once and then filter out the houses with the wrong classname instead the other way around?

still forum
#

do more work in engine, more better

cosmic lichen
#

Oh, @winter rose already mentioned that 😄

#

This convo is too fast for me xD

compact maple
#

just did a quick test, nearestTerrainObjects took 17546ms
and nearestObjects took 13392

little raptor
#

nearestTerrainObjects took 17546ms
after filtering?

compact maple
#

no without

#

so I didnt bothered testing with filtering

winter rose
#

You win this time, @little raptor!!

finite sail
#

well.......

little raptor
#

🥇

finite sail
#

Result:
57.6667 ms
Cycles:
18/10000
Code:
nearestterrainobjects [alpha_1, ["house"], 10000, false, true]
.
.
.

#

Result:
73.2143 ms
Cycles:
14/10000
Code:
nearestobjects [alpha_1, ["housebase"], 10000, true]

#

alpha_1 being me, in mission

little raptor
#

that's not fair! you're sorting the nearestObjects results!

finite sail
#

nearestobjects always sorts

#

the true was 2dmode

#

let me just edit the results for clarity

little raptor
#

my bad

little raptor
finite sail
#

in the nearestterrrainobjects searcn, iid usually add "fuelstation", "lighthouse", "hospital" to the search array

little raptor
#

because the result is cached the second time

compact maple
#

No I didnt

little raptor
#

Tested on Altis (empty mission with just a player unit)

Result:
215 ms

Cycles:
5/10000

Code:
nearestTerrainObjects [ [worldSize/2, worldSize/2], ["house"], worldSize/sqrt 2, false, true] select {_x isKindOf "Land_i_House_Small_01_V2_F"}
Result:
178 ms

Cycles:
6/10000

Code:
nearestObjects [ [worldSize/2, worldSize/2], ["Land_i_House_Small_01_V2_F"], worldSize/sqrt 2, true]
spark turret
#

+1 for very clean result presentation.

winter rose
#

-1 for saying I'm wrong

#

@little raptor
may you try with```sqf
select { typeOf _x == "Land_i_House_Small_01_V2_F" }
// instead of
select { _x isKindOf "Land_i_House_Small_01_V2_F" }

still forum
#

last one slower. Ad they said they wanted same type, not same or subtype :u

austere granite
#

I remember there was some script out there somewhere to scan buildings using intersects, to get more accurate bounding boxes. Anyone can recall it?

cosmic lichen
#

@austere granite Dunno the script, but the boundingBox command was updated at some point. Maybe you can get precise bounding boxes with it now.

worn forge
austere granite
#

Not what i meant. I found killzonekids selection scanning. Maybe I was misremembering because it was years ago

spark turret
#

is there a way to find out the clientID used for remoteexec from a players name?
like
-get allPlayers
-store a value individual to each player

  • remoteexec hint "hello there" after _value seconds for each indidual player
#

so player A gets 5 seconds delay, player B gets 20 seconds delay, all called from a centralised, serverside script

rancid mulch
#

@spark turret server can do 'owner OBJECT' to get the network id of a player object.

spark turret
#

ah thanks. i looked at it and wrongly read "returns owner of machine that runs this code"

little raptor
#

I mean "internally"

finite sail
#

is nearestterrainobjects vs nearestobjects still being discussed?

#

ive been afk

little raptor
#

no,

#

anyway I don't think you can get reproducible performance results with those commands (because of caching)
and you can see that the results were pretty close
the terrain one being slow mainly because of select
without select it was ~ 190 ms

finite sail
#

agreed

#

i think, nto is quicker in the engine for large distances, but nearestobjects is better if you are looking for a single type of object that has a classname, nto gets roads, trees, pavements , other tricky things that nearestobjects dont get

#

both have their uses, i use both a lot for mission dynamics

little raptor
#

wasn't that nearEntities?

finite sail
#

critically, nearestobjects finds object made by the mission, nearestterrainobjects ONLY finds stuff 'baked' into the terrain

#

i dont know the proper terminology for that

little raptor
#

If it's entities only, then it won't return terrain objects, right? (but afaik it's not and it does return the objects)

finite sail
#

right, entities are things added in script or edeneditor

#

thats the wierd thing, nearestobjects does return terrain objects like trees and bushes

#

so there is some overlap

oblique arrow
#

Hey peeps, is there a command to get (as an example) 10 random numbers at once in an array?

#

Or do I just have to generate 10 the normal way

little raptor
#

I don't think so

oblique arrow
#

Oki

finite sail
#

make an array, size it to 9

#

_x apply random 1

#

or similar? pseudo code

little raptor
#

size it to 9
10

finite sail
#

is size zero based?

little raptor
#

it's the number of elements

#

_a resize 10

finite sail
#

not size... what command i thinking of?

#

yes, that lol

oblique arrow
finite sail
#

if written correctly, yes

oblique arrow
#

Ah nifty

finite sail
#

im barely awake here, lol

#

im quite old

oblique arrow
still forum
#

we need iota

winter rose
#
private _array = [];
_arr resize 10; // 10× nil
_arr = _arr apply { random 1 }; // 10× random 1
finite sail
#

that

spark turret
#

im trying to define a function through the description ext.
i followed the biki closely but if i try to call the functions, it always says they are undefined.

#

pls help

#
author            = "IR0NSIGHT";
onLoadName        = "Testing some stuff yah`know";
onLoadMission    = "A group of weebs is tasked with infiltrating the christian values of America.";
//loadScreen        = "images\loadScreen.paa";

class Header
{
    gameType =  Coop;    // Game type
    minPlayers =  1;    // minimum number of players the mission supports
    maxPlayers = 10;    // maximum number of players the mission supports
};

class CfgFunctions
{
    class IRN //my tag class
    {
        class myCategory {
            class calcSoundPos {file = "WOLF_Modules\ambient_battle\fn_calcSoundPos.sqf";};
            class testFunction  {file = "WOLF_Modules\ambient_battle\fn_test.sqf";};
        //   class spawnSalvo {file = "WOLF_Modules\ambient_battle\IRN_spawnSalvo.sqf"};
        //    class remoteSound {file = "WOLF_Modules\ambient_battle\IRN_remoteSound.sqf"};
        };
    };
};

thats my description ext

still forum
#

try leading \ on the file

spark turret
#
_sourcePos =[_x,_center,_dist,[0,0,0]] call IRN_fnc_calcSoundPos; //["_player","_center","_dist","_headPos"]

Thats the code to call it

#

will try dedmen

#

didnt work

little raptor
#

try leading \ on the file
not necessary for mission functions

still forum
#

they are not mission functions

spark turret
#

they are.

still forum
#

wuht

spark turret
#

testing before i make it to a mod

still forum
#

you posted the whole mod files in there?

spark turret
#

yeah for testing. dont wanna restart arma for each change

still forum
#

filePatching

#

enable -filePatching in launcher options

#

put Steamapps/common/Arma 3/WOLF_Modules/ambient_battle/... folder like that

spark turret
#

maybe next time. never done it before

little raptor
#

. dont wanna restart arma
you only need to restart the mission

still forum
#

game will load sqf files from that folder

still forum
spark turret
#

lets get this test function working first

little raptor
#

well you can create a folder with the same name as your mod in the mission folder

still forum
#

Are you sure you are not loading the mod pbo with the functions too? because if the mod defines them too, you can't overwrite them in mission

little raptor
#

but it shouldn't say undefined.

#

according to IRONSIGHT

still forum
#

checked RPT for errors? file not found, compilation errors?

#

config in itself looks correct to me.
so I don't think there's an issue there

#

that leaves file not found, file fails to compile, description.ext not loaded

spark turret
#

ah my file path is wrong.

#

wierd that it didnt complain about that

still forum
#

it should in RPT

#

ingame message box is only shown once

silk ravine
#

Hi there

still forum
silk ravine
still forum
#

_op1_exterior_lights undefined variable

silk ravine
#

I am really outta ideas by now.
It is called in init.sqf via if (isServer) then

#

But its defined right an the start

still forum
#

yes

#

but not in the action

silk ravine
#

B I G OOF

still forum
#

local variables carry over to current script and lower

#

your action, is not your current script

#

its a piece of code, that you put somewhere to be executed some time later. When your variable is long gone

#

you need to pass parameters to the action

#

quite sure createAction has a option to do that for you

silk ravine
#

And here I thought the variable would be present of the server if the script is called via init

still forum
#

also your spawn's are weird

#

global variables yes

#

but your variable is not global

silk ravine
#

yea I see... damn

#

whats with the spawns?

still forum
#

well they seem not needed

#

I can't see anything that needs a spawn in your spawn block

#

private["_op1_exterior_lights"]; don't do that, its bad for performance.
private _op1_exterior_lights = do that instead

#

I don't know if executing that only on server is right.
I don't think addActionToObject actually sends the action to other players via network

#

but that's probably what you wanted to have

vague geode
silk ravine
#

Oh okay then you probably should not see the private line of that cram script I am trying to make xD

still forum
#

but you run it server-side only

silk ravine
#

Thanks!!
I tried it in the play in Multiplayer via Eden, an it gave me the option as slotted player after I spawned, weird

still forum
#

yes, you are the server when you preview locally

silk ravine
#

Thank you alot. I will switch the script around a bit then and simply let the server execVM the stuff locally with player side Action of the object.

willow hound
#

What object for example?

spark turret
#

the tutorial for lightpoints on the biki has an error. it gives this example code:

private _lightpoint = "#lightpoint" createVehicleLocal player modelToWorld [0,2,1.5];

which throws "expected array got object"
code should be this:

private _lightpoint = "#lightpoint" createVehicleLocal (player modelToWorld [0,2,1.5]);
#

do i have to attach the light to some kind of object to give it movement? i tried "_lightpoint setVelocity _myVector" but it didnt move the light

willow hound
#

Is that MP? How does it behave with createVehicle?
Either way the reason is probably Arma physics.

young current
#

if you create stuff that collides with players collision model player takes damage

willow hound
#

I mean you could disableCollisionWith or allowDamage, but other than that...

young current
#

or possibly explain what exactly are you trying to do and perhaps there is a better way

willow hound
#

Well player allowDamage false will certainly prevent the player from taking damage when sprinting into a table...

#

But other than that... This strikes me as an issue similar to that where two colliding vehicles have a chance to experience unplanned flight.

#

I don't.
Instead of createVehicleLocal you could try using createSimpleObject and the Simple Object framework, maybe that doesn't suffer from the same issue.

#

But I'm just guessing; I treat the Arma physics as an untouchable force of nature. You can not reason with them.

young current
#

create vehicle local means the thing does not exist in server

#

and when it does not exist in server different things happen on both ends of the pipe

#

perhaps you are not doing the correct thing

#

what are you creating that much that it takes performance?

#

and if it takes performance (like runs on every player instead of just once) then its a problem of execution

#

so again

#

explain what you are trying to achieve and perhaps there is a right way to do it

#

that is quite a lot yes

willow hound
#

Tried Simple Objects too?

young current
#

let him finish first

#

why are they not just created in the editor?

#

since they got static locations

willow hound
#

And did you try Simple Objects too when you searched for a way to improve performance?

young current
#

It sounds like perhaps your scripts are running for each player

#

instead just once on the server

sharp grotto
#

Is there a way for apply a NVG vision if you watch a player with

_unit switchCamera cameraview;
willow hound
#

In theory you could use createSimpleObject together with the path to an object's .p3d

young current
#

how is this code above executed?

#

or any code your mission runs?

willow hound
#

Can always treat those special objects differently.

young current
#

I strongly feel this is not the right way to do things.

#

in that scope yes

#

well missions are not mean for large scale building either

#

but also you just might be running something silly in there that tanks it

#

instead of it being caused by the objects themselves

#

have you packed those 4000 objects into very small area?

#

are you using vanílla or modded objects?

sharp grotto
# sharp grotto Is there a way for apply a NVG vision if you watch a player with ```sqf _unit sw...

To answer my own question. You can simply do this

pp_Color = ppEffectCreate ["ColorCorrections", 1502];   
pp_Color ppEffectEnable true; 
pp_Color ppEffectAdjust [1, 3, 0, [0, 0.1, 0, 0], [0, 2, 1, 0], [1, 1, 1, 0]];       
pp_Color ppEffectCommit 0; 


//Destroy NVG effect
ppEffectDestroy pp_Color;

Fullscreen NVG (Pilot helmet) comparison https://gyazo.com/80c63214ed372d21252e90ce02f8c14f
Script NVG https://gyazo.com/d1d6049d2148211feaae5f5c1a4a08d1

rough heart
#

Rabitoooo 👀

#

(prolly would not given the explanation on the wiki)

sharp grotto
#

You cant use it while watching a player via _unit switchCamera cameraview;

finite sail
#

guys, in an exitwith, can I have multiple lines of code?

{
  diag_log "exited!";
  _exitcount = _exitcount +1;
};
winter rose
#

yes

finite sail
#

thanks

#

signs I might be too tired....

#

22:58:27 Error Missing ;
22:58:27 File C:\Users\Paul\Documents\Arma 3 - Other Profiles\Tankbuster\mpmissions\COOP40_Authority.Tanoa\server\secondary_missions\do_barricadedefend.sqf..., line 1

#

line 1 lol

topaz field
#

@finite sail What do you mean it will work if the serve is also a player. You mean the server is being hosted by a player?

proper sail
#

How big is in the impact on networking performance between:
Is one favorable over the other?

setVariable ["test0",0,true];
setVariable ["test1",1,true];
setVariable ["test2",2,true];
setVariable ["test3",3,true];

and

setVariable ["test0123",[0,1,2,3],true];```
exotic flax
#

Well, the difference is "sending small amounts of data a lot of times" and "send a lot of data once".
And I would say that sending everything once is better, since in total it's less data to be send.
However if you change those variables (especially only one per time) a lot, it might be more useful to separate them.

proper sail
#

Right, I thought this was going to be the answer. Especially as your last sentence applies to our case

exotic flax
#

It also depends on where you need to store it; if it's local it doesn't really matter. Although I would try to group stuff together anyway, since it will make your life easier with working the data.

proper sail
#

ye i was just hoping that spamming one array instead of 4 seperate variables would have been more efficient on networking

#

add them to your stringtable...?

exotic flax
#

it is more efficient to have one variable being broadcasted, and if it only contains true/false the size is also manageable. But sending a lot of data (full objects, massive texts, etc.) when only a single bit changes becomes a burden.

#

in that case you shouldn't get the error(s)

#

might be better, since people who know more about configs / translations might not look here

still forum
#

Arrays are terrible on network traffic due to how they are implemented.. sadly
large arrays is bad.
But not sure if still better/on par with multiple small variables

little raptor
still forum
#

not slow

#

it takes more traffic/space than it needs to

#

you probably don't care about network traffic with todays internet speeds

#

just look at arrays in mission.sqm

#

the Item1, Item2, Item3

compact maple
#

Hi, if I return a value being in a for loop, it will instantly exit the loop ?

still forum
#

no difference

#

why would string or not string matter?

#

@compact maple return how?

little raptor
#

return a value being in a for loop
loops can only return values from their last iteration. (if defined)
it will instantly exit the loop
not sure what you mean

willow hound
queen cargo
#

loops can only return values from their last iteration. (if defined)

fnc = {
  scopeName "foobar";
  {
    _x breakOut "foobar";
  } count [1, 2, 3, 4, 5];
};
diag_log ([] call fnc); // 1```
little raptor
queen cargo
#

in that way, there is no return in any language because they "just end early" 🤪

still forum
#

maybe he means break/breakWith.
I dunno.
Need context @compact maple

little raptor
queen cargo
#

well your code is not even a loop.
It is a very common forEach loop in arma 🤷
Also:

fnc = {
  scopeName "foobar";
  for "_i" from 0 to 100 do {
    _i breakOut "foobar";
  };
};
diag_log ([] call fnc); // still 1``` tho ... i think you kinda took my response wrong, did not wanted to blame you or something, just correct what you said there as it is indeed possible in arma
little raptor
#

I know, but still what I'm trying to say is that it is not a real loop. you're returning the result from the "foobar" scope, not your loop scope. so technically it is not a loop.

still forum
#

notlikemeowcry

for "_i" from 0 to 100 do {
  breakWith _i;
};
little raptor
#

same difference!

#

even exitWith was possible

still forum
queen cargo
#

problem with sqf tho is:

scopeName "0";
fnc = {
  scopeName "A";
  for "_i" from 0 to 100 do {
    scopeName "B";
  };
  // scope "A" now has 100 passed over from "B"
};
[] call fnc;
// scope "0" now has 100 passed over from "A"```
#

aka: you always get the value from the lowest scope

#

if one is bored btw. he/she can explore the possibility of "out parameters" in SQF:

fnc = {
  params ["_out_var"];
  _out_var set [0, 12];
};

private _var = 0;

private _boxed_var = [_var]; // box variable
[_boxed_var] call fnc;
_var = _boxed_var select 0; // unbox variable

diag_log _var; // 12
winter rose
#

I sometimes did that but directly with arrays yes, since they are modified by reference ^^

languid oyster
#

Found this in a mod

[_unitPosition, _cartridge, _unit, _weapon, _ammo, _magazine, _projectile, _vehicle] spawn {
    params ["_unitPosition", "_cartridge", "_unit", "_weapon", "_ammo", "_magazine", "_projectile", "_vehicle"];
    private ["_unitPosition", "_cartridge", "_unit", "_weapon", "_ammo", "_magazine", "_projectile", "_vehicle"];
...

Is this double definition good for anything?

warm hedge
#

Never, params already does what private does

cosmic lichen
#

This is why arma has bad performance 😄

languid oyster
#

Thanks for clarification, thought so, but wanted to go for sure

#

I'm playing cleaning maid because I am annoyed by my error riddled .rpt

finite sail
#

we all have error riddled RPTs

#

think of it like this... an old car has oil under it's engine because there is oil IN it

#

arma RPTs are the same... when the RPT is empty, something is terribly wrong

little raptor
languid oyster
#

Must not be perfect, but when 10.000+ lines look like this
20:29:30 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:32 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:32 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:33 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:33 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:33 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:33 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:33 Cannot create non-ai vehicle hz_,
20:29:33 Cannot create non-ai vehicle ,
20:29:34 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:34 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:34 Cannot create non-ai vehicle hz_,
20:29:34 Cannot create non-ai vehicle ,
20:29:34 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:34 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:34 Cannot create non-ai vehicle hz_,
20:29:34 Cannot create non-ai vehicle ,
20:29:34 Trying to call remoteExec(Call) with a null-object as JIP ID
20:29:34 Trying to call remoteExec(Call) with a null-object as JIP ID

#

it is not good

little raptor
#

I meant if your rpt is empty (except for vanilla stuff)

languid oyster
#

Ah 🙂

finite sail
#

Id be looking closely at the 'cannot create non-ai vehicle'

#

thats usually a bad classname being given to createvehicle or createunit

#

often, a sneaky space sneakily sneaks into the classname

#

sneakily

languid oyster
#

I already have found the function responsible for that. Now I'll try my luck fixing it without braking anything.

little raptor
#

without braking
Happy racing!

finite sail
#

hehe

compact maple
#

Sorry I had to leave.
@still forum Actually I wanted to return a value in a for loop like (its just an example)

for "_i" from 1 to 5 do {
  if (_i >= 3) then {
    _i
  };
};
little raptor
#

exitWith

still forum
#

every iteration of the loop always returns a value (inside the loop)

#

so.. no it won't exit

#

otherwise loops wouldn't loop

compact maple
#

Okay, exitWith will leave the if statement ?

little raptor
#

will exit the current scope

#

if, while, for, etc.

compact maple
#
for "_i" from 1 to 5 do {
  if (_i >= 3) then {
    exitWith{}; //will exit the if statement?
  };
};
little raptor
#

no

#
for "_i" from 1 to 5 do {
  if (_i >= 3) exitWith {//will exit the for loop and runs the following code
  };
};

or

for "_i" from 1 to 5 do {
  if (_i >= 3) then {
    break; //or breakWith _i for example, if you want to return _i
  };
}
compact maple
#

Okay I got it! thanks

languid oyster
#

BREAKING 😆

little raptor
#

break and breakWith are not in the stable build yet (dev only)

finite sail
#

brakeWith

#

there is precedent, judge.. i present exhibit a

winter rose
#

Mister Attorney please! This case has already been through trial! 🔨

finite sail
#

indeed m'lud. I present this only as case law

#

when's lunch?

winter rose
#

you're late, it was 2 hours ago

#

as per Judge decision, getDammage objection is also overruled 👨‍⚖️

little raptor
#

setDamnAge wen?

tough abyss
#

Question, does anybody know how is called that function from contact that allows objects to levitate?

little raptor
#

Dunno, but you can create one yourself. It's not difficult

compact maple
#

I did a function to get the closest door from the player in a building, do you see things that I should change?

params [
    ["_player", objNull, [objNull]],
    ["_building", objNull, [objNull]]
];

if (isNull _building || { isNull _player }) exitWith {};

private _doors = getNumber(configFile >> "CfgVehicles" >> (typeOf _building) >> "numberOfDoors");

if (_doors < 1) exitWith {};

/**
* Get the position (relative to the building then to the world) of the first door to use it in the for loop
*/
private _door_pos_1 = _building modelToWorld (_building selectionPosition "Door_1_trigger");

private _distance = (getPosATL _player) distance _door_pos_1;

/**
* Set the first door to be the closest one, and if a door is closer, override the variable
*/
private _closest_door = 1;
 
for "_i" from 1 to _doors do {
    /**
    * Get the door position relative to the building then to the world
    */
    private _door_pos = _building modelToWorld (_building selectionPosition format["Door_%1_trigger", _i]);

    if (((getPosATL _player) distance _door_pos) < _distance) then {
        _distance = (getPosATL _player) distance _door_pos;
        _closest_door = _i;
    };
};

_closest_door
little raptor
#

not all buildings have that Door_x_trigger selection

#

if (((getPosATL _player) distance _door_pos) < _distance)
probably faster to sort than check manually

#

depends on the number of doors

#

private _distance = (getPosATL _player) distance _door_pos_1;
no need, it's a duplicate distance. you could just define _distance = 1e20; (infinity)

#

_closest_door = _i
usually doors are identified with their selectionName and not their number

spark turret
#

during testing i noticed that my spawned light sources are only visible at below ~1.5 km.
is there a way to raise the distance the lights are calculated?

winter rose
#

only raise the dynamic lights quality in video settings, note that the amount of lights in the scene play a role too

spark turret
#

im on ultra. changing it to "low" did not affect the distance

winter rose
#

then no dice I'm afraid, mods maybe

finite sail
#

its doesn't affect the distance, it affects the number actually rendered

spark turret
#

😢

#

dedmen pls fix

little raptor
#

I think it'd hurt performance

spark turret
#

so i tested some more. it seems at around 2km the light stops having "collision" with objects and only lights up the flat ground

#

which is why you can see it from a plane but not a nearby hill

finite sail
#

is this im mp or sp?

spark turret
#

sp

finite sail
#

k

compact maple
#

@little raptor Thanks for answering.
I should create an array with all the position, then sort it ascending, and select the 0 index ?

Actually I want the the id of the door because I want to manipulate it with animate

little raptor
#

also, another mistake: getPosATL is in ATL format; modelToWorld is in AGL format

#

@compact maple

_arr = [];
_pos = getPosASL player;
for "_i" from 1 to _doors do {
  _door_pos = _building modelToWorldWorld (_building selectionPosition format["Door_%1_trigger", _i]);
  _arr pushBack [_pos distance _door_pos, _i];
};
_arr sort true;
_arr#0#1;
#

delete everything after (door < 1) exitWith and replace with this

compact maple
little raptor
#

you can add privates if you want

compact maple
#

I will

#

is # faster than select btw ?

little raptor
#

@winter rose I hate unnecessary privates

#

no

compact maple
#

okay!

#

why 'unnecessary' ?

little raptor
#

depends where and how you plan to execute that code

compact maple
#

private is only justified if you need to use a variable multiple time on different scopes?

little raptor
#

but putting private _var inside a loop is definitely bad

compact maple
#

okay good to know

little raptor
compact maple
#

yup!

#

then my question would be, when to use private ?

winter rose
winter rose
little raptor
#

for example let's say you're calling that code from here:

_pos = getPosASL _someObject;
call MY_fnc_closestDoor;
_someObject setPosASL (_pos vectorAdd [0,0,1])

if _pos is not private inside the MY_fnc_closestDoor (as in the code I posted a few comments back), it will change _pos in this code, thus the result will be wrong

compact maple
#

Oooh okay

#
params [
    ["_player", objNull, [objNull]],
    ["_building", objNull, [objNull]]
];

if (isNull _building || { isNull _player }) exitWith {};

private _doors = getNumber(configFile >> "CfgVehicles" >> (typeOf _building) >> "numberOfDoors");

if (_doors < 1) exitWith {};

private _distance     = 1e20;
private _doors_arr    = [];
private _player_pos   = getPosASL _player;

for "_i" from 1 to _doors do {
  _door_pos = _building modelToWorldWorld (_building selectionPosition format["Door_%1_trigger", _i]);
  _doors_arr pushBack [_player_pos distance _door_pos, _i];
};

_doors_arr sort true;
_doors_arr select 0 select 1;

so here, the private is useless, right ?

little raptor
#

distance is not used

compact maple
#

ups

#

fixed

winter rose
#

but I wonder if not using private would add some scope lookup time, hopefully not of course

little raptor
#

like I said, it depends what is calling this code

compact maple
#
private _door_id = [_player, _building] call SRV_fnc_get_closest_door_from_player;

if (_door_id == 0) exitWith {};

_building animate [format["door_%1_rot", _door_id], 0];
_building setVariable [format["bis_disabled_Door_%1", _door_id], 1, true];

is calling it

little raptor
#

if you're spawning it for example, it's useless

#

if that's all of it, then it's useless yes

still forum
#

private doesn't make your code slower, it can only make it faster. So there is no performance reason to leave it away

little raptor
#

private inside spawn?

#

doesn't make your code slower
are you sure?

still forum
#

yes, any idea how it could?

#

only place it does nothing, is if you have no parent variable scope. But there it just does nothing at all, it doesn't hurt

little raptor
#

I don't know, but it definitely adds some delay:
_a = 1;
private _a = 1; (is slower

still forum
#

huh, makes no sense

#

all private does is disable lookup into parent variable scope.
if there is no parent, it makes no difference. If there is a parent, it makes stuff faster by not checking it

little raptor
#

I mean by 0.0001-2 ms

still forum
#

thats probably measurement error

little raptor
#

not a huge difference

oblique arrow
little raptor
#

so if I use private in a loop it won't be slower?

still forum
#

yes

oblique arrow
little raptor
still forum
#

only thing I can think of is

_var = 1;
loop
{
_var = stuff
}

if you use private there, every loop iteration will delete and recreate _var.
Whereas without, it will reuse the one in upper scope.
But not sure if recreating is actually slower there, as you'd overwise do atleast 2 hashtable lookups in both variable scopes

winter rose
#

it is a bit slower (see above link)
at least in 1.82 when I tested

little raptor
#
private ["_a", "_b", "_c", "_d"];
for "_i" from 1 to 10 do
{
    _a = 1; _b = 2; _c = 3; _d = 4;
};
// 0.0195 ms

for "_i" from 1 to 10 do
{
    private _a = 1; private _b = 2; private _c = 3; private _d = 4;
};
// 0.0235 ms
#

what the wiki says

still forum
#

yeah what I wrote above

#

That's the only case I can think of where private might be slower, but ONLY if you actually really put that variable directly in the parent scope, not multiple scopes away, and also not undefined in parent scope

#

but if you tell people "don't use private if you don't need it" they won't think of that very specific optimization and apply it

And if you don't do the private ["_a", "_b", "_c", "_d"];
then the second case will be faster

compact maple
#

how can you see the time execution of a script btw ?

still forum
#

debug console, the speed dial button on bottom left

little raptor
#

there's a speedometer button in debug console

#

you can also use the diag_codePerformance command

hollow thistle
#

private can't make the code slower as it's not an SQF operator (not talking about private <array> ofc)

little raptor
#

I used to think it was. now I get what it does (thanks to Dedmen)

compact maple
#

even if it does, we're not running after 0,0000xxxx ms, are we?

hollow thistle
#

It's a modifier or whatever it was called in SQF

#

private "_variable" // BAD
is an operator

#

private _variable // GOOD
it's a single thing, declaration of local variable with private modifier

little raptor
#

but if it is something you do a few thousand times, it could matter!

winter rose
#

Premature Optimisation, etc 😛

compact maple
#

yupp

still forum
#

its a keyword and its handled at compile time and generates a seperate variable assignment instruction.
Its actually a keyword/modifier to the = thing

modest vector
#

Good evening people, I would like to know if it was possible to define variables in a player's inventory items?

still forum
#

uniform/vest/backpack (vehicles) yeah. items (weapons) no

modest vector
#

Okay thanks

quartz pebble
#

How precise serverTime is?

#

I mean wiki says it syncs each 5 minutes, but what kind of desync can it accumulate within that sync interval?

winter rose
#

it may not help you, but I would guess the same precision as time - it depends on client's performance

wet hill
#

Hey, i have a question. I have something like Real Life Role Play in Arma with my frieds, and i want to have that only one person can unlock (or lock) his own car (and only then someone else can enter the car). Can someone help me? (I know my English sucks pepe_apu )