#arma3_scripting

1 messages ยท Page 604 of 1

still forum
#

There wasn't talk about functions in hours

astral dawn
#

SetLocation

still forum
#

you mean the command?

winter rose
#

which function does this command fill? ๐Ÿ˜

astral dawn
#

No, I mean the operator

winter rose
#

the medium-endian defragmented CPU

astral dawn
#

But yes you are right, things must be called as they are

spare mauve
#

So Im using MCC modules and I set up an IED. Im trying to put people to attack once the IED is exploded without them attacking prior, but I cant really figure that part out since they attack even if they are hidden behind rocks or cover.

winter rose
#

hmm, how to easily get a random normalised vector? for example, in any direction

vectorNormalized [-1 + random 2, -1 + random 2, -1 + random 2]```?
astral dawn
#

This way it won't be completely isotropic but it will do think_turtle

#

It's an interesting question

#

๐Ÿค”

#

Don't want to dive deep into this now. But you can for instance generate an array for one 1/8 of variants (for x>0, y>0, z>0) (in matlab or somewhere), store it, then select a random element from there, then randomly flip signs of x,y,z components

winter rose
#

hmmโ€ฆ

surreal peak
#

looks decent, what you trying to achieve with it?

winter rose
#

Isn't it obviousโ€ฆ Fireworks, of course! ๐Ÿ˜„

surreal peak
#

ooo nice

winter rose
#

with light effects. Just no sound

surreal peak
#

why not? Just detonate some bombs nearby :Z

astral dawn
#

boooo not fully isotropic boooo

#

๐Ÿ˜„

winter rose
#

gib :p

#

still welcoming a "finer" formula ๐Ÿ˜‰

surreal peak
#

@winter rose I found a paper which seems to answer your question, not sure if I can post since its just a link to a PDF which chrome automatically downloads

winter rose
#

as long as it is legal and descriptiveโ€ฆ otherwise dm

surreal peak
#

DMed

winter rose
#

โ€ฆI will stay with my method atm ๐Ÿ˜„

surreal peak
#

sounds fair :Z

winter rose
#

โ€ฆI'm stoopid with maffs

surreal peak
#

same here, thought I understood it. Then I read more of it

#

and then I realised it wasnt the best thing to be implimented into SQF

astral dawn
#

IDK how complex the math you are talking about but it's a good solution to use pre-generated values in such cases

#

then you just do selectRandom one of them

winter rose
#

what, you don't like my```sqf
vectorNormalized [-1 + random 2, -1 + random 2, -1 + random 2]

surreal peak
#

TBF I dont see anything wrong with it

astral dawn
#

I was talking about and then I realised it wasnt the best thing to be implimented into SQF

#

TBF I dont see anything wrong with it
position is uniform, but is angle uniform? I don't think it is

#

although it doesn't matter much I agree

surreal peak
#

I sent him some paper from some russian mathematicians with a solution which techincally does what he wants

#

but was way over our heads

tough abyss
#

Setting a vehicle's texture in a custom mission for MP, do I want to set that in the vehicle's init, initPlayerLocal.sqf, or initServer.sqf?

winter rose
#

do it through Eden Editor properties?

#

some lines can be seen I guess, but that's for an awful number of dots

tough abyss
#

do it through Eden Editor properties?
@winter rose Thanks! It's just that I've read some threads online saying that only host could see the vehicle textures and not the other players.

winter rose
#

changes through Eden are sync'ed, no worries

astral dawn
#

But it's not stated there ๐Ÿคท

slender schooner
#

well, i mean, is it needed?

#

if you are on altitude 5000, and you use nearestlocation, you get the same, as if you use it on altitude 0

winter rose
#

I don't know if locations can be effectively set to an altitude though @astral dawn

#

tried with getPos ?

#

yep, Z is -1 anyway

astral dawn
#

locationPosition returns 3 components

winter rose
#

Z is -1 * getTerrainHeightASL

#

(from getPos page)

astral dawn
#

I don't even understand what it means, it means that its Z component is actual Z component multiplied by -1?

#

ah wait

#

Anyway I can set position of a location to a 3d position and it returns a 3D position

winter rose
#

it means that altitude cannot be set to locations I think
therefore, a 2D search is the smart choice

#

wait, you can?

astral dawn
#

sure

winter rose
#

ah, then a wiki edit is in line

astral dawn
#
(getpos player) params ["_x", "_y", "_z"];

gLoc setPosition [_x, _y, 9000];

locationposition gloc returns [6251.91,4762.31,9000]

winter rose
#

@astral dawn are you suresuresure so I can press the button? ๐Ÿ‘€

astral dawn
#

yes, a location 9km above surface can't be 50 meters away from me if it was 3D ๐Ÿค”

winter rose
#

ok ๐Ÿ˜„

astral dawn
#

Thanks Lou ๐Ÿ‘

winter rose
#

updated - thanks for bringing it up, testing and confirming ๐Ÿ‘

dusky cairn
#

Hi I want this text to appears for 2 sec "Kill every soldier in this outpost to weaken the enemy" I'm trying this but it doesn't work titleText ["Kill every soldier in this outpost to weaken the enemy", "PLAIN", 2];

winter rose
dusky cairn
#

It does not go away. The only problem is that it doesn't go away

#

@winter rose

#

otherwise the script is working

winter rose
#

and where do you run it?

#

in the init, ok

dusky cairn
#

yes

winter rose
#

weird

dusky cairn
#

I took an old backup. It's working but thanks anyway

hallow mortar
#

The third parameter or 'speed', as it's called in the description, refers to the amount of time the message will be shown on-screen. Multiply each number by 10 to get the number of seconds it will be shown. You can even use floats as input, like 0.1, to show a message for only 1 second.

#

I bet it would go away if you waited 20 seconds

#

The main description of the parameter says it's the "time in seconds", but if that comment is correct (and it says it was tested so it probably is) then that should probably be changed to say it's a multiplier

dark ivy
#

Hello guys. I'm setting up a multiplayer mission and I'm trying to have some specific, playable units have an addAction for a loadout. I cannot figure out how to limit this addAction to the unit itself and only itself. This is what I have in the unit's init:

this addAction 
[ 
 "<t color='#008000'>Normal Instructor Loadout</t>", 
 "InstructorLoadouts\Instructor.sqf", 
 6, 
 0
];```
I've tried setting the radius to 0 and 1 but it has no effect and just defaults back to 50 meters. Any help?
fair drum
#

try using the initPlayerLocal and onPlayerRespawn files. Give the unit a variable in the editor.

if (player == unit) && (!isNil "unit") then { insert your addaction here };
tough abyss
#

Can anyone help me with my "While" loop? I'm trying to stop it but it doesn't stop even though the variable changes to false.


 // This will give _inTrigger a value of true since script is ran while player is within trigger area

private _inTrigger = [AreaTrigger, player] call BIS_fnc_inTrigger;

while {_inTrigger} do {

     // Checks to see if variable needs to be set to false if player left trigger area in hopes to stop the loop
private _inTrigger = [AreaTrigger, player] call BIS_fnc_inTrigger;

     // Debug to tell me variable status in-game (true or false)
hint format["_inTrigger set to: %1",_inTrigger];

     // !! --> Right here is the problem: If the variable is now set to false, the While loop will still keep looping.
     // !! --> Confirming in-game that the variable is now false and keeps looping telling me it's false

Sleep 5;

};

fair drum
#

Have you tried removing the second private?

tough abyss
#

Will try right now

dark ivy
#

@fair drum What if I have multiple units (specifically 7)?

#

Do I just use an array?

#

Like, sqf if (player == [unit1,unit2,...])...

fair drum
#

You might have to do some FindIf stuff

tough abyss
#

Have you tried removing the second private?
@fair drum Wow. I'm completely stupid. It worked! Thanks a lot!

fair drum
#

be careful of private usage

dark ivy
#

Sorry if I haven't put it out there yet but I'm a beginner to SQF so it'll take me some head scratching

fair drum
#

FindIf will go through the array and look for something that satisfies the code, it will then return the index of that array that satisfied. If nothing returns, then it will result in -1. So if you wanted it to be true for any of them, and not a specific index you would want to get your result != -1

dark ivy
#

And since I don't want it to be true for all units, the result should be unit1, unit2, etc...

fair drum
#

for starters, I would just name all 7 of them and write it out for each of them, its good practice, then when it all works, then optimize it

dark ivy
#

Hmm, that's quick & dirty, but hey it should work ๐Ÿ˜‚

fair drum
#
if (([unit1,unit2,unit3,...] findIf {player == _x}) != -1) then {};

If any of the units = the player, find If will return the index. So if unit1 was a player it would result in 0 and if unit 2 was a player it would result in 1 and unit3 2 etc etc. So if you want the statement to be true for any of the units in the array, you would want != -1 so that any indexes 0 to inf works.

copper raven
#

player in [...] or if you want index, [...] find player, no need for predicate

dark ivy
#

Hypo, just throws an error saying my second unit is an undefined variable. Lemme try removing all units except for one, see if it works

fair drum
#

do sharps way, its simple

dark ivy
#
if player in [instructor1,instructor2,instructor3,instructor4,instructor5,instructor6,instructor7] findIf {player == _x}) != -1) then {
// Insert addAction here
fair drum
#

you'll probably run into the same issue. if a player is currently not active in that unit, it technically doesn't exist. so you'll need to add a

(!isNil "unit2")
#

etc. it can get complicated for multiplayer scripting

copper raven
#

player in [instructor1,instructor2,instructor3,instructor4,instructor5,instructor6,instructor7] findIf {player == _x}) != -1) what is this? missing (, and then <BOOL> findIf <CODE> doesnt exist, choose one, either use findIf, or in

dark ivy
#

what is this?
๐Ÿ˜‚ I'm sorry you have to look through that!
Sorry if I haven't put it out there yet but I'm a beginner to SQF so it'll take me some head scratching

hallow mortar
#

only use if (player in [array]) then { ...

#

Trying to mash together the if in and findif methods like that is not what you want and will not work. Also, regardless of being sqf, brackets must always be a matched open/close pair. Don't leave em hanging.

dark ivy
#
if (player in [instructor1,instructor2,instructor3,instructor4,instructor5,instructor6,instructor7]) then {
//Insert addAction here```
throws me an undefined variable on instructor2
#

hmm let me check if in

hallow mortar
#

That means instructor2 doesn't exist

#

No don't check if in that was just me referring to the method you are now using

dark ivy
#

It does, I'm looking at the unit in the editor rn

hallow mortar
#

And is the variable name exactly and specifically instructor2?

dark ivy
#

yep!

#

instructor2 copy paste from editor

fair drum
#

like I said, if you go into game and that unit is not a player OR a AI, it technically doesn't exist as a playable unit

#

you'll have to add something to skip the code if they don't exist

dark ivy
#

Alright let me try with AI

#

So, it didn't throw any errors, but it didn't show any of the addActions either

fair drum
#

paste the whole code you have so far

dark ivy
#

DMs?

hallow mortar
fair drum
#

you can just link a pastebin or something

dark ivy
#

Hold on a second

fair drum
#

you got an extra squiggle on line 2

dark ivy
#

