#arma3_scripting

1 messages · Page 520 of 1

knotty arrow
#

i know

sudden yacht
#

Good luck bud, let us know how it turns out.

knotty arrow
#

haha thanks

tough abyss
#

@sinful flame init.sqf is executed once on mission start, allows waiting and executed after all objects initialised. Object init field executed for every client present and future in multiplayer, doesn’t allow suspension and is executed quite early so some commands might not work when placed in it

#

@sudden yacht where do you put the code when the game freezes?

sudden yacht
#

init box. Have any suggestions?

robust hollow
#

init box is unscheduled so this loop wouldnt be sleeping.

while {alive player} do {nul = [getPos player,240,"Banshee",2] execVM "MIL_CAS.sqf"; sleep 60;};```
sudden yacht
#

How do i make it scheduled?

robust hollow
#

put it inside a spawn

#

though i dont know if ur player exists when init boxes are executed so that may end up being a new problem.

tough abyss
#

Don’t put stuff in init box

#

Simple

sudden yacht
#

never mind

#

i got it

still forum
#

@hasty violet The benefit to the FUNC macro are that it allows you to very easily move stuff between modules or rename modules or split things apart, the FUNC macro automatically changes the function name that you are calling, no need to do it manually.
XEH_PREP is basically like CfgFunctions, but it has correct line numbers for errors (CfgFunctions does not if you have #include's) and has better caching.
And the specific files for pre/postInit and preStart are just very handy, because you immediately see the entry point. If it were CfgFunctions you'd first need to look into the config to see which file has which kind of init.

@knotty arrow use the private keyword, not the command.

@robust hollow
init box is unscheduled so this loop wouldnt be sleeping. And it also wouldn't be looping as the script get's killed on the sleep.

#

Your thingy seems really weird. Scripts shouldn't be able to crash the game no matter if unscheduled/scheduled.
Some UI Eventhandlers can crash the game because BI is missing some checks. But if you don't do any UI stuff you should be in the clear (unless you spawn a broken vehicle model or whatever else)

dim kernel
#

hey was wondering how could i see the server threads that are running

still forum
#

Profiling build would show them. But that is not out yet for 1.90

dim kernel
#

so i cant check

#

?

still forum
#

Currently not

dim kernel
#

what about checking Client threads?

still forum
#

same

dim kernel
#

does diag_activeScripts return value of scripts?

tough abyss
barren valley
#

That function will return how many scripts are running depending on how you have ran them.

dim kernel
#

ye just read it

formal vigil
#

PROBLEM: Programmatically created trigged does not execute activation statements.
DESCRIPTION: I'm creating a side mission of destroying enemy's cache. If I destroy the crate nothing happens, where it should show the chat message. Could anyone assist?
CODE:

_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
_trigger_name  = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setTriggerStatements [
        "!alive _nva_crate", 
        "systemChat 'Cache destroyed'", 
        "systemChat 'Cache NOT destroyed'"
    ];
still forum
#

!alive _nva_crate Local variables don't carry over to other scripts

#

_nva_crate is undefined

tough abyss
#

VAR_changing is a global variable that changes many times by various scripts on the mission. On the code bellow there is a chance of the different diag_log str VAR_changing; (1, 2, 3 and 4) return differente values? waitUntil { diag_log str VAR_changing; //1 (some code with no sleep)... diag_log str VAR_changing; //2 (some more code with no sleep)... diag_log str VAR_changing; //3 (some more code with no sleep)... diag_log str VAR_changing; //4 false };

formal vigil
#

How to properly pass it, then? Should I use i.e. missionNamespace setVariable ["crate", _nva_crate]; and call missionNamespace getVariable "crate"; in the condition?

#
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
missionNamespace setVariable ["crate", _nva_crate];
_trigger_name  = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setTriggerStatements [
        "!alive (missionNamespace getVariable 'crate')", 
        "systemChat 'Cache destroyed'", 
        "systemChat 'Cache NOT destroyed'"
    ];
still forum
#

@tough abyss yes script might be suspended at any point in scheduled

#

@formal vigil That's unnecessarily complex.
You set/get a global variable by just writing the name. So
crate = _nva_crate and !alive crate would do it.
If you use a global variable then there can only be one crate. Also global variables should always have a prefix like DAR_crate to not conflict with anything else.
You can instead setVariable onto the trigger.
And then getVariable from thisTrigger in the condition. That way you can have multiple crates.

formal vigil
#

So it would be as simple as:

_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
OS_crate = _nva_crate;
_trigger_name  = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setTriggerStatements [
        "!alive OS_crate", 
        "systemChat 'Cache destroyed'", 
        "systemChat 'Cache NOT destroyed'"
    ];

?

tough abyss
#

@still forum if the code runs in a EachFrame event handler (unischeduled) the answer is no?

still forum
#

yes

#

But again only can have one crate with that

#

@tough abyss correct

floral spade
#

i'm looking through a3wasteland code to learn about multiplayer scripting. can somebody explain to me reason for some functions defined in CfgFunctions and other using globalCompile.sqf in that file i see that functions are compiled final if debug mode is turned off. is the debug mode only reason for this kind of compiling scripts?

still forum
#

Probably yes. With CfgFunctions you cannot control whether compileFinal or not that easily.

formal vigil
#

Oh, I think I understand what you've meant by setting a trigger variable...

#
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
_trigger_name  = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setVariable ["OS_crate", _nva_crate];
_cache_trigger setTriggerStatements [
        "!alive (thisTrigger getVariable ""OS_crate"")", 
        "systemChat 'Cache destroyed'", 
        "systemChat 'Cache NOT destroyed'"
    ];

Right?

still forum
#

yep

formal vigil
#

👌 I'll test it out right now

#

So then probably systemChat also should be escaped with double quotemarks instead of apostrophe?

still forum
#

double quotes or apostophe makes no difference

#

same end result

#

both work

formal vigil
#

Tested the code. Seems the condition still doesn't work, even if I use double quotes instead of apostrophes.

copper raven
sinful flame
#

Is there an external way of compiling and testing sqf?

formal vigil
#

@copper raven what other way would you recommend? Attaching to some kind of like ObjectIsDestroyed event?

copper raven
#

sqfvm

#

yeah, like an event handler, either assigned to the crate itself, or like an EntityKilled on server

still forum
#

There is Deleted or Killed eventhandlers. Or HandleDamage

formal vigil
#

Worked like a charm! Thanks guys, I owe you 😃

tough abyss
#

@formal vigil there is only one name you could use to create trigger, where did you get an idea you could just make one up?

still forum
tough abyss
#

@sinful flame Depends on what you want to test. SQF is pretty much an API to the game engine, without the actual engine you could only emulate script functionality to a certain degree.

sinful flame
#

@tough abyss Ahh okay I wasnt sure if it was it;s own language that Bohemia decided to use or if it was created for the game.

tough abyss
#

Yes it is, but 90% of sqf operators are getters and setters for engine methods

radiant egret
formal vigil
#

this is the code that's I'm having right now:

_cache_number = floor random 100;
_ammo_pos         = [getPos _module, 5, 10, 10, 0] call BIS_fnc_findSafePos;
_ammo_marker_name = format ["mrk_cache_%1", _cache_number];
_ammo_marker      = createMarker [_ammo_marker_name, _ammo_pos];
_ammo_marker setMarkerType "b_uav";
_ammo_marker setMarkerText "Ammo Cache";
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
_task_name = format ["DestroyCache_%1", str _cache_number];
OS_task_id = _task_name;
[west, _task_name, ["Enemy Ammo Cache is present in this area. Find it and destroy using explosives","Destroy Enemy Ammo Caches"], objNull, "ASSIGNED", 1, true] call BIS_fnc_taskCreate;
_nva_crate addEventHandler ["Killed",{
    [OS_task_id, "SUCCEEDED"] call BIS_fnc_taskSetState;
}];
#

I will still need to change those BIS_fnc_task* calls to remoteExecCall for the tasks sync

tough abyss
#

No you don’t, task framework is supposed to be global already

formal vigil
#

Oh, nice.

knotty arrow
#

@still forum i don't understood u

still forum
#

ok

#

And I don't remember about what I was last talking to you. That makes two people that don't understand what's going on

knotty arrow
#

this

still forum
#

Ah

knotty arrow
#

u say use the private keyword, not the command.

#

u refer to private[]

still forum
#

Use private _item = param... instead of

private "_item";
_item = param...
knotty arrow
#

ajam

#

ok

#

will try thanks ❤

still forum
#

private keyword infront of variable is free. The other private is a command call that costs you performance

#

additionally you can more easily see where a variable is defined for the first time (because that's where the private is) making your code a bit more readable

knotty arrow
#

yep, but my problem is when i exec this from a function, arma crash

#

thanks for the tip

still forum
#

Ah yeah. I thought about that but I can't see any reason in the script why Arma might be crashing.

knotty arrow
#

when i have a magazine semi-empty and another full Crash

still forum
#

you could add tons of diag_log's into your script. One in every line.
And then when your game crashes look into your RPT to see at which line of the script, the game crashes

knotty arrow
#

i try to debug all code with diag_log

#

and not showing anything on rpt

#

i try it already

still forum
#

nothing at all? are you 100% sure it's that script that crashes then?
Try emptying the script file and running it. Maybe it's something before the script you posted

knotty arrow
#

i don't think so...

#

but i will try

#

let me a min

tough abyss
#

How do you call is as a function @knotty arrow ?

knotty arrow
#

["classnameofmagazine"] call x_fnc_repack

#

exactly:["50Rnd_570x28_SMG_03"] call rb_fnc_repack

#

i empty the file and game not crash @still forum

still forum
#

makes no sense that the diag logs don't show up

knotty arrow
#

maybe the game crash when precompile the script, and not exec it

#

😦

still forum
#

well easy to find out

#

compiled at mission start. executed sometime later

knotty arrow
#

nap

#

if i test it block for block, game not crash

#

and if i exec all the function crash

#

i will do another one

#

@still forum thanks for ur help ❤

thin pond
#

I have a script that gives players certain items. Is there a way that this script detects the players weapon and gives the player X amount of a defined magazine ? For Example: 2 players (one with ak one with m4)... both access the script via "addaction" ..... both get the items the script contains plus 5 mags for their weapon... the mag count should be adjustable aswell as the mag type (classname)

#

anyone that knows how if can make this work ?

knotty arrow
#

if (currentweapon player isequalto "m4") then {player addmagazine "m4magazine"} else {player addmagazine "akmagazine"}

#

@thin pond

thin pond
#

okay I'll give it a try

#

thanks

digital hollow
tough abyss
#

Have one OnEachFrame with all code instead of having the code broken in 5 OnEachFrame is better in terms of performance?

still forum
#

Yes

#

slightly

#

most important is to not have the actual code directly in the eachframe

#

but to instead call a function

tough abyss
#

Yes i do that

still forum
#

addMissionEH ["EachFrame", {call myFunction}]
instead of
addMissionEH ["EachFrame", {function code here}]

tough abyss
#

Thanks Dedmen!

knotty arrow
#

@still forum if call it with spawn, instead of call works

#

and no crash

tough abyss
#

I'm transforming some code i have in this format _var1 = 0; _var2 = []; _var3 = objNull; waitUntil { (CODE...) false }; to OnEachFrame. Sadly i will need to transform _var1, _var2 and _var 3 in global variables.

copper raven
#

You can go for stacked oneachframe EH. It allows you to pass arguments @tough abyss

tough abyss
#

@copper raven not sure... _var1 for example is a incremental variable, inside (CODE...), in the waitUntil, i have that: if (...) then {_var1 = _var1 + 1;}; The variable needs to maintain itself each cycle.

copper raven
#

Yeah, then you need to go for global var.

limber tangle
#

Would there be a way to script a MP missions to allow certain players (possibly with their steam ID) be allowed a specific slot in the lobby of the server? say i have 20 playable units, but three were only restricted for 3 individuals

radiant egret
limber tangle
#

So that script would be placed on the specific unit in question?

radiant egret
#

No one will script it for you, learn sqf and ask questions if you stuck somewhere, the link is only a hint for the steam check

limber tangle
#

I was not asking for it to be scripted, just a starting point

#

But thank you for the help

sinful flame
#

Okay I think im getting the basic understanding of this now. so _var is for private varibles where as var is for global? Objects are just like 90% JSON objects? All lists/arrays are tuples? Is that a fair jugement?

still forum
#

Objects are just like 90% JSON objects no
All lists/arrays are tuples no. Arrays are arrays.

#

_var is for local variables.
There is a private keyword which makes the variable local to the current scope, instead of the variable potentially overwriting ones in parent scopes.

tough abyss
#

_var is local not private, becomes private when you make it private

sinful flame
#

ahhh okay I see. so you have to staticaly declare its private

#

so 'private _innerVar;'

still forum
#

no

#

private _varname = ...

#

private is a modifier to the =

tough abyss
#

private "_innerVar";

still forum
#
_var = 5;
if (true) then {
    _var = 10;
}
//_var is 10 here
_var = 5;
if (true) then {
    private _var = 10;
}
//_var is 5 here
sinful flame
#

ahh okay i see. This is unlike a language i have used before. You guys must have had to really power through learning it.

#

Have you ever come across any other languages like this?

still forum
#

Nope. Syntax wise there are many similarities ofc. But backend wise not really

#

You can compare private keyword with javascript's let

sinful flame
#

if and then i have used before in Bash scripting and Perl, i think. but that was years ago

#

I know Java and C++ so I'm familiar with access modifiers

#

Now i know what let does 😃

still forum
#

IMO SQF is easier to understand if you know the low level stuff.
Everything is a command. There are 3 types of commands. nular, unary, binary

sinful flame
#

Interesting...

tough abyss
#

You guys must have had to really power through learning it comes down to remembering the commands

still forum
#
if (true) then {true_code} else {false_code}

if, then and else are commands.
https://community.bistudio.com/wiki/if
https://community.bistudio.com/wiki/then
https://community.bistudio.com/wiki/else
else has highest priority and just returns an array like [{code1}, {code2}]
then takes a IfType on the left side, and either array or code on the right side.
So after the else is evaluated you have

if (true) then [{true_code},{false_code}]

Next up the if

IfType then [{true_code},{false_code}]

Last the then command is executed. It get's the IfType and the array of code values as argument.
The IfType internally stores the result of the condition (true command returned a boolean true. So the condition is true.)
then command then chooses the corresponding code value in the array, and executes what's inside it

sinful flame
#

Thanks 😃 I've been looking over the Wiki for a couple of days now and it seems like there is tones of calls you can do

radiant egret
#

Look at the Workshop, then you will see what ppl do with arma

restive leaf
#

Scope for variables is fairly common though in other languages

tough abyss
#

A lot of game functionality could be duplicated with scripts and a lot could not be

sinful flame
#

Im trying to focus on learning a little bit a day. yesterday I got the say3Dsound method working and i could make some sound come out the radio which was cool but today I think im gonna focus on making an intro and cut scenes

tough abyss
#

say3Dsound say3D or playSound3D?

still forum
#

There is also a C++ scripting mod btw.
But it's only really useful for playing around and making specialized tools as it doesn't work with battleye

sinful flame
#

It was say3dsound

still forum
#

say3dsound doesn't exist

tough abyss
#

no such method

sinful flame
tough abyss
#

if you know c++ you may want to jump to callExtension

still forum
#

callExtension doesn't help you learn scripting tho

tough abyss
#

helps you to learn about strings and arrays

sinful flame
#

Yeah I best just try learn some SQF so if i want to make something multiplayer I know battleye wont play up.

tough abyss
#

what this has to do with battleye?

still forum
#

callExtension and Intercept both don't play with battleye

tough abyss
#

callExtension?

still forum
#

you need to get the extension whitelisted

tough abyss
#

And why is it a problem?

#

Battleye doesn't care about your SQF skills, unless you tell it to care @sinful flame

sinful flame
#

Ah im sure about that since its only designed to interact with Bohemias API and AFAIK Battleye is made by Bohemia. i think.

tough abyss
#

Nope

#

BE is independent and used for lots of games unrelated to Bohemia

sinful flame
#

Ohh okay.

#

Yeha I seen it being used in battlefield.

#

not sure which one.

#

3 i think

restive leaf
#

And if your extension is not whitelisted you cannot run on a server running BattlEye. Even if it is whitelisted there are problems occassionally where BE on your client barfs on the DLL

tough abyss
restive leaf
#

Happens for me with ACE3 every now and again...

sinful flame
#

Insurgency, thats what i was thinking of. I had a friend by Arma and he instantly got perma banned by battle eye for cheating. He kept trying to email support to say he only just purchased the game and didnt even get to play it before he got banned. That was years ago and he said he would never buy it agian.

tough abyss
#

BE might have deeper integration with Bohemia games for historic reasons

radiant egret
#

arent a2 banns carried over to a3?m quite few ppl complained in the steam forums purchased a3 and beeing banned on their first altis life visit xD

restive leaf
#

Isn't a BE ban applicable to all BE supported games... that is what I assumed. Asking because I may be wrong?

tough abyss
#

Doubt it

radiant egret
restive leaf
#

And for DayZ Standalone too... just checked that

tough abyss
#

Thats nice

restive leaf
#

Solution is: Don't get banned!

#

infiSTAR global bans cross ARMA2 and ARMA3 too thankfully

sinful flame
#

If a method has a return type do you always have to give it a varible to return to? even if you are not going to use that return value?

tough abyss
#

no, but sometimes you might want to

#

like if you put the code in init field in editor it will complain if you have something returned

#

but because assignment operation doesn't return anything you can just use assignment to dummy variable

sinful flame
#

ahhh I see. thx

tough abyss
#

no he assigns to it then uses it as argument for binary commands

#

arg1 command arg2 <- binary command

#

= <- assignment

#

camdestroy is unary

#

command arg1 <- unary

sinful flame
#

and binary is when a method take arguments but also returns an array/object/value?

tough abyss
#

returns something or nothing

#

or anything

sinful flame
#

and if a command takes no input and has no output then it is a nulary method?

#

nular* method

tough abyss
#

select returns anything, because it returns whatever you have in array which can be anything

thin pond
#

if (currentweapon player isequalto "m4") then {player addmagazine "m4magazine"} else {player addmagazine "akmagazine"} any way to make this detect the handgun aswell ?

tough abyss
#

nular can have output

#

for example forceEnd is nular that returns nothing, but allPlayers is nular that returns array of objects

copper raven
sinful flame
#

okay so its like a return type that can be void but it can also be a varible or an object?

#

its not fixed to HAVE to return something?

tough abyss
#

yeah something like that only instead of void it returns nil which can be tested with isNil

#

its not fixed to HAVE to return something? dont understand the question

#

I know what you need

#

type this in debug console:

thin pond
#

also is there any way to make for "_i" from 1 to X do {this addItemToVest "X";}; any shorter like with player addMagazine ["X", 10] for example

tough abyss
#
{diag_log _x} forEach supportInfo "";
sinful flame
#

okay thanks. I will give it a go

tough abyss
#

Then go to your .rpt and get the long list of all commands it printed

#

each command will have TYPE of argument used, but for return type you will need to look up wiki

sinful flame
#

Ah awesome. Thanks man!

#

I want to improve the sound of the rain. would a 2D sound be better than a 3D sound call? How does 2d sound call relate when you go indoors/car? do you know if it filters the sound like a 3d sound?

tough abyss
#

you can just make a mod and change sounds

#

people have done this

#

there are things that are easy to do with scripts and there are things that are better done with mods

sinful flame
#

I have seen JSRS and Dynasound mods

tough abyss
#

@thin pond no, additemtovest could also add a weapon or magazine as well as items, but addmagazine adds magazines only

sinful flame
#

But I only want to change the rain, and wind sounds. Sound engineering is one of myhobbys and im sure I could make it sound better.

tough abyss
#

so make a mod and replace the sounds with yours

empty tartan
#

How can i check if a vehicle was killed vs just got despawned or deleted?

robust hollow
#

killed event vs deleted event

#

or, just alive _veh vs isNull _veh

tough abyss
#

!isNull _vehicle && !alive _vehicle <- dead

empty tartan
#

thanks!

thin pond
#

player removePrimaryWeaponItem "acc_flashlight"; should also be able to remove magazines but can you also remove any magazine in the weapon ?

#

I want to remove any magazine that is currently equiped in the weapon, also i cant seem to get items removed that are inside a vest/uniform/backpack

sinful flame
#

Good point, I will stick with mission making for now. Don't want to over fry my brain

errant widget
robust hollow
#

that is how you use step.... what do you mean it should read "greater than" rather than neq?

errant widget
#
The loop processes as follows:

    A variable with the name VARNAME is initialized with STARTVALUE
    If VARNAME is not equal to ENDVALUE, the code block is executed
        If ENDVALUE is greater than STARTVALUE, the variable VARNAME is incremented by 1
        If ENDVALUE is less than STARTVALUE, the variable VARNAME is decremented by 1
    Go back to step 2

To me, that suggests that once the VARNAME is equal to the ENDVALUE, the code does not execute

#

what happens in game is that it executes until (excluding) the increment pushes VARNAME over ENDVALUE

ionic orchid
#

yeah ingame its inclusive

#

that reads as exclusive

robust hollow
#

it depends which way your interval goes. if you use a negative step it needs to be less than the end value.

#

regardless, that does read wrong.

errant widget
#

fixed 😃

thin pond
#

any chance to get this to work with vests and uniforms ?clearMagazineCargo (unitBackpack player)

sinful flame
#

Where is the output for the debugger?

ruby breach
#

Ahh conflicts. I was just going to reword to say #The code block will be executed until <tt>VARNAME</tt> increments beyond <tt>ENDVALUE</tt>, but your works

robust hollow
#

@thin pond
clearMagazineCargo (vestContainer player)
clearMagazineCargo (uniformContainer player)

#

If ENDVALUE is less than STARTVALUE, the variable VARNAME is decremented by 1
this isnt right either is it?

_a = [];
for "_i" from 5 to 1 do {_a pushback _i};
_a // []
#

its only if you specify a negative step

tough abyss
#

@sinful flame what debugger?

ruby breach
#

correct. I'll update

sinful flame
#

the Eden debugger. I ran the code you gave me and i get no visible text output

robust hollow
#

then there was no return value?

sinful flame
#

But I have just founf about about arma.rpt so I think i know where the results are going.

tough abyss
#

.rpt file

sinful flame
#

😃

#

@robust hollow Nope

thin pond
#

I made a template script for the other mission makers of our unit. Is anybody willing to take a lock at it and tell me if its compatible with dedicated servers ?

robust hollow
#

whats with all the X?

#

o right, template

thin pond
#

they are going to be replaced by classnames of items

#

;D

#

i tested all of it in the edior/singeplayer and everything worked there

robust hollow
#

should be fine, you could reduce it to a single setUnitLoadout command but either way gets the job done.

#

you're using this in your for loops though. instead of player

thin pond
#

already fixed that... little copy and pasting mistake

#

the players decide which weapons/vests/uniform etc they want to wear after that they execute these template scripts to get their "role loadouts"........ i just need a gui that can excecute .sqf files (like with addaction and the actionmenu)

#

so no player has to make sure he has everything he needs.... reduces mission prep from 30-40 minutes down to 10 (without briefing and joining)

#

i just need a gui that can excecute .sqf files (like with addaction and the actionmenu) is there anything out there that does this ? otherwise i'm going to make my own (atleast try :D)

robust hollow
#

not sure how to answer that, any gui can execute files if you tell it to

thin pond
#

hm than i have try to make my own.... just a list where you select which sqf is excecuted and than closes should be easy

robust hollow
thin pond
#

I'll take a look at it but it looks promissing

#

okay thats a bit complicated for me... I can do some sqf stuff but that looks a bit much for me... dont have the time to dig into it right now

thin pond
#

how much work would it be to make a gui with a list to select from, where the selected option excecutes a sqf ?

radiant needle
#

Can I store code in a variable? Like var01 = {hint "test"}; call var01;

astral dawn
#

@radiant needle yes, variable can be of type code

#

in fact if you do allVariables missionNamespace, you will find lots of code-type variables there, which are in fact functions from function library and other places

#

You can store code in a local variable too

radiant needle
#

Thanks, thats what i figured but wanted to double check

sinful flame
#

How do i get out of that weird camera mode in the eden editor? I can see the X, Y and Z axis and I can't move. Is this a big? Its happend to me a few times now.

thin pond
#

I'm currently using "cutText" to display a text when a player excecutes my script, but i cant seem to let it only show for the player you executes it

robust hollow
#

what do you mean? cutText is a local effect.

thin pond
#

okay i didnt know it was local, consider my question stupid and answered then 😄

ebon ridge
#

I forgot the name of a function: it rescales a value from one range to another range. Could someone please remind me?

high marsh
#

Rescales?

ebon ridge
#

yeah value is in range a -> b, and it can return that value relative to range x -> y

#

so if v=0.5, a=0, b=1, and x=2,y=4, it will return 3

#

useful for animating something based on time, which is what i am trying to do now

high marsh
#

you can apply an array of values under a certain value

ebon ridge
#

?

#

I know this function exists I have used it, can't remember the name or which mission though :/

robust hollow
#

linearConversion

ebon ridge
#

WOO

#

that is it

#

thank you

#

pr _actualX = linearConversion [animStartTime, animCompleteTime, time, _prevx, _currx, true];
@high marsh it does that

thin pond
#

anybody know a way to remove the magazine in any weapon equiped via sqf script ?

robust hollow
#
player removePrimaryWeaponItem (primaryWeaponMagazine player # 0);
player removeSecondaryWeaponItem (secondaryWeaponMagazine player # 0);
player removeHandgunItem (handgunMagazine player # 0);

not sure how reliable that is at removing the mag in the gun before any in inventory, but it worked in a quick test.

high marsh
#

weaponState can return all this

robust hollow
#

yea that would probably work better.

thin pond
#

@robust hollow how should i use this to achive what I'm trying to do ?

robust hollow
#

use what? weaponState?

thin pond
#

the first thing you wrote worked but i dont know how i should use "weaponstate" to remove a magazine in a weapon

robust hollow
#

weaponState player # 3 but it only shows the currentWeapon. not sure how to get it showing the holstered weapon info.

radiant needle
#

Seems like that linear conversion would be useful for converting colors

thin pond
#

one last thing than my template is done: I cant remove the "launcher" i.e. secondary weapon, tried multiple things but none seem to work

robust hollow
#

@radiant needle it is, made a colour picker grid using it

radiant needle
#

You tried player removeWeapon (secondaryWeapon player)?

thin pond
#

yep... says ) missing, which is weard

radiant needle
#

Can you post the actual code you have?

thin pond
#

wow.... found the error..... the side where i copied the line "player removeWeapon (secondaryWeapon player)" had a } instead of )... couldnt see it because fkn 4k 😄

#

should turn up my "font size"

#

thanks for the help guys script is working perfectly with all intended functions and customizations !

fringe nova
#

Hey guys

So I want the AI in the player's squad to be in BLUE (forced hold fire) state at the beginning of the mission but I don't want to hear my guy say "Hold Fire" at the opening. Is there a way to make that silent? I've tried it from the init.sqf and my guy still says "Hold Fire"

robust hollow
#

could do _unit setSpeaker "NoVoice" on the unit temporarily.

fringe nova
#

Oooh that's interesting, how would I turn the voice back on?

#

What's the opposite of "NoVoice" I mean

robust hollow
fringe nova
#

Ah yes, I can use the voice I defined in their class, perf

#

Thanks!

radiant needle
#

How do I put quotes into a format[]

#

Like if I want to display "Hi", I can't imagine format[""HI""]; would work

robust hollow
#

no it wouldnt

#

format["my thing ""%1""","word"]
format["my thing '%1'","word"]

radiant needle
#

Do I need doubles like format["""Hi"""];

robust hollow
#

if its just a plain string "hi" you can do str "hi", otherwise yes double quotes inside a quote

radiant needle
#

The quotes aren't part of the var iteself though

#

Like say _var = 6; format["""%1""",_var]; would display "6"

#

?

robust hollow
#

yes it would.

fringe nova
#

Btw thanks Connor that worked like a charm

rotund folio
#

hey guys are they a script for apply durty in arma 3 ?

robust hollow
#

"apply durty"?

rotund folio
#

use a new texture when you roll

robust hollow
#

setObjectTexture on keydown event 🤷

high marsh
#

"roll" ??

robust hollow
#

i assume the Q and E roll

high marsh
#

What about animation change event?

rotund folio
#

drive

robust hollow
#

the vehicle gets dirtier automagically doesnt it?

rotund folio
#

yes

runic surge
#

is it possible to not be the commander of a vehicle with a gun?

#

I can't seem to just be a passenger

#

vehicle only moves if I command it with wasd keys

radiant needle
#

Why am I getting "Type number not array" for_Array = _Array pushBack ... in this code

[] spawn {
_Crates = nearestObjects [SearchObj, ["plp_ct_LockerBig"], 100];
_Array = [];
{
    _WeaponCargo = getWeaponCargo (_this select 0);
    _MagazineCargo = getMagazineCargo (_this select 0);
    _ItemCargo = getItemCargo (_this select 0);
    _Weapons = "";
    _Magazines = "";
    _Items = "";
    {
    _CurrentIndexWeapon = format["_x addWeaponCargoGlobal [""%1"", %2];",_x,(_WeaponCargo select 1 select _forEachIndex)];
    _Weapons = [_Weapons,_CurrentIndexWeapon] joinString " ";
    } forEach (_WeaponCargo select 0);
    {
    _CurrentIndexMagazine = format["_x addMagazineCargoGlobal [""%1"", %2];",_x,(_MagazineCargo select 1 select _forEachIndex)];
    _Magazines = [_Magazines,_CurrentIndexMagazine] joinString " ";
    } forEach (_MagazineCargo select 0);
    {
    _CurrentIndexItem = format["_x addItemCargoGlobal [""%1"", %2];",_x,(_ItemCargo select 1 select _forEachIndex)];
    _Items = [_Items,_CurrentIndexItem] joinString " ";
    } forEach (_ItemCargo select 0);
    _Array = _Array pushBack format["%1 %2 %3",_Weapons,_Magazines,_Items];
} forEach _Crates;
copyToClipboard _Array;
};
robust hollow
#

send error log

radiant needle
#

Where can that be found?

robust hollow
#

rpt file

#

dont worry actually

#

pushback returns the index the element was inserted to. remove _Array =

radiant needle
#

oh yeah, for some reason I was thinking of it like joinString

still forum
#

@sinful flame
If a method has a return type do you always have to give it a varible to return to? No. But there is a bug where in script fields in the Editor you cannot have a value left on the stack at the end. So you have to do something like 0 = ... or _dummy = ... or whatever just to make it go away.
and binary is when a method take arguments but also returns an array/object/value? no, binary is when a command takes two arguments. One on the left and one on the right. Whether it returns something or not depends on the command.
and if a command takes no input and has no output then it is a nulary method? no. If it takes no arguments it's a nular command. Says absolutely nothing about return values, refer to the wiki page of that command for return values.
@sinful flame the Eden debugger. I ran the code you gave me and i get no visible text output The debug console you mean?
There is the big text box on the top for script to put into. Then there is a small textbox below that where the output of the code goes.
If there is no output aka "nil" is returned then that box stays empty.

@radiant needle Why am I getting "Type number not array" for_Array = _Array pushBack ... in this code
Because you didn't read the wiki page for pushBack.

radiant needle
#

I don't think reading a wiki page influences code execution

#

Connor found the issue

still forum
#

It influences whether you write correct code or whether you have wrong assumptions and your code fails because of that

#

You would've found the issue yourself if you had read the wiki page and had seen that it modifies the array, and that it returns a number.

radiant needle
still forum
#

Woah _AddItems = compile (_Array select _forEachIndex); Don't do that. Why are you doing that? Don't do that

#

Performance of compile is terrible. And there was a memory leak in there just recently

#

Just make 3 arrays of weapons, magazines and items. And then iterate through them

radiant needle
#

I mean it runs once, is performance really an issue?

#

well for each crate, but only once per mission

still forum
#

As I said there was recently a memory leak in that. The string stays in memory forever.
And it's just not good practice.

radiant needle
#

Is there another way to turn the string, into not a string?

still forum
#

No

#

Just don't use a string

#

as I said. Just collect arrays of the things you wanna add

#

You are just using format and compile to work around the fact that you don't know how to properly script

radiant needle
#

Is there a reason for the hostility?

still forum
#

Which hostility?

radiant needle
#

Telling people they don't know how to script.

still forum
#

Why is that hostile?

radiant needle
#

Because it's rude and uncalled for. My script works fine as is. If you have suggestions make them, if not shut up. Telling someone they don't know how to script is completely unconstructive and useless information

#

I'll consider and appreciate valuable or constructive input, but that's not it.

still forum
#

without hacky format/compile workarounds

#

You should also get used to using private. You already did at your _dialog but nowhere else.
It makes sure that you are not accidentally overwriting other peoples variables And it makes the code more readable because you can see where a varible is first defined

#

Also see how I used apply, instead of a forEach with tons of pushBacks.
It does the same thing, but it's shorter and faster.

radiant needle
#

Basically I wanted to turn it into code the user could copy the code, save it in their files, and execute it later. SearchObj is fixed, and locations of the containers are fixed, figured a sorted search would maintain consistency among the containers

still forum
#

Basically I wanted to turn it into code the user could copy the code, save it in their files, and execute it later. I did the same. Without any call compile

radiant needle
#

So what does private actually do? I thought it being underscore local already made it private?

still forum
#

Nope. Just _var looks if the var already exists in any parent scope

#
_var = 10;
call {
    _var = 5;
};
//_var is now 5.
_var = 10;
call {
    private _var = 5;
};
//_var is still 10.
#

imagine the call being someone else calling some function that you wrote.
The user will then be completely confused as to why their variables magically change around without them actually changing it

radiant needle
#

But what if I want the innerscope to set the var for the outerscope, do I not make it private or is there another way

still forum
#

You just leave away the private when you assign the variable

#

Btw your script is collecting the cargo of many crates.
And then combines all that cargo and puts it in all crates.

So if you start out with 2 crates that has each one bandage.
If you run that script on 2 crates later. You will have 2 crates with each 2 bandages. Instead of one bandage each.
But there is no real way to fix that besides making sure that you only have one crate in the input

radiant needle
#

Nothing a little clear cargo can't fix

#

Also whats the difference between local and global arguments?

still forum
#

Local argument means the command only works when the object is local to you.
Generally only objects that you spawned yourself (not spawned by the mission) and vehicles that you are the driver of are local to your computer.
The rest runs on either other players computers, or on the server.

#

Btw that script for the crates. Do you intent to put that into a init script in the editor? or init.sqf? or where do you intent to put that?

radiant needle
#

Achilles execute code module

still forum
#

So live then? not set somewhere in the editor?

#

Because init boxes in editor, or init scripts run for each player.
Meaning if you have your script in there, and you have 10 players, the crates would be filled 10 times.

radiant needle
#

It allows me to execute as local

#

It's pretty much just like the debug console

#

Looks like with the string one, it's a zero divisor error

#

on this line

_weaponsArray append ((_WeaponCargo select 0) apply {[_x,(_WeaponCargo select 1 select _forEachIndex)]});
still forum
#

I guess _WeaponCargo might be empty

radiant needle
#

Dialog output looks like this

 
        [[["rhs_weap_pb_6p9",1],["FirstAidKit",1],["rhs_weap_fim92",1],["rhs_weap_fim92",<null>]], [["rhs_mag_an_m14_th3",3],["ACE_M14",<null>]], [["rhs_6b26_ess_green",3],["TFAR_anprc148jem",3],["rhs_acc_1p78",4],["rhs_acc_1pn93_2",4],["ACE_RangeTable_82mm",4],["rhs_6b23",<null>],["rhs_6b23_medic",<null>]]] spawn { 
            params ['_weaponsArray', '_magazineArray', '_itemArray']; 
            private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100]; 
            { 
                private _crate = _x; 
                {_crate addWeaponCargoGlobal _x} forEach _weaponsArray; 
                {_crate addMagazineCargoGlobal _x} forEach _magazineArray; 
                {_crate addItemCargoGlobal _x} forEach _itemArray; 
            } forEach _Crates 
        }; 
    
still forum
#

That happens when the two arrays of getWeaponCargo are not the same size. But why would that happen 🤔

radiant needle
#

Looks like quantity is shifted somehow

still forum
#

Oh I see. Duh.

#

no _forEachIndex in apply :/

radiant needle
#

Does there happen to be an _applyIndex?

robust hollow
#

no

radiant needle
#

Wiki being really slow for anyone else?

robust hollow
#

not really

radiant needle
#

So the only way i know to retrieve index from an array, is with the find command. But I imagine it's quite performance intensive

#

Or would it be better just to swap the apply for forEach?

still forum
#

forEach would definitely be the easy way. Trying to think of a better way

#

I wanted to do it in a better and shorter way anyway. One minute

#
[] spawn {
    private _Crates = nearestObjects [SearchObj, ["plp_ct_LockerBig"], 100];
    private _weaponsArray = [];
    private _magazineArray = [];
    private _itemArray = [];
    {
        (_weaponsArray) pushBack getWeaponCargo _x;
        (_magazineArray) pushBack getMagazineCargo _x;
        (_itemArray) pushBack getItemCargo _x;
    } forEach _Crates;

    
    private _Output = format ["
        [%1, %2, %3] spawn {
            params ['_weaponsArray', '_magazineArray', '_itemArray'];
            private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100];
            {
                private _crate = _x;
                (_weaponsArray select _forEachIndex) params ['_weaponClasses', '_weaponCounts'];
                {_crate addWeaponCargoGlobal [_x, _weaponCounts select _forEachIndex]} forEach _weaponClasses;
                (_magazineArray select _forEachIndex) params ['_magazineClasses', '_magazineCounts'];
                {_crate addMagazineCargoGlobal [_x, _magazineCounts select _forEachIndex]} forEach _magazineClasses;
                (_itemArray select _forEachIndex) params ['_itemClasses', '_itemCounts'];
                {_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach itemClasses;
            } forEach _Crates
        };
    ", _weaponsArray, _magazineArray, _itemArray];
    
    uiNamespace setVariable ['Ares_CopyPaste_Dialog_Text', _Output];
    private _dialog = createDialog "Ares_CopyPaste_Dialog";
};

Only slightly shorter I think

radiant needle
#

zerodivisor @ (_weaponsArray select 1) append (_WeaponCargo select 1);

still forum
#

Ah ffs. I should test my code.

    private _weaponsArray = [];
    private _magazineArray = [];
    private _itemArray = [];

->

    private _weaponsArray = [[],[]];
    private _magazineArray = [[],[]];
    private _itemArray = [[],[]];

Can't select the second element out of an empty array ofc

radiant needle
#

_itemArray params ['itemClasses', '_itemCounts']; local variable in global space

velvet merlin
#

is there a reliable way to get an AI driver to move somewhere when you are in as gunner/commander (effectiveCommander)

still forum
#

_ missing on itemClasses.
Error is actually "global variable in local space" arma is not very accurate

#

I need to step up my code review game

runic surge
#

@velvet merlin it doesn't seem like it can be changed

#

any vehicle with a weapon mount of some kind automatically sets the player as effectiveCommander for some reason

radiant needle
#

only problem is, now it adds the items from all containers combined, into each container

velvet merlin
#

i have limited success with move the AI and back in just before the command, yet its not fully reliable

runic surge
#

I ran into this issue earlier when testing ai visibility with vehicles and nothing I have tried has worked

#

not a priority for my purposes, but for actual mission makers it is a serious oversight

#

I don't remember it always being this way

still forum
#

only problem is, now it adds the items from all containers combined, into each container
Yeah that's what I said before.
Oh FFS I need to learn to read better

#

Even shorter now

[] spawn {
    private _Output = format ["
        %1 spawn {
            private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100];
            {
                private _crate = _x;
                (_this select _forEachIndex) params ['_weaponsArray', '_magazineArray', '_itemArray'];
                _weaponsArray params ['_weaponClasses', '_weaponCounts'];
                {_crate addWeaponCargoGlobal [_x, _weaponCounts select _forEachIndex]} forEach _weaponClasses;
                _magazineArray params ['_magazineClasses', '_magazineCounts'];
                {_crate addMagazineCargoGlobal [_x, _magazineCounts select _forEachIndex]} forEach _magazineClasses;
                _itemArray select params ['_itemClasses', '_itemCounts'];
                {_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach itemClasses;
            } forEach _Crates
        };"
    ,  
        (nearestObjects [SearchObj, ["plp_ct_LockerBig"], 100]) apply {[getWeaponCargo _x, getMagazineCargo _x, getItemCargo _x]}
    ];
    
    uiNamespace setVariable ['Ares_CopyPaste_Dialog_Text', _Output];
    private _dialog = createDialog "Ares_CopyPaste_Dialog";
};
radiant needle
#

You forgot this _

#

On itemClasses again

still forum
#

oh the second one. yeah

#

fixed

radiant needle
#

So here is the output

[[[[[],[]],[[],[]],[["gorkaemrs"],[2]]],[[["rhs_weap_6p53"],[2]],[[],[]],[[],[]]],[[["FirstAidKit"],[2]],[[],[]],[[],[]]]]] spawn { 
            params ['_Array']; 
            private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100]; 
            { 
                private _crate = _x; 
                clearWeaponCargoGlobal _x; 
                clearMagazineCargoGlobal _x; 
                clearItemCargoGlobal _x; 
                (_Array select _forEachIndex) params ['_weaponsArray', '_magazineArray', '_itemArray']; 
                _weaponsArray params ['_weaponClasses', '_weaponCounts']; 
                {_crate addWeaponCargoGlobal [_x, _weaponCounts select _forEachIndex]} forEach _weaponClasses; 
                _magazineArray params ['_magazineClasses', '_magazineCounts']; 
                {_crate addMagazineCargoGlobal [_x, _magazineCounts select _forEachIndex]} forEach _magazineClasses; 
                _itemArray select params ['_itemClasses', '_itemCounts']; 
                {_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach _itemClasses; 
            } forEach _Crates 
        };

_itemCounts undefined variable error on this line

{_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach _itemClasses;
#

fixed

still forum
#

What was it?

radiant needle
#

for some reason you had select params

still forum
#

Oh

#

Maybe I need glasses

radiant needle
#

But now it works great

still forum
#

And way more compact now. Also the string to copy-paste should be alot smaller

#

I'm sure there are still a couple characters that can be chopped off 😄

#

Actually I see 22 characters that I can remove. Probably not worth posting the script again now....... But I can edit my above one!

radiant needle
#

yeah somethings up with the wiki for me, can't even access now

still forum
#

Just removed the [] from the spawn. As we are already passing an array to it. Don't need array in array ^^

#

Works fine here

radiant needle
#

yeah working now, just insanely slow, like 10 seconds for a load

#

whoops I forgot about backpacks

#

easy enough fix though

runic surge
velvet merlin
#

yep

runic surge
#

I'm starting to worry that it's intended behaviour

radiant needle
#

Just have to remember that the save crates all have to be same classname, and remember to click on the same crate when saving and loading

swift crane
#

I need command to get class of the vehicle (Truck , MotorCycle, Tank e.t.c.)
is there any command for this?

radiant egret
swift crane
#

@radiant egret

still forum
#

You can't

#

You can use isKindOf to check through each of them. And then take the first one you found

#

but you can't just "get" the "type" of the object. Because what you are thinking of is not actually the class/type of the object. It's one of it's many parents

swift crane
#

yeah, isKindOf should work for me, thx

thin pond
#

is there any way to customize (paint/parts) vehicles that are already spawned or is there a vehicle spawner that allows a player to customize a vehicle before spawing ?

ebon ridge
#

I have a related question, but I want to be able to change appearance of ANY object in game. Any ideas? setObjectTexture/setObjectMaterial won't work on lots of objects (H-barriers for instance). I want to make the semi-transparent preferable, or at least be able to change their color. My next approach to look at is using particles. Can this be done? i.e. pull the p3d from the object config and make a fake particle using it and apply alpha/whatever?

restive leaf
#

Would it not be setObjectTextureGlobal

#

For MP anyway

#

And setObjectTexture whether global or local only works on objects with hiddenSelections iirc

thin pond
#

@ebon ridge those would be way to complicated as we have 20-30 different vehicles that are spawnable through a menu.... setting this up for every single part wouldn be practical

ebon ridge
#

Yeah you remember correctly @restive leaf, that is the problem I am trying to find a solution to now

#

Okay you didn't give any constraints just asked if there was a way, that is a way. Maybe someone made a mod that gives you a UI for doing it? In fact I think I maybe remember something like that.

restive leaf
#

Not that tough to script on start since you can extract the hiddenselections easily. I retexture the UGV in a roaming AI script with these two lines but it wouldn't be difficult to automate it for many vehicles: _vehicle setObjectTextureGlobal [0, "x\addons\EpochZMod\data\UGV.paa"]; _vehicle setObjectTextureGlobal [2, "x\addons\EpochZMod\data\UGV.paa"];I'm sending you a PM btw with a couple of references

#

PMing you too @ebon ridge

fleet hazel
#

Guys. Prompt. I have a script that creates furniture in the house.

dom setVariable ["Furniture",[
["Land_Sofa_01_F", [-3.63843,-0.175781,0.852625 + 0.2],181.334,true],
["Land_TableDesk_F", [-1.47363,-0.185059,0.852638 + 0.2],0.00568346,false]
],true];


life_downloadFurniture = {
    {
        if !(_x select 3) then {
            _getPos = dom modelToWorld (_x select 1);
            _oilModel = (_x select 0) createVehicleLocal [0,0,0];
            _oilModel setDir (_x select 2);
            _oilModel setPosATL _getPos;
        };
    }forEach (dom getVariable "Furniture");
};

When I request a location again
dom worldToModel getPosATL _obj;
The result on the x-axis is slightly different from the original data. What am I doing wrong?

#

Data to Spawn:
[-1.47363,-0.185059,0.852638 + 0.2]
After
[-1.47339,-0.185059,0.872818]

still forum
#

might be adjusting to a slope

ebon ridge
#

I fixed this by using getGlobalPos I believe

#

and setting the up and dir vectors iirc

still forum
#

getPosWorld

ebon ridge
#

yeah sounds more like it

still forum
#

setVectorDirAndUp

fleet hazel
#

Thanks, guys.

ebon ridge
#

So if nobody has ideas for my one I will ask more specific question: can I get a p3d model from any object config and apply it to a particle and have it render that model in particle form?

fleet hazel
#

@still forum What should I do with setVectorDirAndUp

still forum
#

you can set the direction and up vector with that

#

can I get a p3d model from any object config and apply it to a particle and have it render that model in particle form?
AFAIK yes

ebon ridge
#

Awesome, and I would guess all particles can be alphed?

still forum
#

But not sure if it let's you apply alpha if the object itself doesn't support it. Need to test

ebon ridge
#

Okay I will definitely do that

#

Thanks

thorn saffron
#

How can I check if player is near a rear of vehicle? I want to make the Open Ramp user action available to be used by someone outside of the vehicle.

still forum
#

from vehicle getRelDir to player

#

if >90/<270 then he's behind the vehicle

thorn saffron
#

ok so the UserAction for opening the ramp has this as a condition

this doorPhase 'Door_1_source' < 0.5 AND Alive(this) && {(player in [driver this, this turretUnit [0], this turretUnit [1], this turretUnit [2]])} && {((this getVariable ['bis_disabled_Ramp',0]) != 1)}

The issue is that it lets only the gunner, pilot or FFV guys to open the ramp. I would like it so they can open the ramp as well as allow somebody near it to open. If I remove the turret check, then you can open the turret when standing near the rear, but it removes the action from the crew.
The user action has the radius and everything set up, so I would prefer use those setting instead of construction a completely custom check for radius

surreal peak
#
[
    "Test Dialog",
    [
        // The last number is optional! If you want the first selection you can remove the number.
        ["Combo Box Control", ["Choice 1","Choice 2"], 1]
    ]
] call Ares_fnc_showChooseDialog;

// If the dialog was closed.
if (_dialogResult isEqualTo []) exitWith{};

// Get the selected data
_dialogResult params ["_comboBoxResult"];

// Output the data to the chat.
systemChat format ["Combo Box Result: %1", _comboBoxResult];
#

rpt log: ```16:51:46 Error position: <isNil "Ares_var_showChooseDialog" };

