#arma3_scripting

1 messages Β· Page 636 of 1

still forum
#

getOrDefault might be more readable

winter rose
#

why not a prefix? mapGet/mapSet?

#

or it could be confused with a real map control

still forum
#

Yes. and I'm using set.. what's the problem here?

#

you use get to get, and set to set.
or now... getOrDefault if you want a fallback

winter rose
still forum
#

Yeah but i never talked about set so why do you assume that i cannot use it :U

#

I just asked a simple question, and get answers about like 3 different topics that I didn't even ask about ┬─┬ γƒŽ( γ‚œ-γ‚œγƒŽ)

winter rose
#

I don't answer to false dichotomy :p

spark turret
#

Lets ask him about arma 4 to completely push him into a ragefit

spark turret
little raptor
spark turret
#

Also misleading

still forum
#

yeah getDefault sounds like you only want the default value or smth

#

ACE people also brought up tryGet but to me that entails that it will just tell you that it failed when it failed

little raptor
#

not bad

winter rose
#

do, or do not 🟩

little raptor
#

getIfYouCan πŸ˜„

winter rose
#

how to really get Dedmen out of himself: getKeyValue_OR_Getdefaultvalue

little raptor
#

getValueIfDoesntExistGetDefault

winter rose
#

*naming conventions left the chat

cosmic lichen
#

Still missing the variant with two "t"

#

gettOr

#

Would fit with some naming conventions πŸ˜‰

winter rose
#

You…!!

little raptor
#

get _key and gett [_key, def]

winter rose
#

but sometimes there is not a get*, e.g setBehaviour/behaviour
so the proper naming would be 😁

little raptor
#

makes sense

winter rose
#
private _value = _hashmap "key";
private _value = _hashmap orDefault ["key", "default"];
little raptor
#

_hashMap get _key orDefault _def meowtrash

winter rose
#

_hashmap select "key"? arf, not going to happen.

cosmic lichen
#

private _value = hashmap getOrDefault ["key", "default"];
This is definitely the way to go. It almost reads like plain English which is good

little raptor
#

get1 _key and get2 [_key, _def]...it says it all

cosmic lichen
#

A bit more and dedmen will be like "Hashmap is not gonna happen, bye"

winter rose
#

he's gonna keep it aaall to himself πŸ‘€

still forum
#
_hashMap = createHashMap;

_hashMap get "test"; // bench only this line

0.00113ms

_array = [];

_array find "test"; // bench only this line

0.00110ms blobcloseenjoy

_array = ["abc", "def", "lol", "test"];

_array find "test"; // bench only this line

0.00144ms

_array = ["test"];

_array find "test"; // bench only this line

0.00124ms

_hashMap = createHashMap; 
_hashMap set ["abc", 0];
_hashMap set ["def", 0];
_hashMap set ["lol", 0];
_hashMap set ["test", 0];
 
_hashMap get "test";  // bench only this line

0.00143ms

_hashMap = createHashMap; 
_hashMap set ["test", 0];

_hashMap get "test";  // bench only this line

0.00144ms

little raptor
#

your test seemed wrong

#
_array = [];
diag_codePerformance [{_array}];
#

_array doesn't exist in { }

winter rose
#

now it reminds me of some JS I did 2 years ago πŸ˜† performance-based for millions of data objects

still forum
#

it does

little raptor
#

doesn't it run in a separate thread?

#

I thought it was supposed to be a "clean" test

still forum
#

it shouldn't πŸ€”
Huh

#

I thought it doesn't, well retest then :U
(definitely not seperate thread at all though) but maybe it doesn't link the parent scope afterall, I thought it does

little raptor
#

use _this instead

little raptor
still forum
#

numbers adjusted

#

I expected them to be very close for small array vs small hashmap yes

little raptor
#

isn't it just a two dimensional array?!

#

_hashMap = [_keys, _values]?!

still forum
#

what?

little raptor
#

j/k

#

anyway, is it case sensitive?

still forum
#

yeah

little raptor
# still forum what?

I mean I used to do "hashmaps" before like that! I created a two dimensional array:
[_keys, _values]
then I used find to find the index and get the value

still forum
#

I know, other people did too.

spark turret
#

True Hashnaps dont search entries like arrays tho afaik

little raptor
#
_hashMap = createHashMap; 
_hashMap set ["abc", 0];
_hashMap set ["def", 0];
_hashMap set ["lol", 0];
_hashMap set ["test", 0];

can we get a more convenient syntax too?

_hashMap = createHashMap [
  ["abc", 0],
  ["def", 0],
  ["lol", 0],
  ["test", 0]
];
still forum
#

that is not possible because nular commands can't be unary too

#

createHashMapFromArray maybe. But i don't think so as iterating array and inserting is a really easy thing to do

winter rose
#

I don't mind a createHashMap [] though

little raptor
#

btw, which one is faster?

_unit getVariable ["var1", 0];
...
_unit getVariable ["var100", 0];

or

_hashMap = _unit getVariable "hashmap";
_hashMap getOrDefault ["var1", 0];
...
_hashMap getOrDefault ["var100", 0];

?

#

also is there a "hashNull"?!

still forum
#

first is faster. As second need to hash the whole script value including its type while first one only pulls out the string and only hashes that

#

also is there a "hashNull"?!
yes, its called "createHashMap"

#
_array = [];
_hashMap = createHashMap; 
for "_i" from 1 to 6 do {
_array pushBack _i;
_hashMap set [_i, _i];
};

6 values:
Find last value
Array: 0.00149
Hash: 0.00132
Find first value
Array: 0.00127
Hash: 0.00137
Find non-existent value
Array: 0.00137
Hash: 0.00120

50 values:
Find last value
Array: 0.00307
Hash: 0.00212
Find first value
Array: 0.00123
Hash: 0.00141
Find non-existent value
Array: 0.00299
Hash: 0.00134

100 values:
Find last value
Array: 0.00443
Hash: 0.00128

100 values as strings:
Find last value
Array: 0.00436
Hash: 0.00219

with small arrays like 10 elements all values are basically within margin of error

opal mulch
#

Sorry to interject, I'm trying to use an SQF file to addAction to an object in an mp mission.

The object's init:

this execVM "file.sqf";```

file.sqf:
```sqf
params ["_myUnit"];
_myUnit addAction ["action", {}];

This code doesn't work. any idea why?

little raptor
still forum
#

I guess I theoretically don't need to hash the type of the variable.

little raptor
#

instead of a null

still forum
#

fast enough? if I make a hashNull it would be exactly the same

little raptor
#

because nulls usually have ~ 0.0005 ms delay

still forum
#

Result:
0.0013 ms
Cycles:
10000/10000
Code:
createHashMap;

Result:
0.0014 ms
Cycles:
10000/10000
Code:
objNull

winter rose
little raptor
opal mulch
#

the object is a soldier

worn forge
#

@opal mulch what's the error?

still forum
little raptor
#
Result:
0.0006 ms

Cycles:
10000/10000

Code:
objNull
still forum
#

We are on different computers, did you think of that?

little raptor
#

there's no way my computer is faster than yours! cuz it's the very definition of potato

still forum
#

its equal to objNull

spark turret
#

You havent seen dedmens computer :D

still forum
little raptor
#

I thought it was just one test

still forum
#

Result: 0.0011 ms
Code: []

Result: 0.0013 ms
Code: createHashMap;

Result: 0.0014 ms
Code: objNull
its even comparable to array :u

little raptor
#

oki doki

opal mulch
#

I've found my problem. the file.sqf was in a folder and I used a forward slash instead of a backslash. thanks to your feedback i was able to deduce the problem. thanks!

still forum
#

but your code didn't show any folder or slashes :u Always show the code you're having problems with πŸ™ƒ

opal mulch
#

Will do

still forum
#

hehe

_array = [];
_hashMap = createHashMap; 
{
_array pushBack _x;
_hashMap set [_x, configName _x];
} forEach ("true" configClasses (configFile >> "CfgVehicles"));

LastClass = _array select (count _array -1);

[
diag_codePerformance [{
_this find LastClass;
}, _array, 10000],
diag_codePerformance [{
_this get LastClass;
}, _hashMap, 10000]
]

[[0.194024,5154],[0.0039,10000]]

🍿 8049 entries

forEach (("true" configClasses (configFile >> "CfgVehicles")) select [0, 50]);
50 entries: [[0.0038,10000],[0.0024,10000]]
20 entries: [[0.0025,10000],[0.0025,10000]]
10 entries: [[0.0021,10000],[0.0024,10000]]

little raptor
#

diag_codePerformance [{
_hashMap get LastClass;
}, _hashMap, 10000]
]
?!

still forum
#

reeeee

#

fixed

little raptor
#

the values too?

still forum
#

ye

winter rose
#

are hashmaps "sorted" by insertion then?

still forum
#

unsorted

#
_array = [];
_hashMap = createHashMap; 
for "_i" from 1 to 6 do {
_array pushBack _i;
_hashMap set [_i, _i];
};

_array
[1,2,3,4,5,6]
keys _hashMap
[<null>,<null>,<null>,<null>,<null>,<null>,1,2,4,5,3,6]

ehh... oops

little raptor
#

[[0.194024,5154],[0.0039,10000]]

🍿 8049 entries
this doesn't seem right! that's way too fast (in comparison)!

still forum
#
_cbaHash = [] call CBA_fnc_hashCreate;
_hashMap = createHashMap; 

{
  [_cbaHash, _x, configName _x] call CBA_fnc_hashSet;
  _hashMap set [_x, configName _x];
  LastClass = _x;
} forEach ("true" configClasses (configFile >> "CfgVehicles"));

[
diag_codePerformance [{
[_this, LastClass] call CBA_fnc_hashGet;
}, _cbaHash, 10000],
diag_codePerformance [{
_this get LastClass;
}, _hashMap, 10000]
]

[[0.212089,4715],[0.0077,10000]]

hatcat

little raptor
#

not necessarily string right?