I was just about to say that!

#

Sneaky bastard...

hallow mortar
#

Where is this code placed?

#

i.e. what script file or editor field

fair drum
#

also, this for multiplayer or singleplayer?

dark ivy
#

Works!

fair drum
#

but now take AI out and it won't. so are you doing multiplayer or singleplayer and do you want AI

exotic flax
#

btw... assuming you run that code in the init field, make sure the if statement also uses this instead of player.
Otherwise it will be added on all units when one player is in that list (since the init field is executed by every client)

hallow mortar
#

If it wuz me I'd run it in initPlayerLocal.sqf. still need to resolve the non-existent units problem but at least locality would be easier

fair drum
#

i'm not sure how you would go about doing an isNil through an array actually

hallow mortar
#

Probably run through with a forEach and add the ones that do exist to a new array

#

Or something. 2am brain no work

fair drum
#

lets say you had a forEach into an exitWith {}. Wouldn't the forEach cancel the code if any of the array was nil instead of just 1 element?

exotic flax
#

for initPlayerLocal.sqf it's simple:

params ["_player", "_didJIP"];
waitUntil {!isNull _player};

private _namesArray = ["unit1", "unit2", "etc"];

if (_player in _namesArray ) then {
   _player addAction [...];
};
#

and since it only runs when actual people join the mission you won't have issues with AI or non-existing players

fair drum
#

lets say you are the first player and no one else joins. wouldn't you still throw an undefined in line 6 because unit2 isn't defined yet due to it not spawning yet?

#

or is there something with using a string instead of an object in line 4

exotic flax
#

doesn't matter, it will check if player is in the array, not the other way around

hallow mortar
#

doesn't matter, it will check if player is in the array, not the other way around
Have doubts about this reasoning since the exact same check (using non-string array elements) was previously causing undefined variable errors

#

Strings would certainly prevent the errors since, you know, they aren't variables that can be undefined - as long as whatever you're comparing them to is a data type that can be compared with strings

exotic flax
#

if it would return errors, you can always use