if>
16:51:46 Error Generic error in expression
16:51:46 File \achilles\ui_f\functions\dynamic\fn_ShowChooseDialog.sqf [Ares_fnc_ShowChooseDialog], line 292

thorn saffron
#

Ok, I think I found the simplest solution: I will just have a separate action for opening the ramp from outside

devout stag
#

What's the best way to get the base mod name that a piece of a equipment comes from?

#

I am working on the UO Framework and I'm creating a conditional that hides gear presets if a user does not have the mod that a piece of gear comes from.

robust hollow
devout stag
#

I've been trying to use SQF Linter with Atom recently

#

But I keep getting this error

#
linter-registry.js:145 [Linter] Error running SQFlint Error: Traceback (most recent call last):
  File "c:\users\alex\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\alex\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Alex\AppData\Local\Programs\Python\Python37\Scripts\sqflint.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'sqflint'
    at ChildProcess.<anonymous> (C:\Users\Alex\.atom\packages\linter-sqf\node_modules\sb-exec\lib\index.js:56)
    at emitTwo (events.js:126)
    at ChildProcess.emit (events.js:214)
    at maybeClose (internal/child_process.js:925)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209)
robust hollow
astral tendon
#

I did not manage to make setWaypointScript and setWaypointStatements to work, none of the exemples works, is there any other way to check if a group finished a waypoint that does not require a loop to run?

