#arma3_scripting

1 messages · Page 332 of 1

halcyon crypt
#

you can read all the files with loadFile or you can use a config exporter like the ones used for the all in one config exports etc

tough abyss
#

@tough abyss I meant function library is the better way. but thats not the point. Question is why should a function compiled with function library and called from init.sqf run in unscheduled environment? that is how I understood ur answer. Is that the case?

peak plover
#

preinit has the preinit = 1; tag or whatever, it means this will automatically be ran in the preinit

#

The function is not called from init.sqf or anywhere else

#

It's called from the library

#

By the library

tough abyss
#

okay. understood.
It's necessary to run it with preinit tag. hmm. I think I' ve to reconsider my whole scripting habits

#

thank u for clarification.

peak plover
#

No problem, glad to be of help

tough abyss
#

@peak plover
another but related thing...
if I like to have unscheduled code at a later time during mission then I cant use preinit because suspension is forbidden. Could I workaround with executing an .sqs script and call a function from it? thats what the wiki implies:

unscheduled: sqf code which is called from sqs-code

peak plover
#

Yes

#

Another question is why do you need unscheduled code?

#

In some cases you can work around using it completly instead

tough abyss
#

its just for clarification, no actual use case. sometimes u need it if u want to have fast and reliable results .

peak plover
#

Yeah sure, then just write your script as a function and run it from .sqs

#

call

tough abyss
#

thx again 😃

peak plover
#

No biggy 😃

sleek nova
#

hello, i want to pass some variables to my dialog when i create the dialog. Should i first declare global variables and then open the dialog or is there a way that i can pass the variables when i create the dialog?

#

i made a module that can be opened in zeus but i need to pass through the module tot the dialog so that when the user presses ok in the GUI it will send the module to the function and starts working.

still forum
#

@tough abyss to start script unscheduled isNil {your script here; nil} Also all code from Eventhandlers runs unscheduled. Don't use SQS.
@tardy wagon too bad that encryption will come down to a single point where the key is loaded into memory and used Not talking about encryption though. It's just obfuscation what nigel called Encryption. Can quite easilly be unpacked but then you just have a garbled mess of files. But again very easy to find the config.bin and debinarize it and done. Scripts are harder to get to.

#

@sleek nova you can dialog setVariable ["myVariable",value]

#

and then inside the dialog get it back via getVariable again

tardy wagon
#

shouldn't be much of a problem

sleek nova
#

@still forum thanks! That helped me a lot!

#

why didn't i think of this 😃

tough abyss
#

@still forum this is very useful info. thx a lot.

still forum
tough abyss
#

yeah cool.! should be added in isNil entry as well.

still forum
#

And I added a link for functions with pre-init attribute. So everyone knows what's meant.
Afaik it is already in isNil I think.

tough abyss
#

I searched the page for "sched" and had 0 hits ...

still forum
#

True. I'll add it to the notes

tough abyss
#

thx

still forum
#

@mortal halo Which script command page is missing? Please write in #community_wiki or mention me when you answer so I don't overlook it. I can also make you a biki account btw. But as you already asked Dwarden better not doubleduty that.

little eagle
#

lbSetText and lbSetTextRight for example

#

lbSetTextRight is used in ACE

still forum
#

So they are confirmed working?

little eagle
#

I haven't tried it myself, but I guess?

still forum
#

lbSetText has 2 variants. Control lbSetText Array and lbSetText Array.
I guess these behave the same as over lbSet commands?

little eagle
#

Yes.

#

IDC of current display or control

still forum
#

K. I'll add them in a couple hours

#

Intercept has a huge list of undocumented functions. But I didn't add these to Biki because I don't know if they even work.
stuff like lnbsetpicturecolorright
or lnbsetpicturecolorselectedright

little eagle
#

Someone who has time to waste should check.

tough abyss
still forum
#

@tough abyss No. over 80% of that doesn't exist

little eagle
#

Yeah, param1 and param2 for example are not commands.

still forum
#

Atleast not available in release build. They probably existed at some point in time. And probably still do in the source. They are just disabled

tough abyss
#

Or they're internal and are only used by the devs.

still forum
#

Which is what I just said. somewhat. Or atleast tried to say

tough abyss
still forum
#

Profiling stuff.

tough abyss
#

Gibberish to 99% of players.

still forum
#

Should be more used than it is IMO. People constantly complaining about bad performance. But too lazy to check why their performance is actually bad.

#

I always run profiling build so I can quickly check why FPS are getting low in a Mission

mortal halo
#

@still forum he said he'll only create my acc towards the end of the week. take a look at "All Arma Command Pages" page. There are alot of undocumented important functions

little eagle
#

Gibberish to 99% of players.
I think you mean content creators, but that is more their own problem then.

mortal halo
#

my command was ctrlSetTextRight for example

#

but so many more are

still forum
#

ctrlSetTextRIght is not in there. It doesn't exist in the game

little eagle
#

It's lbSetTextRight

mortal halo
#

yeah

#

my mistake

little eagle
mortal halo
#

lbSetTextRight

#

its simple

#

i knew it existed

#

just didnt know the name

#

so i sat down for hours

#

hehe

#

until i decided to use supportinfo

still forum
#

But most stuff on that all commands page doesn't actually exist. But I have the Intercept list so I actually have a list of commands that exist and need docs

#

Just need time to add that stuff

mortal halo
#

yeah

still forum
#

in a couple hours I'll have time to atleast add the lbSetText commands

tough abyss
#

How did you lads from Intercept find out about those commands?

mortal halo
#

^^

#

you can check commands with supportInfo

#

but it only gives you the operands type

#

not actual usage or meaning

still forum
#

supportInfo. Basically

#

We also get description and examples for the commands that have that.

#

The info that is shown when you type the command in DebugConsole and press F1

tough abyss
#

I've some weird AI behaviour in my mission.
Prerequisitues:
I'm running an edited domination 3.74 mission. Enemy AI is spawned by HC_1.
Now I ve a script (executed by action menu) which let u spawn friendly AI (on another HC) in all positions where can be fired from of the vehicle u r currntly driving.
Those AI is NOT joined in players group, it has its own group. This is needed to hold the locality of that AI to HC and NOT get it to players client.
This is essential because those AI should use the ASR AI Mod which is enabled on HC (on server as well).
The script is a variant of this one:
https://forums.bistudio.com/forums/topic/205284-solved-get-servers-ai-instantly-in-player-driven-vehicle-in-mp/?do=findComment&comment=3196078

Behaviour:
The AI is just not firing on enemies... its sometimes aiming but not firing.

What I tried:
I tried to reveal all by any player known enemy AI to that AI gunners to ensure that these AI gunners know about enemies. But this helped just not.

What I need:
A suggestion a hint or anything that leads me a new way because I ve no clue why that AI isn't just firing on enemies.

peak plover
#

Do they fire if player leaves the vehicle?

tough abyss
#

can't say for sure but I think they don't. what r ur thoughts behind that question?

peak plover
#

Well I've experienced similar things since arma 1, that ai in vehicles won't shoot at targets if you don't command them to do it. and as soon as you dismount they fire

#

Could be unrelated

tough abyss
#

sounds very related and an BI issue.
but what Im actually thinking bout is if it has todo with turrets locality. Maybe turrets locality is not changing from player (who has vecs locality) to HC. I think this could cause such thing.

peak plover
#

I assume you lack the information to wether this odd behaviour takes place in singleplayer/editor environment

tough abyss
#

I ll test that later ( but Im at work now).

peak plover
#

Alright, sure let's just get some ideas out there 😄

tough abyss
#

thats why I posted here, to get ideas 😃

peak plover
#

Also

#

In your script, when you evaluate the seats for vehicle

#

There is a lot of else

#