if ((vehicleVarName player) in _namesArray) then {

to make it String vs String

unborn drum
still forum
#

@unborn drum confused? there is a example you can literally copy-paste 1-to-1, I don'T understand the problem.

astral dawn
#

@astral dawn
http://sqf.ovh/sqf math/2018/05/05/generate-a-random-position.html
can probably pretty easily turn this into 3D.
@still forum
Yes second variant with square root should be correct I think?
Another idea - generate 3 random numbers x,y,z until position x,y,z is within sphere, then normalize it? I think it should give uniform direction too?

vague geode
#

Is there any way I can execute a script whenever someone places a marker in the map (not when lines are drawn but only when an actual marker is placed) and pass the marker that was just placed as an argument to said script?

still forum
#

yeah

#

in the marker creation window (Don't know if its in vanilla too? I'd assume so?) just add a eventhandler to the "OK" button

vague geode
#

How do I find that window? (How exactly can I add an eventhandler to it?)

still forum
#

its somewhere in config I'd assume, can't guide you to it besides telling you to search for it

vague geode
#

Ok, could you tell me by any chance how those windows are generally named in the configs (in case there's some sort of naming convention)?

hollow thistle
#

or if you're using CBA

still forum
#

Rsc or Display or Ctrl

#

cba checks markers every frame? oof

hollow thistle
#

oof
maybe it's not that heavy, otherwise you would notice it on your profiler already ๐Ÿ˜‰

still forum
#

won't notice in profiler if no marker EH's were added, it only starts the PFH on first EH being added

hollow thistle
#

yeah, just looking at the code.

#

allMapMarkers every frame, should not be that heavy.

#

I guess it just references some internal array and gives copy of it?

still forum
#

dunno how workz ๐Ÿ™ƒ

ebon citrus
#

It just bรถrks away

vague geode
#

@Dedmen Thanks.

dark ivy
#

Hey @fair drum and @hallow mortar, sorry but it was 4 AM my time and I had to sleep. Hypo, yes this is for multiplayer, no I don't want AI. The code is in initPlayerLocal.sqf

hallow mortar
#

If it's in initPlayerLocal.sqf then I'm interested in what this ended up referring to

dark ivy
#

An error, I'll need to refer this to the unit variable names

#

Would [instructor1,instructor2,...] = this select 1; work?

still forum
#

no

hallow mortar
#

No. the operator = means you are trying to set the variable before the operator to the output of what comes after the operator.

dark ivy
#

Yeah (minus the squiggle on line 2)

hallow mortar
#

i.e. _yourVar = 2 sets the variable _yourVar to 2

still forum
#

this will be a undefined variable

dark ivy
#

Yeah, I need to tell initPlayerLocal what this is

still forum
#

or just.. not use this and instead use what you intended to use

dark ivy
#

So instead of this, [instructor1,instructor2,...] addAction...?

#

I don't think an array would work there

hallow mortar
#

No, you can't do that. addAction only works on one thing at a time

dark ivy
#

Oh, so instructor1 addAction then instructor2 addAction and so on and so forth right?

still forum
#

wat

hallow mortar
#

yes, BUT you will also need to account for the possibility of those units not existing.

still forum
#

Should all instructors have all the actions?

hallow mortar
#

The actions appear to be different for each instructor unit.

dark ivy
#

Yeah I want the instructors to have the actions BUT I don't want other units to have said action

still forum
#

Then just add the actions to the instructors

hallow mortar
#

Wait wait wait, let me clarify something

dark ivy
#

Init field? Tried it, other units can still walk to the instructor and get the action

still forum
#

But the "how" depends on your answer to my question

#

instructors can use the action on themselves?

dark ivy
#

Basically what I'm trying to do is have a "personal action menu" that only the instructors can access

still forum
#

Ah

#

why overcomplicate it then?

#

you check if player is a instructor

#

you want all instructors to have the action on themselves

#

player is a instructor

#

thus.. add the action to player.

#

player instead of this. Done.

hallow mortar
#

It looks like each instructor has a different action they need to receive

dark ivy
#

No no, all instructors have the same actions

hallow mortar
#

Then why do they all have different scripts?

#

Oh, no, I get it

#

never mind

dark ivy
#

๐Ÿ˜›

hallow mortar
#

Yes, but you still need to work out the undefined variable problem right at the start

dark ivy
#

Okay, so if no one is in the slot, it will still give the action to the other slots right?

#

Like, if instructor1, 2, 3 are occupied, but 4 isn't, 1 2 and 3 will still get the actions?

hallow mortar
#

Yes but that's not the problem

still forum
#

it may just error out, because you try to access a undefined variable (if instructor7 didn't spawn yet, the variable will be undefined)

hallow mortar
#

The problem is that your array to check against at the start, may consist of units that do not exist - hence the undefined variable error

#

Change your very first line to this:

if ((vehicleVarName player) in ["instructor1","instructor2","instructor3","instructor4","instructor5","instructor6","instructor7"]) then {```
dark ivy
#

Wait, I can use strings instead?

#

That would be easier

hallow mortar
#

That is what the change I just posted does

#

but only if you do it like that - player doesn't return a string so you can't compare it directly with a string (using this method)

still forum
#

might aswell check if vehicleVarName contains "instructor" ๐Ÿ˜„

#

easier than above, and just as reliable (or unreliable)

dark ivy
#

But why "vehicle"? Wouldn't that be for a car, helicopter, or stuff like that?

hallow mortar
#

Dedmen's proposal would be

if ("instructor" in (vehicleVarName player))```
still forum
#

a unit is also a vehicle

#

same as a backpack or a ammobox, all vehicles

dark ivy
#

so everything is a vehicle... that sounds redundant but what do I know...

hallow mortar
#

When you play as a unit you are actually an invisible brain controlling a human-shaped vehicle.

dark ivy
#

Well now that you put it that way, that makes sense...

hallow mortar
#

you never wondered why the command to delete anything is deleteVehicle?

dark ivy
#

Both if ("instructor" in (vehicleVarName player)) and if ((vehicleVarName player) in ["instructor1","instructor2","instructor3","instructor4","instructor5","instructor6","instructor7"]) then { have worked! Thank you guys, appreciate it!

lost copper
#

You can set object variable to every instructor and check it, when you add action:

// in instructor init field
this setVariable ["isInstuctor", true];

And when you add action:

if (player getVariable ["isInstuctor", false]) then {
   //add action to player here
};
still forum
#

more code, more effort, more inefficient

exotic flax
#

why not use player setUnitTrait ['instructor', true, true] ๐Ÿ˜ฎ

winter rose
#
[player, ["instructor", true]] remoteExec ["setVariable"] // !
still forum
#

oh wow. That remoteExec would be a great code obfuscation technique

winter rose
#

like sqf [player, false] remoteExec ["allowDamage", player]?

unique sundial
#

probably wonโ€™t event get send to the server

spark turret
#

If you can use the player var, then your are already local to the players machine. Why would you remoteexec on the same machine you are local to?

still forum
#

remoteExec has special handling for local yeah

unborn drum
#

@still forum I donโ€™t know where to copy paste it. Iโ€™ve tried multiple places with no avail.

spark turret
#

@unborn drum still trying to call a function?

still forum
#

depends on what you intend to do with that function. init.sqf maybe

spark turret
#

Are you sure you are giving the function the correct oarameters, the function exists and your code is executed?

#

@unborn drum

spark turret
#

im gonna tag him again. how dare he ask and then go offline

#

btw, are knowsAbout values still abstract and are not able to extract precise information from it?

#

or does someone have new insight?

#

like, 3.75 = knows side and location but not gun and 1.33333 = knows side but not location

quartz pebble
ebon citrus
#

Too little information

#

Could be anything with just the screenshot

#

Starting from a faulty gpu, corrupted game etc.

#

Need to know what you have done to know

#

And if it occurs on other systems too

wary dome
#

can some explain why this script wont work?
i want player setcaptive false; when rating increases >0

ebon citrus
#

Codeblocks

wary dome
#

srry

still forum
#

while {true} do
{ rating player;};
that does nothing but looping endlessly doing basically nothing

ebon citrus
#

Reassign _score inside the loop

wary dome
#

i know

still forum
#

so fog started looking so?
I think thats "normal"

wary dome
#

thought it needed constant re-checking.

still forum
#

but you're not really checking anything

wary dome
#

didnt need it before but nothing wanted to work now ๐Ÿ˜›

ebon citrus
#

It does nothing because the loop doesnt check anything

still forum
#

you are grabbing the rating, and throwing it away again without doing anything with it

ebon citrus
#

Well, it doesnt get any new values

still forum
#

I guess you want to move your "if" inside the loop

ebon citrus
#

This too

#

I didnt manage to read the whole script before you removed it

wary dome
#

delete rating player?

ebon citrus
#

Nah

wary dome
#

no

#

wrong

ebon citrus
#

CODEBLOCKSA

still forum
#

Currently you are running a endless loop, and after the endless loop is over you check the score.
But a endless loop is never over

wary dome
#

im trying sorry

still forum
#

what Nica means with codeblocks is see pinned messages for how-to example

ebon citrus
#

You are getting a value, then checking the value in an endless loop

#

Youre never updating the value

still forum
#

not even checking anything, just getting the value

ebon citrus
#

Didnt have time to read

wary dome
#
while {true} do 
{ rating player;};
if (_score > 199) then {
player setcaptive false;
};
ebon citrus
#

Oh yeah

#

I see it now

wary dome
#

freaking hidden apostrophe

still forum
#

so.
You grab the score and store the store.
Then you endlessly loop, grabbing the score and throwing it away without doing it anything.
and after the endless loop is over which it never will be, you check the previously stored code

ebon citrus
#

Delete "rating player"

#

And move all else inside the script

still forum
#

What you probably want is to endlessly loop, grabbing and checking the scope every time. inside the loop

ebon citrus
#

Also true-while loops are bad

#

Make score some smart public variable and set it inside the loop to rating player

#

Then set the if as a reverse condition for the loop

#

And add the if statements script after the while

#

Not "clean", but ok

still forum
#

Well we don't know what he needs, and what you said can be done easier

ebon citrus
#

Indeed

#

I would not use a while loop

#

But an EH

#

There is a player score eh or similar

still forum
#

is the intention "wait till score goes above 199 and remove the captive" or "constantly check the score and repeatedly remove the captive" ?

wary dome
#

remove the captive

still forum
#

both my things say that

wary dome
#

just become enemy

still forum
#

which one

wary dome
#

the first

ebon citrus
#

So if the player kills someone of the enemy, disable captive

#

Use EH

wary dome
#

yes!

#

ok

still forum
#

so the first.

waitUntil {rating player > 199};
player setCaptive false;
#

wait until, the players rating is above 199, and then remove captive

wary dome
#

aha

ebon citrus
#

sleep 1 in the waituntil

#

Atleast

#

Or use an EH

#

Loops are bad

wary dome
#

๐Ÿ™‚

still forum
#

Telling someone who doesn't know basic scripting to use a EH, before understanding basic scripting is not the best idea ๐Ÿ˜„

ebon citrus
still forum
#

start small, grow bigger over time

ebon citrus
#

They can always ask

#

But similarly

wary dome
#

ive used EH. not difficult, but too much thinking :S

ebon citrus
#

Telling someone who doesnt understand scripting to use loops isnt smart

#

They'll clog up the scheduler and reduce performance

still forum
#

loops are easy

wary dome
#

yeah bruh

ebon citrus
#

Nro 1 reason for the "arma 3 runs bad" myth

still forum
#

and when writing like, a dozen lines of code the minimal performance impact doesn't matter much

ebon citrus
#

Not good

still forum
#

clogged up scheduler won't reduce performance by that much, its limited to 3ms anyway

ebon citrus
#

Teach good practise from the start

wary dome
#

also true

austere granite
#

start small, grow bigger over time
What are you talking about here Furmen?

ebon citrus
#

Small streams make a big river

#

You start with one bad loop and end with 50000

austere granite
#

But that doesn't just magically happen suddenly

ebon citrus
#

It kind of does

#

Football knees are caused by teachig bad practise to children

austere granite
#

There's also mvp that you sometimes use

ebon citrus
#

Teaching a basic thing well can make a big difference in the end

austere granite
#

Which for a beginner often works ok, then after you can refine

ebon citrus
#

You have to teach also what are the correct ways

still forum
#

When you start learning how to ride a bike, you don't learn how to crouch down when going 40+ downhill to be as efficient as possible against the wind and keep your maximum momentum.
You learn not to fall over.

ebon citrus
#

Bad example

still forum
#

There is nothing "incorrect" about not having a sleep in your waitUntil, its just not most efficient

#

and for beginners it literally just doesn't matter

#

makes no difference to the function of the script

ebon citrus
#

When you learn to ride a bike, you learn to break with the bike breaks instead of the soles of your shoes

hallow mortar
#

sometimes you just have to go "here, this will solve the problem you are currently having" and not worry about teaching a full scripting class on the fly

ebon citrus
#

It matters ALOT

austere granite
#

I love my event driven stuff, but it's not like if a beginner puts a singe while True in suddenly you get 0 fps

#

I think this is the moment where we agree to disagree

still forum
#

And a dozen waitUntil's running won't do anything.
Now if you write lots of scripts, or mods, and end up with hundreds of waitUntils, it does matter ALOT. But in this case that's obviously not the case and thus not required.

ebon citrus
#

Teaching bad practise and not explaining the good one will lead to the person repeating bad practise over and over and over because they dont know better

austere granite
#

I'd also add that using pfh style stuff is not an instant fix to any performance problems a beginner might create

still forum
#

There is no bad practise here

wary dome
#

if I may offer my own take, i kind of learn by doing the quick and dirty method

still forum
#

Eventhandlers and PFH's are great for the professionals, but a beginner can F up big time with that, while they can't really break anything with a simple while true loop in scheduled

ebon citrus
#

There is no bad practise here
Can i quote you on this in the future?

hallow mortar
#

some of us aren't professional coders in our day jobs and just want to overcome the immediate challenge so the mission works how we want it

ebon citrus
#

Doesnt mean you cant guide correctly

#

I dont mean Dedmens example is bad, it's adequate

still forum
#

The important thing about such stuff is to know when to apply them and when not to.

ebon citrus
#

But it should be noted that a more appropriate method exists

wary dome
#

I actually am a professional coder ๐Ÿ˜†

#

thats a lie. bad joke

austere granite
#

if all you're doing is literally a single while... and you're not running other massive modsets that might a ton of whiles themselves

#

... it's not really more appropriate though

ebon citrus
#

Do you know that?

austere granite
#

Do you know that?

ebon citrus
#

And yes, it IS more apropriate for the task

#

Dont reinvent the wheel

still forum
#

If someone comes here, obviously working on some kind of framework or a mod, I'll darn well put some fire under them for not taking performance seriously.
But a guy writing 5 lines of code for his quick mission that he's making where performance of this literally won't make any noticable difference... Don't waste time for that, let him learn and don't throw tons of stuff at him that literally doesn't matter right in that moment.

ebon citrus
#

Especially when it costs cpu time

still forum
#

and you're not running other massive modsets that might a ton of whiles themselves
if you do, your own while won't matter anyway. The mods will make out a bigger chunk

ebon citrus
#

The point still stands

#

A waitUntil is not wrong, but it should be noted that for continued use, more appropriate measures exist

austere granite
#

Noted

still forum
#

If you want to teach beginners hundreds of things that they currently don't even care about, instead of simply telling them what they need and want to know then go ahead. Just doesn't make much sense.

ebon citrus
#

Then youre a bad teacher, but a good signboard

#

Some point the way, some guide the way

#

๐Ÿคทโ€โ™‚๏ธ

wary dome
#
    params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}]; ```  
Where do I put "player addrating 50;" ?
austere granite
#

Are you saying you're the former there? ๐Ÿ˜„

#

Because that's what it seems like

still forum
#

My teachers first taught me how to add and subtract, and told me negative numbers weren't will be gotten to later and are currently not possible.
When they made sure everyone understood that, they moved on to explain negative numbers.

ebon citrus
#

@austere granite where did i say that?

austere granite
#

Just reading between the lines while 'avin a giggle is all

#

Let me stop derailing

still forum
#

@wary dome depends on what you want to do.
But I don't see how Fired handler is applicable here, or do you want to punish players simply for shooting? not for hurting anyone?
what's "this" ?

ebon citrus
#

@still forum your teacher was with you for the whole of the way.

If your teacer told you that negative numbers dont exist and sent you on your way, you would have a lot of problems. Stop giving irrelevant examples that dont apply

still forum
#

I give up. no sense in trying to argue with you, we know that already

ebon citrus
#

But, i have taken this too far. You guys have a fine night

still forum
#

go ahead and hold his hand and teach him everything, I'm out.

wary dome
#

"this" was player, but I just put it in to units init field.
I want setcaptive false to happen once fired accumulates

ebon citrus
#

He can feel free to DM me and i will help

wary dome
#

think of it like a police holdup

ebon citrus
#

Im not looking into talking here where propper pedagogical methods are frowned upon

wary dome
#

after a few warning shots - suspect shoots at us

#

@ebon citrus maybe its just an issue of preference? some of us prefer to be told all of it off the bat, others just what we need atm. I dont know.

#

wow.

#

oh, it goes between the curlies

#
player addrating 50;}]; ````
Thats what i needed
wary dome
#

im realized that im just using score to count events until player setcaptive becomes false

#

maybe theres a better way to change setcaptive by doing other things, obviously i want the enemy to not shoot at first, but after whatever (havent thought of what yet) shooting breaks out

#

think of it as a police "put up your hands!" gone wrong.

still forum
#

how many shots do you want?

#

is it multiplayer or singleplayer?

wary dome
#

sp

#

maybe player distance to enemy?

still forum
#
adam_playerShotCount = 0;
player addEventHandler ["Fired", {
adam_playerShotCount = adam_playerShotCount + 1;
if (adam_playerShotCount > 12) then {player setCaptive false};
player removeEventHandler ["Fired", _thisEventHandler]; 
}]; 

waits till over 12 shots, then removes captive, and removes the eventhandler as you don't need it anymore

wary dome
#

once too close boom

still forum
#

maybe player distance to enemy?
thats relatively hard

wary dome
#

oh

#

i imagine

still forum
#

You'd need to find nearby units, and then filter if there are enemies

wary dome
#

yeah. i just understood what playershotcount is. much better than score lol

#

while i have your attention, would that code block be repeatable like if there where multiple "confrontations" per missons?
you could just use a sleep 30 for simplicities sake

still forum
#

you can only remove captivity once

wary dome
#

yes to have it reset to true again

still forum
#

if you readd it some way, just paste that exact code again, it will add the eventhandler again, and start counting shots from 0 again

wary dome
#

i see

unreal scroll
#

Sometimes there is a need to remove several elements from a list at once, not caring about changing elements indexes.
I've wrote a simple function to do it.
Maybe someone could find it useful.

/*
Function for deleting list entries by indexes or by passed condition.
Input params:
    _list - the target list.
    _params - can be a list on indexes (int) or a condition with _x magic variable (like {_x > 6}).
Result: modified target list.

Examples:
    [[3,6,5,2,0,1],[2,4]] call fnc_RemoveFromArray --> [3,6,2,1] (removes third and fifth elements)
    [[3,6,5,2,0,1],{_x > 2}] call fnc_RemoveFromArray --> [2,0,1] (removes all elements which are > 2)
*/

fnc_RemoveFromArray = {

    params ["_list","_params"];

    if !(_list isEqualType [] && ((_params isEqualType [] && {(_params findif {!(_x isEqualType 0) or (_x isEqualType 0 && {(_x < 0) or (_x % 1 != 0)})}) == -1}) or _params isEqualType {})) throw "Invalid arguments";

    private _sorted = [];
    if (_params isEqualType []) then {
        _sorted = _params;
        _sorted sort false;
    } else {
        {
            if (call _params) then {_sorted pushbackUnique _foreachindex};
        } foreach _list;
        _sorted sort false;
    };
    {
        _list deleteAt _x;
    } foreach _sorted;
};

For example, you have a list of vehicles in convoy, and I want to check it and remove dead/nonexistent ones from the list.
[_vehiclesList,{isNull _x or !(alive _x)}] call fnc_RemoveFromArray
I've found it extremely useful for my campaign.

wary dome
#

afk. btw thank you. All. ๐Ÿ™‚ what a way to join a channel. i
and thank you all again for the help

still forum
#

@unreal scroll

(removes third and fourth elements)
you mean third and fifth

#

; true} count
that would be slower than a simple forEach

#

[_indexes,[],{_x},"DESCEND"] call BIS_fnc_SortBy;
ALOT slower than a simple sort

#
fnc_RemoveFromArray = {

    params [["_list", [], [[]]], ["_params", [], [[], {}]] ];

    if (_params isEqualType []) then {
        if (!(_params isEqualTypeAll 0) || {selectMin _params < 0} || {selectMax _params >= count _params}) throw "Invalid arguments";
        {_list deleteAt _x} forEach (_params sort false);
    } else {
        private _indexes = [];
        {
            if (call _params) then {_indexes pushBack _forEachIndex};
        } forEach _list;
        
        {_list deleteAt _x} forEach (_indexes sort false);
    };
};

If you could just return the altered array, you could just use apply for the code case and return result, which would probably be faster

unreal scroll
#

Thanks

still forum
#

If you sort anyway with BIS_fnc_SortBy, in the code case you could just sort by code. Then you have all the false at start, and true at end, and then you can just deleteRange/resize all the true's away
Ah seems like sortBy requires a number return, not a boolean thonk turning the bool into 0/1 will probably make it quite a bit slower..
though parseNumber is quite fast.. maybe

#

or (_x % _x != 0)
that can never be true.
_x % _x is always 0.

#

I assume you want to check if the array elements are in bounds.
You can use selectMin/selectMax, and check that min >= 0 and max < count

#

and if you want to check that _params only contains numbers, you can just use isEqualTypeAll

unreal scroll
#

"that can never be true"
Yes, thanks, it is my typo - it should be _x % 1 - to check if it is int, to select the element with it.

still forum
#

don't need to be rounded to full number to select

#

select 0.1 also works as select 0

#

but 0.1 in the array will probably be a typo of the intended 0,1

unreal scroll
#

Ah, didn't know, thanks. But from the user's point - it should be the typo in passed params too (or just an error in a script for calculating indexes), so it is better to check it, I believe.

rugged spindle
#

Hey everyone, maybe someone can help me with this as I don't understand what's going on. Probably some stupid novice mistake. If I run this in the debug console, it works:

_objectiveMarker = "marker_target_0";
_objectiveMarker setMarkerType "mil_objective";
_objectiveMarker setMarkerColor "ColorBlack";

Where marker_target_0 is an invisible marker on the map. However, when running it on a script inside an if statement, I get an "undefined variable in expression" error when it tries to change the marker type:

if (_missionPosition isEqualTo "marker_insertion_0") then {
  _objectiveMarker = "marker_target_0";
};
_objectiveMarker setMarkerType "mil_objective";
_objectiveMarker setMarkerColor "ColorBlack";

I've checked if the if statement is working, and it is. I could change the characters position by using setPos inside it.

still forum
#

yep. variable is undefined

#

you define _objectiveMarker inside the if scope, then it goes out of scope and is deleted, and then you try to reference it after its gone

#

fix

_objectiveMarker = "some default value or whatever?";
if (_missionPosition isEqualTo "marker_insertion_0") then {
  _objectiveMarker = "marker_target_0";
};
_objectiveMarker setMarkerType "mil_objective";
_objectiveMarker setMarkerColor "ColorBlack";

rugged spindle
#

OK, got it, it makes sense. Thank you very much.

cosmic lichen
#

What's the best way to find the starting indices of multiple strings within a string. For example I wanna retrieve all indices where _display starts in this string:

// The display
private _display = findDisplay 313;

// Validate display
if (isNull _display) exitWith
{
    "Unable to get 3DEN display" call BIS_fnc_error;
};

// Input handling
_display displayAddEventHandler ["KeyDown", {_this call BIS_fnc_3den_onKeyDown;}];
_display displayAddEventHandler ["KeyUp", {_this call BIS_fnc_3den_onKeyUp;}];
mortal wagon
#

hello guys i was wondering if there was a script that made it possible for players to dont get shot when not having a wheapon on them? since i was planing on making a mission with players destroying and enemy force to the point where the military could move in.

#

pls ping me if you guys would like to help

unreal scroll
#

@mortal wagon Just spawn them with captive=true flag, and disable it when needed.

robust hollow
#

@cosmic lichen I'd probably do it in a similar way to how CBA_fnc_replace works, and instead of replacing substrings it returns an array of indices.

cosmic lichen
#

Thanks for the hint, I m gonna check that out

copper raven
#
private _fnc_findStringsInString = { 
    params ["_string", "_search", "_index"];
    private _searchLength = count _search;
    private _return = [];
    private _i = 0;
    while {_index = _string find _search; _index != -1} do {
        _string = _string select [_index + _searchLength];
        _i = _i + _index + _searchLength;
        _return pushBack _i - _searchLength;
    };
    _return
};

something like that probably, reference: https://github.com/CBATeam/CBA_A3/blob/master/addons/strings/fnc_replace.sqf mentioned by Connor

bold kiln
#

Is there an easy way to disable a Gunner turret without kicking someone inside it?

winter rose
#

I believe there is a lockTurret command of some sort

#

@bold kiln ^

hexed lagoon
#

is there a script that when an ai squad is killed(led by a player squad leader) they can respawn on a select few markers? also would there be a way to remove one of the possible spawn markers once a certain object is destroyed for example !alive commander_e;

#

sorry im very new and ive only made a few barebone missions so far

trail grove
#

is it possible to return ammocount for mags in Cargo inventory ?

trail grove
#

magazinesAmmoCargo

tough abyss
#

Anyone know how to fix a player respawning with a blank face and no identity? I set each different player with a unique identity via class CfgIdentities in the Description.ext file. They're set correctly at the start of the mission and have this set on each players init:

p1: this setIdentity "p1";
p2: this setIdentity "p2";
p3" this setIdentity "p3";
p4: this setIdentity "p4";

I've tried adding the following in onPlayerRespawn.sqf but it's doesn't work. It doesn't give me any errors either.

_unit = _this select 0;
player setIdentity "_unit";

PS: Each players variable name is p1, p2, p3, p4,etc..

And each identity set is named according to each player: p1, p2, p3, p4,etc..

#

Also, _unit returns the correct player's variable name

#

So it SHOULD be translating it to: player setIdentity "p1"; if the player is "p1"

winter rose
#
// awful solution:
_unit setIdentity str _unit;```
tough abyss
#

Thanks again for the help for the millionth time, Lou!

#

Trying now

winter rose
#

So it SHOULD
nope, as _unit is an object reference
if you setIdentity "_unit", you set the identity to the string "_unit", not "the unit but as a string"

tough abyss
#

Just learned something new, thanks!!

unreal scroll
#

@still forum {_list deleteAt _x} forEach (_indexes sort false);
Interesting. It doesn't work for me at all.
Seems like we need to sort it before starting foreach cycle.

{} foreach _indexes;```
Ah, yeah, sort returns bool.
still forum
#

I thought _indexes returns sorted, yeah it doesn't derp.
Yeah needs to be done in a seperate statement before then

jaunty zephyr
winter rose
#

know, no, but I would say local

#

aL eL I think

#

of course, if you can test and come back with resultsโ€ฆ ๐Ÿ˜

#

or aG eL

#

anyway, it should be a combination of a[G|L] / e[G|L] ๐Ÿ˜„

jaunty zephyr
#

just tested on my dedi. it's eL

winter rose
#

aG?

jaunty zephyr
#

arguments are boolean, last time i checked those dont have locality :P

#

(what am i missing?)

winter rose
#

hah, I half-read it (thought there was a group param at some point)

#

(my bad, am @ workz)

#

Thanks for testing! ๐Ÿ‘

cosmic lichen
#

I guess it's local too

jaunty zephyr
#

loooks like it ๐Ÿค”

#

atm i dont have any more players there so if theres any glitches i wont catch them, but as far as playing with getters/setters on dedi/local goes, it looks everything is eL here

unique sundial
#

Ah, yeah, sort returns bool.
@unreal scroll
No it doesnโ€™t

still forum
#

would maybe be convenient if sort returned reference to the sorted array. But many people will probably just get confused and assume it returns a copy

jaunty zephyr
#

@winter rose setGroupIconParams does have a group parameter, and it's aL eL

winter rose
#

thanks
I would have expected aG eL

jaunty zephyr
#

oh wait. waaait

#

i might have been stupid

#

@winter rose yes sry, it's aG ๐Ÿ˜ฌ

winter rose
#

Thanks ^^

oblique lagoon
#

Have done a plenty times of search, but can not fine; can we use blacklist/whitelist in virtual garage??
Even ["Open",false] call BIS_fnc_garage; comes up with all vehicles.
Tried code by Larrow at https://forums.bohemia.net/forums/topic/181683-bis_fnc_garage/ But no luck.
bis_fnc_garage_data is overrided after garage opened.

#
    //CARS
    [
        //model
        "\a3\soft_f\offroad_01\offroad_01_unarmed_f",
        //config paths of classes that use above model
        [
            config.bin/CfgVehicles/C_Offroad_01_F,
            config.bin/CfgVehicles/B_G_Offroad_01_F
        ],
        "\a3\soft_f\mrap_02\mrap_02_gmg_f",
        [
            config.bin/CfgVehicles/O_MRAP_02_gmg_F
        ]
    ],
    [],        //ARMOR
    [],        //HELIS
    [],        //PLANES
    [],        //NAVAL
    []        //STATICS
]```
and running this code comes up with error
slate cypress
#

When using playMission command and regarding the second parameter which is the mission, can I specify a file path such as:

#

J:\Arma 3\...

#

To eventually get to the mission? Otherwise where does it start as the base directory?

winter rose
winter rose
#

@vernal dust please use pastebin

hallow mortar
#

In what way does it not work? Does it throw an error?

winter rose
#

also, you started with \class, is this wanted?

#
class CfgRadio
{
    sounds[] = {};
    class RadioMsg1
    {
        name = "";
        sound[] = {"\sounds\Intro.ogg", db-70, 1.0};
        title = "Alright we infil in 3 mikes, get ready and gear up fast.";
    };
};

{
    sounds[] = {};
    class RadioMsg2
    {
        name = "";
        sound[] = {"\sounds\Intro2.ogg", db-70, 1.0};
        title = "The HVT might leave the compound so we need to move quick.";
    };
};

// should be

class CfgRadio
{
    sounds[] = {};
    class RadioMsg1
    {
        name = "";
        sound[] = {"\sounds\Intro.ogg", db-70, 1.0};
        title = "Alright we infil in 3 mikes, get ready and gear up fast.";
    };
    class RadioMsg2
    {
        name = "";
        sound[] = {"\sounds\Intro2.ogg", db-70, 1.0};
        title = "The HVT might leave the compound so we need to move quick.";
    };
};
#

description.ext is not a script; it is a config - you define resources in it

astral dawn
#

Another idea for in operator:
string in object
Given that objects are hash maps, it's a good alternative to !isNil {object getVariable string}

hollow thistle
#

neat idea, should be usable for any valid namespace tho.

astral dawn
#

Yeas agree meowthis

severe vapor
#

I am hoping someone might have a suggestion for me. I am trying to create a script to check if a vehicle has any players in it. the helicopters will be flown by AI and the ones that have no players in them should be shot down. I have a script that works for shooting them down and I have the AI doing what they are supposed to but I don't know how to see if any player might be in the vehicle without checking if each player is in each vehicle.

hollow thistle
#
fnc_hasPlayerCrew = {
    params [
        ["_vehicle", objNull, [objNull]]
    ];

    (crew _vehicle findIf {isPlayer _x}) != -1 // return
};

someVic1 call fnc_hasPlayerCrew;
#

something like this should work

severe vapor
#

awesome thank you! I'll give that a shot here in a bit

astral dawn
#

How do I know if a given object is a terrain object or dynamicly created?

#

..and another one: how do I know that a given object is a tree?

hollow thistle
#

you can check if object is in nearestTerrainObjects

#

I don't remember about any specialized commands that allow for easy detection if object is an terrain object.

astral dawn
#

Wow that's a whole new branch of thinking emoji evolution

hollow thistle
#

that's a big thiiiiiink

astral dawn
#

That's arma face when I do nearestTerrainObjects and it returns six thousands of them and I start iterating them

hollow thistle
#

it's more like

#

๐Ÿคฏ

#

welp it's retarded but I think there's no better way.

#

Unless terrain objects have special netId or smth

exotic flax
#

you should be able to use typeOf, which should return an empty string when it's a terrain object

hollow thistle
#

not always

#

Houses will have classes

#

and a lot of other stuff too.

#

but some bushes or trees or rocks might not have them.

exotic flax
#

but the object itself (which is placed in terrain) doesn't have a config entry, even when they exist in the configs

hollow thistle
#

I think simple object will also return a ""

#

but it's not an terrain object.

astral dawn
#

but the object itself (which is placed in terrain) doesn't have a config entry, even when they exist in the configs
houses do

exotic flax
#

hmm... so the only way to be sure is with:

_object = "<some_object_you_want_to_check>";
_search = nearestTerrainObjects [getPos _object, [], 1];
if (_object in _search) then {
   return true;
};

something like this, the if in then will most likely not work

astral dawn
#

yeah I guess so... thanks

hollow thistle
#

typeOf <obj> == "" should work for most of the vegetation and rocks I think.

#

but if you want to be 100% sure...

#

what's the use case?

astral dawn
#

replacing the check _object in _terrainObjects, while _terrainobjects is a huge array, I am iterating all objects within a large area

winter rose
#

nearestTerrainObjects has a "tree" filterโ€ฆ

tough abyss
#

If I place the following in initServer.sqf, it would show up for every single player, right?

player addMPEventHandler ["MPHit", {

params ["_unit","_causedBy","_damage","_instigator"];

hint "Test: I got hit!";

}];

hallow mortar
#

Yes, in the sense that that hint would appear for everyone whenever anyone got hit

winter rose
#

No

#

@tough abyss initServer runs on the server only, and player is objNull for a dedicated server
@hallow mortar

#

add this to the init.sqf only, should be fine

cosmic lichen
tough abyss
#

add this to the init.sqf only, should be fine
@winter rose Thanks for the clarification!

spark turret
#

Player is a variable that only exists on the local machine of each player. Therefor it can only be used if the code is run on each client. F.e. through init, initPlayerLocal etc.

tough abyss
#

Got it, thanks!

fervent kettle
#

is there a way I can tell an if X then Y option to do nothing?

winter rose
#

if (y) then {}, or better, no code at all

lilac kettle
#

Hey guys, have a problem here. Is there a way to change or cancel Curatorโ€™s selecting? For example, I have some Unit Vasya, which I donโ€™t want to be selectable, but need to be editable by Curator. I know there is curatorselected, which returns an array of selected objects. Maybe I can somehow change it?

distant oyster
#

theres no command to insert an element to a specific index in an array, is there? i found BIS_fnc_arrayInsert though

still forum
#

there is "set" but not insert

#

not sure if fnc_arrayInsert is efficient, aka using the new select ARRAY thing

distant oyster
#

thats what i am a bit concerned about but in the end the script will not be time critical

vague geode
#

@Dedmen I think I found the right display and I think I can work out how to add the event handler but how do I get the marker that has been place after the 'Ok'-button has been clicked?

still forum
#

๐Ÿค”

#

store previous markers (can grab them when the display opens), grab all markers after ok button click, diff

vague geode
#

@Dedmen Isn't that very expensive? Basically what I am trying to do is autometically add a time stamp (in-game time) to the markers description so that if someone places a marker with the description "ZSU-39 Tigris" on the map you always know how old the intel is because the marker description would state the time it was placed (e.g. "ZSU-39 Tigris [0600]").

still forum
#

no

#

well depends on number of markers

#

_newMarker = _newMarkers - _oldMarkers;

fervent kettle
#

if (y) then {}, or better, no code at all
@winter rose simple but effective, thanks

still forum
#

actually pretty ineffective ๐Ÿ˜„

#

writing code that does literally nothing

vague geode
#

@fervent kettle Why would you even what to do that? Or better what do you actually what to do?

peak plover
#

What's the deal with filepatching, do the files have to be in the game directory same as the mod or without the @modname/addons/

#

Using a juncture directly from pdrive to the game directory, would that work?

still forum
#

game directory

#

and then same path as inside the pbo's

#

Using a juncture directly from pdrive to the game directory, would that work?
yeah

#

P:\x
->
SteamApps/common/Arma 3/x

symlink is what I do (somewhat, not actually)

peak plover
#
//v1
arma3/modname/pboname
//v2
arma3/pboname
still forum
#

the pboprefix

peak plover
#

Aah, okay. Perfect!
Thanks

fervent kettle
#

@fervent kettle Why would you even what to do that? Or better what do you actually what to do?
@vague geode that is what I did, dont mind the "//s"

_items = items player;// legt Namen fรผr Parameter fest

if ("ACE_EarPlugs" in _items) then {}// รผberprรผft ob sich Item "ACE_EarPlugs" im Inventar befindet 
else {
player addItem "ACE_EarPlugs";// fรผgt Item "ACE_EarPlugs" dem Inventar hinzu, falls oberes negativ ausfรคllt
};

if ("TFAR_anprc152" in _items) then {}// รผberprรผft ob sich Item "TFAR_anprc152" im Inventar befindet  
else {
player linkItem  "TFAR_anprc152";// fรผgt Item "TFAR_anprc152" dem Inventar hinzu, falls oberes negativ ausfรคllt
};

//รœbersetzt: falls sich "TFAR_anprc152" im Inventar des Spielers befindet, mach nichts, ansonsten fรผge dem Spieler Item "TFAR_anprc152" hinzu.
//            if       ("TFAR_anprc152"           in _items)                 then {}     else {      player linkItem  "TFAR_anprc152";}
still forum
#

So basically you just want an else?

fervent kettle
#

It is working like that, so yea

still forum
#

Why don't you instead of

if it has it, don't do anything else add it
just do a
if it doesn't have it, add it

#

if !("ACE_EarPlugs" in _items) then {player addItem "ACE_EarPlugs";}

#

That TFAR radio thing won't work btw

fervent kettle
#

It does, tested it

still forum
#

the classname will be changed right after you add it

#

no it won't

#

TFAR dev here btw..

fervent kettle
#

Oof, isnt there a way to say like ANPRC-152 is XY

still forum
#

easiest way, just check if player has a handheld radio. Thats what you want to check right?

fervent kettle
#

I want to check for that exact one radio type, the ANPRC-152

still forum
#

oof.. thats a bit more complicated

#

Btw I think items in radio slot, are not returned by items command, so that also won't work

fervent kettle
#

but when I tested it and dropped the radio it gave me a new one in that exact slot

still forum
#

in singleplayer it might, in multiplayer it will constantly spam new radios

#

ah the code for that is so annoying

#
_items = [player] call CBA_fnc_uniqueUnitItems; // If player has lots of items, this is faster and more efficient than simple items player;

if (_items findIf {
      (_x call TFAR_fnc_isRadio || {_x call TFAR_fnc_isPrototypeRadio}) 
      && {
        [_x, "tf_parent", ""] call TFAR_fnc_getWeaponConfigProperty == "TFAR_anprc152"
      }
    } == -1) then {add tfar radio}
#

Think that might work

#

or atleast.. that would be the correct way to do it

#

Due to how TFAR is currently built, you could do

_items = [player] call CBA_fnc_uniqueUnitItems; // If player has lots of items, this is faster and more efficient than simple items player;

if (_items findIf {"TFAR_anprc152" in _x} == -1) then {add tfar radio}

But that might break when TFAR updates

fervent kettle
#

We are using the (BETA!!!) version, wich didnt update in a while

still forum
#

Yes I know

#

but I'm the one pushing the next update soooo..

#

just telling you, you don't have to listen

vague geode
#

@fervent kettle Yeah, that's needlessly complicated.

As Dedmen said just negate the expression with an expression mark (! == not) so instead of
if ("ACE_EarPlugs" in _items) then {} else {player addItem "ACE_EarPlugs";};
(if "ACE_EarPlugs" is in _items do nothing, else add the item "ACE_EarPlugs" to the player)
put in
if !("ACE_EarPlugs" in _items) then {player addItem "ACE_EarPlugs";};
(if "ACE_EarPlugs" is NOT in _items do add the item "ACE_EarPlugs" to the player).

fervent kettle
#

Yea, I am still pretty unskilled when it comes to arma scripting, thats why mine always end up... different lol

vague geode
spark turret
#

I dont remeber why but i use" find" and not "in' as well. Iirc it produced more reliable results back when i first tested the diffrerent methods.
Correct me if im wrong.

#

Keep up that style of commenting. ๐Ÿ‘

winter rose
#

upper/lowercase maybe?

ebon citrus
#

both are case-sensitive

exotic flax
#

find returns the position the needle was found, -1 when not
in returns true when found (false if not)

torpid quartz
#

How would i delete a respawn module point when a trigger activates

the wiki says
[west, 1] call BIS_fnc_removeRespawnPosition;

but i'm not sure what it means by the "1" being the ID and needing to be a number.

I've got the respawn module called "RS1", but yeah i haven't figure out the right way to do it yet.

exotic flax
#

when you use BIS_fnc_addRespawnPosition you get an array back with [target, id], which is the same array needed for BIS_fnc_removeRespawnPosition

torpid quartz
#

so there isn't a way to remove respawns placed in the editor via the module, I'll need to use the AddRespawnPosition?

exotic flax
#

you should be able to get the ID since it's stored in the logic

#
_logic = "Respawn Module Logic";

_respawn = _logic getvariable ["respawn",[]];
_respawn = _respawn param [0,[],[[],""]];
if (typename _respawn == typename []) then {
   if (count _respawn == 2) then {
      _respawn call bis_fnc_removeRespawnPosition;
   };
};
spark turret
#

_logic is the variable name of the module?

exotic flax
#

that should work, but I'm not sure (I just copied that code from BIS_fnc_moduleRespawnPosition)

torpid quartz
#

uh, how would i even use that?

#

and readying through it, it seems to imply that the respawns are just giving an id i assume from 0 then upwards based on where they were placed?

#

if this works for respawn modulus i guess i just need to run the delete function for 0, 1, 2 to get rid of the 3 i want since i placed them first.

#

i'll do a test

spark turret
#
_logic = "Respawn Module Logic";  //probably the variable name of the logic module, set in editor, replace the string text with your var name

_respawn = _logic getvariable ["respawn",[]];  //gets variable of the logic module
_respawn = _respawn param [0,[],[[],""]];  //assigns "names to variables for further use
if (typename _respawn == typename []) then {  //checks if _respawn is an array: error avoidance
   if (count _respawn == 2) then {  //error avoidance again
      _respawn call bis_fnc_removeRespawnPosition;  //delete logic module
   };
};
#

@torpid quartz check it out again, i commented on how i think it works

#

you use it by copy pasting the code and replacing the string in line 1

torpid quartz
#

um, where would i run it though? should i just have something that triggers when the game starts, how am i going to get the info this finds does it print it on the screen?

still forum
#

typename _respawn == typename []
-> _respawn isEqualType []

#

Where you place the code depends on when you want it to run

#

if you run it at the start of the game, it will remove the respawn position right at the start.
Which to me doesn't make sense, might aswell just remove the module

torpid quartz
#

OH right this is the code to remove the module, right, i thought it was to find the respawn ID lol

still forum
#

bis_fnc_removeRespawnPosition
removes respawn position

torpid quartz
#

yeah sorry had a bit of a brain fart there

#

alright give me a sec i'll have a try

exotic flax
#

typename _respawn == typename []
-> _respawn isEqualType []
Blame the BI dev who wrote that ๐Ÿคฃ

spark turret
#

true

still forum
#

its just old code

spark turret
#

Text text = "text"

#

just to clear things up.

#

thank you all for coming to my ted talk

torpid quartz
#

so uh, for the _logic = "Respawn Module Logic"; was i supposed to but the respawn module variable name in the "respawn module logic" part? or in the ["respawn",[]]; part on line 2?

spark turret
#

_logic = "Respawn Module Logic"; yes

#

dedmen will correct me if im wrong

torpid quartz
#
_logic = "RS1"; 
 
_respawn = _logic getvariable ["respawn",[]]; 
_respawn = _respawn param [0,[],[[],""]]; 
if (_respawn isEqualType []) then { 
   if (count _respawn == 2) then { 
      _respawn call bis_fnc_removeRespawnPosition; 
   }; 
};
#

I'm using this at the moment but i'm getting an error when it runs

spark turret
#

What error

#

Also, you can (and should) debug stufff like that, with stuff like diag_log and hint str

#

Hm wait is diag log unity or sqf

winter rose
#

_logic = RS1

#

"RS1" is a string

spark turret
#

Umm

torpid quartz
#

Oop, yup _logic = RS1 did it

#

thank you so much Lou

hallow mortar
#

diag_log works in Arma.

spark turret
#

Just for my understanding, how is rs1 a string? Is it a string variable with the name RS1 that holds a string?

torpid quartz
#

thanks i'll have a gander at it now

spark turret
#

also, get dedmens Debug engine mod from steam workshop, and get yourself visual studio code with the "sqf language","sqf lint" and "sqf debugger" extensions to create an IDE

ebon citrus
#

and i get criticized for flashing noobs with information

winter rose
#

you do it wrong, that's why!

ebon citrus
winter rose
#
player;     // reference to an object
"player";   // string with "player" value
str player; // "stringified" player object (e.g "Alpha B-1-1 (Joe)"```
spark turret
#

Well, debugging and ide s are noob friendly bc it actually helps them

#

Just knowing that stuff exists is a milestone

ebon citrus
#

str(player); Not necessary but nice to do. Completely up to you if you do it or not in this case

#

in sqf it matters not, but in other similar languages it does

spark turret
#

So varnames are actual variables that hold strings

torpid quartz
#

oh and while i'm here might as well ask, I was using markers to set random start positions, however i want an object to spawn randomly in one of multiple locations inside different buildings and markers aren't good for that.

Is there a way to have SetPos move an object randomly to one of multiple locations, or just set a bool to a random state? because using that I could get an if else type situation going.

ebon citrus
#

yes

#

have an array of locations and pick one at random

torpid quartz
#

actually could set a civi up in a trigger, give it a random chance to spawn, have that set a bool, and if that bool is true or false have the object spawn at one location or another lol

spark turret
#

There is random functions yes

spark turret
#

Theres more like random number generators etc.

ebon citrus
#

the random-toolset of arma 3 is more than enough for any task you might have with a little creativity

spark turret
#

If you want spawn positions for every position you can use any object and not just markers.

#

Houses have special points in then where ai can stand and move, its complicated

ebon citrus
#

markers are good for 2d-locations, objects if 3d is necessary

#

you can also get the positions the AI stands in

#

-1 will return ALL positions

spark turret
#

for your task an array that stores all available spawn positions and a selectRandom would probably be ideal

torpid quartz
#

So something dumb along the lines of CRT1 SetPos [4783.464,6112.624,3.453] or [4728.515,6154.601,4.023]; isn't going to work haha

spark turret
#

no its exactly that

#
_allSpawnPos = [ [4783.464,6112.624,3.453],[4728.515,6154.601,4.023]]; //array that holds all available spawn pos
_randomPos = selectRandom _allSpawnPos; //select randomly from array
CRT1 setPos _randomPos; //teleport unit to selected pos
#

and now the pro gamer move is to automatically fill the _allSpawnPos wth cool locations instead of hand writing it

torpid quartz
spark turret
#

Ah nice

torpid quartz
#

giving me the pro tech tips

#

_allSpawnPos is the array name right? so i could call that _Box1SpawnPos? or is it something held locally so i could use this exact same code (change the CRT1 of course and coordinates)

spark turret
#

Yeah, variable names are (in sqf) marked with the _ prefix.

torpid quartz
#

awesome

spark turret
#

Pro move: replace it with your own var names by ctrl h > replace all

#

So you dont forget one and eff up the code

torpid quartz
#

i'll put that in the brain bank thanks

spark turret
#

i used the editor waypoint (iirc) and they would always rope to high and bc the rope was short fall off

still forum
#

Well, debugging and ide s are noob friendly bc it actually helps them
not my debugger and its IDE integration lol

queen cargo
#

Sqf-vm ftw

spark turret
#

where do i find that file?

#

File A3\functions_f\Waypoints\fn_wpLand.sqf [BIS_fnc_wpLand]..., line 19

winter rose
#

in A3\functions_f\Waypoints\fn_wpLand.sqfโ€ฆ? ๐Ÿ˜„

astral dawn
#

@ironsight it's one of arma's pbo files, you can unpack them, they are in addons folder within game

still forum
#

functions_f.pbo

spark turret
winter rose
#

bns?

spark turret
#

params taken are
Author: Karel Moricky

Description:
Let group members land at the waypoint position

Parameters:
    0: GROUP
    1: ARRAY - waypoint position
    2: OBJECT - target to which waypoint is attached to

Returns:
BOOL

and thats it. i went over the script, it only takes/uses 3 params (the ones above).
I tested with the above params, works well

#

uh

winter rose
#

_TKOH means Take On Helicopters - a note is missing to state that

spark turret
#

oh boy

#

now i look like a fool

winter rose
#

naaah, it's OK

#

j/k

#

I'll fix it when home

#

np, thanks for pointing the potential issues though @spark turret ๐Ÿ‘

spark turret
#

i would comment but "Registraion of new accounts for the Community Wiki has been temporarily suspended. We apologize for the inconvenience."

coarse schooner
#

u can pm dwarden if ud like an account

robust hornet
#

hey guys I want to have a respawn point in a cave but the module is weird because it picks the highest terrain point
not sure if somehow I could place some code into an invisible helipad so that would be a respawn point?

unkempt sorrel
#

i think so, im pretty sure the helipad registered z coords, so wherever u put it it should be a viable spawn point

#

u might need the right position script though

#

some examples should help u there

spark turret
#

@coarse schooner thanks i did that

still forum
signal raven
#

anyone know how to use the debug console to see which mods are loaded? (i'm doing dedicated test server, so connecting via client as admin)

winter rose
#

@signal raven
getDLCs 1 for DLCs,
getLoadedModsInfo for Modsโ€ฆ available in the next patch

signal raven
#

@winter rose ty! Can't wait for next patch ... I settled for dropping 4 folders of various depth into my thing & going to test that next

smoky verge
#

I'm basically counting on the fact it might be poorly explained
is there a way to damage anyone who is in a certain trigger area except people in a trigger area inside the first trigger

young current
#

the overlapping triggers dont exactly "see" each other

#

so probably is not as simple as it sounds

#

why trigger areas?

#

would be simpler if you explain what is it you are trying to achieve

smoky verge
#

yeah
basically trying to damage anyone within a certain area
except people behind wall covers
the only example I can think of is that Mass effect mission were standing in sunlight damages you

young current
#

is it a some sort of explosion thing or something?

smoky verge
#

radiations

young current
#

is there a source for it?

#

like a bomb or device?

#

also radiation goes through most walls

#

or well depends on the type

smoky verge
#

its walls made exactly to shield from it
but its not exactly radiations its a sci fi beam
I'll make the science for it after I'm done with the scripting part

digital jacinth
#

could just do a lineIntersects check if the players body is somehow exposed to it

smoky verge
#

I'm interested

digital jacinth
young current
#

yes that was what I was coming to too

smoky verge
#

oh yeah was thinking about that exact function

young current
#

pick direction you want the beam to come from and check if the characters can are visible

#

might need like check for head, hands and feet to be accurate

digital jacinth
#

possible. this function only really goes for feet, torso, head area

smoky verge
#

I can settle for that

digital jacinth
#

you can do select position the head, hands, etc if you wan more accurate results

signal raven
#

@winter rose - did I mention that for now I fell back to using the *.rpt log - which lists all the mods & official or not for the time being?

spark turret
#

i cant seem to remeber what the function for making ai run was.

#

someone help

#

aaaah speedMode.

distant oyster
#

was there a command for getting the addon that a config belongs to?

still forum
#

the CfgPatches classname yeah

#

something configSource

distant oyster
smoky verge
#

I don't think I can know which player is in contact with line intersect and damage that player specifically
I'll have to play with trigger areas I guess

still forum
#

why you think you can't?

smoky verge
#

how would that be possible syntax wise?

still forum
#

lineIntersectsSurfaces

#

returns the objects it intersects.
Players are also objects

smoky verge
#

oh thats useful

distant oyster
#

whats the meaning of

configSourceMod (configFile >> "RscText");
``` returning an empty string?
robust hollow
#

usually means it came from the arma3/addons folder i thought.

distant oyster
#

according to the biki

configSourceMod (configFile >> "CfgVehicles" >> "Car");
``` should return `"A3"`
signal raven
#

How do we decide what the mission template field should look like in the server.cfg?

https://community.bistudio.com/wiki/server.cfg#Example_Configuration_File > Mission rotation

class Missions
{
class TestMission01
{
template = MP_Marksmen_01.Altis; <-----------This line

...

I'm trying to load: AntistasiAltisCommunityVersion.altis (this is the folder) which holds the mission.pbo ... my cfg below:

class Missions
{
class Mission_1
{
template = "AntistasiAltisCommunityVersion.altis";

robust hollow
#

more of a #server_admins question, but you use the name of the pbo. so in your example the pbo should be called AntistasiAltisCommunityVersion.altis.pbo

jolly jewel
#

Does anyone know what kind of position that eden uses? I'm trying to set position of objects in script

#

When I do

    _obj setPosWorld (_house modelToWorldWorld _pos);
    //_obj set3DENAttribute ["Position", getPosATL _obj];

The object is where it should be

#

But when I do

    _obj setPosWorld (_house modelToWorldWorld _pos);
    _obj set3DENAttribute ["Position", getPosATL _obj];

It is offset

exotic flax
#

modelToWorldWorld = ASL (sea level)
modelToWorld = AGL (ground level / sea level)
3DEN "Position" = ATL (ground level)

jolly jewel
#

Yeah nevermind, turns out that I need to set the eden position and then the eden rotation

tiny wadi
#

It accepts 3d positions, but I don't think that necessarily means it'd be able to determine a volume based on the polygon array

exotic flax
#

3d position means it's an XYZ position, not 3d as in volume

tiny wadi
#

Yeah, ill probably end up just using inpolygon in addition to a fixed height value to determine if a point is within it

jolly jewel
#

Don't know if there's a specific syntax for polygon vectors

#
[1,1,1] inPolygon [[0,0,0],[0,2,0],[2,2,0],[2,0,0],[0,0,2],[0,2,2],[2,2,2],[2,0,2]]```
#

Returns false, even though I would think it should be inside

#
[1,1,500] inPolygon [[0,0,0],[0,2,0],[2,2,0],[2,0,0]]```
#

Returns true

tiny wadi
#

I believe the array has to be formatted in a counter clockwise or clockwise order

#

I couldnt figure out though if jt took height into account

jolly jewel
#

My conclusion would be that it does not

exotic flax
#

you could try inArea (see syntax 3) to check if a position exists within an area

tiny wadi
#

inArea would work but sometimes i'll have a shape I need to check that isn't rectangular or elliptical

exotic flax
#

With complex polygon shapes you'll need a custom function which does that.
Looking at how math solves it there are a lot of methods of doing exactly that, which can be translated to SQF

exotic flax
#

@tiny wadi here's an SQF version of pnpoly (Point Inclusion in Polygon Test):

/*
    Author: Grezvany13

    Description:
        Checks if a 2D Position exists in a 2D Polygon shape

    Parameter(s):
        0: ARRAY - 2D Position of test point
        1: ARRAY - Array with 2D Positions of polygon verticles.

    Returns:
    BOOL
*/

TAG_fnc_pointInPolygon = {
    params ["_point", "_vs"];

    _x = _point[0];
    _y = _point[1];

    _inside = false;
    for [ { _i = 0; _j = ((count _vs) - 1) }, { _i < (count _vs) }, { _j = _i + 1 } ] do {
        _xi = _vs select _i select 0;
        _yi = _vs select _i select 1;
        
        _xj = _vs select _j select 0;
        _yj = _vs select _j select 1;

        _intersect = ((_yi > _y) != (_yj > _y)) && (_x < (_xj - _xi) * (_y - _yi) / (_yj - _yi) + _xi);
        if (_intersect) then {
            _inside = !_inside;
        }
    };
    _inside;
};

PS. not tested in-game, but should work.
PPS. if BI wants to include this, feel to implement ;) guess it's the same as inPolygon

source: https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html

jade abyss
exotic flax
#

he did, although it doesn't support 3D locations (XYZ), just like my script

tiny wadi
#

Yeah ^^
I think the solution I am going to go for is to check first if it is within the 2d polygon, and then have an additional variable that determines the height to create a volume. So it won't support oddly shaped volumes, it'll just extend the 2d upwards whatever height I set

jade abyss
#

Yep

exotic flax
#

btw... you might be able to find some math solutions for Point Inclusion in Polyhedron ๐Ÿ˜‰

jade abyss
#

Just checked the code above ๐Ÿค”

#

Why is there even a Z Value in Polygon ๐Ÿค”

exotic flax
#

that code does the same as inPolygon... also noticed that

tiny wadi
#

Ahhh, yeah that would work @exotic flax. I forgot what the term would be to call it so I couldnt google anything relating to it:P

#

Ill see what I can find, but it might be a bit overkill

jade abyss
#

inPolygon + ZCheck

exotic flax
#

hmmm.... checking some search results on "Testing Point Inclusion in a Polyhedron", and they all go to scientific papers trying to explain the problem and possible solutions... but no real solution has been found (yet?)

jade abyss
#

Just keep in mind: Each following coord you add will be a "line". So example for a square: TopLeft,RopRight,BottomRight,BottomLeft
Otherwise it would be faulty

exotic flax
#

with a Polyhedron you would need a full matrix of points and vertexes... because each point can go to 1 or more other points...

#

which is most likely why there is no real solution for that problem

tiny wadi
#

Yeah, at that point you'd need to define surfaces and normals

#

it'd get pretty complex

jade abyss
#

It's not always a rectangle, right?

tiny wadi
#

No, it could be any number of points

#

=3

jade abyss
#

meh, okay.

tiny wadi
#

yeah, i 'll go with inPolygon + zcheck for simplicity

#

it'll be way too much work

jade abyss
#

Yeps

tiny wadi
#

for very little reward

jade abyss
#

gl

tiny wadi
#

Thanks ๐Ÿ‘

quasi rover
#

This is run by server, and I want to let clients set the variable "attackHeli" and values in their profilenamespace on each machine.
but nothing changed on client's machine. what am I doning wrong?

 [profileNamespace, ["attackHeli", [obj_name, false]]] remoteExec ["setVariable", -2, true];

unique sundial
#

@brittle apex try boundingBox/boundingBoxReal

#

@quasi rover try to make a function and remote exec the function

tough abyss
#

Anyone know why it's not re-adding the goggles here? It does everything else right:

[player,"25thID"] call BIS_fnc_setUnitInsignia;

// Re-assign players identity which gets removed after user loads a loadout
player setIdentity str player;

// Re-set eye wear that's removed when setIdentity was re-assigned
Sleep 0.5;
_goggles = goggles player;
player addGoggles _goggles;

// Save player loadout
[player, [missionNamespace, "Var_SavedInventory"]] call BIS_fnc_saveInventory;
robust hollow
#

if setIdentity removes the goggles, then _goggles = goggles player; would just be an empty string wouldnt it? because by the time it execute the identity has already been set. try setting _goggles before setting the identity.

tough abyss
#

Oh crap you're right

#

I need some more GFuel

torpid quartz
#

Hey i'm not sure it's possible, but i want to start a timer on a trigger, and then later when another one goes off stop the timer and print the time on screen.

Is there anyway to do the timer part of this? It's for a mission where my guys are competing to get the best time casually and there's a bit at the start where you can customize your loadout so i can't just use the final mission timer.

#

something like the shoot house time trail challenges.

warm hedge
#

time command to get the in-game time. You can use this command to save the start time, and calculate end time

#

Like:

startTime = time;```
```sqf
endTime = time - startTime;```
torpid quartz
#

awesome, yeah i think i've got an idea of how to implement that with triggers, i'll post it if i get it working

runic quest
#

excuse me, i need help. _a = [1.992e+006]; _a = _a select 0 ; _a = _a tofixed 0 ; _a = parseNumber _a ;hint str _a ; why the output is still 1.992e+006 instead of 1992000?notlikemeow

warm hedge
#

Why you do parseNumber _a? Shouldn't if you don't want to show e

fair drum
#

what would be the most efficient way to go about taking an element out of an array as it is selected?

if (isServer) then {

    params ["_box"];

    private _count = [1,2,3,4,5];
    private _items = ["rhs_acc_1p63","rhs_acc_1p29","rhs_acc_1p78","rhs_acc_ekp1","rhs_acc_ekp8_02","rhs_acc_okp7_dovetail","rhs_acc_pkas"];

    _box addItemCargoGlobal [selectRandom _items,selectRandom _count];
    _box addItemCargoGlobal [selectRandom _items,selectRandom _count];
    _box addItemCargoGlobal [selectRandom _items,selectRandom _count];
    _box addItemCargoGlobal [selectRandom _items,selectRandom _count];
    _box addItemCargoGlobal [selectRandom _items,selectRandom _count];
};
runic quest
#

@warm hedge I execute the sql statement select to get such a number, 1.992e+006. I need to convert it to a normal number (1992000), but what I get with tofixed is a string, I also need to convert it to a numeric value.

robust hollow
#

i dont think this is right but something like this @fair drum
_item = _items deleteAt floor random count _items;

warm hedge
#

1.992e+006 and 1992000 are equal to each other. So you only need to think when you prefer either way to output

#
_a = [1.992e+006];
_a = _a select 0;    //1.992e+006
_a = _a tofixed 0;    //"1992000"
_a = parseNumber _a;    //1.992e+006
hint str _a;     //"1.992e+006"```
So instead
```sqf
_a = [1.992e+006];
_a = _a select 0;    //1.992e+006
hint (_a tofixed 0);    //"1992000"```
or
```sqf
_a = [1.992e+006];
tofixed 0;
hint (_a select 0);    //"1992000"```
runic quest
#

@warm hedge tks,bro!

lilac kettle
#

Hi! How to make a loop? I tried to use while and waituntil, but every try lead to some kind of nonsense. Will something like this work?

#

_fnc = {
if (condition) then {do stuff} else {exitwith {call _fnc}}

unique sundial
#

@robust hollow cfgidentity has glasses property

still forum
#

Will something like this work?
no.

while {condition} do {
do stuff;
}
unique sundial
#

@lilac kettle check wiki

quasi rover
#
CIY_fnc_resetHeli = {
    profileNamespace setVariable ["attackHeli", [obj_name, false]];
};
remoteExec ["CIY_fnc_resetHeli"];

@unique sundial It works on hosted server, but not dedi-server.

unique sundial
#

@runic quest why do you need to convert it like this?

#

if you want to display it it will be string if you want it for calculations it makes no difference

#

@quasi rover because you need to saveProfileNamespace for it to stick?

still forum
#

It works on hosted server, but not dedi-server.
IF you posted your actual code, then yes of course because you only define that script function on one machine

ebon citrus
#

What Dedmen said. You need to either A. Make that variable public, or B. Define the function on all clients through other means, such as cfgFunctions or by just a script that runs on all clients. Your best bet here is to not remoteExec the function but the code inside of it. Youre also going to possibly have some issues with other variables in your script, but i cant say because were not getting the full story. I recommend you take a look at this guide.
https://community.bistudio.com/wiki/Variables

quasi rover
#

The script was run by server machine, so I just thought remoteExec is enough to be executed on every connected client. but I need to study more. thanks, guys.

fervent kettle
#

Due to how TFAR is currently built, you could do

_items = [player] call CBA_fnc_uniqueUnitItems; // If player has lots of items, this is faster and more efficient than simple items player;

if (_items findIf {"TFAR_anprc152" in _x} == -1) then {add tfar radio}

But that might break when TFAR updates
@still forum thus is dropping me a "missing ;" error, even after adding it

still forum
#

after the then{};
maybe, but otherwise I don't see it

fervent kettle
#

thats exactly where Ive placed it, still the same error

unique sundial
#

paste your exact code if you need help with error and full error from .rpt

fair drum
#

say I got a gigantic cfgSounds section in my description.ext. Is there a way I can write it somewhere else, then port that into the description.ext?

smoky verge
#

been trying to loop the EMP script from ALIAS but can't seem to make it work
it triggers only once

can't post the entirety of the EMP script because its several sqfs and it would be spam but this is what I'm using to loop the activation line

while {true} do {
sleep 20;
playMusic "Beam";
sleep 0.5;
Beam hideObject false;
[emp_me,2000,true,true,0.1] execvm "AL_emp\emp_starter.sqf";
sleep 3;
Beam hideObject true;
};```
anyone who has used it in the past knows what could prevent it from looping?
still forum
#

@fair drum you mean #include?

#

anyone who has used it in the past knows what could prevent it from looping?
script errors? but I don't know where, maybe undefined variable?

smoky verge
#

not getting any error log
and the rest of the stuff in the looping script works fine
I can post the content of emp_starter.sqf if thats ok

still forum
#

have you added logging into the loop

#

to check if the loop itself is running?
cuzz you're telling me the loop itself doesn't work, and now you say the rest of the looping stuff works.. so what now ๐Ÿ˜•

smoky verge
#

the looping works
the hideObject and the playMusic loop just fine
its the [emp_me,2000,true,true,0.1] execvm "AL_emp\emp_starter.sqf";
that doesnt
and if it does
it doesn't seem to work twice

still forum
#

well then its probably the content of that script file

#

meaning we need to see it

smoky verge
#
if (!isServer) exitWith {};

_obj_emp    = _this select 0;
_rang_emp    = _this select 1;
_viz_eff    = _this select 2;
_player_viz = _this select 3;
_dam_unit    = _this select 4;

if (!isNil {_obj_emp getVariable "is_ON"}) exitwith {};
_obj_emp setVariable ["is_ON",true,true];

emp_dam =_dam_unit; publicVariable "emp_dam";
if (_viz_eff or _player_viz) then {[[_obj_emp,_viz_eff,_player_viz],"AL_emp\viz_eff_emp.sqf"] remoteExec ["execVM"]};
[_obj_emp,_rang_emp] execvm "AL_emp\config_obj.sqf";
waitUntil {!isNil "special_launchers_emp"};
waitUntil {!isNil "emp_dam"};
[] execvm "AL_emp\emp_effect.sqf";

it does call to 3 other scripts
maybe the problem could be in config_obj.sqf

#

oh nevermind that only marks the objects to jam with the emp

still forum
#

Well

#

if (!isNil {_obj_emp getVariable "is_ON"}) exitwith {};
_obj_emp setVariable ["is_ON",true,true];

smoky verge
#

not too sure I'm reading it right
looks like it stops the rest of the code from launching if _obj_emp has the is_ON variable?
something to prevent looping?

still forum
#

yes

smoky verge
#

I don't think I can just remove it but I'll try

still forum
#

you can just unset that variable

#

on the object

smoky verge
#

_obj_emp setVariable ["is_ON",true,true];
which one do I turn false?

still forum
#

neither

#

the second one to nil

smoky verge
#

๐Ÿ˜… the what?

still forum
#

you want to unset that variable, on that object

#

you remove a variable by setting it to nil

#

he mod uses !isNil to check whether it should exit, so make the variable nil, and it won't exit anymore

smoky verge
#

sorry if I sound dumb but
like this?
_obj_emp setVariable ["is_ON",true,Nil];

winter rose
#

nil, true

#

it's <value>, <broadcast>

smoky verge
#

I'll try

still forum
#

I don't see why they do the broadcast, seems useless to me

smoky verge
#

so now it loops but it gives me an error on that line saying
error type any, expected bool, number, array

#

not sure if I should ignore but it may cause issues once in a server

winter rose
#

don't ignore errors, ever

smoky verge
#

yeah

#

figured it may cause some memory leak or something
what should I do about it?
I guess it says that because it expects a bool instead of the Nil

still forum
#

What exactly did you add now?

smoky verge
#

_obj_emp setVariable ["is_ON",Nil,true];

still forum
#

where

smoky verge
#

on that same line of the previous one
or should have I added a new one somewhere?

still forum
#

add a new one in your script

smoky verge
#

oh at the end of the loop

#

still learning the basics but how would I identify _obj_emp in my script?
do I write _obj_emp = _this select 0; at the beginning of the loop where 0 is the same "slot" used in AL_emp\emp_starter.sqf?

still forum
#

uh

#

[emp_me,2000,true,true,0.1] execvm "AL_emp\emp_starter.sqf";

#

...^

smoky verge
#

not sure I understand

still forum
#

the arrow points at the object

#

you already have it in your script. You are passing it to execVM

#

just take it

smoky verge
#

but I'm getting an undefined variable in the expression error if I just add
_obj_emp setVariable ["is_ON",Nil,true]; to the loop

still forum
#

Yes...

smoky verge
#

you're implying that I should rename emp_me to _obj_emp?
because otherwise I don't get what you mean

still forum
#

no, the opposite

#

I'm confused? whats your scripting knowledge? You've been here for years, I assumed you're on intermediate kinda level

smoky verge
#

haven't really been modding or scripting heavly
this is probably the first time I try something so complex
I've usually just found cheaty ways to do what I wanted and it worked for 2-3 years
but I'm trying to get more in depth recently with the little time I have

still forum
#

Guess I missjudged then, I thought just pointing a direction is sufficient to let you figure it out, here

while {true} do {
    sleep 20;
    playMusic "Beam";
    sleep 0.5;
    Beam hideObject false;
    emp_me setVariable ["is_ON",nil];
    [emp_me,2000,true,true,0.1] execvm "AL_emp\emp_starter.sqf";
    sleep 3;
    Beam hideObject true;
};
smoky verge
#

I noticed and appreciated that
dont like people making scripts for me
I did just learn a bit but Im still pretty noob on the subject

thick merlin
#

Been using some radio chat in my missions latelt and thought i would get all fancy and add some lip files.I used the a3 tool set to do it .I am mostly using radio based chat in vehicles so iam not at all using the say commands.I made up the files according to the instructions.Making sure no spaces etc were in the name or filepath.I have the audio files and lip files stored together in their folder.Tried in my sounds folder in my mission and also in a data pbo thats a loaded mod.But no lip moving is going on..Any ideas? I ve had a bit of a search here and didnt really find a solution to my application.

#

Any help appreciated.Thanks.

rough heart
#

@smoky verge take a look at the wiki how call and execvm and such work and how you can pass variables tru parameters to the script

smoky verge
#

it works @still forum

#

thanks a lot

#

I will @rough heart

waxen tendon
#

how to get ground altitude ASL of position?
[x,y] call altitudePosition
> z

#

im trying to check if [x,y] is on ground or on sea

#

anything that does that also works

warm hedge
#

getTerrainHeightASL

#

Or surfaceIsWater

waxen tendon
#

thats great, thanks!

hallow mortar
#

oh wow, just the other day I was complaining about == not working with booleans and now they're making it work

#

BI....good???

exotic flax
#

issue where?
fix where?

hallow mortar
#

Dev branch patch notes:

Added: Support for Boolean type to == and != FT-T64965

exotic flax
#

that's a issue known since OFP and reported in 2016... I doubt you made them change their mind ๐Ÿ˜‰

hallow mortar
#

I can dream that my comment reminded them about it. But I just thought it was a neat coincidence (and neat that they're making that change)

exotic flax
#

BI recently got some new people on board to do bug fixing in Arma 3, while BI themselves can work on Enfusion. So the FT is (finally) being looked at ๐Ÿ˜‰

hollow thistle
#

~~bool == bool is quite stupid code. I hope they won't add this.~~It's real changelog ๐Ÿ˜

warm hedge
#

Foolproof!

exotic flax
#
if (true == false) then {
   // TODO
};
still forum
#

I said the same

hollow thistle
#

It's nothing big but it's just... stupid ๐Ÿ˜„

#

At least it will be easier for begginers blobshrug

still forum
#

easier for beginners to write stupid code that they themselves don't understand

tough abyss
#

badcode has absoulutely no idea whats going on

still forum
#

And they'll now say "but it works fine, so that means there's nothing wrong with it and I will now use it in my tutorial videos to teach others"

hollow thistle
hallow mortar
#

it's such a minor thing that I personally think making == behave consistently is worth the possibility of people adding 5 unnecessary characters to their script

exotic flax
#

so does that mean we also get ===, !==, <=> and more? ๐Ÿคฏ

still forum
#

isEqualTo is better in most cases anyway :U

#

=== you already have that, isEqualTo

exotic flax
#

3 chars vs 9 ๐Ÿคทโ€โ™‚๏ธ

spark turret
#

Whats wrong with the != stuff? It makes imverting booleans for "button" functions a lot easier

still forum
#

inverting booleans?
!true

spark turret
#

Ah whoops

still forum
#

See! Thats the point that beginners often miss. They only stumble upon it when they see that bool == bool doesn't work

spark turret
#

So why is comparing booleans evil?

still forum
#

Its slower, and in most cases just stupid

spark turret
#

So why is comparing booleans evil?

still forum
#

if (condition == true)
but condition is already a boolean, that does nothing

spark turret
#

But you could compare 2 booleans.

#

If (bool1 == bool2)

exotic flax
still forum
#

yes you always could with isEqualTo if you really needed to in the few rare cases where you need to

warm hedge
#

bool1 and bool2?

still forum
#

nope

spark turret
#

Just a tought example.

still forum
#

false and false -> false
false == false -> true

spark turret
#

Hmm

warm hedge
#

Ah I recognize my fault after the post

still forum
#

I needed to compare booleans once in the last 3 years

spark turret
#

I see your point

still forum
#

That means out of maybe about 2k (I literally have no idea how much I wrote) lines of code written over that time, one single case where bool == bool would've made sense

spark turret
#

Well but its comparing about 2 variables and less about the bool. I dont really see a problen other than it being a bit confusing for newbs

still forum
#

But on the other hand, a couple dozen beginners that thought
if (isPlayer player == true) then {..}
made sense

hallow mortar
#

I just don't see the huge harm in letting people do that if they want to. Having the command behave in the way you would expect it to is important for accessibility, and commands having arcane, unpredictable limitations is half the problem with sqf in the first place.

spark turret
#

Yeah true

still forum
#

Which then came here as they couldn't figure out why it didn't work, which were then educated about why it doesn't make sense to do that

spark turret
#

But tbh if ppl dont know what they do its most often not the functions fault