still forum
#

working now: Number, bool, string, array(containing supported types), code, side, config

#TODO Nil, Any, Namespace, NaN

winter rose
#

NaN??

#

(i)

still forum
#

One question I haven't decided on yet.

{} forEach _hashMap
inside the loop there are _x and _y variables available? or better _key and _value? or have _x be an array?

little raptor
#

that's tough πŸ˜–
I'd say use the old convention and use the magic variable _x so we could use _x params ["_key", "_value"]
but again having the _key and _value predefined by the engine could be faster (or is it?). and also _forEachIndex doesn't seem to be relevant anymore...

still forum
#

it will be faster yeah

#

_forEachIndex can just give iteration count, I intended to implement a iteration count command that works in any loop anyway

little raptor
#

apply and select included?

still forum
#

"any loop"

little raptor
#

cool

#

even for?!

#

and while?

still forum
#

┬─┬ γƒŽ( γ‚œ-γ‚œγƒŽ)

cosmic lichen
#

_x and _y if you ask me

little raptor
#

_his and _hers

still forum
#

shorter variables will be faster.
pulling stuff out of _x would be slower even than _key and _value variables.

winter rose
#

_k _v?

still forum
#

Ah, that reminds me, I wanted to speed up the _x and _forEachIndex assignment in forEach loop

cosmic lichen
#

I think the ppl who use hashmaps can remember that _x == key and _y == value πŸ˜„

still forum
#

_x and _y it'll be then :u

winter rose
#

if there were no standards, I would love
_k for key, _v for value and _i for iteration ofc

cosmic lichen
#

I already see ppl complaining why they need to write _key instead of _x πŸ˜„

little raptor
#

I just noticed that SQFLint doesn't have magic variables...I'll go back to NPP

cosmic lichen
#

πŸ˜„

winter rose
little raptor
spark turret
still forum
little raptor
#

wait hashmap is an object?!

still forum
#

no

#

objNull is an object

austere granite
#

Your mom is an object

queen cargo
#

Objectifying foxes is not cool!

little raptor
#

oh so the array should be constant? (or made up of constants)

still forum
#

no

#

only supported types are allowed for keys. including values in arrays

still forum
#

People modifying HashMap while iterating over it will be fun

little raptor
still forum
#

no

little raptor
#

then what's fun?!

#

I mean is it more fun than iterating over an array and modifying it in the loop?!

austere granite
#

hows MP stuffs for them?

little raptor
#

I think they're like arrays in that regard

austere granite
#

im just asking because of common usage of setVariable currently, and i believe different things also giving the global option for createNamespace with that.

little raptor
still forum
#

Yeah they are like arrays in MP

little raptor
#

can you also delete elements from the hashMap to make it smaller for looping?
like:

_map set [_key, nil];
still forum
#

_map deleteAt _key

#

nil is a valid value, so it won't delete

jade abyss
#

How will you get a specific key in the end?

still forum
#

what do you mean?

jade abyss
#

e.g. _value = dictdata["key"] in other languages *

still forum
#

with the "get" command?

jade abyss
#

So you will add get then?

#

(idk what you know/plan to do, hence why i am asking)

still forum
#

did you skip the whole conversation and benchmark results above?

jade abyss
#

Yeps

austere granite
#

does it have both:
_uwot get ["key", "default"]; // default
_uwot get "key" // nil

little raptor
still forum
#

then scroll up

jade abyss
#

i am lazy

austere granite
#

... :DDDD

#

i just clicked that and saw lol

jade abyss
still forum
#

use text to speech

jade abyss
#

(joke aside: πŸ‘ sounds lovely)

still forum
#
_hashMap = createHashMap;
_hashMap set [["test", 1], "test"];
_hashMap set [1, "test"];
_hashMap set [2, "test"];
_hashMap set [3, "test"];

_stuff = [];
{
  _stuff pushBack [_x, _y];
} forEach _hashMap;
_stuff

[[2,"test"],[1,"test"],[3,"test"],[["test",1],"test"]]
blobcloseenjoy sweating

little raptor
austere granite
#

arent they unsorted in a lot of languages

little raptor
#

shouldn't it be like [["test",1],"test"], [1,"test"], ....

still forum
#

why sorting? no sorting

#

HashTable's are not sorted

queen cargo
jade abyss
#

Something like that won't be possible, right?

_a = [["things",1],["thongs",2]];
_val = _a get "thongs"; // 2 ?

❓

little raptor
#

that's an array

#

but I think he said no

#

createHashMap [["things",1],["thongs",2]]

still forum
#

that is an array Dscha

jade abyss
#

Oh rly?

#

... of course it's an array.

queen cargo
#
obj = {
    Foo: "Bar"
};
Diag_log(obj.foo); // bar

Fun with SQC πŸ€”πŸ€” really need to get the Documentation done for my lil transpiled lang :D

still forum
#

Yeah how did you imagine that to work..

#

you can use find and findIf if you want to find stuff in arrays

#

dunno how that's related to the HashMaps were talking about..

jade abyss
#

That wasn't the question.

queen cargo
#

You could Auto convert with Arrays πŸ€·β€β™‚οΈπŸ€·β€β™‚οΈ

still forum
#

Okey the answer to your question is No. That's an array, not a hashmap

little raptor
jade abyss
#

Your result was [[2,"test"],[1,"test"],[3,"test"],[["test",1],"test"]], i was asking to confirm, that the array stuff wouldn't work.

little raptor
#

to avoid set

still forum
#

His question doesn't really say what the question is.

jade abyss
#

More or less, Leo

still forum
#

Yes I have a script that spits out an array. I don't see why a hashMap access command would work on an array

#

If you are asking if you can create a hashmap by yourself, insert values from an array and then call get on the hashmap, yes you can

jade abyss
#

Yes I have a script that spits out an array.
Something you know, and i don't.

still forum
#

yes you do

#

just read the script

jade abyss
#

Now i do.

still forum
#

its a forEach loop that does a pushBack into an array

jade abyss
#

How should i know how it looks "before", when the forEach normaly uses arrays?

still forum
#

wha

#

you know how
_array = [];
_array pushBack value;

works right?

little raptor
jade abyss
#

Yeps.

still forum
#

But we also discussed above that forEach will support HashMap and how, I thought you read the conversation above now?

jade abyss
#

Nope, doing other things here atm.

still forum
#

notlikemeow Please no ask confusing not clear enough questions that were already answered above

little raptor
jade abyss
#

reading pages of text vs talking with another person here
erm.... prios are set for me.

still forum
#

Yes, but you probably only convert an array to a hashmap once

#

new insert command could get alt syntax, that it inserts from key,value array into hashmap

little raptor
#

maybe string too?!

still forum
#

that way you can also insert from array mid-lifetime without having to create new hashmap

#

yeah that too

little raptor
#

does anyone have an 8k or 4k monitor?
I wanted to ask for a favor

winter rose
#

4K here

little raptor
#

can you take a screenshot of windows color picker and send it to me?!

winter rose
#

Windows?

little raptor
#

yeah

#

paint > edit colors

winter rose
#

like, in MS paint? or Windows main colour, or something else? ok

little raptor
#

thanks!

winter rose
#

may I know why? πŸ˜„

little raptor
#

much better than my 1080p!

#

I wanted to take that rgb color "range" on the right and put it in my mod!

#

for a color picker obviously

#

I just realized that it is pixelated anyway.
So it probably would've looked the same on my monitor if I resized it! πŸ˜„

#

I wanted to create it using controls, but I think 32*32 controls was a little too many! πŸ˜„

still forum
#

nothing some macros can't solve πŸ‘€

winter rose
#

I can stretch the pic to 8K if you want πŸ˜„

little raptor
#

how?

#

right never mind

winter rose
#

you could blur it a bit?

little raptor
#

no that's fine

#

it won't be big enough to be visible

spark turret
#

Make it with a script yourself?
Create image, for i fron 0 to 16000 do
(Setpixelcolor 0,x to x.x.x)

#

That gives you 16 bit colors i believe on the same Resolution

little raptor
#

I mean even Microsoft didn't care that much! πŸ˜„

spark turret
#

Is that script produced?

#

The thing is that the resolution is equal to the amount of colors you have. So if its 8bit color, it ll always look 255 px Resolution :D no matter if 4k or not

little raptor
spark turret
#

Ah alright

graceful kelp
#

Hi im trying to make a script using Trigger ammo so it always delpoys the submunition the approprieate distance from the ground but i cant thing of a way to get the distance from the rocket to the ground and i cant use alt as a trigger because the rocket might be comign in from diffent ellivation meaning different Angles of attack

willow hound
cosmic lichen
astral tendon
#

For some reason, in the object init the systemchat does not work, it does not display with the mission start

#

Is that a intend behavior?

exotic flax
#

It's most likely being called before you can even join the mission.
Try to also use diag_log and see if that is called.

astral tendon
#

were?

#

the init or the debug console?

exotic flax
#

at the same place as where you use systemchat

astral tendon
#

ok

exotic flax
rough scaffold
#

Anybody know if it’s possible to make the drone jamming mechanic from contact DLC work in the main branch of the game?

exotic flax
jade abyss
jade abyss
#

@opal zephyr stop posting your questions in multiple Channels!

opal zephyr
#

Sorry, I saw #arma3_config after I posted it here and thought it would be more appropriate there

jade abyss
#

read #rules regarding crossposting.

sharp skiff
#

is there a way to find out which "states" devices have for example the campfire: What is on or off?

peak thunder
#

Hi guys!
I have a question about the CreateDialog command.
If I enter this command while sitting in an airplane with the engine on, the throttle starts to increase. So the plane started to move.
Any ideas?

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

warm hedge
#

How did you even do?

peak thunder
#

What exactly?

#

I called createDialog inside the plane

#

createDialog "RscDisplayGame" in the Debug console

#

i tried to handle it with setAirplaneThrottle 0 but failed

warm hedge
#