devout stag
#

@robust hollow I've already attempted that fix. Tis the reason I asked here.

earnest roost
#

right, I assume this needs to go in here. I want to have a drone act on its own, just following a unit around like it's a normal private, only without actually having a guy controlling it. Just have it have its own AI. Is that possible? Are there examples of this?

cosmic kettle
#

@devout stag
As suggested by Connor, https://github.com/LordGolias/sqf/issues/22#issuecomment-326786174
The problem is most likely environment variables not being set. If you did not succeed, you probably did something wrong.
Make sure you:

  1. Installed all dependecies.
  2. Configured its' settings the way they should be. (Both the Executable path and the Python path)
  3. Apply forementioned fix.
    If all those are done and you are still failing, try again.
frigid raven
#

Suggestion: What about splitting scripting into scripting-help & script-review.
I don't want to disturb posts of people who are looking for help while I just want a quick review of my script-logic

still forum
radiant needle
#

What's the best way to have an object point at another object?

#

Pitch and yaw

high marsh
#

You mean apply the pitch and yaw of one object to another?

radiant needle
#

More like say I have a car on a road facing north, and a helicopter hovering 50m in the air, 100m to the east, I want the car to point at the helicopter so that if I did car setVelocityModelSpace [0,1000,0]; it'd hit it