I had that as well before but now I use ```sqf
call {
if (isNull (assignedDriver _vehicle)) exitWith {
_unit moveInDriver _vehicle;
_unit setskill ["aimingAccuracy",0.1];
};
if ((_vehicle emptyPositions "Gunner") > 0) exitWith {
_unit moveInGunner _vehicle;
_unit setskill ["aimingAccuracy",0.1];
};
if ((_vehicle emptyPositions "Commander") > 0) exitWith {
_unit moveInCommander _vehicle;
_unit setskill ["aimingAccuracy",0.1];
};
if (count _turrets > 0) exitWith {
_unit moveInTurret [_vehicle,(_turrets select 0)];
_turrets = _turrets - [ (_turrets select 0)];
_unit setskill ["aimingAccuracy",0.1];
};
if ((_vehicle emptyPositions "cargo") > 0) exitWith {
_unit moveInCargo _vehicle;
_unit setskill ["aimingAccuracy",0.1];
};
};

because it looks a bit cleaner
tough abyss
#

thats not the script im currently using

peak plover
#

Using call and if exitwith looks a bit cleaner then 100x else

tough abyss
#

I know and I think Ive improved it meanwhile

peak plover
#

(Y)

#

👍

tough abyss
#

if not... I ll do ;-D

peak plover
#

Also I love your name, it was my favourite thing in math for a while

tough abyss
#

I ve that pseudonym sins 20 years in www and its really good because that name is unused on every webservice where I like to create an account 😃

peak plover
#

Hmm, can a function be turned into a string?
Ex.

_func = bis_fnc_endMission;
_mystring = format ["%1",_func];
#

and later use ```sqf
call call compile _mystring;

tough abyss
#

why not _str_func = str(bis_fnc_endMission);

peak plover
#

I'll try that, got a update can't launch ;'(

tough abyss
#

probably, but i guess you might run into rare issues

peak plover
#

I think that str will return somethign wrong

#

Like the value of that instead

tough abyss
#

the function is not called

#

it's just a variable containing code afaik

peak plover
#

Yeah, it just puts the whole function into the string

#

But is there a way to only put (bis_fnc_endMission) in there

#

I want the variable not the value of the variable

#

There must be a way

indigo snow
#

Well where are you getting the variable to contains the function code from?

#

I mean functions are just a code type variable

peak plover
#

Yeah, but I want to be able to send the function over internet

#

If I try to send a string that's the whole function, it will cause network lag

#

I guess my only alternative is to just string the function in the beginning

tough abyss
#

RemoteExec?

peak plover
#

_myfunc = "bis_fnc_endMission";
call call compile _myfunc;

indigo snow
#

Yes but where is it coming from. Are you just getting the CODE type variable into your function or what?

peak plover
#

[_unit,spec_fnc_exit] call respawn_fnc_addRespawnUnitScripts;

indigo snow
#

Also call missionNamespaceGV ["fnc",{}]

chilly wharf
#

is there an easy smart way to truncate what "player" returns? i just want the name of the player not "1-1 alpha remote playername"

indigo snow
#

Anyway

peak plover
#

I guess I'll just have ot use [_unit,"spec_fnc_exit"] call respawn_fnc_addRespawnUnitScripts;

indigo snow
#

Well yea

#

If you only have a value, there is no direct link to a function variable necessarily

#

Unless you parse allVariables and hope it a variable in a namespace you check

peak plover
#

I just want to be able to add a script to my stupid event handeler, I guess this'll do

indigo snow
#

Yea since you already know the name

peak plover
#

Just figured I might try to give the possiblity to use a function instead of a string and stuff...

indigo snow
#

If you just had a value of 1, good luck finding the variable that was the original source of it, if it exists

#

So you already have the name of function since you wanted to str it

#

Why add more commands instead of just adding some quotes :P

chilly wharf
#

nvm on my question i just found profileName

peak plover
#

Yeah, I wish there was a command like varName so I could _varN = varName myvariable_1; //"myvariable_1"

#

Yeah I know, I'm just overthinking and making things overcomplicated again

#

Stupid brain...

indigo snow
#

Well the issue is where you have myVariable_1 on the right side of the = operator

#

Its simply a value, there are no references to any variable that might also contain that value

#

The sort of exception is the preprocessor commands but they of course get resolved before the script ever runs

peak plover
#

Yes, getvariable/setvariable can be used instead for cases where I get variable names which are generated inscripts

indigo snow
#

Im not directly following

#

I meant the fact that when you start interpreting the script, everything to the right is just values

#

Right of the = sign that is

peak plover
#

Yes, but I require the value of a variable that I do not know the name of

indigo snow
#

So now where getting back to where do you get the code type variable from?

#

Eg the value youd feed into a varName command

#

Its there where you need to solve it

#

Because now youre basically asking which variable contains 1

#

Theres a sneak tho, i think the cfgFunctions framework inserts some shit

#

__functionName or whatever

peak plover
#

Yeah, so I can relay the variable that currently contains 1, which might change and I might want to use the same variable later

#

Does that even make sense?

#

ohh shit, I've lost it... nvm... nvm

mortal halo
#

okay

#

i need help

#

whats the action for dropping an item (specifically, a vest or uniforms) into a container

#

there's DropWeapon

#

there's DropMagazine

#

there's DropBag

#

but no item 😱

peak plover
#

Uniforms and vests did not exist before arma 3, That's probably why you can't find the action

mortal halo
#

but..

#

i need to put a vest with items inside a container

#

..

#

😦

tough abyss
#

is it all engine hardcoded in the vanilla inventory?

peak plover
mortal halo
#

sadly

#

lappihuan

peak plover
#

This'll get you started

mortal halo
#

yeah i went to do this with the dummy unit workaround

#

not possible because there is no action

peak plover
#

You just make your own action that grabs the uniform data, deletes it and recreats it in the container/on the ground

tough abyss
#

but how would you execute a function that you only have the name as string?

peak plover
#

call call compile "bis_fnc_endmission"

tough abyss
#

wuups scrolled up 😄

mortal halo
#

well the thing is

tough abyss
#

hmm ok

mortal halo
#

wait hold on

tough abyss
#

why are you not customizing the vanilla inventory and keep this functionallity in from it?

mortal halo
#

because vanilla inventory sucks in every possible manner

#

i am making a complete redesign of how it works

peak plover
#

Didn't ace2 have custom inventory?

mortal halo
#

i haven't looked at other custom inventories

#

ruins all the fun

peak plover
#

Yeah, inventory can be pain.

mortal halo
#

lemme explain the basic functionality here..
my inventory system is complex. basically except for the assigned items - i grab each and every possible container and make a "window" of it

#

so a container could be the players uniform, player's vest, player's backpack

#

but also

#

ground holders,

#

dead bodies' uniforms

#

etc. etc.

#

there's no actual menu but rather a 3d camera rotating around the player and the nearest supply containers are floating 3d button

#

clicking on a button opens the container window

#

you can open as many containers and move items between them

#

see

#

that's like

#

totally redesigned

#

i have the whole UI set up

#

the only thing left is to implement populating windows with items

peak plover
#

Whoa, that sounds really cool

mortal halo
#

yeah

peak plover
#

Got me all excited

mortal halo
#

it is

#

obviously currently i only have the ui part going and only the player containers are hardcoded to display

#

but yeah

tough abyss
#

old max payne style esc menu cheating 😛

#

rotating camera will be abused for sure

#

but still a cool idea

mortal halo
#

it will

#

but who cares

#

haha

still forum
#

@peak plover CODE is basically just a String.
use _string = bis_fnc_endMission though

mortal halo
#

this is going to be part of a survivalish kind of mod anyway

#

you can't go survival without abusing 3d here

#

especially in arma

tough abyss
#

1p is always better

mortal halo
#

yeah i know but im not hardcore enough

peak plover
#

@still forum _string will be too big for networking, if I intend on having more than one big functions

still forum
#

Why do you need strings for networking?

#

if you publicVariable a script it sends the string AND the compiled instructions. So if you send code it's actually bigger than the string

peak plover
#

I'm currently only sending the fallowing > "bis_fnc_endMission"

#

Instead of the whole function only the function name

#