Ah, yeah I can confirm it starts to increase its thrust weirdly. Maybe because of the autopilot when you can't control the plane because a dialog is open, but 100% sure it's not an supposed behavior

peak thunder
#

So bug report confirmed, isn't it? )

#

Thank you for help.)

oblique arrow
peak thunder
#

I suppose it's a Dialog too

warm hedge
#

Suppose both are the same

peak thunder
#

So how can i report the bug?

warm hedge
peak thunder
#

thank you!

warm hedge
#

Make sure you don't duplicate a ticket, search before post

peak thunder
#

didn't find any dialog before

little raptor
#

It's a controlsGroup with this picture in it

#

And the whole thing in a another controlsGroup

peak thunder
oblique arrow
jade abyss
peak thunder
#

@oblique arrow i didn't, because the same tickets already exists.)

oblique arrow
#

Ah, then add a link to the relevant ticket @peak thunder

#

That way its easier for someone to find the ticket rather than needing to search for it for themselves

peak thunder
#

done

#

Thank you for help, guys! :3

oblique arrow
peak thunder
#

Yep, createDisplay works fine!

little raptor
peak thunder
#

But how can i check it opened in code? With createDialog i can use the Dialog command. Any ideas?

#

β€œ_this lazzyMod on”

little raptor
#

!isNull findDisplay IDD

#

another way is the onLoad event handler

peak thunder
#

Exactly! Good point! Thank you kindly!

little raptor
little raptor
robust hollow
#

sure πŸ‘

hybrid dragon
#

O

#

I'm confused as to how you access the parameter values in a event script

#

I've created a onPlayerKilled.sqf and want to use the value of the _oldUnit parameter to evaluate a conditional

robust hollow
#

so it is provided to the script in _this

hybrid dragon
#

what would be the syntax for access that value though?

#

I kind of get thrown off by _this in sqf too, it makes it look like you should be able to use dot notation to access the value of that instance

warm hedge
#

Huh, params just does assign values into the variables. In this case, Just _oldUnit returns the old unit

hybrid dragon
#

like ```sqf
_this._oldunit

or
#

something

warm hedge
#
_this#0```is the old unit
hybrid dragon
#

Oh I see, ```sqf
params

#

like a dictionary or array

warm hedge
#

params isn't a data type, but a command

hybrid dragon
#

Is there a better write up for the syntax of sqf for somebody who knows how to program anywhere?

#

The wiki is kind of a mess

warm hedge
hybrid dragon
#

I'll just re-read the page

#

I just disliked the style that it was written in lol

robust hollow
#

the pages say basically everything worth knowing

warm hedge
#

I'm a poor guy so didn't even experienced other languages than SQF, but I'd say I agree πŸ˜„ I feel SQF is a really strange language, especially when I look up into a β€œproper” language's code

hybrid dragon
#

The write up on the wiki is just written in kind of poor English

warm hedge
#

Not everyone is native Englishman, mate...

little raptor
warm hedge
#

setDammage Buldozer πŸ˜„

hybrid dragon
#

is the ```sqf
_var

just a style convention?
winter rose
#

@hybrid dragon but yeah, if you have any ideas to improve the wiki, please send your input in the #community_wiki channel πŸ™‚

hybrid dragon
#

I might do a little write up when I understand SQF better

#

I really wasn't trying to be rude

winter rose
#

np then πŸ˜‰
the underscore means something; see the Identifier page

hybrid dragon
#

ok I see

#

does .sqf have any sort of automatic garbage collection?

winter rose
#

yep

#

local vars are auto killed at the end of their scope

#

(btw the Variable(s?) page has a nice illustration for that)

hybrid dragon
#

"A global variable is visible from all scripts on the computer on which it was defined. Names given to units in the Mission Editor are also global variables pointing to those units, which may not be redefined or modified.

#

So can you not have the names of a unit be repeated across missions?

#

Surely that's not the case

robust hollow
#

not in the same mission

hybrid dragon
#

so is a global variable in scope for the mission then?

#

as in that's the highest level scope that a user-defined variable can exist?

winter rose
#

No, there are other namespaces

#

but you then have to use setVariable on them

robust hollow
#

depends how you look at it. local variables exist within the script scope. global variables exist inside the missionNamespace (usually, wiped on mission exit), uiNamespace exists until the game exit, profileNamespace exists even after game restart (saved to file)

hybrid dragon
#

The local variable definition is very clear, I found the page on namespaces too

#

Sorry for asking so many dumb questions

winter rose
#

nope, beginners questions and we are glad to help

#

"there are no stupid questions, only stupid people" I don't know if it is also an English saying πŸ˜‹

little raptor
#

question about __EVAL and __EXEC:
I'm assuming I can't have , in the expression. What if I did this?

__EVAL(call compile "'9999' getTextWidth ['EtelkaMonospacePro', 0.75 * ((safezoneW / safezoneH) min 1.2) / 30]");

is it valid?

robust hollow
#

pretty sure you can use ,

little raptor
#

I think Dedmen said you can't

robust hollow
#

you cant use () inside __EXEC though i think

#

actually that might be eval, i used to toArray my code to get around the () issue in eval

hybrid dragon
#

are there not escape characters?

winter rose
#

what for?

hybrid dragon
#

Say you wanted to print a hint that had a quote

cosmic lichen
#

Well we have \n, but it doesn't work everywhere I believe

hybrid dragon
#

is that not the newline character?

winter rose
#

double quote, or use single quote to define the string

#
hint 'hello "friend"';
// or
hint "hello ""friend""";
robust hollow
# little raptor question about `__EVAL` and `__EXEC`: I'm assuming I can't have `,` in the expre...

__EXEC doesn't like round brackets () inside expressions. If you need to have grouping, perhaps you could calculate values inside the brackets separately and assign to local variables
https://community.bistudio.com/wiki/PreProcessor_Commands#EXEC

__EVAL doesn't like curly brackets {}, if you need to have code in your expression use compile String instead
https://community.bistudio.com/wiki/PreProcessor_Commands#EVAL

doesnt say anything about ,

little raptor
#

toString [13,10] gives you "\r\n"

#

toString [10] is \n

winter rose
#

endl?

little raptor
#

anyway,
is this valid?

__EXEC(_editWidth = call compile "'9999' getTextWidth ['EtelkaMonospacePro', 0.75 * ((safezoneW / safezoneH) min 1.2) / 30]")
little raptor
#

not string

winter rose
#

I think there was something else then

#

(but as you said, anyway ^^)

little raptor
winter rose
#

yes both these two ^^ I so much don't use them, sooo…

hybrid dragon
#

the scripting language is a lot more powerful than I would have assumed though

#

πŸ’ͺ

#

Having a lot of fun

little raptor
#

another question guys:
is this valid?

w = ... + __EVAL(_var);
#

I'm assuming it is right?

past tiger
#

Bad codes from Pico:

My_fnc = {call My_fnc;};
call My_fnc;```
I did something like that acidentally ![notlikemeow](https://cdn.discordapp.com/emojis/700311897937018890.webp?size=128 "notlikemeow")
robust hollow
#

and your earlier __EXEC errors

little raptor
#

because of ,?

robust hollow
#
19:29:18 Error in expression <_editWidth = call compile "'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error position: <"'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error Missing ""
19:29:18 Error in expression <_editWidth = call compile "'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error position: <"'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error Missing ""
19:29:18 Error context .2) / 30]")
19:29:18 Warning Message: File d:\users\connor\documents\arma 3\missions\_debug.vr\description.ext, line 0: '.min': '1' encountered instead of '='
19:29:18 Warning Message: Config : some input after EndOfFile.
19:29:18 Error in expression <_editWidth = call compile "'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error position: <"'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error Missing ""
19:29:18 Error in expression <_editWidth = call compile "'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error position: <"'9999' getTextWidth ['EtelkaMonospacePr>
19:29:18   Error Missing ""
19:29:18 Error context .2) / 30]")
19:29:18 Warning Message: File d:\users\connor\documents\arma 3\missions\_debug.vr\description.ext, line 0: '.min': '1' encountered instead of '='
19:29:18 Warning Message: Config : some input after EndOfFile.
little raptor
#

oh!

robust hollow
#

__EXEC doesnt like ()

little raptor
#

my bad!

#

I figured it'd be ok if I put it in string!

robust hollow
#

it should work if you take it out of the string and use the macro for ((safezoneW / safezoneH) min 1.2)
nope

little raptor
#

That's weird.
Anyway, I think it'd be better if I just did this (in debug console)

('9999' getTextWidth ['EtelkaMonospacePro', 0.75 * ((safezoneW / safezoneH) min 1.2) / 30])/(((safezoneW / safezoneH) min 1.2) / 40)

and put the result as:

res * ((safezoneW / safezoneH) min 1.2) / 40

in my config

robust hollow
#

the width might change on different ui scales/sizes no?

#

you can put gettextwidth directly in the config calculation

little raptor
#

yeah but I was trying to make it faster!

#

also avoid the " "

robust hollow
#

mmm, well, the ugly toArray option is always available πŸ˜›

little raptor
#

so you mean:

call compile toString array

?

robust hollow
#

yea, to use code with () in __EXEC. though i wouldnt recommend it as it is inconvenient to edit

little raptor
#

it scales somewhat properly according to my tests

#

but I only tested the interface sizes.

#

not sure about aspect ratios (I only have a 16:9 monitor)

robust hollow
#

yea, my point was if you do it once in debug and put the result directly in the calculation it wouldnt be correct for people using a different ui size/aspect/resolution

little raptor
#

yeah but I also scale the font too (using that expression)

sizeEx = 0.75 * ((safezoneW / safezoneH) min 1.2) / 30;
#

It would indeed not be accurate

#

but works as an approximation doesn't it?

robust hollow
#

depending on the aspect ratio i suspect it could be considerably off. only for what you were suggesting here though
#arma3_scripting message

cosmic lichen
#

Why use GUI grid and not UI_GRID (pixelGrid)?

little raptor
#

I've never used it so I'm not familiar with it

robust hollow
#

you're missing out. i find pixelGrid much nicer to work with.

little raptor
#

oh no! notlikemeowcry
that is definitely much more convenient!
I wish I'd used that sooner!

cosmic lichen
#

Should be easy to convert.

real tartan
#

where should I put this? It says that is have a local effect. So init.sqf or initPlayerLocal.sqf or initServer.sqf or some combination? (using it on dedicated server)

addMissionEventHandler ["EntityKilled", {
    params ["_unit", "_killer", "_instigator", "_useEffects"];
];
still forum
# little raptor question about `__EVAL` and `__EXEC`: I'm assuming I can't have `,` in the expre...

hacky.. yeah should work, it shouldn't look inside strings, but maybe it does, it was never built for such shenanigans. You can also call script functions from there if they were compiled before the config entry is parsed.
like calling mod function from uiNamespace in description.ext

Btw if you have a number entry, you don't need/want __EVAL.
if you do it in a config that will be binarized, you get the wrong numbers out of the getTextWidth.
If its unbinarized, you can just use a string.

robust hollow
real tartan
#
addMissionEventHandler ["EntityKilled", {
    params ["_unit", "_killer", "_instigator", "_useEffects"];

        if (faction _unit in ["OPF_F", "IND_F", "BLU_F"]) then 
        {
            removeAllWeapons _unit;
            removeAllItems _unit;
            removeAllAssignedItems _unit;
            clearMagazineCargo _unit;
            deleteVehicle (nearestObject [_unit, "WeaponHolderSimulated"]);
        };
    }
];
robust hollow
#

missing a semicolon on the clearMagazineCargo line

#

because some of those commands require a local argument and others have a local effect, I'd say you'd be right to add it to players and the server, and do a

if local _unit then {
    removeAllWeapons _unit;
    removeAllItems _unit;
    removeAllAssignedItems _unit;
    clearMagazineCargo _unit;
    deleteVehicle (nearestObject [_unit, "WeaponHolderSimulated"]);
} else {
    clearMagazineCargo _unit;
};```
or something like that.
little raptor
still forum
#