high marsh
#
_dirToHelo = car_1 getDir helo_1;
car_1 setDir _dirToHelo;
robust hollow
#

he wants his car to point in the direction of the heli, and up at it.

#

i know what u mean, just cant think of how to do it 😕

earnest roost
#

Is it possible to just use gonio functions? Does this support math?

still forum
#

getPos. Vector diff will give you direction

#

set vector dir

radiant needle
#

Also is there a reason why this is so far off depending where I spawn it on map?

[(_this select 0),615] spawn {     
params ["_Location","_Adj"];     
_LocAdj = _Location getPos [6000, 0];     
_projectile = createVehicle ["Sh_120mm_HE",[0,0,0],[],0,"NONE"];     
_LocAdj set [2,4000];   
_projectile setPosASL (_LocAdj);   
_light = "#lightpoint" createVehicle getPos _Projectile;    
 _light attachTo [_projectile, [0, 0, 0]];    
 [_light] remoteExec ["fn_meteorLight", 0, true];    
_vector = vectorNormalized ((getPosATL _projectile) vectorFromTo (_Location vectorAdd [0,0,((getTerrainHeightASL _Location) + _Adj)]));     
_projectile setVelocity (_vector vectorMultiply 1800);    
waitUntil {!alive _Projectile};    
deleteVehicle _light;    
};
still forum
#