Some examples ```sqf
// TO UNIT:
// [_unit,"spec_fnc_exit"] call respawn_fnc_addRespawnUnitScripts;
// TO SIDE:
// [side,"_unit setVariable ['reSpawned',true]"] call respawn_fnc_addRespawnUnitScripts;

mortal halo
#

anyway about my problem. the workaround you suggested @peak plover is probably the only way to go here. the only problem is... I am dealing with not a single container but an array of containers. there can be multiple vests of the same type with different items in them. this can be easily solved using a hashmap.. but this is not an object oriented environment here so im gonna have to make 2 arrays - one for the types and one for the items and manually link each type to its items

#

this is getting really out of hand 😦

#

but i'll do it.

still forum
#

Why don't you just send Code instead of string @peak plover ?

tough abyss
#

@peak plover isn't remoteExec already only sending the function name to the target?

still forum
#

no

tough abyss
#

[] remoteExec ["someScriptCommand", targets, JIP];

still forum
#

But if you remoteExec {call bis_fnc_dummy;} that's way less networking load than sending the whole thingy

#

yeah

#

that only sends the name.

#

Didn't think of that variant

tough abyss
#

isn't someScriptCommand a string that is sent to the target?

#

👍

peak plover
#

These commands are not to be executed instantly

#

I add this to the array of scripts/code which are all strings which will be executed at one point

#

This way I get the least amount of traffic at once. If I want to add some stuff for player to run when it respawns I can do that. But if I used the server to manage all the players and remoteExec for all the scripts/functions. when a ton of players respawn the traffic would be insane

mortal halo
#

is there a function i might be missing

#

to get item cargo

#

without vests / uniforms (items with containers)

#

i need this badly if it does

#

like now

#

or else im gonna have to do soooooooo many array substractions 😦

peak plover
#

You need to get a list of items inside container?

mortal halo
#

no no no

#

nevermind actually

#

it is so god damn stupid to categorize an ACO scope with a god damn heavy plate carrier

#

where's the logic

#

backpacks have their own category because arma 2

#

cant you add a new one for vests and uniforms? 😦

peak plover
#

Maybe there is one but it's not implimented in sqf or not documented

mortal halo
#

im scared

peak plover
#

Jeezz 😄 don't lose your mind

mortal halo
#

wow

#

i think im done

still forum
#

Again nigel. Just use code instead of messing around with strings and compiling stuff

peak plover
#

I don't understand the benefits

still forum
#

compile is slow

#

If you store the code instead of the string you need a little more memory. But don't need to compile anything

#

also you don't need to mess around with quotes in your string

peak plover
#

So ```sqf
_nul = {
_code = call compile _x;
_nul = _unit call _code;
true
} count _respawn_scripts;