number values get evaluated when they are read

#

scope = "if (isClass configFile 'cba_main') then {2} else {0}"

#

stuff like that

little raptor
#

so I should make them strings?

still forum
#

if they are numbers, you could yeah

#

they should only be evaluated once when the UI opens, if you're doing UI stuff there

little raptor
#

if you're doing UI stuff there
yeah. what about something like this?

w = ((safezoneW / safezoneH) min 1.2) / 40;
#

it does have some other stuff too

#

besides numbers

still forum
#

its a script

#

w = "((safezoneW / safezoneH) min 1.2) / 40";

little raptor
#

It works just like that

#

in description.ext

#

not need to make it a script (string)

#

you mean it doesn't work in config.cpp?

still forum
#

it works in both

willow hound
#

I think it should, if you don't use absolute values for x, y, w, h they are represented like that (safeZone * 42) without "" too.

still forum
#

the quotes around it are added automatically if you don't put them there

#

but I prefer not to rely on it doing that properly

little raptor
#

so the expression will be evaluated every time? that's actually a good thing (because of ui changes)

still forum
#

everytime it evalue is read

#

it doesn't cache the result

jade abyss
#

Yeps

still forum
spark turret
#

Check if line interesects with each plane of the bounding box

#

Thats highschool math

still forum
#

any plane* ?

#

each plane won't ever happen

spark turret
#

Yeah,any

#

By checking collison with each plane, if any returns true => interesects

still forum
#
HashMap = createHashMap;
HashMap set ["test", "testval"];
HashMap set ["ref", HashMap];

You want to do bad, you get bad πŸ‘€
[["ref",!!HashMap circular reference!!],["test","testval"]]

little raptor
#

!!HashMap circular reference!!
what's that? is that an error?

#

because I think it shouldn't work like that

still forum
#

It handles circular reference and prints you an error.
Instead of the way Arrays work by doing expensive checks on every insert and crashing if it detects a circular reference.
You'll probably still get crashing or atleast offensive warning messages in your face, but no performance impact on insert

willow hound
#

Out of interest: What hash function are you using?

still forum
#

FNV-1A 64bit

still forum
queen cargo
#

i like dat

rocky mortar
#

yes nice πŸ˜„

spark turret
#

Is the hashmap a pure for-fun thing for sqf or will it go into the arma engine -> potentially speeding up things in there?

still forum
#

Why would I work on a pure for-fun thing all day while I'm at work, and while I already built the exact same thing for fun over a year ago πŸ€”

winter rose
#

cause you funny

exotic flax
#

because actual "features" don't need work, only new "bugs" need to be implemented 🀣

spark turret
#

Yeah well idk. Maybe bohemia has a policy that 25% of worktime employees should do what they want to encourage creativuty

#

Like google

#

Idk

oblique arrow
#

Maybe bohemia has a policy that 25% of worktime employees should do what they want to encourage creativuty
Then Dedmen would props just switch from one arma project to another heh

spark turret
#

You mean arma 4? πŸ‘€

austere granite
#

<Insert going back and forth 10 more times with this cool kitty, but ill not to do that to not annoy everyone>

exotic flax
#

warning Dedmen, posting images in wrong channel
warning Dedmen, posting off-topic content

#

πŸ˜‡

still forum
#

"posting images in wrong channel" thats not a thing
"posting off-topic content" you started reee

still forum
#
Circular reference found in HashMap, this will cause a memory leak!
  βž₯ Context: Hash Key: "ref" <- Serialize Game Variable: hashmap

I hope getting this as a popup in your face, even telling you the path to get to the circular reference, will deter people from doing that wrong :u

winter rose
#

question, why would it be a bad thing? an array cannot reference itself?

#

or only on print (which would then be understandable)

still forum
#

memory leak, it cannot delete itself because there is always a reference to it (being itself)

#

It even says that in the message notlikemeow

winter rose
#

not the delete paaaart :U

#

well, fix the memory allocator for cleaning self-references before deletion then!

still forum
#

memory allocators don't clean stuff

jade abyss
winter rose
#

the whatever magic stuff duuu eeet

jade abyss
winter rose
#

NAO

still forum
#

Only need to add support for some more key types and then it should be done :3

winter rose
#

zo, which items? πŸ˜‹ @bold mica

bold mica
#

stuff in UAS like the god awful rifle grenades

#

like items you can grab from arsenal

winter rose
#

I don't know "UAS"?

bold mica
#

universal ammo system

#

its a mod

winter rose
#