_Location vectorAdd A location is not a vector

radiant needle
#

yeah but it doesn't know that

#

I could just use set I guess

still forum
#

yeah but it doesn't know that what?

#

You can't vectorAdd a location. That doesn't make sense

radiant needle
#

vectorAdd will accept any 3 element array

still forum
#

But location isn't one

#

Or is it?

radiant needle
#

yeah it adds the 0

still forum
#

I'm assuming that Location is a Location

radiant needle
#

It'll print [1234,5678,0]

still forum
#

So location is not a location then

#

okey that confused me

radiant needle
#

more of a position

#

yeah not a location in Arma terms

still forum
#

Why are you using ATL position on the left of vectorFromTo.
But whatever _Location is and ASL on the right?
Don't mix position types

#

ATL might be 100 while ASL might be 5000

radiant needle
#

Basically LocAdj is Location shifted 6000m away, and 4000m above. I basically just need to make sure that the projectile always spawns 4000m above the terrain height of location, regardless of ATL of LocAdj

#

And that _Adj is always 615m above Location

#

So basically 2D distance from _LocAdj should always be 6000. 3D distance from _LocAdj to _Location should always be the same.

still forum
#

so you want to have the projectile come in sideways, not straight from top down?

radiant needle
#

correct

#

_Adj is an aimpoint that accounts for ballistic drop

still forum
#

Basically LocAdj is Location shifted 6000m away, and 4000m above.
Not 4000m above. You set the height to 4000m. If location is at 5000m it might even be below location.

radiant needle
#

Basically I only care about the height of the aimpoint and spawn point relative to the target point

#

If terrain under spawn point is 3995m, it doesn't matter that the shell is only spawning 5m over the terrain

still forum
#
[(_this select 0),615] spawn {     
    params ["_Location","_Adj"];
    _projectileSpawnPoint = _Location vectorAdd [6000, 0, 4000]; //6000m northwards, 4000m above location     
    _projectile = createVehicle ["Sh_120mm_HE",[0,0,1000],[],0,"NONE"];     
    _projectile setPosASL _projectileSpawnPoint;   
    
    _light = "#lightpoint" createVehicle getPos _Projectile;    
    _light attachTo [_projectile, [0, 0, 0]];    
    [_light] remoteExec ["fn_meteorLight", 0, true];    
    
    //Let it fly towards _Adj above location
    _vector = vectorNormalized ((getPosASL _projectile) vectorFromTo (_Location vectorAdd [0,0,_Adj]));     
    _projectile setVelocity (_vector vectorMultiply 1800); //1800 m/s    
    waitUntil {!alive _Projectile};    
    deleteVehicle _light;    
};

How about this maybe? I also changed the spawn point of createVehicle to be in the air, because if you are unlucky it might crash into the ground immediately before you setPos.

radiant needle
#

mhm looks like the distance between spawn point and aimpoint is still different

radiant needle
#

Surely the maps in Arma don't have projection?

#

They're a flat plane right?

#

wtf

#

So this is what I'm running:

[(_this select 0),430] spawn {      
    params ["_Location","_Adj"]; 
    _projectileSpawnPoint = _Location getPos [6000, 180];
    _projectileSpawnPoint set [2,4000 + (getTerrainHeightASL _Location)];
    _projectile = createVehicle ["Sh_120mm_HE",[0,0,1000],[],0,"NONE"];      
    _projectile setPosASL _projectileSpawnPoint;
    _light = "#lightpoint" createVehicle getPos _Projectile;
    _light attachTo [_projectile, [0, 0, 0]];
    [_light] remoteExec ["fn_meteorLight", 0, true];
    _vector = vectorNormalized ((getPosASL _projectile) vectorFromTo (_Location vectorAdd [0,0,_Adj]));
    _projectile setVelocity (_vector vectorMultiply 1800);
    systemChat format["%1",_projectileSpawnPoint distance (_Location vectorAdd [0,0,_Adj])];
    waitUntil {!alive _Projectile};
    deleteVehicle _light;
};
#

I'm clicking at the Thronos castle on Altis

#

When I change between _projectileSpawnPoint = _Location getPos [6000, 180]; and _projectileSpawnPoint = _Location getPos [6000, 0]; my projectile spawn altitude, and aimpoint altitude are the same (between the two different directions)

#

But yet the distance is different

#

by about 90 meters

still forum
#

Surely the maps in Arma don't have projection what do you mean?
They're a flat plane right No.. Mountains and underwater terrain are not flat

#

altitude above terrain might be the same.
But altitude above waterlevel might not be.

frigid raven
#

The following logic is checking through an array of CBA hashes. These hashes have a property that contains a timestamp value. In the forEach I am checking these times and control if the timestamp is too old. If it is too old it gets added to an array that contains all "too old" timestamps. This array should be substracted from the original array. The resulting array should only contain those elements where the timestamp is "valid" in context of the logic.