where ``_respawn_scripts = ["bis_fnc_endMission","_this setVariable ['dude_dead',true,true];``
should be instead ``_respawn_scripts = [{---code frmo endMission---}, {_this setVariable ['dude_dead',true,true];}];``
#

And I remove compile

#

The issue I'm getting is that what if I have 5 functions and I add them from a remote client or I want to remove some of the functions

#

Also publicVariable might not work if there are qoutes in the function?

still forum
#

no

#

_respawn_scripts = [{call bis_fnc_endMission}, {_this setVariable ['dude_dead',true,true];}];

#

otherwise yes

peak plover
#

Hmmmm

#

I'll try to send bigger variables and see what happens

#

How slow is compile is also a good question

#

Ohh wait

#

ohhhhhh

#

_script = {bis_fnc_endmission};

indigo snow
#

{{Contentsofscript}}

mortal halo
#

holy shit

#

after much debug

#

the function works

#

I took a vest, put 4 first aid kits in it.
put it inside a box.

#

then I made a complex algorithm and i replicated the container into another box

#

and

#

there you go! 2 boxes, with a vest and inside the vest 4 first aid packs - each

#

that single function spanned across over 5 hours and two scripting sessions. one sitting for researching how this works and the other implementing

#

gonna do a test soon on a box << backpack << weapon << aco sight

#

see if i can replicate that

tardy wagon
#

nice

peak plover
#

holy shit, yeah that's deep

tough abyss
#

consider magazines and their ammo count aswell

peak plover
#

format ["%1",{(bis_fnc_endMission)}];
//{bis_fnc_endMission}

#

This is actually what I wanted to do, thanks dedman

little eagle
#

The curly brackets can be though of as quote marks and CODE as strings.

peak plover
#

That's brilliant

little eagle
#

What?

peak plover
#

the use of curly brackets

little eagle
#

Usually it's done like this:

{call My_fnc_aFunction}
#

So it's still executable, but saves memory and is faster to recompile as eventhandler.

peak plover
#

_nul={call call _x;false}count [{myFNC},{yourFNC}];

little eagle
#

While it does look weird, I guess it works.

#

What's the _nul for? It seems to me that it always results to 0.

peak plover
#

count results to whatever number but I don't want a random number going around my scope

#

Sometimes causes issues

little eagle
#

It doesn't unless you're working with those ingame init boxes in the editor

peak plover
#

I could swear it happened to me more than once and now I do it out of habbit and fear

little eagle
#

Okay, but that seems to be very superstitious.

#

You could say that the "return value" of the assignment "operator" is more prone to cause problems, especially when it's the last operation in your function.

#

The quote marks are there to please Dedmen.

royal abyss
#

Me again 😄

#

Is there a reason why scripts cant correctly count ace items ? 😄

little eagle
#

The script could be broken.

royal abyss
#

but it works with all other items

little eagle
#

Have you tried it with the mine detector?

royal abyss
#

if he counts it correct?

little eagle
#

No, but if it doesn't, then we know that the script is broken.

royal abyss
#

well the microdagr is fine too only bandages and earplugs and stuff like that

little eagle
#

Try the vanilla mine detector.

royal abyss
#

why is arma scripting such a pain?

little eagle
#

I guess that means that your script does not work with the vanilla mine detector?

royal abyss
#

it does

#

everything else from weapons magazines helmets everything but ace doesnt

little eagle
#

Hmm, then I don't know why that would be.

royal abyss
#

even other mod items work...

#

wish there would be something like UE4 script visualisation for arma where u see in a visual why where there problem sits while play testing would make stuff way more easy

little eagle
#

What does counting items mean here anyway?

still forum
#

Well. You could just use a Debugger. That is essentially UE4 script visualization

royal abyss
#

saw a release of arma ied but still

peak plover
#

diag_log after every line, then you know exactly when the error occurs

still forum
#

IED? RUN!

royal abyss
#

is there a reason on my other project i placed a 20-30 weapon crates and it totaly wrecked the performance ?

little eagle
#

Maybe too many operations.

queen cargo
#

visual programming would fully be possible using SQF
however ... i do not know of such a framework for wpf so ... wont create a tool for it

#

(just like you can do all languages with visual programming as it essentially just is a visualization of an AST)

peak plover
#

What's the best way to remove an array element?

little eagle
#

deleteAt

peak plover
#

Thanks, well, it will proboly not work in a loop, because it might shift the array when deleting

little eagle
#

Yep

#

In that case

peak plover
#

I'll make a new array and use pushback

still forum
#

or you use select to filter the old array and move the result into a new one

little eagle
#
{
    if (whatever) then {
        _arr set [_forEachIndex, objNull];
    };
} forEach _arr;

_arr = _arr - [objNull];
peak plover
#

I've never used the select filter, but I've seen it used many times

little eagle
#

It really depends on what you're trying to do exactly.

peak plover
#

_respawnUnitscripts = [[{myfnc},false],[{yourfnc},true]];
_respawnUnitscripts select {!(_x select 1)}
#

Does this make sense?

tough abyss
#

selects the element ith yourfunc?

#

with

#

oh not...

peak plover
#

But it says !, so it should select myfnc

tough abyss
#

yeah

peak plover
#
_respawnUnitscripts = _respawnUnitscripts select {!(_x select 1)};
#

Whoa, yeah select looks pretty awesome

tough abyss
#

i love it

little eagle
#

It is.

tough abyss
#

as well as aply

#

apply

little eagle
#

Sometimes I wish it had _forEachIndex, but I guess that would be weird as the array size changes.

peak plover
#

aye

#

Whoa, the amount of lines I can save with select is incredible

tough abyss
#

with apply u could create an index i think...

#

not the _forEachIndex but an own.

little eagle
#

Well, the name is weird, but it would work.

tough abyss
#

or u just count while exexuting select ... would be easier.

little eagle
#

like _n = _n + 1 ?

tough abyss
#

yes

little eagle
#

Yeah, that always works ofc, but it's not very convenient.

peak plover
#
_respawnUnitscripts = _respawnUnitscripts select {
    if ((typeName _x) isEqualTo "ARRAY") then {!(_x select 1)} else {true}
};
#

Correct use of select?

little eagle
#
if (_x isEqualType []) then {
obsidian chasm
#

Think it'd be hard to take a script from escape Malden and put it into Escape Tanoa?

peak plover
#

Thanks commy2

little eagle
#
_respawnUnitscripts = _respawnUnitscripts select {_x param [1, true]};
obsidian chasm
#

It would currently involve making a BLUFOR helicopter into an OPFOR one and then spawning it via the special events scripts

little eagle
#

This is what I'd use instead of what you proposed.

peak plover
#

ohh gosh, that's even better

#

Cashmere money right there, thanks!

little eagle
#

Warrants a comment though, since it's probably not obvious to the not SQF veterans.

peak plover
#

wait, does 1 param [10,false]; work?

little eagle
#

Yes, it would report "false".

peak plover
#

Whoa, mind blown

little eagle
#

Because 1 would be treated as [1] and that array has no tenth element, so it uses the default value

#

param is THE command when dealing with arrays. The only reason to ever use select is because it's faster in simple scenarios when you already know lots of things about your array.

peak plover
#

Does params have the same features? as in 3 params ["_a",["_b",3]];

cedar kindle
#

yes

#

param for single values params for multiple

peak plover
#

But it still works if I feed it a intriger instead of an array?

cedar kindle
#

a intriger?

#

oh integer

#

uh, think so?

#

test it in debug console 😛

#

should be fine

#

_a would be 3 and _b 3(default)

peak plover
#

works, whoa

little eagle
#

nigel is easily impressed.

peak plover
#

Or... maybe, these things are just extremely impressive

little eagle
#

I was impressed when they added them like 2 years ago.

#

They changed a lot about how SQF looks.

rancid ruin
#

they did?

little eagle
#

Arma 3 didn't have these commands at launch, so yes, they were added in a patch.

#

Release date: July 16, 2015

#

wow, 2 years and 2 days

rancid ruin
#

yeah well params doesn't really change how SQF looks imo, it's just another command

little eagle
#

Except that you now have one line handling all passed arguments instead of one line for every one plus one if for all the default values.

rancid ruin
#

how does x39 feel about params?

still forum
#

it didn't change the looks. Except almost every script function that has parameters starts with a call to params now.

#

So it didn't change how SQF looks but how every SQF script file looks

#

so it kinda did change how SQF looks didn't it?

little eagle
#

So you're saying it didn't change how SQF looks, just how the beginning of almost every SQF function looks.

#

Yeah.

still forum
#

just saying oneoh is wrong in a very weird way

little eagle
#

params is a game changer and so is param, even though it's still underutilized imo.

#

In different ways.

still forum
#

a lot of new stuff is underused

little eagle
#

Goes to show how much copy pasting is going on.

still forum
#

Most people apparently learn from old Mission scripts

little eagle
#

That's the nice way of saying the same thing.

still forum
#

It's true. You saw that learn mission post on armaworld

#

and even the guy building a Mission so that everyone can learn from it doesn't know about params

little eagle
#

I saw that one blog.

#

Same guy I think.

peak plover
#

The real question is which is faster, select or count, for executing a function for a large array

#

For every element for a large arra

still forum
#

count

#

because select well... if you always return false..

#

if you always return false then select is theoretically as fast as count

little eagle
#

select and apply create new arrays, so...

peak plover
#

Hmm

still forum
#

yeah. But if you always return false it's an empty array

#

and that's not much different from a number

#

processing time wise

rancid ruin
#

me wrong? that doesn't sound likely

little eagle
#

There is probably a bit more going on in C++ land for select though compared to count

peak plover
#

count = 0.0442 ms
vs
select = 0.0444 ms

#

code inside brackets sqf {_x distance player > 1000;false}

jade abyss
#

execute that about 10 times

little eagle
#

One thing I prefer about selectvs. count is, that the select version has the array first and then the code. It seems to me that that is easier to write down for whatever reason.

peak plover
#

Yeah it does, they both have their uses

rancid ruin
#

you use macros everywhere though so you have strange tastes commy

little eagle
#

Well yeah, they're different.

#

I don't use that many macros, oneoh.

peak plover
#

I need to get in on that macros, I want to see if it influences performance

still forum
#

*facepalm*

#

It doesn't.

little eagle
#

They don't influence performance at all. And if they do, then probably negatively.

still forum
#

they don't.

rancid ruin
#

why would macros change performance?

still forum
#

they might increase preprocess time by a few microseconds

#

considering that's only done once per script.

peak plover
#

hmm, I want macros for easily readable scripts 'tho

little eagle
#

Well you could use a macro for it's readability even though it's not the most performance effective solution. That is what I mean.

still forum
#

if you execute all your scripts via execVM then it's probably worth it not to use macros

#

but macros have 0 effect at runtime. And that's what you have to care about.

peak plover
#

That's always in consideration, always

jade abyss
#

if you execute all your scripts via execVM <-- Why would you do that oO

peak plover
#

I'm also considering going from conventional function names to fnc_01, fnc_02. This will save on characters

rancid ruin
#

you must be trolling now

little eagle
#

It's shorter than writing spawn compile preprocessFileLineNumbers @jade abyss

peak plover
#

less bytes per script and less time to process shorter variables

#

I actually was considering it

still forum
#

@jade abyss Some Mission scripters do that. And most People copy from these idiots

jade abyss
#

Oh my...

rancid ruin
#

yes i'm going to learn korean so i can say more in fewer characters

still forum
#

@peak plover Don't.

peak plover
#

korean characters proboly take more bytes than normal/numbers

still forum
#

not worth it

#

true

peak plover
#

I was already writing kind of a dictionary for the functions

jade abyss
#

We are still talking about microSeconds, right?

#

XD

rancid ruin
#

what kind of life do you lead nigel?

jade abyss
#

lol

still forum
#

if you go from myasdasdasd_fnc_asdwekjfetgehjgiesjfoskfoiesfihjesfhesfjesiofesifesfesiojf to my_fnc then it is actually worth it. But don't.

#

If you want to get max performance... Never call functions

#

inline everything

peak plover
#

Well, if this script runs 1000 times in less than a second then, yes I belive it might make a difference

jade abyss
#

+Oneline everything, no spaces

#

(doesn't Arma does that anyway?)

still forum
#

that will only have a compiletime difference.

#

no runtime

peak plover
#

Having a program that converts regular script into a oneliner might be cool as well

#

But wait, doesn't the engine do that?

still forum
#

replace \n with nothing

#

notepad++

#

done

#

the engine compiles the code into binary internally

#

at runtime there are no spaces or newlines

#

or semicolons

#

or comments

rancid ruin
#

it removes bugs too

jade abyss
#

and fixes missing ;'s

still forum
#

except if you use comment "My comment" That will still be there and eat performance at runtime

peak plover
#

🌴 😵

rancid ruin
#

comment "My comment"
ahhh the function nobody uses

jade abyss
#

Yeah

#

//Text, done.

#

/* Text2 also done */

still forum
#

I think either CBA or ACE uses comment atleast once. Atleast it used to

rancid ruin
#

yeah but they use macros too because they're satanic

jade abyss
#

@little eagle bad commy! Bad commy! Shame! SHAME! SHAME!

still forum
#

don't anymore

#

no because macros are useful

jade abyss
#

Doesn't matter, found a reason to blame Commy. Leave me alone.

still forum
#

and ensure a clean codestyle. Getting rid of over 50% of typos

little eagle
#

No, Dedmen, comment is never used, because it's like the one command that does have absolutely no use.

jade abyss
#

And fkn up readability =]

still forum
#

if you typo a macro you get a compile error. If you typo a variable name you get weird unexpected behaviour and bugs

#

I thought comment was used in some string script because // wouldn't work in there.. don't remember

little eagle
#

No, even then you could just put the comment as string into the code and don't use the command.

#

The command literally just eats execution time for nothing.

still forum
#

does Arsenal loadout export use that? maybe?

rancid ruin
#

ye

still forum
#

Then that's probably where I saw it used

little eagle
#

Yes, but you could just remove the comment command and nothing would change.

jade abyss
#

Wasn't it just copyToClipboard and diag_log?

still forum
#

true

little eagle
#

I guess it could be faster for an empty function that only contains a comment.

jade abyss
#

_Comment = "abcdefgh Text";

#

I bet that takes less than comment

little eagle
#
{
    "does nothing";
    nil
};

vs.

{
    comment "does nothing";
};
rancid ruin
#

would putting a load of comment "blah" in an each frame EH do anything? or would it just be ignored?

peak plover
#

0.0002 ms
0.0002 ms

jade abyss
#

Nigel, exec at least 10 times.

still forum
#

@jade abyss probably not. That's searching if a variable exists. seeing it doesn't then allocating a new variable and moving the string in there

little eagle
#

òneoh, comment is a command that reports nil and expects a string.

#

It does take execution time

still forum
#

the comment command takes a reference to the string from the stack. and does nothing and returns nil

peak plover
#

0.0069 ms
0.007 ms

rancid ruin
#

so it's not even stripped out like a //?

jade abyss
#

Tl;DR;
useless command.

little eagle
#

Nope, oneoh

still forum
#

No. That's exactly the point

rancid ruin
#

which cunt thought we needed this command

jade abyss
#

¯_(ツ)_/¯

peak plover
#

0.0001 ms faster when run 10 times

still forum
#

back in sqs when you didn't have // probably

#

or no preprocessor

rancid ruin
#

i thought it was new?

little eagle
#

I argue that this is a true useless command, yet types like X39 will defend it and actually use it.

jade abyss
#

rly Nigel? massive 0.0001ms faster!

still forum
#

nooooo

rancid ruin
#

(relatively)

jade abyss
#

lol Commy

still forum
#

OFP old that command is

peak plover
#

Well comment is 0.0001 slower, the other one is faster

rancid ruin
#

@queen cargo how good is the comment command and why should we use it ?

#

👀

still forum
queen cargo
#

you are literaly a reatarded @rancid ruin

rancid ruin
#

you spelled retarded wrong

still forum
#

ah! trigger activation field! // doesn't work there that's why comment is used there.

little eagle
#

you are literaly a reatarded

still forum
#

and literally

jade abyss
#

as you're able to introduce comment lines with semicolons in a SQS script.

queen cargo
#

pressed accidently three times the l ... corrected by pressing one time too much the backspace

still forum
#

if you don't preprocess your scripts then that's probably useful.

#

but who does that

jade abyss
#

Don't ask

queen cargo
#

comment can become useful in cases where you need to be able to find the start of something
only ever used it in ArmA-UI-Editor for custom events when the editor used some partion of eg. the init event

jade abyss
#
Revo
comment can also be used to create comments inside trigger activation fields where // or */...*/ does not work.```
@still forum
still forum
#

if you need to mark the start of something just use //start

jade abyss
#

So Trigger again (damn you trigger)

still forum
#

yeah. I already wrote that above ah! trigger activation field! // doesn't work there that's why comment is used there.

jade abyss
#

Ah, haven't seen it

peak plover
#

What's so bad with triggers?

queen cargo
#

in config strings not possible @still forum
init = "sometoolcode; comment ""userspace""; someusercode;"; was the way to go

still forum
#

And if you write your code inside a string (cuz you're dumb) then you also have to use comment. Because you can't preprocess from string. You can only preprocess from file

rancid ruin
#

why am i a retarded 😦

jade abyss
#

Reasons, oneoh

queen cargo
#

because you try to get drama out of nothing

jade abyss
#

like... erm...

little eagle
#
init = "sometoolcode; ""userspace""; someusercode;";
still forum
#

again you can just use the plain string without comment in there

little eagle
#

how is this different?

peak plover
#

oneoh is a troll

#

🚎

rancid ruin
#

that doesn't sound right

little eagle
#

I think Dedmen wrote the one use one could consider.

jade abyss
#
init = "sometoolcode; /*userspace*/; someusercode;";```
still forum
#

no Dscha

little eagle
#

I think that errors, Dscha

tough abyss
#

i think someone needs to add a new channel called "Scripting - showdown"

jade abyss
#

i am not sure, i think i used that before

still forum
#

won't work if not preprocessed. And I think that won't be preproced

#

or scripting discussion

#

because we ALWAYS go offtopic in here

tough abyss
#

yep

rancid ruin
#

weekly scripting challenge has been needed for a while

#

i suggested it ages ago

tough abyss
#

^ smart man

little eagle
#

How so? This is very much on topic.

peak plover
#

When your brain boils it's good to have a few arguments about the tiny things

still forum
#

you just need to advertise it

rancid ruin
#

i am a very smart man when i'm not trolling or being a retarded

still forum
#

yeah. we're not offtopic right now

tough abyss
#

yep

still forum
#

but often

jade abyss
#

How often is that? @rancid ruin 😄

rancid ruin
#

99% of the time imo tbh

little eagle
#

oneoh is literaly reatarded.

still forum
#

🍪

jade abyss
#

very literaly.

tough abyss
#

quiet literally.

jade abyss
#

-l

tough abyss
#

-2

rancid ruin
#

whenever i see commy's name i think of that "macho macho man" song except it's macro macro man

#

anyone else?

tough abyss
#

yes

#

#define commy2 0x1337

little eagle
#

Better a macho than a wimp I guess.

tough abyss
#

🤦

rancid ruin
#

tbh it's only because i want to be a macro macro man

tough abyss
#

i dont use macro

#

im bad scriptzer

queen cargo
#

end-user might delete such strings ... which is dangerous as that would "harm" the tools experience
thats why the comment
with the comment command they at least barely know "ahhh ... maybe i should not touch this" ... and there are plenty of dumpasses out there who still would remove it as they want a "CLEN CUNFIG"

little eagle
#

"start also pls no delet"

#

What kind of code would that even be that has to separate the config entry string like that?

queen cargo
#

cannot remember anymore
nee dto check

little eagle
#

Seems weird to me.

queen cargo
subtle ore
#

Do i need to grab my popcorn again?

tough abyss
#

🍿 lets share

queen cargo
#

the fuck is wrong with you guys

rancid ruin
#

they are all a retardeded

jade abyss
#

literaly.

queen cargo
#

i know
it is the default mindset you need to even start playing arma

subtle ore
#

Totally literally.

jade abyss
#

-l -l

queen cargo
#

sry that i did not fixed a typo fast enough for you

#

so that you could notice

jade abyss
#

apology accepted.

queen cargo
#

looks pretty much like this:

//in config
onLoad = "comment ""<{0} ctrlShow {1};>"";(_this select 0) ctrlShow false;comment ""</{0} ctrlShow {1};>"";comment ""<{0} ctrlEnable {1};>"";(_this select 0) ctrlEnable true;comment ""</{0} ctrlEnable {1};>"";";

//extracted
comment "<{0} ctrlShow {1};>";
(_this select 0) ctrlShow false;
comment "</{0} ctrlShow {1};>";
comment "<{0} ctrlEnable {1};>";
(_this select 0) ctrlEnable true;
comment "</{0} ctrlEnable {1};>";
little eagle
#

That looks horrible though.

queen cargo
#

it is an editor
there is no need to manually edit theese fields

little eagle
#

I don't believe that this had to use comment though.

queen cargo
#

how you would want to make user space stuff and multi-sqf properties possible in a generic interface then?

#
  <group name="SQF">
    <sqf infinite="false">
      <name>Enabled</name>
      <format>{0} ctrlEnable {1};</format>
      <arg index="0"/>
      <arg index="1">
        <boolean/>
      </arg>
    </sqf>
    <sqf infinite="false">
      <name>Displayed</name>
      <format>{0} ctrlShow {1};</format>
      <arg index="0"/>
      <arg index="1">
        <boolean/>
      </arg>
    </sqf>
  </group>```
still forum
#

make a seperate config entry that stores your information

#

onLoad_UIEditorInfo

#

that wouldn't need to be scripting conformant and executable

queen cargo
#

onLoad is the config based event
since when you can have more then one of those?

still forum
#

you don't

#

Never said that

queen cargo
#

see the point then?

still forum
#

no

little eagle
#

#rekt

still forum
#

You have two entries onLoad with your script and onLoad_UIEditorInfo with all the other info you need to store alongside with that script

#

you can even store the XML you posted above

queen cargo
#

UIEditorInfo stuff still would need to be executed

#

onLoad thus would require a hook for that

little eagle
#

UIEditorInfo stuff still would need to be executed
Why?

queen cargo
#

because those are things that are setable in the editor?

little eagle
#

So?

#

The comment's aren't executed either.

#

So having them in a string or in a separate config entry makes no difference.

still forum
#

As I said. Put the stuff that needs to be executed into onLoad

#

the stuff in the Info variable doesn't get executed and doesn't need to

#

because everything that needs executing is inside onLoad

queen cargo
#

you mean carry another field for the offsets or what?
requires updating the offsets with each update for onLoad which can get bloated too and can cause easy trouble when user edits the field by hand

still forum
#

true

#

you need to update both fields

#

Your one field solution doesn't create any problems if the user edits it by hand?

queen cargo
#

only if he puts code inbetween the comment sections

#

as his custom code would vanish

#

with every edit

#

or if he deletes the comment
which would break any other solution too 🙈

still forum
#

so not much different

little eagle
#

What if the user edits your comments away?

queen cargo
#

back when i coded that i put quite a lot of thought into it
and that was the best solution in my opinion
user still could edit the field if he wanted manually, i could get the required info without any problems

#

as said @little eagle any other solution would break at that point too

little eagle
#

I question that the solution you came up with is the best.

queen cargo
#

feel free to find a better solution

little eagle
#

Well dedmen convinced me of one.

queen cargo
#

next week the implementation of the ui editor in arma.studio will start
so ...

#

i am open for ideas

little eagle
#

It's better because it doesn't use comment.

rancid ruin
#

how many people use this program anyway?

still forum
#

in your info struct you can store how long your part of the script is. So then any user could add onto the End without problems

queen cargo
#

quite a lot actually @rancid ruin
cannot say how many exactly as i only see the requests to the version
but still everyday at least one is on board

rancid ruin
#

at least one person per day uses it?

queen cargo
#

would not solve that every property might or might be not set
it all is pretty dangerous to use when user manually edits
eg. he could place stuff in front of the field as he just thinks "that should work or shoulndt it?"
and all that stuff could break

as said: best solution was imo to create a start and end tag and put stuff inbetween
everything else is userspace

#

and does not requires a hacky way that could be broken easily by a Luser

still forum
#

you can do
""<UIEditor Code starts>""; code; ""<UIEdtor Code ends>""

#

no comment. And the user clearly knows he shouldn't edit inside there.
And as you need to use the seperate info field you can now store as much info as you want without bloating and wrecking the readability of onLoad

little eagle
#

"pls no edit"

rancid ruin
#

if there's only one user i'd just email him and let him know of the best commenting policy

queen cargo
#

today only i got ~10 accesses to ArmA-UI-Editor update api page

rancid ruin
#

how many were from your IP?

queen cargo
#

only one

still forum
#

not one user. One per day atleast. Online. Using it.

queen cargo
#

one access from my ip

#

that was what i was talking about

#
SELECT * FROM `analytics` WHERE path LIKE "ArmA-UI-Editor" GROUP BY timestamp, source```
if one can improve that little SQL query, you can get better info
need to learn for exam
little eagle
#

Now we're off topic.

queen cargo
#

oneoh wanted to know

rancid ruin
#

rookie numbers

#

CBA has like 1mil subscribers even with all those macros

queen cargo
#

cool
ArmA-UI-Editor is a tool (not that wide appliance) without any advertising of mine going on

#

wanna now compare it to a framework that ppl have to use to get access to mods they like?

#

great idea

peak plover
#

But how many of thiose 1 mil subscribers are from <insert undesirable group here>

#

/jk

waxen jacinth
#
private _player = objNull; 
  {      if ((name _x) == "h0nkX") exitWith { _player = _x; };  } forEach allPlayers;  
  private _adminPos = getPosATL _player;  _adminPos params ["_posX","_posY",""];  
  private _adminUID = getPlayerUID _player;  private _marker = createMarker ["veh", [_posX, _posY]];  
_overxiled setMarkerShape "ELLIPSE"; 
_overxiled setMarkerBrush "SOLIDBORDER"; 
_overxiled setMarkersize [1, 1]; 
_overxiled setMarkerColor "ColorYellow"; 
_overxiled setMarkerAlpha 0;
_bomb = "B_Truck_01_transport_F" createVehicle getmarkerPos "veh";``` always spawns me 5-8 vehicles at the same position, why is this?
subtle ore
#

@waxen jacinth surely thats not all of the code if that is the case

waxen jacinth
#

@subtle ore updated

queen cargo
#

where is that script callen

waxen jacinth
#

debug

still forum
#

if you call that script 5-8 times then indeed it spawns 5-8 vehicles

subtle ore
#

Global or local execution?

waxen jacinth
#

global, so it prolly spawns for each all player?

subtle ore
#

Yep

waxen jacinth
#

ha

queen cargo
#

for every instance on the server

subtle ore
#

^

queen cargo
#

if you got 8 clients, (server counts as client in net architecture) it will spawn 8 times

waxen jacinth
#

but if executed local, vehicles still visible to everybody - right

#

wasn't sure about that

#

since it's local, how would i circumvent that to spawn it not for all instances

still forum
#

there is createVehicleLocal if you want a local vehicle. Thus through logic thinking you can deduce that createVehicle is global

waxen jacinth
#

😅

#

thanks for helping me out pals 😘

little eagle
queen cargo
#

BI Broke it

#

simple as that

still forum
#

would mean that addWeapon is local

#

Though this add's weapon to a unit

#

and unit inventories are always global I think

#

Lul
the addWeaponGlobal command will replace the weapon currently in a slot with the added weapon if it shares the same slot
KK comment: If you do not remove weapon first, using this command from dedicated server will duplicate weapon.

little eagle
#

My fav:

    In Arma 3, the alternative variant of this command (addMagazine ARRAY) accepts global arguments Arguments of this scripting command don't have to be local to the client the command is executed on, i.e. you can use it on the server to give remote unit a magazine with limited ammo.
peak plover
#
// Remove the script to the list
_unit_scripts = _unit_scripts select {!(_x param [0,nil] isEqualTo _script)};
#

very select

#

exciting

little eagle
#

Might as well write param [0] if the default value is nil. I'm also not sure what select does if the code reports nil.

still forum
#

Removing to a list doesn't make much sense

#

you mean from?

#

and... use deleteAt and find

#

_unit_scripts deleteAt (_unit_scripts find _script)

little eagle
#

I too suggested deleteAt, but I guess this handles multiple?

still forum
#

that's true.

#

But are multiples expected?

little eagle
#

Dunno. Also worth thinking about good old - [_script] then instead of this.

still forum
#

true. That might be even faster

little eagle
#

I seldom handle arrays full of code (script ?)

peak plover
#

It handles multiple, yes

still forum
#

_unit_scripts = _unit_scripts - [_script] then

peak plover
#

0.0514 ms
vs
0.0524 ms
Check mate

  • [] is 0.001 ms slower for x100
#

Im actually more suprised to the select thing

#

It actually works, and it's nice

still forum
#

how big is your _unit_scripts array?

peak plover
#

Currently it's empty, but it might be 1000s of elements

#

One day

#

I am prepared for that day

still forum
#

You are perf testing something on an empty array?

little eagle
#

There is no point in testing it if the array is empty.

peak plover
#

Not testing empty

#

Testing with 2 elements

still forum
#

test again with a few dozen

queen cargo
#

am im the only one who does not understands what point the whole code has? did i missed something?

still forum
#

you are the only one

little eagle
#

The point is to remove some elements from an array.

#

Seems like something common and straight forward.

queen cargo
#

_script makes no sense for me

peak plover
#

0.0541 ms // select
0.0536 ms // -[]

little eagle
#

It's a variable, X39

queen cargo
#

no shit

peak plover
#
// Removes respawnUnit scripts to the unit specificied
// [_unit,{spec_fnc_exit},"onRespawn"] call respawn_fnc_remScriptUnit;
"respawn_fnc_remScriptUnit" spawn debug_fnc_log;

// Code begins
params ["_unit","_script","_scriptType"];
/*
unit_onKilled_scripts
unit_onRespawn_scripts
unit_respawn_scripts
*/
// Get the scriptType
_scriptTypeName = format ["unit_%1_scripts",_scriptType];
// Grab old scripts
private _unit_scripts = (_unit getVariable [_scriptTypeName,[]]);
// Remove the script from the list
_unit_scripts = _unit_scripts select {!(_x param [0,nil] isEqualTo _script)};
// Update the script array on the unit
_unit setVariable [_scriptTypeName,_unit_scripts,true];
rancid ruin
#

why are you using // not comment command?

queen cargo
#

if _user_scripts is a collection of scripts
what point does removing one has?
multiple instances of the same are also kinda stupid
seems like a concept issue for me

peak plover
#

I'm new to this, leaf alone @rancid ruin

still forum
#

so @peak plover considering it might have thousands of entries. Do you choose the remove method that's slower if you have more than about half a dozen elements? Or do you use the one that's fastest for 2 elements?

#

yeah. Multiple times the same script actually makes not much sense

#

you should use pushBackUnique and then stop having to care about multiple instances in the array

queen cargo
#

<array> select <code> to remove those could also be replaced by a simple <array> - [ <code> ] which should be faster for non-empty

still forum
#

Which we are talking about right now inbetween your messages @queen cargo

little eagle
#

Is it CODE or SCRIPT we're talking about?

peak plover
#

@queen cargo There can be cases where I want some thing to happen more than once, like stack it

still forum
#

is there a difference?

little eagle
#

{CODE}
SCRIPT = execVM "blah"

still forum
#

Ahhh

#

code then

queen cargo
#

also a question that is not answered

#

so we talk about CODE

little eagle
#

SCRIPT = [] spawn CODE

peak plover
#

code

queen cargo
#

the purpose still is not clear to me ... why you remove all isntances of a particuilar code?
why not execute all and then clear the array?

peak plover
#

I guess naming it wrong is the mistake here

#

There might be cases, when a punishment code is applied to player and then I want to remove it

#

Or a reward is given to the unit for respawn, but then I want to remove it because something else

#

What if

little eagle
#

It's a very abstract task to handle arrays full of CODE. The whole thing could probably be made obsolete. It's like a bureaucracy working on itself.

still forum
#

@queen cargo Think of it like removeEventHandler

#

He removes a element because he doesn't want it to execute anymore

peak plover
#

Exactly

still forum
#

but he still wants the others to execute

#

so why not execute all and then clear the array Because that doesn't make any sense

little eagle
#

That made a lot of sense actually.

peak plover
#

I have a variable _keep, which I use which determines if the code is removed when used

little eagle
#

I mean, what you said before. Not X39.

queen cargo
#

the whole concept seems weird to me ...
if it is seen as event handler, the stackable thing makes no sense
as it is for executing after death the remove all thing would make sense
if it was just for a set of actions after death and additional actions based on events (eg. killed by idk ... a grenade adds a grenade on respawn to player inv) then two arrays would be the most simple way to archive

little eagle
#

It's not to be executed after death. It's to be executed all the time I guess.

queen cargo
#

// Removes respawnUnit scripts to the unit specificied

peak plover
#

haha, specificied

#

It can be used to remove scripts which may run onRespawn, onKilled and respawn. I guess yeah it's like a custom event handelere

still forum
#

Stackable eventhandlers make no sense?

queen cargo
#

why add multiple instances of the same EH?

peak plover
#

But those don't allow this kind of customization

still forum
#

because you want the script to fire multiple times

peak plover
#

I can have mission_onRespawn_scripts and unit getVariable ["unit_onRespawn_scripts"];

little eagle
#

It's not like he copies the whole function. He uses stuff like [{My_fnc_blah}, {My_fnc_blah}]

peak plover
#

Also there is no event for custom respawn. Essentially onRespawn is when unit goes into spectator, then respawn is when he comes out

#

But I can't use events from a single spectator script, because I might want to switch them out

#

This is a base so I can have 3 spectator scripts and switch inbetween using paramaters.

#

Basically where you see solutions I see issues

#

What if scenarious

subtle ore
#

Makes sense

little eagle
#

More than using comment.

subtle ore
#

Damn it, Commy you're buying my popcorn this time. Not enough in the budget

jade abyss
#

You guys still on comment damn

#

you must be bored.

rancid ruin
#

most of this channel is people arguing for 2 hours over 0.0001ms

peak plover
#

Like that's a bad thing?

#

"ooh, there's people with immense passion about what they do, all they do is try to figure out the best ways to do the smallest things"

queen cargo
#

you tested on an empty array right?
with a filled one it should be slower due to code execution vs engine

peak plover
#

Tried with a filled one

still forum
#

He retested it after I told him. At 9:25 PM

peak plover
#

0.0543 ms //select
0.0537 ms // -[]

#

10 elementos

tough abyss
little eagle
#

why do people write stuff like 0.0001ms. Just write 10e-7s instead.

peak plover
#

Wouldn't that be 10e-4s?

little eagle
#

No.

rancid ruin
#

fewer keys need pressing, saving me 0.0001ms

little eagle
#

It's 1e-7 or 10^-7, but maybe I was too obvious with the trolling.

tough abyss
#

Ahhhhh fuck typing on mobile.

peak plover
#

soo... 1e-4 is 0.0001?

little eagle
#

Yes.

#

It's how adults write down numbers.

queen cargo
#

1e-8 @little eagle
milli is 1e-3

little eagle
#

Oh ffs.

queen cargo
#

ohh wait ...

#

my fault

tough abyss
#

:joy:

little eagle
#

Thank god.

peak plover
#

oooh, you said s. so it's ms with the combination of 1e-4

queen cargo
#

seeing duplicates already 🙈 thought it was 4x0

tough abyss
#

Classic X.

little eagle
#

yup, nigel

queen cargo
#

missread 🙈 thought 0.00004ms was written

peak plover
#

Damn, this is pretty sick.

little eagle
#

lmao, learning lots of new things today.

peak plover
#

Yes, it has been quite an interesting day

#

Really fun

tough abyss
#

And yeah stacked EHs really don't make sense when you think about it.

little eagle
#

Nothing makes sense if you think about it long enough.

rancid ruin
#

that's deep

little eagle
#

It's also false.

tame portal
#

Write it in EEE standard for float please

tough abyss
#

So how do I go about displaying text on the screen with display?

little eagle
#

ctrlSetText

rancid ruin
#

text on the script with display?

#

what does this mean

tough abyss
#

Fixed.

#

Assuming rscCut

#

Or cutRsc.

#

Basically I need an example of a RscTitles config.

peak plover
#

Make a CT_STRUCTURED_TEXT and use ctrlSetText

little eagle
#
private _control = findDisplay 46 ctrlCreate ["RscText", -1]; 
 
_control ctrlSetPosition [0,0,safezoneH / 5, safezoneH / 10]; 
_control ctrlCommit 1; 
_control ctrlSetText "COMMY WAS HERE"; 
tough abyss
#

Thanks

jovial nebula
#

Hello, I can't understand a part of a wiki page ( https://community.bistudio.com/wiki/addMPEventHandler )
Specifically where it is stated that :
"MP event handlers are added globally to every client on network in multiplayer and will fire on every client too upon event."

I wanted only to add a killed event handler which fires on the server , is this the command i'm looking for?

still forum
#

You can add a isServer check

#

I actually didn't know it did that. Commy probably knows best but he's gone to bed already

dusk sage
#

There is always EntityKilled (missionEVH)

still forum
#

KK's comment confirms what the wiki says

jovial nebula
#

@dusk sage and where will this event handler fire?

#

@still forum I'll just add a check then

still forum
#

addMissionEventhandler is local

dusk sage
#

^, if you add it on the server, just there

jovial nebula
#

Cool,but I can't attach it to a specific object unfortunately

#

So will just have to use mpkilled,right?

still forum
#

if you check isServer and exit directly the perf impact on clients will be negligible

dusk sage
#

or just use the killed event..

#

😄

still forum
#

No that fires only where the unit is local

#

which won't work for human players

jovial nebula
#

""Killed" and "Hit" eventhandlers are executed where given unit is local." D:

dusk sage
#

They are players?

#

Why do you want just one object tracked? 😄

jovial nebula
#

Yeah sorry didn't specify that

dusk sage
#

Seems odd

jovial nebula
#

Actually I want vehicles local to players to be tracked

dusk sage
#

From the server?

tough abyss
#

how does one determine if a vehicle is a jet/plane?
i assume theres a config about somewhere

jovial nebula
#

Yeah exactly

subtle ore
#

@tough abyss isKindOf 'Plane'

still forum
tough abyss
#

lol mybad

#

i actually remembered as i hit enter

#

thanks guys

#

😄

jovial nebula
#

Will the EH throw an exception if the function does not exist on the client machine?

dusk sage
#

what function

still forum
#

nothing throws an exception

subtle ore
#

@tough abyss Ayy, don't worry about it

still forum
#

I don't even know how to give EH a function that may not exist 😮

jovial nebula
#

Well the function I want to execute from the EH code

dusk sage
#

I think he means the body

#

yeah

still forum
#

The EH code won't run on the Client right?

#

so no.

jovial nebula
#

Well actually,let's suppose i'm doing something like this

_vehicle addMPEventHandler ["mpkilled",{_this call Server_fnc_myEventHandlerScript}];

The Server_fnc_myEventHandlerScript function is defined only on server

still forum
#

would throw script error in RPT then yes.. Although...

#

Actually..

dusk sage
#

unscheduled

still forum
#

in unsche.. yeah

#

but call nil might..

dusk sage
#

^

#

was about to say

#

one half will 😄

still forum
#

just put the isServer check before your call

jovial nebula
#

Lol my mind is blowing 😂

#

Yeah it'll be better

#

Thank you both !

subtle ore
novel path
#

thank you @subtle ore

still forum
#

@novel path this is #arma3_scripting. You couldn't be any more wrong in your channel choice

novel path
#

my ENG is bad sorry

still forum
#

Why don't you post in the channel you started in when you joined the Discord? The first channel in the list that you can write in?

novel path
#

becuse i saw you talking here so i say it here

tardy yacht
#

Hey guys I'd like to show my own HUD on screen with a bullet and mag count. I was thinking of updating it every frame but is there any other way of doing it? Would updating it only on firing/reloading/switching weapons/doing other stuff that needs an update ... do the trick?

warm gorge
#

Don't see why not @tardy yacht

cloud thunder
#

How Can I get a list of editor enabled/attibutes of a Jet's sensors preInit when ForceRespawn is enabled in Vehicle Respawn Module? I'm using forcedRespawn because I apply custom modifed loadouts with Vehicle Respawn Module at mission start.
expression field of module: if (isServer) then {params [["_newVeh",objNull],["_oldVeh",objNull]]; private _sensors = listVehicleSensors _oldVeh; diag_log text format ["PreInit Detected Sensors: %1", _sensors];}; returns empty array. Only After postInit/ second instance of vehicle is the array not empty, but then these are not editor enabled sensors only default.

little eagle
#
if (isServer) then {
    params [["_newVeh", objNull], ["_oldVeh", objNull]];

    private _sensors = listVehicleSensors _oldVeh;

    diag_log text format ["PreInit Detected Sensors: %1", _sensors];
};
#

```sqf
code
```

#

@cloud thunder The Vehicle Respawn Module does not pass any arguments, so params will make _newVeh and _oldVeh report objNull. I checked the module and it seems to me that the module isn't supposed to. No idea where you got that from.

#

Of course

listVehicleSensors objNull

is

[]
cloud thunder
#

Your saying the Vehicle Resawn Module does not pass the entities of new vehicle and old vehicle when new vehicle is created?

little eagle
#

It doesn't. Why would it?

subtle ore
#

I surely wouldn't want it to

#

maybe once you get a vehicle destroyed you no longer have a certain type of asset

cloud thunder
#

Not true. It does. I already have 1 function wich applies loadout to new vehicle and another function wich applies sensors that where on old vehicle to new vehicle It just doesn't apply sensors on second instance preInit when ForceRespawn is enabled..

#

Thre after all params are fine

little eagle
#

I just tried it and the Vehicle Respawn Module doesn't pass any arguments in _this in it's init field.

cloud thunder
#

True it doesn't in init. Try expression field as I mentioned before

little eagle
#

Are you using a mod for this? I don't have an expression field in that module.

cloud thunder
#

no mods

little eagle
#

I found it. It's a single line and not a field.

#
 9:52:42 ["a",[bis_o1,<NULL-object>]]
 9:53:16 ["a",[bis_o1,<NULL-object>]]
#

But it doesn't work as described for me. The new object is reported as null

#

It is also not executed for that initial forced respawn.

#

Eh, Editor and Modules being broken. Nothing new.

#

I guess it's a race condition between Eden setting these sensors and the respawn module killing the vehicle.

cloud thunder
#

Ok anybody with experience with Vehicle Respawn Module expression "line" in here?

#

PreInit the new vehicle is isEqualType "" so it this case (first instance) function is spawned with same parameters passed then new loadout is applied. There after new vehicle is never "" or null in my custom loadout function..

little eagle
#

Also btw. preInit refers to the phase before any objects exists. So there are no vehicles at preInit.

cloud thunder
#

I already use that command to apply the sensors in my function

little eagle
#

But did you use the alternative syntax with the object classname instead of the object?

cloud thunder
#

No i am using the object

little eagle
#
"B_Plane_Fighter_01_F" enableVehicleSensor [componentClassName, state]
#

This should enable it for every vehicle with that classname in the mission if I understand it correctly.

cloud thunder
#

The objective is to apply desired sensors in vehicle obect editor then respawn the vehicle with the sensors set in the editor.

#

how do you make a box for code in discord?

little eagle
#

```sqf

```

#

I just tested the alternative syntax of enableVehicleSensor and it doesn't work.

#

Here is what I'd do:

["Plane", "init", {
    params ["_plane"];

    // do magic
}] call CBA_fnc_addClassEventHandler;

But you said no mods.

#
"B_Plane_Fighter_01_F" enableVehicleSensor ["IRSensorComponent", true];

^ this gives me a generic error. So the wiki also lies to us.

vivid quartz
#

it expects object tho description isnt right

little eagle
#

vehicleClass is a string / classname usually though.

#

Well, it's obvious that the expression line doesn't work and reports null as "old vehicle".

#

            [missionnamespace,"respawn",[_newVeh,_veh]] spawn bis_fnc_callscriptedeventhandler;

            //--- Delete the old vehicle
            if (_wreck > 0) then
            {
                if (simulationenabled _veh) then
                {
                    //--- Delete after init code is finished (in separate thread, so this one can continue)
                    _veh setVariable ["BIS_fnc_moduleRespawnVehicle_destructionScript", [_newVeh,_veh,_wreck,_initScript] spawn
                    {
                        _newVeh = _this select 0;
                        _veh = _this select 1;
                        _wreck = _this select 2;
                        _initScript = _this select 3;

                        waituntil {scriptdone _initScript};

                        if (_wreck == 2) then
                        {
                            private ["_boom"];
                            _newVeh allowdamage false;
                            _boom = createvehicle ["M_AT",position _veh,[],0,"none"];
                            _boom setvelocity [0,0,-1];
                            sleep 0.5;
                            _newVeh allowdamage true;
                        };

                        deletevehicle _veh;
                    }];
                }
                else
                {
                    //--- Delete without any effects
                    deletevehicle _veh;
                };
            };
        }
#

The first line here does the execution of the expression line and is spawn'ed. So executed at least one frame after the module function has deleted the wreck.

#

Have I mentioned how scheduled environment scripting sucks and leads to all kinds of race conditions today?

#

There.

#

Don't use the expression "field" line.

#

It's broken.

cloud thunder
#

That ticket is not accurate it will never be null object after the first time.

little eagle
#

It reported null for me multiple times.

#

And it's a race condition, so it might report null some times and other times will appear to work correctly.

cloud thunder
#

then your doing something wrong. Its working for my reinstae sensors function exept first run

little eagle
#

Look at the code excerpt I posted. It is the modules script. It clearly is a race condition.

#

And that is a sufficient explanation for _oldVeh being null.

#

So I'm going with that unless you have a better one.