oh, ok
well you can filter arsenal items per-mission in description.ext iirc (or whitelist, I don't remember)

bold mica
#

arsenalRestrictedItems[] = { "U_B_Soldier_VR" };?

#

where do i put that?

winter rose
#

in the mission's description.ext file

bold mica
#

just make a new line and add that in?

winter rose
#

add the class of the item you want to blacklist

bold mica
#

okie

queen cargo
#

Arma just needs proper gc instead of refcounting πŸ€ͺπŸ€ͺπŸ€ͺ

#

And SQC instead of sqf
Tho.. Binarizing scripts would be enough to get sqc working too 🀫🀫

analog walrus
#

Okay very quick question

player addScore

Working for server host, not working for server client, what do?

spark turret
#

Remoteexec

#

Assuming that its a local commans

willow hound
analog walrus
#

Fair enough

willow hound
#

Solution remains the same, use remoteExec to run it from a client machine if you need to.

fiery orbit
#

I believe I am struggling to write a proper return statement in my function. I am currently utilizing a test function to check whether or not I am doing things correctly
My current bit is:

private _pos1 = call llama_fnc_testReturn;

The function it calls is:

private _pos1 = position Patrol_1A;
exitWith{_pos1;};

What am I doing wrong here?

willow hound
#

There is only one way to use exitWith:

if (...) exitWith {...};
```What you need in `llama_fnc_testReturn` is simply:
```sqf
position Patrol_1A
```Or alternatively:
```sqf
private _pos = position Patrol_1A;
_pos
```The value of the last executed line is the return value in SQF; usually written without `;` at the end.
fiery orbit
#

So if I do a:

if(_letter isEqualTo "A") exitWith{position Patrol_1A};

would that happen to work?

willow hound
#

Yup

fiery orbit
#

thank you

hybrid dragon
#

what exactly am I doing wrong here? This is onPlayerKilled.sqf

if (_this#0 == playerC) then {
    []spawn BIS_fnc_fadeEffect;
    [1] spawn BIS_fnc_fadeEffect;
    selectPlayer silentSniper;
    10 fadeMusic 0;
    playMusic "";
    call populate_tasks
} else {
    "end1" call BIS_fnc_endMission;
};
#

calling the function with an empty array as the parameter so that it populates with the default fields also does not end the mission if you're playing as the "silent sniper" character

#

oh actually I see lmao

#

Nope, I thought maybe it was just that I forgot to terminate a statement properly

still forum
#

what is the default for _this#0 ?

#

nvm, onPlayerKilled.

playerC is not nil right?

robust hollow
#

unless you define default values, calling it with an empty array will mean it has no values... so _this#0 doesnt exist

drifting sky
#

Is it possible to left justify hints?

robust hollow
#

as in the text or the control on the screen?

drifting sky
#

hint text

robust hollow
#

hint "<t align='left'>your hint</t>" should do the job

#

maybe parsetext first

#

hint parsetext "<t align='left'>your hint</t>"

#

yea, parsetext first πŸ‘

drifting sky
#

by the way i'm talking arm2oa in game hints

robust hollow
#

give it a test, im pretty sure ive seen stylised hints in a2 before.

drifting sky
#

do you need a special command to display parsed text?

willow hound
robust hollow
drifting sky
#

can you mix parsed and non parsed text?

#

into a single string

robust hollow
#

sort of. it all comes out parsed in the end but you can use composeText with setAttributes on specific text elements inside the compseText array to have some stylised text and other "plain" text.

#

ill get an example

#
composeText [
  text "first text" setAttributes ["color","#FF0000"],lineBreak,
  "second text which allows 'bad' characters such as & (would usually break structured text)",lineBreak,
  text "third text" setAttributes ["size","1.5","color","#00FF00"]
] setAttributes ["align","left"];```
#

so you can apply styling to individual segments and to the parsed text as a whole

drifting sky
#

parsetext is removing \n line breaks

robust hollow
#

change them to <br/>

drifting sky
#

Yes, that seems to work. Thank you.

exotic flax
#

I use something like this:

_result = 123;
hint parseText format ["<t color='#ff0000'>some text</t><br/>some other text &amp; even more<br/><br/>result: %1", _result];

and there are no "bad" characters if you use proper encoding πŸ˜‰

robust hollow
#

ive had issues with characters from other languages (russian, chinese) so it is easier to use the raw text in composeText rather than replacing substrings. especially for the frequency in which one of my mods would be doing it. and because the text it displays is player input it isnt easy to have a replacement for every possible bad char.

#

also avoids needing to filter out player inputted style tags

winter rose
#

forceUnicode soon\β„’

robust hollow
#

that wouldnt have an effect on structured text though would it?

still forum
#

dont think so no

#

maybe we can add unicode support for structured text tho, dunno. But don't think we did

robust hollow
#

i wouldnt expect it to, seeing as it is for strings and the bad char issue is specifically to do with the structured text side of parseText.

fiery orbit
#

I'm having an error thrown saying that _posReturn is undefined, what am I doing wrong?

private _posReturn = [_ID,_Letter] call llama_fnc_returnObjectPos;
_posArray  pushBack _posReturn;
winter rose
#

seems that the function returns nil?

fiery orbit
#

I ran with a testing function that doesn't return nil and I have the exact same issue

robust hollow
#

is that snippet the exact code you're using?

fiery orbit
#

yes

robust hollow
#

is _ID, _Letter and _posArray defined? also are there any other errors? if it were done right that snippet would work.

fiery orbit
#

_ID and _letter work

#

and I defined

_posArray = [];
``` earlier
#

sorry, ```sqf
private _posArray = [];

robust hollow
#

and are there any other errors or is _posReturn is undefined the only one?

fiery orbit
#

just _posReturn

#

I can obtain a count from _posArray

robust hollow
#

is the function defined? and in the same namespace the code is executing? also how are you executing the code (eg init files, evh, etc)

fiery orbit
#

it itself is a function

spark turret
#

if you try to call an undefined function, it tells you in the rpt

#

"undefined etc"

robust hollow
#

my logic being if the function isnt defined, it will error but the _posReturn error would override it ingame so you only see that. if the function is defined, you may be executing in a different namespace (unlikely).

serene quiver
#

Hello guys, I have this old script (not mine)
https://sqfbin.com/enumahikacehonadofuk
is part of a dialog that allows to place a tablet near a door and use it as a keypad. It throws this error:

`1:30:27 Error in expression <_doorList;

_tempSel = _doorList select _index;
_closestDoor = _tempSel select 0>
1:30:27 Error position: <_index;
_closestDoor = _tempSel select 0>
1:30:27 Error Undefined variable in expression: _index`

#

How to fix?Thank you

robust hollow
#

exit if index is nil after the foreach (L28). or set a default value but i imagine that wouldnt be ideal for what that script is doing.

#

also _keypad isnt defined on line 1, so it doesnt know what building to use

exotic flax
#

looks like the closest building doesn't have a door, so it will not be able to return a valid index πŸ€·β€β™‚οΈ

serene quiver
#

@robust hollow it's defined in another script..

tablet = "Land_Tablet_01_F";
_objects = allMissionObjects _tablet;
{
    null = [_x] execVM "kitty_lockFolder\setupKeypads\setup.sqf";
} forEach _objects;```
robust hollow
#

in a parent scope?

serene quiver
robust hollow
#

you should really provide _keypad as an argument, just for the sake of using best practice.

fiery orbit
#

function is defined properly, as hints built into it for debugging are going off exactly as they should

serene quiver
#

sorry..while copy/paste I left this out in the SQFbin link

#

_keyPad = (_this select 0);

exotic flax
#

wonders how many different L*fe Frameworks we already build in this channel

serene quiver
#

is at the top of the script

spark turret
#

I dont mind if the people are trying to figure it out themselves :)

robust hollow
spark turret
#

Script-spoonfeeding-parasites never stay long

fiery orbit
#

@robust hollow
my testing one which executes in the same way as the full function is:

private _pos1 = position Patrol_1A;
if(true) exitWith{_pos1};
robust hollow
#

is Patrol_1A defined?

fiery orbit
#

except the full one has a longer list of if statements

spark turret
#

No need for exitwith

fiery orbit
#

yes

spark turret
#

Last value will be returned anyways

fiery orbit
#

its a helipad on the map

robust hollow
exotic flax
fiery orbit
#

the problem is that the issue persists in both the tester and the full up function

balmy reef
#

how do I find people to play arma?

fiery orbit
#

but doesnt if I were to hardcode within the main function

exotic flax
spark turret
balmy reef
#

kk

robust hollow
fiery orbit
#

okay thanks for the help

#

ill see if I can place the fullup function

spark turret
#

Sqf bin ;)

fiery orbit
#

This is the full script i'm currently running for testing purposes

private _posStation = position Station_1;
private _stationID = 1;
private _size = 1;

private _group = createGroup west;
"B_GEN_Soldier_F" createUnit [_posStation, _group, "SERGEANT"];
"B_GEN_Soldier_F" createUnit [_posStation, _group];
"B_GEN_Soldier_F" createUnit [_posStation, _group];
"B_GEN_Soldier_F" createUnit [_posStation, _group];

_group setBehaviour "SAFE";
_group setSpeedMode "LIMITED";
_group setFormation "File";

private _stationLetterArray = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"];

private _posArray = [];

for[{private _count = 0}, {_count < _size*6}, {_count = _count + 1}] do 
{
    private _stationLetter = _stationLetterArray select _count;
    private _posReturn;
    _posReturn = call llama_fnc_testReturn;
    _posArray  pushBack _posReturn;
};

_posArray = _posArray call BIS_fnc_arrayShuffle;

//this is what will actually be used once the looping part is fixed
//private _pos1 = _posArray deleteAt 0;
//private _pos2 = _posArray deleteAt 0;
//private _pos3 = _posArray deleteAt 0;
//private _pos4 = _posArray deleteAt 0;
//private _pos5 = _posArray deleteAt 0;

//this is for testing purposes
private _pos1 = call llama_fnc_testReturn;
private _pos2 = call llama_fnc_testReturn;
private _pos3 = call llama_fnc_testReturn;
private _pos4 = call llama_fnc_testReturn;
private _pos5 = call llama_fnc_testReturn;

private _wp1 = _group addWaypoint [_pos1, 0.1];
private _wp2 = _group addWaypoint [_pos2, 0.1];
private _wp3 = _group addWaypoint [_pos3, 0.1];
private _wp4 = _group addWaypoint [_pos4, 0.1];
private _wp5 = _group addWaypoint [_pos5, 0.1];
_wp5 setWaypointStatements ["true", "{deleteVehicle _x} forEach thisList"];

spark turret
#

Sqf bin 😒

robust hollow
#

it doesnt return an array

fiery orbit
#

this is the llama_fnc_testReturn;

private _pos1 = position Patrol_1A;
if(true) exitWith{_pos1};
robust hollow
#

oh

#

private _posReturn;

#

line 22

spark turret
#

Call the function from debugconsole and print return to systemchat.

robust hollow
#

should shrink it to ```
private _posReturn = call llama_fnc_testReturn;

fiery orbit
#

okay

#

I was still having issues even with that switch

robust hollow
#

mmhm, well the way you have it is not a valid way to use private so thats one issue out of the way.

fiery orbit
#

okay

robust hollow
#

you should test after fixing it to see if anything new happens

spark turret
#

Can functions be called without input parameter?

robust hollow
#

yes

spark turret
#

Llama where exactly does your code break

fiery orbit
#

_posArray pushBack _posReturn;

#

I fixed it and the test function succeeded

#

which means that the error is now in the exitWith of my actual function

#
private ["_stationID", "_stationLetter"];
private _stationID = _this select 0;;
private _stationLetter = _this select 1;

if(_stationID isEqualTo 1) then 
{
    if(_stationLetter isEqualTo "A") exitWith {position Patrol_1A;};
#

I've already run checks to confirm it gets to an runs the exitWith

#

now I need to rewrite it so that it doesn't throw and error

spark turret
#

You dont give back any return value if stationId != 1

#

Which will throw an error

fiery orbit
#

but I know from previous tests that stationID is 1

spark turret
#

Alright

fiery orbit
#

I have replaced the exitWith statement with a hint of "in the exit with for 1A" and gotten it consistently

spark turret
#

Call the function fron the debug console and print its result

drifting sky
#

Arma2OA can you do forEach for each instance of a class of object?

fiery orbit
#

how do I print the result?

robust hollow
#

just call it in debug and see what it says in the return box

exotic flax
#

eg. ```sqf
{
// do something with house object
// _x = actual object
// _forEachIndex = current index
} forEach ([0,0,0] nearObjects ["House", 40000]);

fiery orbit
#

just slap this into the editor and hit local exec?

[1,"A"] call llama_fnc_returnObjectPos;
robust hollow
#

yea

fiery orbit
#

because if so, Im not getting anything

robust hollow
#

what if you just local exec llama_fnc_returnObjectPos

#

does it return code?

fiery orbit
#

yes

robust hollow
#

ok, so the issue is 100% in that function. was this exactly what the function is, or is there more?
#arma3_scripting message

#

actually, also local exec Patrol_1A to see if it returns whatever it is supposed to be

exotic flax
#

private _stationID = _this select 0;; notice the double semicolon...

robust hollow
#

shouldnt be the cause any issues though

fiery orbit
#

when i slap a hint into the exit with for 1A, it pops out just fine after executing

hint "test complete";
robust hollow
#

local exec Patrol_1A to see if it returns whatever it is supposed to be

fiery orbit
#

just gives me Patrol_1A back

#

using my tester I have found that:

private _pos1 = position Patrol_1A;
if(true) exitWith{_pos1};
```works but:
```sqf
if(true) exitWith{position Patrol_1A;};
```does not
#

how would I maintain the integrity of my if statements whilst also getting a successful return?

robust hollow
#

well that makes no sense at all πŸ€”

serene quiver
# robust hollow ok, so i'd add a `if isNil "_index" exitWith {};` after the foreach on line 28

@robust hollow Thanks..that stopped the error...but the script also stop right there. It tells me that is not reconnning the doors...but the funny thing is that in the demo mission it works.Import in my mission,same house, same everything..and it thrown doors errors..it may be conflicting with some other thing..

2:31:22 Error in expression <kDoor = format ["bis_disabled_Door_%1", _doorNumber]; _closeDoor = format ["Door> 2:31:22 Error position: <_doorNumber]; _closeDoor = format ["Door> 2:31:22 Error Undefined variable in expression: _doornumber

fiery orbit
#

this works though:```sqf
if(true) exitWith{Patrol_1A};

robust hollow
robust hollow
fiery orbit
#

Patrol_1A is a helipad I have placed on the map

#

everything checks out when I utilize my test function to return Patrol_1A but as soon as I move over to my full function whose if statements I have confirmed work I all of a sudden cannot get a return whilst still using the exact same syntax

drifting sky
#

Arma2OA is there a way to temporarily disable a trigger?

robust hollow
drifting sky
#

Arma2OA is it possible to set the pitch at which an AI unit will watch... i.e. elevation above or below the horizon.

fiery orbit
#

Based off testing, i have found that this:

//works
if(true) exitWith{Patrol_1A};
//works
if(true) then
{
  if(true) exitWith {Patrol_1A};
};
//doesn't work
if(true) then
{
    if(true) exitWith {Patrol_1A};
    if(_stationLetter isEqualTo "B") exitWith {Patrol_1B};
    if(_stationLetter isEqualTo "C") exitWith {Patrol_1C};
    if(_stationLetter isEqualTo "D") exitWith {Patrol_1D};
    if(_stationLetter isEqualTo "E") exitWith {Patrol_1E};
    if(_stationLetter isEqualTo "F") exitWith {Patrol_1F};
    if(_stationLetter isEqualTo "G") exitWith {Patrol_1G};
    if(_stationLetter isEqualTo "H") exitWith {Patrol_1H};
    if(_stationLetter isEqualTo "I") exitWith {Patrol_1I};
    if(_stationLetter isEqualTo "J") exitWith {Patrol_1J};
    if(_stationLetter isEqualTo "K") exitWith {Patrol_1K};
    if(_stationLetter isEqualTo "L") exitWith {Patrol_1L};
    if(_stationLetter isEqualTo "M") exitWith {Patrol_1M};
    if(_stationLetter isEqualTo "N") exitWith {Patrol_1N};
    if(_stationLetter isEqualTo "O") exitWith {Patrol_1O};
    if(_stationLetter isEqualTo "P") exitWith {Patrol_1P};
    if(_stationLetter isEqualTo "Q") exitWith {Patrol_1Q};
    if(_stationLetter isEqualTo "R") exitWith {Patrol_1R};
    if(_stationLetter isEqualTo "S") exitWith {Patrol_1S};
    if(_stationLetter isEqualTo "T") exitWith {Patrol_1T};
    if(_stationLetter isEqualTo "U") exitWith {Patrol_1U};
    if(_stationLetter isEqualTo "V") exitWith {Patrol_1V};
    if(_stationLetter isEqualTo "W") exitWith {Patrol_1W};
    if(_stationLetter isEqualTo "X") exitWith {Patrol_1X};
}
robust hollow
#

shrink that down to missionNamespace getVariable ["Patrol_1" + _stationLetter,objNull] get rid of each individual exit with

fiery orbit
#

okay

cerulean cloak
#

So I’m trying to create a briefing on the map screen using createDiaryRecord and was watching a video on how to add images (https://youtu.be/XJlCAEYs2uo?t=380) the video says it should be about 350px wide to fit in the briefing tab on the map. However, despite my image only being 240px wide it still extends out of the tab (https://imgur.com/gallery/cwvaxnU) can anyone please tell me what on Earth I’ve done wrong?

#

player createDiaryRecord ["Diary", ["Intel", "
<br /><img image='images\Int_1.jpg'/>
Fig. 1. Image released by the Russians showing the target, Igor Velinov, in their prison.
<br />
<br /><img image='images\Int_2.jpg'/>
Fig. 2. Satellite image taken earlier today showing the prison complex itself.
"]]; ``` There's the code I'm using also
robust hollow
#

if you edited the image after loading it ingame, you will need to restart before you can see the changes

#

otherwise, you might be able to use the size attribute to shrink the image

cerulean cloak
#

Ah, thanks. If I change the image name to something else would that work too?

robust hollow
#

yes

fiery orbit
#

@robust hollow thanks for the help, that fixed the issues

cerulean cloak
drifting sky
#

Arma2OA are there file read / write functions?

hybrid dragon
#

The mission will not end

#

The first part worlds as intended

leaden summit
#

Just putting together a intro script and part of it is driving me nuts. I have SQF 2 cutText [format ["<t color='#ffffff' size='4' face='LCD14' align='center' shadow='0'>%1</t>", _missionName ],"PLAIN",-1,true,true]; sleep 6; 3 cutText [format ["<t color='#ffffff' size='.8' face='LCD14' align='center' valign='bottom' shadow='0'>%1</t>", _quote ],"PLAIN",-1,true,true];
Now the mission name comes up nicely in the centre of the screen, but the quote (despite valign='bottom') actually appears slightly above the mission name. I want it along the bottom of the screen.

Any ideas?

robust hollow
#

remove valign and try "PLAIN DOWN"

leaden summit
#

Oh of course... the easy solution πŸ˜‚ shows I've been staring at things for far to long.
Thanks for that

little raptor
#

Reading the files in the mission folder or mods is possible with loadFile

little raptor
little raptor
real tartan
#

trying to filter out all Arma 3 classes, so only mods will return. Any idea how to improve it ?

private _list = "true" configClasses (configFile >> "CfgPatches") apply { configName _x };
private _list = _list select { !(["A3", _x] call BIS_fnc_inString) && { !(["CuratorOnly", _x] call BIS_fnc_inString) } };
copyToClipboard str _list;
little raptor
#

filter by author maybe?

#

also you can make that faster:

#
_list = [];
"_name = configName _x; !('a3' in toLowerANSI _name) && {-1 == _list pushBack _name}" configClasses (configFile >> "CfgPatches")
robust hollow
#

that is a bit over complicated

Result:
10.6809 ms

Cycles:
94/10000

Code:
_list = []; 
"_name = configName _x; !('a3' in toLowerANSI _name) && {-1 == _list pushBack _name}" configClasses (configFile >> "CfgPatches")
Result:
9.83333 ms

Cycles:
102/10000

Code:
"!('a3' in toLowerANSI configName _x)" configClasses (configFile >> "CfgPatches") apply {configname _x};```
little raptor
#

another thing you can add is:

configSourceAddonList _x findIf {"a3" in toLowerANSI _x} == -1
little raptor
#

select

#

it joins both loops into one. so possibly 2 times faster

robust hollow
#

i'm only referring to your snippet

little raptor
#

yes:
his:

private _list = "true" configClasses (configFile >> "CfgPatches") apply { configName _x };
private _list = _list select { !(["A3", _x] call BIS_fnc_inString) && { !(["CuratorOnly", _x] call BIS_fnc_inString) } };

mine:

_list = [];
"_name = configName _x; !('a3' in toLowerANSI _name) && {-1 == _list pushBack _name}" configClasses (configFile >> "CfgPatches")
#

both do the same thing (I left out the "bad" parts)

robust hollow
#

and im saying your snippet is over complicated (pushback). the faster of the two results here does the same thing
#arma3_scripting message

little raptor
#

oh, ok

#

I thought it was the same old one!

#

I can't read without syntax highlighting! πŸ˜„

cosmic lichen
#

Also check if condition && {} is slower than condition && condition. In many cases the first method is slower

real tartan
#

well, I got multiple conditions

#
private _all = "true" configClasses (configFile >> "CfgPatches") apply { configName _x };
private _list = _all select { !(["A3", _x] call BIS_fnc_inString) && { !(["A3", _x] call BIS_fnc_inString) } && { !(["cba_", _x] call BIS_fnc_inString) } && { !(["ace_", _x] call BIS_fnc_inString) } };
copyToClipboard str _list;
robust hollow
#

you might consider this as it is faster

private _all = "true" configClasses (configFile >> "CfgPatches") apply { configName _x };
private _list = _all select { 
    private _config = toLower _x;
    ["a3","curator","3den","cba_","ace_"] findIf {_config find _x == 0} == -1
};
little raptor
#

it's an if

robust hollow
#

yours:

Result:
22.1522 ms

Cycles:
46/10000

Code:
private _all = "true" configClasses (configFile >> "CfgPatches") apply { configName _x }; 
private _list = _all select { !(["A3", _x] call BIS_fnc_inString) && { !(["A3", _x] call BIS_fnc_inString) } && { !(["cba_", _x] call BIS_fnc_inString) } && { !(["ace_", _x] call BIS_fnc_inString) } };

mine:

Result:
13.48 ms

Cycles:
75/10000

Code:
private _all = "true" configClasses (configFile >> "CfgPatches") apply { configName _x }; 
private _list = _all select {  
 private _config = toLower _x; 
 ["a3","curator","3den","cba_","ace_"] findIf {_config find _x == 0} == -1 
}; 
little raptor
#

this will give you the best results:

"!('a3' in toLowerANSI configName _x) && {configSourceAddonList _x findIf {'a3' in toLowerANSI _x} == -1}" configClasses (configFile >> "CfgPatches") apply {configname _x};
#

unless the pbo is encrypted

#

"a3","curator","3den"
because I'm not sure if all A3 addons necessarily start with/contain these (there could be more)

#

also, since other people might name their mods in a way that it contains these words, it could filter out non-vanilla mods too

#

toLower
no need. use toLowerANSI (2x faster)

ember path
#

why isnt this..working

if ("t1" call BIS_fnc_taskCompleted) then {radioJammer = [[jammer1], 1000, 50, TRUE] execVM "TFARjamRadios.sqf"};
#

previously this was just the radioJammer= part in initplayerlocal

#

its for a radio jamming script, but i want it to activate once a certain task is completed

little raptor
#

and I'm not sure about locality of tasks, so you might wanna check that too

ember path
#

cuz this script comes like this, idk if i can put it into other things.....ig i can try xd

little raptor
#

and leave this in the player init too (for new players I guess)

ember path
#

oh are you saying this script would activate for JIP people?

#

thats cool

little raptor
ember path
#

i..dont ask me xd, i just took it from the interwebs

#

k that works

#

just adding it below the code that completes the task

willow hound
# hybrid dragon The mission will not end

Alright, since I have no experience with onPlayerKilled.sqf we should do some debugging to see what's going on.

systemChat (str _this);
if (_this # 0 == playerC) then {
    systemChat "Entered if-block";
    [] spawn BIS_fnc_fadeEffect;
    selectPlayer silentSniper;
    10 fadeMusic 0;
    playMusic "";
    call populate_tasks;
    systemChat "Finished if-block";
} else {
    systemChat "Entered else-block";
    ["end1"] call BIS_fnc_endMission; //Not sure if String argument works
};
systemChat "Finished onPlayerKilled.sqf";
```Test it like this to see how it behaves, what `_this # 0` is and so on.
https://community.bistudio.com/wiki/Arma_3_Debriefing#Configuration
Have you defined a custom "end1" in your `description.ext`? I've never used the default ones, don't know if they work.
hybrid dragon
#

it was pulled straight from the wiki

#

as a valid way to call that funcitn

willow hound
#

Test it like that anyways, for instance, I don't know if onPlayerKilled.sqf runs when silentSniper dies.

hybrid dragon
#

I'll probably do that tomorrow, just spent like 5 hours working on my car

#

pretty pooped

willow hound
#

Alright. Mention me when you have a result, otherwise I might not see the message.

queen cargo
#

@cosmic lichen @willow hound as a kinda two hour late followup for the question, what to do with hashmaps:

// SQC custom syntax
obj = { Foo: "Bar" };
``````sqf
// SQF
obj = createhashmapfromarray [["Foo", "Bar"]]```
In my alt syntax, I use it for Javascript like objects and in normal sqf, that could technically work to
peak thunder
#

o7

is any way how can I use setVariable command with a projectile?

spark turret
#

Protectile is an object so yes
_myProjectile setVariable ["yeet","yoink",true];

#

You can get the bullet object with a fired eventhandler iirc

willow hound
#

@little raptor What's the "make code safe for scheduled environment"-thing about? What's "unsafe" about the code in question?

little raptor
spark turret
#

So race conditions?

little raptor
#

yes

spark turret
#

Which code were you talkong about?

little raptor
#

for example:

_id = count _ids + 1; //what you expected the ID to be
//lets say scheduler queue ends here
_ids append ["", _this];

but if another code did this before that:

_ids append ["", _this];

then _id would actually be _id+2 (because another code added two other elements)

willow hound
little raptor
#

yes

#

not necessarily the function itself

#

even if it's called from a scheduled environment, it'll still be scheduled

willow hound
#

Bit weird (to me) that it is being used in the case of BIS_fnc_netId because that function needs to be called anyways to get the return value.

little raptor
#

even if it's called from a scheduled environment, it'll still be scheduled

#

Where code starts scheduled

init.sqf
initServer.sqf
initPlayerLocal.sqf
initPlayerServer.sqf
functions with postInit attribute (although suspension is allowed, any long term suspension will halt the mission loading until suspension has finished)
code executed with spawn
code executed with execVM
code executed with exec
**code executed with call from a scheduled environment**
willow hound
#

Disgusting

little raptor
#

yeah. if you want certain events to take place at the same time, you have to switch the environment to unscheduled

#

with isNil

willow hound
#

There's always new surprises in A3.

little raptor
# willow hound Disgusting

the only difference between call and spawn is that call doesn't create a new thread.
call code simply means "execute that code here"

spark turret
#

Whats the isNil bug?

#

/hack

little raptor
#

Syntax:
isNil code
Parameters:
code: Code - code to evaluate:
**the code will not be allowed to suspend while expression is evaluated, even if the parent scope allows it (see Example 4). **

Return Value:
Boolean - true if code returns something other than Nothing

spark turret
#

In what scenario is that useful? Cant you just use call?

little raptor
spark turret
#

Ah okay

little raptor
#

when you want things to happen in exactly one frame

#

for example, if you create a vehicle in an unsafe position, but don't move it in the same frame, it'll explode

spark turret
#

Oh you gotta send that to the alive guys

#

Their cars keep spawning offroad and explode before teleporting

#

So its essentially trading execution control for performance. I assume the game slows down if you force to mucj into one frame

little raptor
#

yes it does slow down

#

sometimes it's inevitable

spark turret
#

probably still more perfomrant than a burning tank ik collision :)

little raptor
spark turret
#

They do, ill do it later if i remeber it

viral tangle
#

Hi everyone, is there any way detect when a player take off his uniform. Preferably with handler "Put"

spark turret
#

check the eventhandlers page

viral tangle
#

And?

little raptor
#

@viral tangle I'm not sure when that EH triggers. I can give you two ideas:

  1. if it triggers after the unit takes off the uniform:
uniform _unit == ""
  1. If it triggers before:
getNumber (configFile >> "CfgWeapons" >> _item >> "ItemInfo" >> "type") == 801
#

either way, the second method is probably safer

sharp skiff
#

is there a way to play a custom sound/music piece locally (on a radio etc.) without using an extra addon or CfgVehicles ? (a method like adding picture to billbords would be nice!)?

little raptor
#

I don't think so

#

there's only playSound3D and it's global

exotic flax
#

and you can add sounds/music in a mission (so no mods needed)

sharp skiff
#

but only with createSoundSource ?

little raptor
#

playMusic

sharp skiff
#

the idea is to have a radio play radio message i prerecorded

#

so not global but on a set position/item

exotic flax
#

createSoundSource (for SFX), playSound (for CfgSounds) or playMusic (for CfgMusic)
check the wiki for the differences, because it's all possible

little raptor
#

playMusic and playSound are local

sharp skiff
#

ah ok thx

#

Music and sound also suggest diffrent channels right?

#

so if music vol is 0 u cant hear that (player pc) but sound is like gunfire etc?

little raptor
#

probably

sharp skiff
#

is there any limite to the file size/length for that? i used playSound3D [getMissionPath "mySound.ogg", player]; which didnt work

still forum
#

format needs to be somewhat right

#

44.1khz mainly

sharp skiff
#

uff okay

#

hope audacity can do that :-I

still forum
#

should

sharp skiff
#

it still wont, work no errors , nothing. debug console exec also didnt work

still forum
#

open your audio file in VLC, and check the media info

#

what format is it

sharp skiff
#

.ogg ,Vorbis Audio,stereo,44100 Hz ,Bits per sample 32 ,bitrate 160 kb/s

#

sounds right

#

im trying wav next was mentioned somewere too

#

path to the file is : mpmissions\AC-130.Altis\shotdark.ogg but i dont have a cfg-sound/music file nor the idea how to make them so that the use the .ogg in the mission folder not as an addon!

little raptor
sharp skiff
#

yep

#

that will get exported to the workshop later

#

well its basicly the scenario folder if i tell the eden editor to go there! @little raptor

little raptor
#
Audio
ID                          : 12733 (0x31BD)
Format                      : Vorbis
Format settings, Floor      : 1
Duration                    : 2 min 44 s
Bit rate mode               : Variable
Bit rate                    : 192 kb/s
Channel(s)                  : 2 channels
Sampling rate               : 44.1 kHz
Compression mode            : Lossy
Stream size                 : 3.77 MiB (99%)
Writing library             : libVorbis 1.0 (UTC 2002-07-17)Audio
ID                          : 12733 (0x31BD)
Format                      : Vorbis
Format settings, Floor      : 1
Duration                    : 2 min 44 s
Bit rate mode               : Variable
Bit rate                    : 192 kb/s
Channel(s)                  : 2 channels
Sampling rate               : 44.1 kHz
Compression mode            : Lossy
Stream size                 : 3.77 MiB (99%)
Writing library             : libVorbis 1.0 (UTC 2002-07-17)
#

sample working .ogg format

sharp skiff
#

weres that sample?

little raptor
#

game files

sharp skiff
#

arma 3 root folder i guess?

little raptor
#

no, unPBOed one of music addons

sharp skiff
#

ah ok

#

i try it with the malden one if that works its the format or the mission cfg music thingi

little raptor
#

also, did you restart the mission?

sharp skiff
#

no but should it be needed when i go back to the editor?

little raptor
#

no, either end or restart.
and did you try it in the debug console?

sharp skiff
#

yep did didnt work

little raptor
#

while the mission was running?

sharp skiff
#

yes and in person on the map not briefing

#

let me check it with a vanila arma 3 song

#

maybe its some script error

#

i try with LeadTrack01_F_Malden.ogg

#

hm that uhm odd

#

after a editor restart both work at least in local exec in debug console

drifting sky
#

Arma2OA.... I'm trying to copy a very long array to clipboard. I'm using format and then copytoclipboard. Does anybody know why it's getting cut off mid way? Or if there is another way to do it correctly?

little raptor
#

I think 8 kb?

#

it's on the wiki

finite sail
#

in a2, it was 2048 chars, iirc

#

hes stuck in 2012

little raptor
#

use joinString

#

if it's a thing in A2

drifting sky
#

in arma2 does string concatenate with the + operator have a size limit?

little raptor
#

I don't think so

little raptor
drifting sky
#

prefixes are added. but I'm going to try copytoclipboard (prefix + (str array))

#

Sure wish I could just save the array directly to a file in the mission folder, that could then be read back in as an array.

little raptor
drifting sky
#

I wasn't clear on a response to a question I had earlier. With doWatch, is it actually possible to get ai units to look up or down?

little raptor
drifting sky
#

is it possible to get the player's current pitch?

little raptor
drifting sky
#

aiming direction

little raptor
#

weaponDirection

drifting sky
#

is that a 3d vector?

little raptor
#

yes

drifting sky
#

or pitch,yaw

little raptor
#

3D vec, you should convert it

sharp skiff
#

"format Vector3D"

drifting sky
#

3d vec actually is better. Thanks

sharp skiff
#

this addAction ["AC/DC", {playSound3D [ getMissionPath "shotdark.ogg",laptop,false,laptop,4]}]; well works as intended ,sort of now i just need to know ho to stop it otherwise u can loop it to death if u reuse it XD

sharp skiff
#

thats a static laptop and needs to stay there or respawn so how to delete the undeletable

sharp skiff
#

which is the laptop too or do u mean the ogg?

little raptor
#

or create a fake source

sharp skiff
#

otherwise i would think deleteaction ,pause x, addaction again?

little raptor
#

then delete that

sharp skiff
#

but how can i create it in the first place and to that every time the song runs

#

sry for asking that many maybe dumb questions its my first time ever doing something in the editor

sharp skiff
#

ok

little raptor
#

use the dummy with playSound3d

sharp skiff
#

thx

drifting sky
#

When doing dowatch does the distant of the position that they're watching have any effect on their ability to detect enemies. For example, if they are watching a position very close to them, does it interfere with their ability to detect enemies farther away?

little raptor
#

no (unless it affects their LOS on farther objects)

drifting sky
#

Correct me if I'm wrong, but there is no function to return whether an ai unit is aiming or shooting at an enemy.

little raptor
#

no

#

you could probably write an approximate one

#

but it'll be slow

#

you'd have to loop over all enemy units

#

also, that's only for the aiming part

#

shooting can be detected with an event handler

drifting sky
#

I thought maybe their animation state could give it away

little raptor
#

not necessarily

#

I don't recall how the animations were in A2, but in A3 that's not a good method

sharp skiff
#

@little raptor i cant get it to work no mather what , either missing ] or something else were and how do i need to put the example in to fit (and delete the source on a rerun?: this addAction ["AC/DC",{playSound3D [ getMissionPath "shotdark.ogg",dummy,false,dummy,4]}];

#

do i need to do it with another { }?

sharp skiff
#

int this case it should be the laptop

#

or at the postion of the laptop

little raptor
#

i don't see any "laptop"

#

is your laptop called dummy?

sharp skiff
#

as far as i know i need to tell the playsound3 were to play the sound in this case the "dummy" i create with the example script from say3d and on a rerun delete the dummy so that the sound stops

#

and dosnt loop

#

okay from 0:

#

i placed a laptop model named "Laptop" with the init :

#

this addAction ["AC/DC",{playSound3D [ getMissionPath "shotdark.ogg",laptop,false,laptop,4]}];

#

BUT the sound loops and needs to be stoped

little raptor
#

syntax highlighting plz (see pinned messages)

sharp skiff
#

oh god

#

uhm that could take a min

#

this addAction ["AC/DC",{playSound3D [ getMissionPath "shotdark.ogg",laptop,false,laptop,4]}];
#

thats right?

little raptor
#

yes

sharp skiff
#

the issue is u can use the action directly after it and therefore loop it and i cant figure out how to do that with

#
/* your code */
private _dummy = "#particlesource" createVehicleLocal ASLToAGL getPosWorld _corpse;
_dummy say3D "whatever";
_dummy spawn {
    sleep 5; // at least the length of your sound
    deleteVehicle _this;
};;
#

should i put that in a seperate .sqf and run it before the playSound3D or what is the best solution?

little raptor
#

u can use the action directly after it and therefore loop it
so you want to remove the action after the first use?

sharp skiff
#

yes and no i want that the song stops if u press the action again so that is doesnΒ΄t loop when u use the ac/dc action again!

little raptor
#

by loop you mean "echo"?

sharp skiff
#

yeah

#

u can start it again and again and again so u have the same song running 3 times behind

little raptor
#

create a .sqf script with this in it (in the mission folder):

params ["_target", "", "_actionId"];
_dummy = "#particlesource" createVehicleLocal ASLToAGL getPosASL _target;
playSound3D [getMissionPath "shotdark.ogg", _target, false, _target, 4];
_target removeAction _actionID;
_target addAction ["AC/DC", {
  params ["_target", "", "_actionId", "_dummy"];
  deleteVehicle _dummy;
  _target removeAction _actionID;
  _target addAction ["AC/DC", "scriptName.sqf"];
}, _dummy];

use this in the init:

this addAction ["AC/DC", "scriptName.sqf"];
#

change the "scriptName" to your actual script name

#

this will create a "toggle" like button

#

you can turn it on and off

sharp skiff
#

Thank you very much

little raptor
#

np

sharp skiff
#

uhm

#

it still echos and creates more actions

#

i dont know but is _actionID not defined?

#

does the laptop need to be set to a specific name?

#

it doesnt remove the action

little raptor
#

fixed.

sharp skiff
#

let me guess removeaction...?

little raptor
#

but if it doesn't stop playing, then you should use say3D

little raptor
sharp skiff
#

simply _target removeAction _actionID again?

little raptor
#

yes

sharp skiff
#

needs to be included with [] or {] right=

little raptor
sharp skiff
#

the second remove action

#

or just ; it behind?

little raptor
#

it is correct as it is

sharp skiff
#

ah okay

#

so same script but replace playsound3d with say3d and description.ext

#

?

little raptor
#

yes,
create description.ext in your mission folder
follow that guide to create a sound class
use say3D instead of playSound3D

sharp skiff
#

got it thx

sharp skiff
#

@little raptor error missing ; wtf does it want there is a fucking ; behind it

exotic flax
#

And also at the correct positions?
Can't tell if it's correct or not without seeing the code

sharp skiff
#

_dummy say3d [acdc,100,1,false,0];

#

3 line

#
 params ["_target", "_caller", "_actionId", "_arguments"];
_dummy = "#particlesource" createVehicleLocal ASLToAGL getPosASL _target;
_dummy say3d [acdc,100,1,false,0];
_target removeAction _actionID;
_target addAction ["AC/DC", {
  params ["_target", "_caller", "_actionId", "_dummy"];
  deleteVehicle _dummy;
  _target addAction ["AC/DC", "acdc.sqf"];
}, _dummy];
exotic flax
#

So... acdc must be a string (line 3)

#

Which does cause that error

sharp skiff
#

acdc is the name of the song defined via description.ext

#
class CfgSounds
{
    sounds[] = {};
    class acdc
    {
        // how the sound is referred to in the editor (e.g. trigger effects)
        name = "acdc";

        // filename, volume, pitch, distance (optional)
        sound[] = { "shotdark.ogg", 1, 1, 100 };

        // subtitle delay in seconds, subtitle text
        titles[] = { 0, "" };
    };
    };;
#

and it doesnt work of course

exotic flax
#

But it must be a STRING

winter rose
#

as in

  • not acdc
  • but "acdc"
sharp skiff
#

ah ok

#

AH god damit 3 time the same shit each time the shit echos again

#

and crates more addaction till it floods the menu

winter rose
#

(coooool down on the language)

sharp skiff
#

sry im sitting on hour 3 now on that Piece of ********

#

i just want it to start one time and if u press it again stop or restart without echoing

exotic flax
#

You can stopΒ say3DΒ sound currently playing in 2 ways:

  • delete the source of the sound (from) withΒ deleteVehicle, or
  • kill the source with e.gΒ setDamage.
sharp skiff
#

im doing it with deletevehicle but it still wont work

hallow mortar
#

I feel like I'm going absolutely insane.
A while back I got GM searchlights to track a certain position, using essentially the same code I'm using now. Only now...they're not doing it. Refusing to look at what I want.

params ["_light"];

// probably works, it's hard to tell
[_light,(nearestObject [_light,"land_gm_tower_bt_11_60"])] call BIS_fnc_attachToRelative;

// this works, the light turns on
[(gunner _light),["SearchlightOn",_light]] remoteExec ["action",(gunner _light)];

while {true} do {

    // All this is executed but the light doesn't move
    _lightTarget = o_cube;
    diag_log "TARGET SET";
    // _lightTarget = [allPlayers,_light] call BIS_fnc_nearestPosition;
    [(gunner _light),_lightTarget] remoteExec ["doWatch",(gunner _light)];
    diag_log "DOWATCH";
    [(gunner _light),_lightTarget] remoteExec ["lookAt",(gunner _light)];
    diag_log "LOOKAT";
    sleep 4
};```
#

(server executed)

sharp skiff
#

uhm no scripting experience but delete // from _lighttarget?

hallow mortar
#

That's just an alternate (more complicated) target system that I commented out to narrow down the issue. You'll notice a dummy target is defined two lines above.

sharp skiff
#

o_cube yeah right saw that now

#

is o_cube an obj in this case?

hallow mortar
#

Yes, and doWatch and lookAt both accept objects.

sharp skiff
#

hmm

willow hound
#

What's up with the remoteExec?

hallow mortar
#

We sometimes have Zeus or headlessclient doing things, so server exec isn't guaranteed to be where the AI is local

#

remoteExec ensures the commands are in the right locality