Here is the script. I'd like to know if I am doing it the right way with substracting an array as mentioned here: https://community.bistudio.com/wiki/Array

    private _tasksToBeRemoved = [];
    
    {
        private _currentTime = call coopr_fnc_currentGameTime;
        private _taskCreatedTime = [_x, COOPR_KEY_TASK_CREATED] call CBA_fnc_hashGet;
        private _freshness = _currentTime - _taskCreatedTime;
        if (_freshness >= COOPR_TASK_MIN_FRESHNESS) then {
            DEBUG2("freshness of task %1 is too old", _x);
            DEBUG2("was: %1", _freshness);
            _tasksToBeRemoved pushBackUnique _x;
        };
    } forEach COOPR_TASKS_QUEUE;
    
    DEBUG2("there are %1 tasks to be removed", count _tasksToBeRemoved);
    COOPR_TASKS_QUEUE = COOPR_TASKS_QUEUE - _tasksToBeRemoved;
    DEBUG("task queue has been cleaned from old tasks");
still forum
#

Looks right to me.
It's a "little" inefficient as the - operator copies the array. Depends on how big your array is.
You could also collect the indicies of all elements to remove. Then reverse that (because if you remove at start you change all other indicies)
and then use deleteAt to delete from back to front

radiant needle
#

Surely the maps in Arma don't have projection what do you mean?

If you had unlimited view distance, would departing ships eventually disappear below horizon?

still forum
#

no. sea is flat

radiant needle
#

Still can't figure out why distance is changing based on direction

errant widget
still forum
#

You mean alt syntax 3?

errant widget
#

no, number 1

still forum
#

That is gaussian distribution. See the image on top right

errant widget
#

yeah

#

gaussians don't have minimums or maximums

tame portal
#

But you can just put the Gaussian curve between your min and max

errant widget
lost copper
#

Hi everyone! I work with ACE 3 medical system now, and have a one question. Info about all units fractures saved in QGVAR(fractures) variable (full name: "ace_medical_fractures"). But i can't find code, which add effects of broken legs and arms to unit (shaking hands, slow speed of moving). Does anyone know where i can find that?

still forum
#

That's done by Arma. Hitpoint damage

radiant needle
#

that's why you need to floor if you want to have chance of 0

errant widget
#

so my question is - what cut-off is chosen? it seems like a reasonably important detail

lost copper
#

@still forum so if i set this variable to [] like:

player setVariable [QGVAR(fractures), [], true];

It fix my leg and arms automatically?

still forum
#

no

#

As I said. It's done by Arma, not ACE

tame portal
#

@errant widget Hm sadly I don't know the cut off points either, what's your use case if I might ask?

errant widget
#

I just want to know what to call a variable lol

still forum
#

@errant widget

random [min, mid, max] ->

randomValue = random 1;
result = if (randomValue < 0.5) then {min + (mid - min) * (randomValue2)} else {mid + (max - mid) * (randomValue2-1)}

errant widget
#

I'm calling it "sigma" at the moment but I think it might actually be sigma / 2

#

wait, that gives you a normal distribution? eugh, computers should be banned

tame portal
#

math

#

ew

lost copper
#

@still forum did that depends on current player damage?
I'm about broken legs and arms.

still forum
#

yes

#

if your legs have too much damage, you can only walk.
If your arms/hands have damage, your aim is shaking

lost copper
#

So fixing that is equal to setting damage of palyer to 0?

still forum
#

I think so yes

lost copper
#

That's a problem for me. But thanks, @still forum

errant widget
#

@still forum , what was that code supposed to be?

still forum
#

that is how the normal distribution random works

errant widget
#

lol

#

are you sure?

still forum
#

yes

errant widget
#

that just remaps a uniform distribution to within a certain range

still forum
#

Well not quite.
It actually does random 1 4 times. And then divides by 4.
I shortened that

errant widget
frigid raven
#

@still forum yeah i was considering the removal by index at first, too. Good you mentioned the reverse "trick". Would not have considered that

errant widget
#

(your code, not ArmA's)

still forum
#

Okey I just tried that and got out a 17 on a max of 15.
Must be a typo in there I'll recheck

errant widget
#

I mean, it's pretty obviously not doing any exponential stuff there

#

it's just doubling a number

still forum
#
randomValue = ((random 1)+(random 1)+(random 1)+(random 1)) / 4
result = 0;
if (randomValue < 0.5) then {
result = min + (mid - min) * (randomValue * 2)
} else {
result = mid + (max - mid) * (randomValue * 2 - 1)
};
errant widget
#

result = 0? does it iterate at all?

#

also, the mean of 4 identical uniform distributions will just the the original uniform distribution

still forum
#

That should be the same as I wrote above right?

errant widget
#

unless I really don't understand random

#

is random x not a uniform distribution?

still forum
#

also, the mean of 4 identical uniform distributions will just the the original uniform distribution I know. That's why I shortened that when I first posted it

#

OH!

#

Yes it's not

#

it's based on a seed that changes every time it's called

errant widget
#

oh, that's a very weird choice

#

ok

#

well yes, your code would rescale a distribution

#

the question is what on earth is random x, then?

still forum
errant widget
#

aha, now we're getting somewhere, thanks

#

hmm, LCGs should be uniform

#

huh, dedmen, taking the mean of the four uniform distributions is the thing that matters

#

I guess I need to brush up on my stochastic algebra a bit more

#

I can't quite believe I said that the mean of four uniform distributions was a uniform distribution. that's clearly just not right

#

what even is the central limit theorem

still forum
#

Maybe not change the link.
But make a note that that is what is actually used.
Few people will care about that. And gaussian is more easy to understand

halcyon crypt
#

does anyone know of a tool or vim plugin that can handle the BI FSMs without all the string crap?

#

don't really want to use the BI FSM editor

queen cargo
#

without the string crap?

#

what string crap?

halcyon crypt
#

well all code is wrapped in strings

#

e.g.

    /*%FSM<STATE "End_delete_group">*/
    class End_delete_group
    {
      name = "End_delete_group";
      init = /*%FSM<STATEINIT""">*/"if (typename _grp == ""OBJECT"") then {_grp = group _grp};" \n
       "[_logic, ""delGroup"", _grp] call ALiVE_fnc_CQB;" \n
       "" \n
       "if(_debug) then {" \n
       "    format[""%1 aborting Simple House Patrol FSM"",  _leader] call ALiVE_fnc_logger;" \n
       "};" \n
       "" \n
       "deleteMarkerLocal _mkr;" \n
       ""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
      };
    };
    /*%FSM</STATE>*/
halcyon crypt
#

anyone know how isNil would behave with

isNil {(_someObj getVariable "an_object_that_might_be_nil") getVariable "possibly_nil"};

?

#

would it start throwing errors or catch the first nil?

#

seems like it catches it, yay 😃

still forum
#

unscheduled code doesn't error on nil

#

isNil's code runs in unscheduled

halcyon crypt
#

👍

tough abyss
#

It would have been pretty useless command if isNil threw error on nil

winter rose
#

True!
want to talk about try-catch that only catch created exceptions?

halcyon crypt
#

well I figured it might've with an operation on nil ^^

still forum
#

Want me to fix try catch to catch engine exceptions too? 😄

#

(I could)

tough abyss
#

@halcyon crypt y u no like bis fsm editor?

late gull
#

guys, a way to whitelist any warlords mission? i mean like:

#
missionWhitelist[]={ 
    "warlords"
};
tough abyss
#

No you need to give full mission name

slow isle
#

can someone give me a script for firing cluster shells?

#

this one can fire cars

#

player addEventHandler ["Fired", { _bullet = _this select 6; _unit = _this select 0; _newPos = _unit modelToWorld [0,8,1]; _veh = createVehicle ["I_MRAP_03_F",_newPos,[],0,"CAN_COLLIDE"]; _veh setDir getDir _unit; _veh setVelocity velocity _bullet; deleteVehicle _bullet; }];

#

I did it

#

nvm

frigid raven
#
private _creationSuccess = [_unit, _taskId , _taskType, _destination, 1, 2, true] call BIS_fnc_taskCreate;
DEBUG2("task creation: %1", _creationSuccess); // [Server] COOPR.TASKS.debug - task creation: coopr_task_type_assault_[]

Where Biki says: Return Value: Boolean
The logging tells me the return value is: coopr_task_type_assault_[] (where coopr_task_type_assault is the _taskId given to the function as parameter)
Am I getting something wrong here? My controls are awaiting boolean values for my guard clauses but I cant get booleans outta the function call

astral dawn
#

If I need to add onEachFrame missionEventHandler, should I use the BIS_fnc_addStackedEventHandler or addMissionEventHandler?
I found Dedmen's message from a year ago if you have many handlers the BIS_fnc_addStackedEventHandler has better performance. Because addMissionEH recompiles the script before every execution., is it still the case because of the disabled compilation cache?

slow isle
#

new question, how do I make a pawnee that fires cluster bombs

knotty sun
#

attach eventhandler to your helicopter

slow isle
#

I dont know shit in coding could u type what I need to add in

still forum
#

is it still the case because of the disabled compilation cache? it was the case with and without the cache

#

the stacked eh scripted stuff also has overhead

slow isle
#

its a shotgun script I found online

frigid raven
#

@slow isle First thing you need to understand is that people here are helping for free. You really have to make their helping as comfortable as possible. Just asking why isn't this working and providing a huge ass of script logic won't work. People in here are lazy yet willing to help - but only if they do not have to work their ass off to figure out what you actually want.

ruby breach
#

If you want someone to write your code for you, you're likely looking in the wrong place. We'll help you to the extent you attempt to help yourself

slow isle
#

I mean I dont understand shit and I found this online and im wondering why its not working, not with a bad intent, im just confused what to ask

#

I cant find the error myself

#

if one doesnt want to help he can pass it, im not making anyone help me

ruby breach
#

Well, for one if you're only executing it once it's not going to do anything

slow isle
#

wdym?

frigid raven
#

@slow isle in this case you really have to get basic knowledge in scripting SQF. It might sound annoying but if you don't even understand what we would tell you what went wrong with that script what is the point of asking then?

ruby breach
#

The first line says "If X exists, do this with X". The second line says "X exists, this is what it is"

slow isle
#

@frigid raven im not wanting to learn it long term, i just found myself playing around with it and got confused why some things dont work and posted it here

#

if someone wants to help he can and if one does not he can pass it

frigid raven
#

@slow isle alright - just telling you what might be a reason why nobody is replying to you

real moat
#

Hoping to get some help with some scripting I'm trying to do.
Is this the right spot for this?

robust hollow
#

yes

radiant needle
#

Is there a way to apply torque force to an object?

still forum
real moat
#

I'm actually hoping someone would be willing to join me on VoIP

still forum
#

scripts are usually text. So writing text messages is usually better than trying to dictate code over voip ^^

real moat
#

And doing both is better :3

#

But I mean, okay.

#

I just the feel Im going to put this code down and get directed to some other place where I can find better code.

#

Id like to go through it with someone and learn, ratther than the former.

#

But alas:

#

[this] call teleportNetwork;

#
params [
    "_target",
    "_caller"
];

// Varify Target is Sensible
//[ Author: Whigital
    if (isNull _target) exitWith {
        diag_log "RGTA_fnc_teleportNetwork::Target object is null!";
    };
    if (!hasInterface) exitWith {
        diag_log "RGTA_fnc_teleportNetwork::Instance has no interface, skipping actions";
    };
//]

_styleOpen     =     "<t size='1' font='PuristaSemiBold' color='#58D3F7'>";
_styleClose =    "</t>";

_target addAction
[
    format ["%1Base%2", _styleOpen, _styleClose],
    {call RGTA_fnc_teleportPlayer}, [_target,"tpNodeBase"]
];
_target addAction
[
    format ["%1Range%2", _styleOpen, _styleClose],
    {call RGTA_fnc_teleportPlayer}, [_target,"tpNodeRange"]
];
_target addAction
[
    format ["%1Explosives%2", _styleOpen, _styleClose],
    {call RGTA_fnc_teleportPlayer}, [_target,"tpNodeExplosives"]
];
#

What am I doing wrong here? The object doesn't get any of the actions.

still forum
#

[this] call teleportNetwork; That means target is set. but _caller will be nil. You don't pass the second parameter. And you also seem to not be using it

real moat
#

My bad

still forum
#

is teleportNetwork variable defined at the point where it's called?

real moat
#

_target is meant to be _caller

still forum
#

where are you defining that?

#

Also why does the teleportNetwork function say RGTA_fnc_vehicleSpawnSetup
? Seems like it should be called RGTA_fnc_vehicleSpawnSetup and not teleportNetwork

#

removeAllActions _target; there is your problem

#

you are adding actions. And immediately removing all actions again

real moat
#

Ah, I hadn't renamed the function yet.
That bit comes from a fellow unit member.

#

Does everything else apart from the end snippit appear correct @still forum ?

still forum
#

didn't notice anything else

real moat
#

Oh my gosh

#

I cannot believe I spent hours ripping my hair out over that

#

Thanks @still forum

#

If I receive the _caller in my params

params [
    "_target",
    "_caller"
];

Could I just directly push it to the next function like I have?

{call RGTA_fnc_teleportPlayer}, [_caller,"tpNodeBase"]
still forum
#

yes

#

well

#

you are passing the _this from the action through

#

that does contain your arguments array. But not only that

real moat
#

What would be the cleanest way to make sure the next function can get the _caller?

#

Also , would it be beneficial to rather have a looped addAction which works from an array?

still forum
#

array would be easier to maintain. but not necessarily better

#

you want the caller who executed the action right?

#

You can get the _caller inside the action code. YOu don't need to pass it beforehand as argument

#

{(_this select 3) call RGTA_fnc_teleportPlayer}, [_caller,"tpNodeBase"]
that would be equivalent to
[_caller,"tpNodeBase"] call RGTA_fnc_teleportPlayer

real moat
#

Thanks!

radiant needle
#

For switch do, can I have or statements in the cases

#

like case ("classname1" || "classname2"):

robust hollow
#

no, but you can do

case "class1";
case "class2":{

};```
radiant needle
#

so if class 1 matches, it executes class 2 code?

robust hollow
#

yes

#

you can do as many of these case "class1"; as you like, itl jump down to the next case with code to execute.

radiant needle
#

unrelated but what is the effective difference between a visual and non visual command

#

what does it mean for something to be done in "render time scope"

robust hollow
#

i dont know exactly, but the idea is visual commands return results for how something actually appears. a practical example being if you use getPosASL to draw 3d icons on a unit, when theyre moving quickly the icon will jitter around, but if you use getPosASLVisual the icon stays fixed on the units visual position.

still forum
#

render positions are interpolated

#

like when you see a car driving somewhere. You see it driving smoothly

#

even though there is only a position update every half a second or so

#

In render/visual scope, the position is predicted as to what it will be in the future. And it's updated every frame to look smooth

astral dawn
#

is it still the case because of the disabled compilation cache? it was the case with and without the cache
the stacked eh scripted stuff also has overhead
I think it's even worse now, right, since the cache is gone?

still forum
#

it's as bad as it was before the cache was added

astral dawn
#

That's another way to look at it 🤔

#

Anyway
SHould I use the BIS_fnc_addStackedEventHandler or addMissionEvent handler?

#

The second has compilation, the first one has overhead?

still forum
#

jup and jup

#

I guess the first one is better

#

I don't know though

astral dawn
#

oh wait
if I pass code to addMissionEventHandler, it doesn't get recompiled
if I pass it a string, the string gets compiled every time
right?

#

nvm found your issue at tracker website

still forum
#

if I pass code to addMissionEventHandler, it doesn't get recompiled it does

#

that's the bug

astral dawn
#

Yes got that, I recalled I've read it in the feedback tracker
I wonder why it wasn't fixed yet :/

still forum
#

it's not trivial

astral dawn
#

I assumed code variable is some sort of assembly or bytecode?

still forum
#

it is

astral dawn
#

and compiling the string is deterministic and should return the same sequence of assembly commands?

still forum
#

it does yes

astral dawn
#

Then I'm confused 🤔

still forum
#

well eventhandlers are stored as strings

#

leftover from SQS times

radiant needle
#

whats the thing I have to do for disc point picking?

radiant needle
#

Also is there a way to make it so civilians can enter blufor vehicles?

#

And access inventory

thin pond
#

I have multiple boxe scattered around the map were players can but items and then delete them, what should i but in place of "this" in order to not make a script for every single box. script is triggert with "addaction"

vestal crow
#

how would one open the cargo ramps on a vehicle that would be used in Splendid Camera?

cursive whale
#

So, further to the ongoing discussion about code compilation and EHs, am I better off making my EH code fragment just a call to an already compiled function (i.e. AddMissionEventHandler ["Event", {_this Call MY_Fnc_EventHandler}]; ) - to minimize this compilation overhead (at the cost of one additional Call) ???

robust hollow
#

depends on the size of the eh code, but in general yea, calling a compiled function from the event is the way to go.

cursive whale
#

Thanks

tough abyss
#

What's the best way to execute a script through a hotkey? Let's say when the player presses HOME, then script should be executed.

winter rose
#

a display event handler I guess

tough abyss
#

yeah ive been trying it with that, unsuccesfully, might be that my code is wrong

#
keydown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 199) then {player execVM 'dialog\fn_adminMenu.sqf'}"];
winter rose
#

where do you exec it?

slow elbow
#

fn_keyHanlder.sqf ```sqf
params["_ctrl","_button"];

if (keys_mainKeyHandlerOn) then {//Provides ability to temporarily disable this key handler
_disableButton = false;
if (_button == someDIKcode) then{[] spawn mld_core_fnc_ep_main; _disableButton = true;};// Earplugs. DEFAULT: F1

_disableButton;

};


some other local script: ```sqf

(findDisplay 46) addEventHandler ["KeyDown",{call tag_fnc_keyHandler}];


This is what i use for that Niko

tough abyss
#

the current line I use is in init.sqf

#

i'll look into that

winter rose
#

I did use

(findDisplay 46) displayAddEventHandler ["KeyDown", "systemChat str _this; if (_this select 1 == 199) then {hint 'working!';}"];```
and it worked
#

(in Eden console)

slow elbow
#

It just allows you to have multiple keybindings in a single function and a single down pres handler.

winter rose
#

maybe waitUntil findDisplay 46 != displayNull

slow elbow
#

That too ^

still forum
#

@tough abyss execute script on hotkey do you have CBA? Could use CBA hotkeys system

tough abyss
#

thank you for the suggestion but I've got it down with displayAddEventHandler

#

@winter rose @slow elbow thanks guys

astral dawn
#

What's the general preferred way of attaching two remoteExec's to the same Object? Making a wrapper function for both remoteExecutions?

tough abyss
#

Make a function which will have both scripts needed for RE and RE only 1 function

astral dawn
#

Yeah got that! Thx!
Somehow I wish there was a version that would not override existing remoteExecs attached to object, but rather queued both of them 🤔

tough abyss
#

Me too

astral dawn
#

Or maybe CBA has such a thing actually?

tough abyss
#

The problem comes when you have other modders wanting to use the same object

astral dawn
#

yes yes, CBA could add a general queue to which we would add CBA-wrapped remoteExecs, for instance

#

Then the CBA's queue could be overwritten by any non-CBA remoteExec 🤦

tough abyss
#

You can’t use object as JIP if you do that

#

Will have to be custom JIP ID

thin pond
#

what do i need to replace "this" with to make "clearitemcargo" applie to the containerthe script called from with "add action" ?

tough abyss
#

Why are you using local command instead of global?

thin pond
#

I'm using global... local was faster to write 😄

#

clearItemCargoGlobal this;
clearBackpackCargoGlobal this;
clearMagazineCargoGlobal this;
clearWeaponCargoGlobal this;

#

this is the "template" that im working of.... i know i can type the variable name of the box... but i dont want to have a script for every single box in my mission

#

the aim is to have multiple boxes in the mission where players can put stuff in and delete it manually.. .script is executed with "addaction"

spark turret
#

you want to add an action that spawns a box?

swift crane
#

In some mp scenarios I saw a delay for respawn button: when you are pressing ESC - respawn button has grey colour and unawaible, but 5 second later - button becomes awaible again. This good to prevent pushing the button by accident, If you are going to settings.
How can I make this kind of delay for respawn button?

ebon ridge
#

Is there vector to dir and dir to vector functions? Searching yields nothing for me

#

I want to interpolate dir

#

Ah I find CBA functions for this now

#

Would be nice if there was vanilla though

tough abyss
#

Vector dir is 3D while dir is 2D how are you using it?

copper raven
ebon ridge
#

@tough abyss I just want to interpolate between directions over time to animate a transition. However it won't work with a single dir value due to discontinuity at 0 etc, so I convert to vector, slerp it then convert back

tough abyss
#

The problem with onpausescript is that it is scheduled and when you press escape, respawn button can still be available due to busy scheduler

#

Use setvelocitytransformation @ebon ridge

ebon ridge
#

that is for a different problem but thanks

#

i don't want to modify an object just have the values and animate the values

tough abyss
#

Oh you can wait for new commands to hit dev branch think you can interpolate vector with them

real moat
#

How can I reference an object in a function?

#
params [
    "_target",
    "_caller",
    "_tpNode"
];

_caller allowDamage false;
_caller setPos (getPos _tpNode);

sleep 5;
_caller allowDamage true;
#

_tpNode is the variable name of an object in-game

still forum
#

from missionNamespace

shadow sapphire
#

I've got this in the initialization field of a box with the appropriate gear inside.

This addaction ["Equip Rifle Kit",
 {params ["_target", "_caller", "_actionId", "_arguments"];
    private _cargo = getitemcargo _target;
    _cargo params ["_items","_amount"];
    private _index = _items findif {_x = "30Rnd_556x45_Stanag_Tracer_Red"};
    if (_index >= 0 && {_amount#_index > 0}) then {
        _caller additem "30Rnd_556x45_Stanag_Tracer_Red";
        _target removemagazineglobal "30Rnd_556x45_Stanag_Tracer_Red";
        _amount set [_index,_amount#_index -1];
    };
}];```

The add action appears. When I use it, nothing happens. No errors are displayed in game or in the report file. But the desired effect is not achieved.
thin pond
#

@spark turret I have multiple boxes on the map were players can but items and then delet all items in the box... a "trashbox".... they can excecute the "delete" with a "addaction".... i know how to do it with a script for every single box but i want to have one script that identifies the box from which its called from and then delete its contents

#

the box should stay where it is

spark turret
#

so a certain class of boxes should all act as the trashcan?

thin pond
#

just the boxes which have the addaction

#

clearItemCargoGlobal this;
clearBackpackCargoGlobal this;
clearMagazineCargoGlobal this;
clearWeaponCargoGlobal this;

#

i just need something to replace this with something that can identify the box from which the add action is called from

spark turret
#

not sure what exactly you want, so you got boxes all around the map and want a script to find them without having to touch the boxes themselves?

#

or do you manually add the addaction to each trashcan box? bc the addaction passes on the object from which it is called

#

its one of the parameters passed in the _this value of the addaction. so if i walk up to the trashcan and use the action, the script run can read that I, the player interacted with that specific trashcan.

#

quote BI webiste: Parameters array passed to the script upon activation in _this variable is:
params ["_target", "_caller", "_actionId", "_arguments"];

real moat
#

Sorry to butt in here! Just a simple question ^^
When using set with arrays, how do I select the index of an array within an array.

spark turret
#

array select 0 select 0 = "hi" in [[hallo,miau],[xyz]] if thats the question

#

@real moat

#

@thin pond

#

ah no it wasnt lol

real moat
#

Not quite, but II iwill wait for @thin pond to be done before I elaborate.

spark turret
#

ah i understand now. not sure, try 0 select 0 as the index for multi dimensional arrays

thin pond
#

I will manually add the "addaction"

#

I'll give _this a try

spark turret
#

then put "_this execVm "scriptyouhave.sqf"; " in your code of the addaction

#

and in the script "_this select 0" is your trashcan and _this select 1" is the player using it

lucid junco
#

Hey guys, dont you know why civilianAi when i go around them and fire, they go into the combat behaviour and then back to safe like they should. But when this "behaviour cycle" goes like four or five times then civs dont react on fire so much. So do someone know why is that?

spark turret
#

no idea

#

asking "why" arma does something not logical is always difficult lol

thin pond
#

@spark turret not quite shure how to use the select0/1

#

here are the "delete" commands clearItemCargoGlobal _this;
clearBackpackCargoGlobal _this;
clearMagazineCargoGlobal _this;
clearWeaponCargoGlobal _this;

spark turret
#

well the _this thing is an array created by the addaction. if you put hint str _this (display it in the game) you get something like "[Player1 IRONSIGHT,trashcanobject102485]

#

_this select 0 selects the first position in the _this array which is the calling entity, here its the player

#

but you need to put _this select 1 since it selects the second position in the _this array which is the object the action was used from, aka the trashcan

#

so put clearBackpackCargoGlobal (_this select 1);

#

is SHOULD work lol can guarantee it tho

#

put this into the trashcans Init line in editor, it will show you what the _this array looks like:
_actionID = _this addAction ["Show me the _this value", {hint str _this;}]

#

keep in mind that the _this value is different for every command or entity. it changes/can be changed by commands and other factors. it basically stores important information you need to know about the object or command

thin pond
#

@spark turret my brain is deep fried after 8 hours of scripting any chance you could tell me what exactly i should put in my .sqf ? 😄 heres my add action i use: this addAction ["<t color='#960600'>TEXT</t>", "scripts\GEN\Trash.sqf", [], 1, false, true, "", "_this distance _target < 2"];

spark turret
#

_actionID = this addAction ["empty the trashcan", {_this execVM "scripts\GEN\Trash.sqf";}]; is the command you need in the init line of the trashcan.

#

in the script you put:

#

clearBackpackCargoGlobal _this select 1;
clearMagazineCargoGlobal _this select 1;
clearWeaponCargoGlobal _this select 1;

toxic temple
#

Hey guys

real moat
#

Yea my brain is beyond friend at this point
Its taken be like 2 days to write 120 lines
But Im trying to learn rather than copy-ppaste

toxic temple
#

Is there anything wrong with this line of code: somewreckthing setTaskState "Succeeded";

#

somewreckthing is the variable name of a task module

spark turret
#

then it should be fine

toxic temple
#

It says there's a general error

spark turret
#

im not sure how the modules work but with chance the variable name of the module is NOT the actualy task name

toxic temple
#

Ohhhhhh

#

Is it the task name?

thin pond
#

@real moat I'm beyond the point to learn something right now ;D

spark turret
#

@toxic temple did you put something in the Task-id field of the module? that should be the name

#

if its empty, it should be the variable name

toxic temple
#

I put a 1 in it

#

Then just ran it again with that in before you asked

#

And it still says Error General Expression Error or something like that

#

Generic Error in Expression

spark turret
#

hm interesting. i have never used tasks tbh

toxic temple
#

I really want this too work...

spark turret
#

where is the command executed?

toxic temple
#

In the trigger's activation thing

thin pond
#

@spark turret "array excepted object" didnt work.. digging into it right now

spark turret
#

yup i noticed sorry

#

give me a second to correct and test

real moat
#

if (_target = _tpList select _i) then {}

#

What is wrong about my condition here ?

winter rose
#

==

still forum
#

its not a condition its a assignment 😄

toxic temple
#

Can anyone help me?

#

@still forum Can you help me?

still forum
#

👀

toxic temple
#

Just scroll up a bit

spark turret
#

can probably yes, want is another thing lol

still forum
#

code looks fine. If somewreckthing is really what you expect it to be

spark turret
#

if (_target == _tpList select _i) then {} needs to have _i defined, either by you or be in a for "_i" from 0 to 100 do {} loop. are you aware of that?

#

i assume you want to check if the _target is in the _tplist. try if (_target in _tpList) then {} for that

#

its case sensitive so watch out

#

@real moat

toxic temple
#

Huh

real moat
#

kinda, but not qute like that

toxic temple
#

I seemed to have found a different way

#

["task1","CANCELED"] call BIS_fnc_taskSetState;

#

Well that works via Debug menu

#

Let's test it with the trigger

#

One sec

real moat
#

This is what I'm tryin to do:

#
params [
    "_target",
    "_caller",
    "_pos"
];

// Establish Array
_tpList = [
    ["_tpNodeBase",        "Base"            ,2],
    ["_tpNodeRange",        "Range"            ,2],
    ["_tpNodeExplosives",    "Explosives"    ,2],
    ["_tpNodeIsland",    "Island Runway"    ,2],
    ["_tpNodeUSS",        "USS Freedom"    ,2],
    ["_tpNodeRGS",    "RGS Posidon"    ,2],
    ["_tpRandom",        "Random"        ,2]
    /* Value 2 = coordinates */
];

for "_i" from 0 to (count _tpList) do { 
    if (_target == (_tpList select _i) then {
        _tpList set [[0,2], _pos];
        //hint "True!";
        //sleep 2;
    }
    //else { hint "False!"}
};
toxic temple
#

Yeaaaaaa

#

It worked

still forum
#

(_tplist select _i) set [2, _pos]
?

#

Btw. Don't do for loop. Use foreach if you need to loop

spark turret
#

@real moat you just wrote a really complicated if (value in array) then {}

still forum
#

btw2 use findIf to find the index

spark turret
#

or a foreach yeah

real moat
#

Thanks. I mean, guys, im learnin.

still forum
#

private _index = _tpList findIf {_x select 1 == _target};
(_tpList select _index) set [2, _pos]

spark turret
#

also just fyi count _array returns all positions added, so count [a,b,c] = 3
for "_i" from 0 to 3 executes the code 4 (!) times

real moat
#

great

#

sigh

spark turret
#

means for "_i" from 0 to count [a,b,c] do {array select _i}; gives an error bc it tries to do array select 3 which does not exist

still forum
#

gives an error bc it tries to do array select 3 which does not exist
No. I think one past the end still returns nil

#

if you go two past the end you'll error with zero divisor

#

Arma is great

spark turret
#

you re probably right, anyways just dont do that lol
if you really MUST use it, use:
for "_i" from 0 to (count [a,b,c] - 1 ) do {array select _i};

still forum
#

I don't see any reason why that would ever be needed

#

At most, you might need the index for something.
but forEach gives you the index

spark turret
#

i dont fully understand foreach commands and dont trust them so if i need a foreach for 2 arrays within each other i use that method

#

not a good reason I KNOW lol

still forum
#
{
private _firstElement = _x;

{
_firstElement setPos _x
} forEach _array2;

} forEach _array1;
spark turret
#

you enlighten me again and again

still forum
#

My bulb is turned on

real moat
#

I dont even know what anymore

spark turret
#

while we are at it, whats the difference between private _variable = ""; and _variable = "";

#

innermost scope only right?

still forum
#

yes

spark turret
still forum
#

Eww 😄

real moat
#

All good and well

#

But iiitts nott waht im trying tto do

spark turret
#

lol

still forum
#

player addMagazines ["M16", 4]

Btw M16 is not a magazine

spark turret
#

its from the BI webiste, im not to blame

still forum
spark turret
#

@real moat what is THAT trying to achieve? _tpList set [[0,2], _pos];

#

it will change the same positon in the array over and over

real moat
#

I really cant explain this in simple over text. Could you join me in the voice chat perhaps?

spark turret
#

the positon of the string "Base" will be changed to _pos every time its called

#

sure why not

still forum
#

I already showed you how to do it ^^

#

select the array you want to set something in first.
Then call set on that

tough abyss
still forum
#

he didn't say it does

#

example 2

tough abyss
#

Oh that, tsk tsk tsk

still forum
#

tzück tzück

toxic temple
#

How to I make it so that a create task module only happens after a trigger?

spark turret
#

condition for existence: change true to whatever global variable boolean you have

#

oh wait i take it back

#

doesnt work

next scaffold
#

I don’t know if this is the case, but some modules if linked to a trigger will only execute once the trigger is activated

#

@toxic temple

toxic temple
#

I did it dw

dim terrace
#

"M16" was both weapon and magazine in OFP

#
    class M16: Riffle
    {
        scopeWeapon=2;
        scopeMagazine=2;
        valueWeapon=0;
        valueMagazine=1;
        model="m16_proxy";
        modelOptics="optika_m16";
        optics=1;
        opticsZoomMin=0.34999999;
        opticsZoomMax=0.34999999;
        displayName="$STR_DN_M16";
        displayNameMagazine="$STR_MN_M16";
        shortNameMagazine="$STR_SN_M16";
        drySound[]=
        {
            "weapons\M16dry",
            0.0099999998,
            1
        };
        magazines[]=
        {
            "M16",
            "Mortar"
        };```
winter rose
#

"good old days" ;-p

real moat
#

How would I go about sending a getPos result through to a called function?

still forum
#

(getpos player) call myfunction

real moat
#
[this,
player,
getPos this
] call function;
#

is this okay?

still forum
#

yes

real moat
#

Thanks

#

Actually

#

I would imagine select 2 would be the getPos result

#

but it just spits out "5"

still forum
#

select 2 is syntax error. what are you actually executing

real moat
#

Object Init:

[
    this,
    player,
    getPos this
] call function;

Function

params [
    "_target",
    "_caller",
    "_pos"
];

Test

hint str(_pos);

Gives me "5"

tough abyss
#

Not possible

still forum
#

Not possible wat?

nocturne forge
#

I've got a question, i'm guessing it's an obvious one, but I can't figure it out. I'm trying to learn how to run scripts on my dedicated server as an admin, and i'm struggling with applying the command to a specific player. An example:

player enableFatigue false;

I can run that locally, and it'll apply to myself, so that's fine. But what I don't understand, is how do I apply this to a specific connected user that isn't me? what do I put instead of "player"? do I need to do something else to make "player" count as that user?

tough abyss
#

Getpos returning "5" is not possible

still forum
#

what do I put instead of "player" it's not that simple

#

allPlayers is a list of all players

#

you can iterate through that till you find the unit that you want

#

what condition you want to base that on is your decision. You could check the name

nocturne forge
#

So i'm guessing I need to loop through all players, find the user, and put that object into a variable that I can then put instead of "player" in the above example?

still forum
#

yes