#arma3_scripting

1 messages Β· Page 245 of 1

queen cargo
#

you do know that the vehicle init is also executed on client?

#

checked with another client?

#

i do not assume different behaviour

tame portal
#

Well anyway, thanks, good to know that they are treated as objects

queen cargo
#

more invalid expectations or observations

dusk sage
#

I was saying, setting only the variable via the init

#

And using debug for the code

tame portal
#

I was really confused when it behaved like a reference

queen cargo
#

@tame portal nope, arrays and objects both are values
however, both just point to somewhere

#

means all is local @dusk sage

dusk sage
#

So it's somewhat of a spoof

tame portal
#

@queen cargo Yeah I mean I assumed assigning an array to a different variable would not copy the pointer to the adress but rather make a copy as it does with all other types

#

Except objects

#

Nah you get what I mean

queen cargo
#

nope
it does not with other types

#

other types are kinda direct

#

kinda ...

#

no fucking clue how it handled internally

tame portal
#

Yeah didnt know that tbh

queen cargo
#

but ... in general ... you can assume that SQF behaves mostly in regards of passing vars like a normal lang

#

_foo = _bar will copy whatever value _bar contains
and if _bar contains a ref ... then it will copy the ref value

dusk sage
#

It still doesn't explain why another client will notice the change aswell though

queen cargo
#

which other client @dusk sage

#

right now in your scenario there is just you

dusk sage
#

Like I said, this happens in MP

#

For anybody, the variable will have changed

#

From what I can see

#

From an issue that arised some time ago

queen cargo
#

ye ... just gimme a few mins

#

will provide you a working example

dusk sage
#

I understand the logic behind what you said, 100%

#

I'm just lost at the broadcasting scenario

queen cargo
#

promise you ... it is not broadcasting ... would break with the entire SQF behaviour

#

as said: gimme some time

#

and i will prove that you just observe invalidly πŸ˜ƒ

dusk sage
#

πŸ‘

queen cargo
#

mhh ... crap

#

biki down

vital onyx
#

@queen cargo opens fine for me

queen cargo
#

weird ...

#

@dusk sage

//name object X_Object
//Put following lines into vehicle init
this setVariable ["test", [[1,1], [2,2]]];
X_Update = {
    _array = X_Object getVariable "test";
    _test = _array select 1;
    _test set [0,5];
};

//execute this in your local client
[] remoteExec ["X_Update", 2, false];
[] spawn {
    sleep 1;
    hint str X_Object getVariable "test"
};```
#

@dusk sage behaves as expected now?

dusk sage
#

Can't test it just yet

queen cargo
#

check ... will head to bed

dusk sage
#

I cannot right this second, go to bed πŸ˜›

queen cargo
#

gn8

dusk sage
#

gn πŸ’€

little eagle
#

copy array pointer:
_newArr = _arr;

copy array contents:
_newArr = + _arr;

Array pointers are a local concept, so they will never be broadcasted.
If you broadcast an array, it will create a new pointer on all remote machines.

queen cargo
#

well ... kinda

#
obj foo = "bar" createVehicle [0,0,0];
_i = 0;
while {true} do
{
    foo set[str _i, _i];
    _i = _i + 1;
};```
#

this for example would be damn stupid

shrewd lichen
#

πŸ˜„

queen cargo
#

but to get back to your question @tough abyss, why are you asking?

#

100%hdd i/o most likely is a broken HDD

#

unless you do permanent I/O operations ... you should not get any IO caused by SQF

native hemlock
#

Are they getting RPT spam?

queen cargo
#

also a way ... but still no 100% hdd IO

native hemlock
#

Also would be interesting to know if they have SSDs

#

I don't think it's anything you can control

#

Probably something in the engine with textures streaming from HDD

queen cargo
#

well ... i personally tend to crash away on I&A ...
so ...

#

you might found some weird bug in SQF by accident

lone glade
#

I&A is written like ass, it's no secret

lone glade
#

1 you mean

versed willow
#

Are there any workarounds for this atm?

lone glade
#

use the command locally

little eagle
#

_a = -1207959552; (_a + 1) in [_a]
-> true

#

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

lone glade
#

hahahahaa

queen cargo
#

uhm ... how is that possible Oo

little eagle
#

FLOATs and their shitty implementation in SQF

queen cargo
#

doubles

#

just to note

#

long float

little eagle
#

they are four bytes afaik

queen cargo
#

rly?

#

you fucking kidding

#

but ...

#

na ... not asking

little eagle
#

that's what they told me

#

makes sense, conidering you can go to 1e007 only

queen cargo
#

but precision somehow does not matches that ...

#

anyway ...

little eagle
#

float precission is 7, which is what you have in Arma

queen cargo
#

soonβ„’ we will get 64bit support and with em doubles etc.

little eagle
#

do we?

lone glade
#

soon (been three years that it was announced)

versed willow
#

@lone glade nah, still doesnt seem to work properly, all calls of setUnitLoadout are only executed by the player

lone glade
#

are you using getUnitLoadout / setUnitLoadout or wrote your own array for it ?

versed willow
#

I have my own array for the respawn

#

yeah

lone glade
#

which branch are you on ?

versed willow
#

the main one

lone glade
#

stable ?

versed willow
#

ye

lone glade
#

can you link to the code ? or gist it ?

versed willow
#

calls are in ln. 4 and 21

#

in the onPlayerRespawn.sqf

lone glade
#

what's the actual issue, you don't have all the equipment ?

versed willow
#

yeah, serverside the containers are empty

#

only the visible items actually get saved

lone glade
#

BIS probably need to fix it, still isn't fixed on dev branch

versed willow
#

huh k, so I'm fucked for now?

lone glade
#

eeeeeh kinda

versed willow
#

ehhh shit

#

do you think you could work around it with the add[thing] commands?

#

do they let you define containers with content?=

lone glade
#

nope

versed willow
#

doesnt this like fuck up anything that's depending on persistent inventories?

lone glade
#

should be fine if you use the command locally

versed willow
#

well I did

#

I send the inventory string to the client via publicvariable

#

and there it gets locally applied

split coral
#

Does anyone know why this happens?

for "_i" from 0 to 1 step 0.1 do {
    if (_i in [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]) then {
        array1 pushBack _i
    }
};
systemchat str array1;
-> [0.1,0.2,0.3,0.4,0.5,0.6]```
Why don't the steps 0.7 0.8 and 0.9 match? The steps aren't literally 0.1 * n?
#

Not a problem for me, I'm just curious.

dusk sage
#

missing ;?

#

nvm if it systemchats

austere hawk
#

I'm a bit of a script nooby, can somebody help me with my config defined useraction? i want to execute a script via a useraction (due to additional conditions).
problem 1) I have no idea how i should properly execute the script... call or execVM etc. inside the statement string.
problem 2) the script code itself seems to have some general error - when used in the action-statemen (with "this" instead of "_this") http://pastebin.com/GdrktYVF

dusk sage
#

@split coral
There is nothing wrong with the loop, or using in, it just seems the if statement breaks it :/

#

I'm sure there is somebody here with the answer though

tough abyss
#

@austere hawk that script seems a bit strange, what should it exactly do?

austere hawk
#

@tough abyss i want to execute 2 animations - first close a vehicle ramp, then hide the interior (for better performance). But before i can hide the interior of the vehicle i need to make sure the ramp is closed.
there is also a large tophatch that can be open or not. So i need to make sure that one is closed as well.

tough abyss
#

@austere hawk untested and not sure if the 0.001 and 0.01 is intend in your paste but i used 0.001

#

but you would need to register your function in cfgFunctions

austere hawk
#

that i can do. doesn't waitUntil check every frame?

tough abyss
#

think so yea

#

waitUntil { _this animationPhase "anim_ramp" < 0.001; sleep 1 };

#

not 100% sure it works.. haven't scripted sqf in a while πŸ˜„

austere hawk
#

Error in expression <mp_AnimSrc",0,false];
waitUntil { _this animationPhase "anim_ramp" < 0.001 };
if>
Error position: <animationPhase "anim_ramp" < 0.001 };
if>
Error animationphase: Type Array, expected Object
File k40_v_chimera\Vehicles\Chimera\ChimeraAPC\Scripts\ChimAPC_close_ramp.sqf, line 4

#

(without the sleep)

tough abyss
#

ah sry forgot to replace _this with _vehicle

queen cargo
austere hawk
#

hm no hiding and no systemchat message. ramp closes at least. No error message either though. Will have to investigate the issue later, i'm off for now. thank you anyway

split coral
#

@queen cargo Yeah. But the game doesn't do steps by 0.1 + 0.1 + 0.1... then?

queen cargo
#

check the page dude ...

split coral
#

Yeah. Now I did. πŸ˜ƒ sorry

queen cargo
#

at least that is pretty much the reason why it is not working as you would intend

dusk sage
#
array1 = [];
for "_i" from 0 to 1 step 0.1 do {
    array1 pushBack _i
};
#

Would work

#

There isn't a problem using in for numbers above 0.6

#

So why sticking it in an if, does it break? @queen cargo

split coral
#

Thanks, X39. That explains it nicely.

little eagle
#

"step 0.1" looks very strange. Usually those steps in for-loops are integers afaik.

crystal portal
#

does anyone know the class name for fake explosive charges that are used to script explosions? i've stumbled upon an entry about that in the bis wiki but some time ago but now that i'd need it i wasn't able to find it

little eagle
#

ClaymoreDirectionalMine_Remote_Ammo_Scripted

#

SatchelCharge_Remote_Ammo_Scripted

crystal portal
#

thank you

little eagle
#

DemoCharge_Remote_Ammo_Scripted

#

I think that's all.

crystal portal
#

perfect, exactly what i was searching

little eagle
#

Well, you can createVehicle every explosive with triggerWhenDestroyed = 1 and it will work

crystal portal
#

cool, good to know

#

but this one should come more like a surprise

#

so i'd need to hide them anyway

#

rather for looks than effect

little eagle
#

A common big explosion is made by using the GBU

#

Bo_GBU12_LGB I think

crystal portal
#

that's a bit too big

#

i wanted a sequence of smaller explosions, i'll take the democharges

empty pagoda
#

does anybody know how to use the onTimer ctrl eventhandler?

#

cant find anything in the wikis

empty pagoda
#

anyone?

vital onyx
#

it is said by using setTimer command which is not listed in biki

#

probably it may use some engine hacks

empty pagoda
#

yh does anybody know what this setTimer function is, or how to use it?

little eagle
#

I've never seen onTimer used anywhere, it's probably broken

vital onyx
#

no, it is not listed by supportInfo command

empty pagoda
#

so there is now way to make a ctrl/display eventhandler that fires after some time? 😦

little eagle
#

sleep command?

empty pagoda
#

i need a eventhandler

little eagle
#

are you using CBA?

empty pagoda
#

no vanialla arma 3 :/

little eagle
#

good luck then : P

empty pagoda
#

;~;

#

thx

vital onyx
#

no sleep

#

uisleep please

pliant stream
#

what are you trying to do @empty pagoda

odd cradle
#

Hello, does anyone have experince with lightbar scripts, and could possilby help me out?

little eagle
#

_lightsource = "#lightpoint" createVehicleLocal _pos;

#

light lightAttachObject [object, position]

#
  • always use createVehicleLocal
  • you might want to try attachTo in case you want to attach it to moving objects
  • you cannot remove the delay when the object is moving
#

Oh and run it only every machine

split coral
#

@little eagle

"step 0.1" looks very strange. Usually those steps in for-loops are integers afaik.
True, but that was just an example. The point was that
0.1+0.1+0.1+0.1+0.1+0.1+0.1 == 0.7 -> false
I'll just have to keep this in mind in the future.

pliant stream
hallow spear
#

why do you want to createVehicleLocal for lightpoint?

versed willow
#

Yo, got another tricky issue idk how to get around.

_wepname = rhsusf_weap_glock17g4;
trader addAction ["Buy Gun", {player addWeapon _wepname}]```
zealous solstice
#

because it only work with createVehicle Local

versed willow
#

so _wepname is retrieved from within a for loop, so idk what it is before

hallow spear
#

ah, ok

versed willow
#

but inside the code I cannot use it like that

#

anyway I can pass the value to the code without referencing the local var?

pliant stream
#

the action handler does not inherit the scope where the action was added

versed willow
#

I know

pliant stream
#

you can use the argument to pass stuff to it

#

3rd parameter

versed willow
#

ahhhh

#

okay sorry, coulda prevented this one by reading the actual article

#

it's kinda late atm

crystal portal
#

is the new "press and hold" action already in the stable branch?

elfin bronze
#

Anyone know how to disable the mouse cursor on createDisplay ?

queen cargo
#

createDisplay has mouseCursor oO

#

well ... always used createDialog anyway ... still kinda weird πŸ˜…

#

but wait ... ye ... remembering now ...

#

@elfin bronze what is your goal with your UI?

elfin bronze
#

I want to show a dialog from player to another, butI want the player be able to move

#

Player A : sent variables : name & some shit
Player B : createDisplay and CtrlsetText with vars "name & some shit"

#

Like hint

austere granite
#

RscTitles? :3

queen cargo
#

RscTitles would be what you want to go for then

#

alternativly, implement some sort of "notification" system

#

or use the already existing one

#

and use those to display the notifications

hallow spear
#

any script commands to have players join a server?

#

or switch servers

hallow spear
#

would be a cool functionality, i will impatiently wait then.

queen cargo
#

what would you want to do with such a command ... you would always end up in lobby first

vapid frigate
#

could do an open world (life/dayz/whatever) spanning multiple maps

queen cargo
#

you would always end up in lobby first

vapid frigate
#

it's a non existent feature.. they could add a solution to that too

vital onyx
#

@queen cargo skippLobby=1; in description.ext pushes player directly to game

#

@hallow spear I would suggest a mod with dll who integrates with launcher and restarts arma with needed params

#

say scripted event > signal to dll > dll contacts launcher > launcher shuts down arma > launcher restarts arma with new server params

#

kind of tricky, but that's the only way coming to mind

little eagle
#

@pliant stream
Your method errors out for
[{A = canSuspend}, []] call fxy_fnc_sync

#

I think this is because you cannot set/pushBack/append a expression that ends with =

#
fxy_fnc_sync = 
{ 
 private "_result"; 
 _result = []; 
 isNil { _result set [0, call {_this select 1 call (_this select 0); false}] }; 
 _result select 0 
};
#

I have to add this call, and return something else (here: false, doesn't matter what though)

#

oh, but then the return value doesn't work anymore. :/

shrewd lichen
#

I'm trying to make an animation mod, it's my first attempt, im using init.sqf file to set keypresses execute scripts - is init.sqf enough or does it have to be XEH_preinit?

#

if(isDedicated) exitWith {};
GCT_Brief = {
switch (_this) do {

    //Key Y
    case 44: {
        nul = [_this] execVM "brief_talk.sqf";
    };
            
    //Key X
    case 45: {
        nul = [_this] execVM "brief_listen.sqf";
    };
};

};

#

Oh sorry how do I do scripting box like commy2

#

?

little eagle
#

three "```" in a new line at the beginning and the end

#

without quote marks

shrewd lichen
#

rpger

#

roger*

little eagle
#

If you want to use keys, then you have to use a keyDown event handler

#

that will be executed when a key is pressed and report which one

#

the state of shift, ctrl, alt etc.

shrewd lichen
#

Oh, I see, lemme rewrite the code

little eagle
#

Are you using CBA or no mods?

shrewd lichen
#

CBA

#

'''if(isDedicated) exitWith {};
gct_brief = compile preprocessFile "brief.sqf";
_display = findDisplay 46;
_display displaySetEventHandler ["KeyDown","_this call gct_brief"];'''

#

Oh, wrong button

#
gct_brief = compile preprocessFile "brief.sqf";
_display = findDisplay 46;
_display displaySetEventHandler ["KeyDown","_this call gct_brief"];```
#

Thats for my init.sqf

#
        
    //Key Y
    case 44: {
    nul = [_this] execVM "brief_talk.sqf";
    };
    //Key X
    case 45: {
        nul = [_this] execVM "brief_listen.sqf";
    };
};```
#

And that's my brief.sqf

#

Looks reasonable?

little eagle
#

the problem with adding these keyDown event handlers is

#

that they are added to a display

#

RscDisplayMission

#

or display #46

#

If you add the event handler on mission start

#

you might add it to the mission display that was already existing

#

which would cause two key handlers to be added - one carried over from the previous mission

#

this happens when you press "restart" in the editor for example

queen cargo
#

I think this is because you cannot set/pushBack/append a expression that ends with =
more because = will take the return value

little eagle
#

Yes, X39 and then it errors out

#

saying invalid expression bla

queen cargo
#

yup
still it is the same like:
foo =;

little eagle
#

@shrewd lichen

["keyDown", {
    systemChat str _this;
}] call CBA_fnc_addDisplayHandler
#

try this

#

it handles all the weirdness with display 46 in save games, restarted games, or when you return to lobby as host in a local hosted MP game

shrewd lichen
#

But im wondering will it be carried over restarted games when it's used as a mod

#

Hm, yeah, problably it will

little eagle
#

But im wondering will it be carried over restarted games when it's used as a mod
Yes. It doesn't matter

#

code is code. addon, mission - if it's executed then it's executed

shrewd lichen
#

Gotta try this, I never did a mod before

#

so im superconfused

#

Thank you very much for help, I appreciate it πŸ˜ƒ

little eagle
#

yup
still it is the same like:
foo =;

#

It's not

#

All it is the method the compiler uses to detect this construction:

#

var = (var2 = 1);

#

It could be interpreted as:
var = nil

#

But the compiler marks it as error. Unfortunately (as usual) the printed error message is garbage

shrewd lichen
#

so my init.sqf looks like this

#
gct_brief = compile preprocessFile "brief.sqf";
_display = findDisplay 46;
_display displaySetEventHandler ["keyDown", {
    systemChat str _this;
    }] call CBA_fnc_addDisplayHandler```
#

Or am I retarded? :D

little eagle
#

it's wrong

#
if(isDedicated) exitWith {};
gct_brief = compile preprocessFile "brief.sqf";
["keyDown", {
    systemChat str _this;
}] call CBA_fnc_addDisplayHandler
#

Also, you might want to replace that isDedicated with !hasInterface

#

That way potential headless clients exit there too

#

headless clients have no display just like dedicated servers, but are obviously not "isDedicated"

pliant stream
#

_var = call { dbg_var = canSuspend }errors out too, it's just SQF being shitty SQF

little eagle
#

yep

#

same with my configClasses method

#

But thanks to this I now figured out why it errors some times, haha

#

all you have to do is add a ; nil

pliant stream
#

yeah

little eagle
#

good enough for me

#

FNC = { dbg_var = canSuspend }; _var = call FNC;

#

this is really strange that this errors

#

seems totally valid to me

#

seems like this is a problem with SQF in general

pliant stream
#

i think in SQF assignment doesn't have a value

#

as in, all commands have a value like a null GameValue or a GameDataNothing, GameDataNil etc.. not quite sure what the difference is there..

#

but assignment i don't think has any value at all

little eagle
#

Yeah, that's probably it

#

= should set the value to GameDataNothing or GameDataNil

#

whatever is more approriate (don't know the difference)

#

On one machine?

#

Hmm. Strange. It obviously triggers twice over all

#

owner as in the owner id number?

pliant stream
#

is this on the client or the server

little eagle
#

seems useful, but it shouldn't report it as argument 0

#

yeah. Ill try to repro on local host

#

1.63 ???

#

I'll try anyway

#

It's probably a new feature going haywire

queen cargo
#

<IDENT> = <EXP> wont return a value as it is no expression
and as the = operation expects an expression (eg. nil), it will error out

little eagle
#

Because hurr durr, let's put unfinished stuff in release branches

pliant stream
#

yeah x39 that's the conclusion we came to as well

little eagle
#

X39, you are saying the same as Foxy, but with different words

pliant stream
#

though it should return either the expression used in the assignment, or nil

little eagle
#

I agree

queen cargo
#

thats what i could have told you from the begining ...
and i just repeated myself

little eagle
#

Good we all agree

#

clap clap

queen cargo
#

I think this is because you cannot set/pushBack/append a expression that ends with =
more because = will take the return value

little eagle
#

hold on

pliant stream
#

it wasn't anything new to me, i used the array initializer atomicity trick a lot, and could never use assignments

little eagle
#

getinman >> addeventhandler 'local' >> EH local fires with params = object/bool >> vehicle becomes local >> EH local fires again with params = number/object

can you write this in actual code?

pliant stream
#

that's why i used the missionNamespace setVariable ... in my ridiculous object init eh dispatcher

little eagle
#

I have a theory

pliant stream
#

guy gets in twice?

#

πŸ˜„

little eagle
#

You are modifing the C++ array while iterating through it

#

the array with all the event handlers

#

Similar issue as the problem with removing a fired event handler from inside a fired event handler

pliant stream
#

different eventhandlers have their own arrays

#

don't ask me how i know this.. i think you're not allowed to discuss reverse engineering :<

little eagle
#

Are you sure? Because someone reproduced it by remoing a different event handler

#

reverse engineering is totally legal. After all, all we do is make educated guesses about what we see ; )

pliant stream
#

it's prohibited by the EULA

prime valve
#

Reverse Engineering, you said ? That is a huge offense to democracy and freedom. Better call in a SWAT Team then

pliant stream
#

i'm just saying, the forums at least have a rule against discussing it

little eagle
#

And maybe this works in reverse too

#

adding eh inside one

#

instead of skipping one, it would execute another one

#

case closed

#

case sensitivity?

#

it sucks

queen cargo
#

@tough abyss toUpper _str1 in toUpper _str2

#

there is a command to itterate through all of them

#

i more hate that string == string is NOT case sensitive ...

little eagle
#

toUpper _str1 in toUpper _str2
X39, tsk tsk

#

STRING in STRING doesn't even exist

queen cargo
#

better have a ==IgnoreCaseSensitive

#

mimimi commy

little eagle
#

STRING in ARRAY is what we are talking about

queen cargo
#

do not have the time to search for the apply command thingy now

little eagle
#

apply {toLower _x}; ?

queen cargo
#

so it really was apply?

#

well ...

little eagle
#

Yes

queen cargo
#

πŸ˜…

little eagle
#

The worst thing about this is how BI doesn't care about consistent case in their configs

queen cargo
#

configs are internally lowercased all anyway

little eagle
#

They could've made BIS_fnc_compatibleItems at least report everything in lower case

pliant stream
#

apply.. what stupid naming

#

should have been where and select like sql

little eagle
#

"apply" implies for me that the original array is modified

queen cargo
#

+1

pliant stream
#

yeah i think the reason they named it that was because they already used select for something else

little eagle
#

Well, select is different

#

filter ? idk

queen cargo
#

but well ... apply is better then
withEachApplyCreateNew

little eagle
#

Yeah

#

Unless you made a popular mission that used apply a global variable

#

: P

#

There are people who name units "commander"

#

and then make tickets on our github page

willow basin
#

Yea made the same mistake once as I had different Uppercases than the actual command which gave the variable a whole new meaning.. then I was confused and searching why my mission stopped working xD

little eagle
#

another common one is naming a supply box items

#

like in items player

#

This is why you should ALWAYS tag ALL of your global variables

#

But I think it's hopeless when I say that

willow basin
little eagle
#

By whom?

icy herald
#

@tough abyss So be it then! @little eagle is right, all globals must be tagged!

tame portal
#

How come there are at times so many BI Minions and then days later they are almost all gone

little eagle
#

It's either statistics and probability

#

Or it's a conspiracy

tame portal
#

I'd go for conspiracy

#

Btw I always tag my variables

little eagle
#

That already elevates your code into the top 10%

tame portal
#

If I showed you my code I would boost it back to where it came from: -100%

deft zealot
#

better use multiple tags if one fails you still have another one πŸ˜‰

#

TAG1_TAG2_myVariable

little eagle
#

:facepalm:

#

@deft zealot

#

A tiny bit faster and no strange config needed

deft zealot
#

nice i hate this dummy config

pliant stream
#

does that work

#

hmm i must have done something wrong when i was testing it before

little eagle
#

It's your method, foxy

pliant stream
#

yea i know

#

but when i was first testing it, it wouldn't overwrite a variable in the outer scope

#

which is why i was using the array for the result

little eagle
#

private _a = 1; isNil {_a = 2}; _a

#

2

#

works

pliant stream
#

yeah i just tried it

little eagle
#

I just used the array method for diag_codePerformance

pliant stream
#

must have done something wrong before then

little eagle
#

cause that runs in a different scope

#

Maybe you used private _a = 1; isNil {private _a = 2}; _a

pliant stream
#

definitely not that since i tested in A2 :p

little eagle
#

local _a = 1; isNil {local _a = 2}; _a

#

then

#

πŸ˜›

pliant stream
#

no clue what i did.. but it works fine now so doesn't really matter

little eagle
#

just beware of crashes πŸ˜‰

deft zealot
#

what does 0 spawn {private _a = 1; isNil {_a = 2}; hint str _a;}; output?

little eagle
#

<script> ?

#

πŸ˜›

#

it's 2

deft zealot
#

ok now do this:
0 spawn {private _a = 1; diag_log diag_frameNo; isNil {_a = 2; diag_log diag_frameNo;}; diag_log diag_frameNo; hint str _a;};
and check the frames

little eagle
#

they will all report the same frame

deft zealot
#

depends what else is running xD

pliant stream
#

fxy_fnc_sync =
{
    private "_result";
    isNil { _result = _this select 1 call (_this select 0) };
    _result
};

0 spawn
{
    _func =
    {
        private "_frame";
        _frame = diag_frameNo;
        DELAY;
        DELAY;
        DELAY;
        DELAY;
        diag_frameNo - _frame
    };
    
    _control =
    {
        _this select 1 call (_this select 0)
    };
    
    systemChat format ["control: %1 frames", [_func, 0] call _control];
    systemChat format ["sync:    %1 frames", [_func, 0] call fxy_fnc_sync];
};```
#

here's a much better test case for you

#

@deft zealot

#

and in the code you posted they will not necessarily all show the same frame

vital onyx
#

got to update my dokuwiki plugin to highlight SQF - it has 2079 unique commands o_O

spring kindle
#

_Mission1 = [hint "You have recieved job 1"];
_Mission2 = [hint "You have recieved job 2"];
_Mission3 = [hint "You have recieved job 3"];
_Mission4 = [hint "You have recieved job 4"];

_missions = [_Mission1, _Mission2, _Mission3, _Mission4];
_mission = _missions select (floor (random (count _missions)));

#

Hello I'm trying to make an array that will choose one of the 4 options randomly with a probability percentage, can't find anything on the webs really... anyone mind helping me out?

dusk sage
#

There is no command for use with a given percentage that I am aware of, but you can create a function for it easily

spring kindle
#

oh and must i say it only outputs the last mission

dusk sage
#

See the alternative syntax

spring kindle
#

is there not like an yeasy way to set it up like how the loot spawns work on epoch and such

lone glade
#

got something for that, gimme a sec

#

you pretty much create a new array with 0 to 10 of your elements, shuffle it and use randomSelect to pick one.

dusk sage
#

But that wouldn't be a probability percentage, unless you added some function for it

spring kindle
#

I'm a begginer so how exactly would that look?

dusk sage
#

Which wouldn't be hard at all

dusk sage
#

Well, they all have equal probabilities, unless you used random with alt. syntax

lone glade
#

not really since some have less entries than others.

dusk sage
#

You didn't mention adding more than one, but that would work yeh

#

You could also abuse a switch fall through

#

πŸ˜„

lone glade
#

not keen on that

dusk sage
#

64+ cases, all good fun

#

😫 πŸ”«

lone glade
#

Also for those that didn't knew init.sqf executes BEFORE remoteExec (JIP flag) has been passed

#

use initPlayerLocal and initServer instead

spring kindle
#

@lone glade what would i do with the if statements? i just want it set up so it chosses one of my elements and then executes a script

lone glade
#

those if statements are not needed in your case, I use them to detect classes I want to.

#

(no percentage there but it's the same principle)

dusk sage
#

You need to make it clear exactly what you want as an outcome @spring kindle

#

Selecting a random element is incredibly easy (one command, same concept as yours), but adding some varying probability will require more

spring kindle
#

I'm making a trucking mission system so you press get job then it picks a random jobv out of a list then executes the script paired with that job to "load" the truck

dusk sage
#

So you want purely a random choice, no varying probability?

#

I.e, one is near impossible to get

spring kindle
#

I want varying proabaility for higher paying jobs so they arent as common

lone glade
#

combine both of my examples there then.

dusk sage
#

Well one option you have is like @lone glade said above, add multiple of the same choices to your array, then select one at random.

spring kindle
#

so what would i do with this from here?

#

@lone glade

lone glade
#

gimme a sec

dusk sage
#

Should be fine

lone glade
#

no shuffle there

dusk sage
#

How much impact will it actually have?

lone glade
#

a lot, since it's not properly randomized

spring kindle
#

so i can put just the script name in the yourtag_fnc_1 spot

lone glade
#

yes.

spring kindle
#

thank you so much

dusk sage
#

What explanation would shuffling the elements have on the outcome?

#

I.e, what flaws has the command got, except not being properly randomized

lone glade
#

I noticed selectRandom like to pick the extremes of an array, making the center less picked

dusk sage
#

Or are you just taking a measure to increase the randomness, say

spring kindle
#

is that last comma an accident?

lone glade
#

yes it is πŸ˜›

spring kindle
#

makes more sense now lol

dusk sage
#
0: 968
1: 924
2: 903
3: 898
4: 890
5: 934
6: 843
7: 870
8: 915
9: 957
10: 899
lone glade
#

:/ weeird.

dusk sage
#

100k iterations:

0 - 9.04591%
1 - 8.99591%
2 - 9.21891%
3 - 9.02591%
4 - 9.06191%
5 - 9.10091%
6 - 9.19991%
7 - 9.01791%
8 - 9.15491%
9 - 9.14591%
10 - 9.03191%
lone glade
#

I must be going crazy then πŸ˜›

dusk sage
#

Seems alright πŸ˜›

lone glade
#

yep seems good

dusk sage
#

Heres 1 million

#

before I delete this code

#
0 - 9.11689%
1 - 9.09769%
2 - 9.06049%
3 - 9.11469%
4 - 9.08899%
5 - 9.10989%
6 - 9.05869%
7 - 9.10909%
8 - 9.06389%
9 - 9.09019%
10 - 9.08949%
#

πŸ˜„

#

Don't want my game to crash on me

#

πŸ’©

lone glade
#

not going to happen, unless you do:
_a = {call _a}; call _a;

dusk sage
#
vehicle player setVelocity[1e10,1e14,1e18];
#

πŸ‘

#

Pretty funny actually

lone glade
#

you should've seen the broken anims extracted from TKOH, those were hilarious

dusk sage
#

Tonic's SpyGlass runs that, preProcesses a file, which causes a memory crash which gives the error : "Hi, it appears that your client crashed. Do not worry we will get back with you in six years."

#

πŸ˜„

native hemlock
#

It bothers me that you used 11 numbers instead of 10

dusk sage
#

haha

native hemlock
#

Yeah wasteland makes you include a non existent file which causes a crash

#

If you want to be sneaky in how you crash their game you have them create a string 9 million characters long and recursively add it to an array until their game runs out of memory

#

But then they would probably blame BI so maybe that's not the best idea

dusk sage
#

Cruelty πŸ˜›

lone glade
#

cruelty is wiping someone profileNamespace

little eagle
#

don't join random servers

#

this game is for milsim only

#

fite me

spring kindle
#

@lone glade

lone glade
#

link the code, I already deleted the gist πŸ˜›

spring kindle
#

πŸ˜„

lone glade
#

missing [] for the elements

#
private _mission = [
[fnc_TM1, 4],
[fnc_TM2, 6],
[fnc_TM3, 1]
];
spring kindle
#

fixed some of it

lone glade
#

which version of the game are you on ?

spring kindle
#

tanoa

native hemlock
#

If you are feeling super basic you can just have an array with the missions in it. Then you can manually add duplicates for however many times you want it in the array, and then you simply use selectRandom on it

lone glade
#

if you're on RC it should work fine

#

oh missing _ on amount

#

that or the RPT cut it

spring kindle
#

heres the full one

#

but where is an _ missing?

lone glade
#

check the bottom of the RPT

#

wrong function variable

#

you're missing your tag

spring kindle
#

i have to have a tag?....

lone glade
#

gimme a sec i'll link you to the CfgFunctions page

spring kindle
#

like that?

lone glade
#

yes.

#

no need for the fnc_ in the name of your file

#

it's added automagically

pliant stream
#

you want weighted probabilities on your items?

#

you can add up all the weights, select a random number X in the range [0, total), then loop through the items adding up the weights until the sum is more than X, return current item

#

this is the low performance, low memory usage method

spring kindle
#

wtf

lone glade
#

CfgFunctions goes into description.ext

pliant stream
#

or you can build a weighted array where each item is present more times for higher weights etc

#

this is the high performance high memory usage method

lone glade
#

which is exactly what he does, and "high memory usage" isn't the case

#

if you knew how many elements arsenal arrays handled you would go crazy.

pliant stream
#

yea i'm not saying it's going to crash your game but you are using more memory than the first method

#

it's a tradeoff

lone glade
#

no

spring kindle
#

AHHHHHHH YES THANK YOU

pliant stream
#

a theoretical tradeoff

spring kindle
#

it works now!

lone glade
#

not a tradeoff at all

#

unless the array you want to manipulate happens to have 10K+ entries

#

(arrays have a 10 million limit)

pliant stream
#

ok if i give you this array [["item1", 1],["item2",99]] build me a weighted array that takes the same amount of memory

#

second element of each subarray is the weight

lone glade
#

you don't need to care about memory on that scale

pliant stream
#

did you even read what i said

#

i never said it's even remotely close to mattering

#

but it's there

lone glade
#

if you're decided to optimize byte by byte ok.

pliant stream
#

πŸ˜„

#

i'm not saying don't use the weighted array solution because it takes more memory

#

but it does take more memory than the first solution

#

that's just a fact

dusk sage
#

Maybe we should start using tabs instead of spaces to reduce file size too while we're at it

queen cargo
#

sigh that was not the point foxy wanted to make
low-performance-low-memory is a relative "term" ...
just like the high-performance-high-memory is ...

it pretty much just means one thing: doing this like this will cause that and have theese advantages
it is just the tradeoffs for the different solutions

as we do not really are limited in ArmA, the high-performance solution can be prefered
if we would run into memory problems we should prefer the low-memory solution

#

the actual consumption do not has to be that large compared to anything... just like the performance gain can be minimal ...

#

still you say "low performance" and "high memory"

#

as "with this solution you save XXXms but it will cause XXXbytes more RAM" would require testing (or calculating ... but that wont apply here)

wispy kestrel
#

Is it possible to control the animation source for the plates on the Land_Target_Dueling_01_F like it is possible for the animation source on aTargetP_Inf3_F pop-up target?

native hemlock
#

Yes

#

You should be able to see the animation names in the config browser, but I'll look for them now

wispy kestrel
#

I'm tryinging {<object> animate [_x, 1];} forEach ["Plate_4_source","Plate_5_source","Plate_6_source"];

native hemlock
#

Easy fix then, use animateSource

wispy kestrel
#

Ahh... face-palm I forgot about that new command

#

I'll try iy

#

*it

native hemlock
#

If you were to use animate you would have to use "Plate_1_rot", "PLate_2_rot", etc...

#

You can get those using animationNames <object>

wispy kestrel
#

Right. animateSource was the ticket. Thanks.

native hemlock
#

For future reference if you want the available AnimationSources of an object the following should work

_animSources = "true" configClasses (configFile >> "CfgVehicles" >> typeOf <object> >> "AnimationSources");
{
    _animSources set [_forEachIndex, configName _x]
} foreach _animSources;
copyToClipboard str _animSources;
#

Oh whoops that technically wouldn't catch inherited animations, this should do it

_animSources = configProperties [configFile >> "CfgVehicles" >> typeOf <object>  >> "AnimationSources", "isClass _x", true];
{
    _animSources set [_forEachIndex, configName _x]
} foreach _animSources;
copyToClipboard str _animSources;
wispy kestrel
#

Nice, thanks for that @native hemlock

fresh hornet
#

Could someone help me make a jammer script that jams missiles to all blufor planes which are in the radius of a blufor plane capable of jamming? We've got it to jam missles from hitting a single plane but can't find a way to have it jam the missiles from every plane within the radius. Sorry if this sounds confusing. Just need some ideas

native hemlock
#

How are you making it jam missiles for a single plane?

fresh hornet
#

It deletes the missiles 60% of the time

#

^that's what it does right now

#

But problem is, it deletes blufor missles too

#

I don't think missles have sides assigned

jaunty drift
#

can't you get the source of the projectile and see what side they are on?

fresh hornet
#

I was unaware that could be done, do you have anything I can look at to see?

#

I'll give it a go, Thx guys

native hemlock
#

So at some point last week I accidentally suggested using toString instead of str for converting an array to a string, but what I really meant was to use joinString instead of str.

For a 1000 element array:
Someone's suggested solution using str

_string = str myArray;
_string = _string select [1, count _string - 2];
//18.8 ms

Using joinString

_string = ('"' + (myArray joinString '","') + '"');
 //0.43 ms

Both outputs will be the exact same but in this case joinString is a little over 40 times faster

abstract sigil
#

anyone had the problem where remoteExecCall sometimes executes everything twice on the remote machine?

vital onyx
#

how would you detect that execution happened twice?

#

it may happen when you for example execute a command with a global effect on multiple machines

little eagle
#

it's karma from using onEachFrame {}

velvet merlin
#

what is the reason BI (and parts of the community) want scripted features (from BI) to merged into the engine?

#

the only benefit i can see is performance (which rarely matters for BI stuff) - the downside is no longer possible to be adjusted by the community, usually very unflexible system and usually bugged and not fixed often by BI in a short time frame

#

what do I miss?

little eagle
#

What do mean exactly? I'm thinking of select CODE and apply and those commands are super usefull.

abstract sigil
#

who the hell uses oneachframe? πŸ˜„

pliant stream
#

whats wrong with onEachFrame

abstract sigil
#

Kappa much πŸ˜„

fossil topaz
#

Hi guys, is there a way to output the result of a count operation in the chat? I have this in my script: leader _vehicle sideChat "the radar has located " + format[(count _testsideunits)] + " Blue side units"; but it only writes "the radar has located Blue side units" without the number

native hemlock
#

@fossil topaz You almost had it, give this a try

 leader _vehicle sideChat format ["the radar has located %1 Blue side units", count _testsideunits];
fossil topaz
#

@native hemlock ok thank you!

pliant stream
#

leader _vehicle sideChat ("the radar has located " + str count _testsideunits + " Blue side units");

native hemlock
#

You kind of mixed the two, the other option would have been to do

leader _vehicle sideChat "the radar has located " + str (count _testsideunits) + " Blue side units";
pliant stream
#

but you should use format

native hemlock
#

Oh, Foxy got it πŸ˜›

pliant stream
#

just saying it is possible via concatenation as well

little eagle
#

You kind of mixed the two, the other option would have been to do
missing parenthesis

native hemlock
#

My code? I thought the same initially but it worked

little eagle
#

maybe + operator has a higher priority than other binary commands? It looks extremely confusing though

native hemlock
#

Yeah it make sense to include them

_vehicle = vehicle player; 
 _testsideunits = [1, 2, 3, 4]; 
leader _vehicle sideChat "the radar has located " + str count _testsideunits + " Blue side units";

Outputs "the radar has located 4 Blue side units"

fossil topaz
#

It's working, thank you all πŸ˜‰

native hemlock
#

Well what's weird is

hint "this" + " " + "is" + " " + "weird";

results in only "this" being hinted

little eagle
#

yes, because hint is a unary command and sideChat is a binary command

#

unary commands have higher priority than binary commands

#

+ being mainly a math command seems to be between unary and binary commands

#

maybe it's not because it's a math command, but because there is the alternative syntax of + being unary too. Who knows

#

Both should use parenthesis. So it's clear what is meant

native hemlock
#

supportInfo for +
"b:SCALAR,NaN + SCALAR,NaN"

little eagle
#

don't trust support info.

pliant stream
#

there's multiple overloads of the + operator

little eagle
#

+ <ARRAY> is the syntax to copy an array and it's unary

native hemlock
#

Oh yeah you are right

little eagle
#

+ <NUMBER> is a command too in SQF. It just reports the same number ...

#

probably to complement - <NUMBER>

native hemlock
#

"b:SCALAR,NaN + SCALAR,NaN"
"b:STRING + STRING"
"b:ARRAY + ARRAY"
"u:+ SCALAR,NaN"
"u:+ ARRAY"

little eagle
#

see

native hemlock
#

Thanks for the info

#

On a separate note, is anyone aware of a way to determine if a CfgPatches entry is from vanilla A3? Only guaranteed way I can figure out is to just have a list of all CfgPatches for vanilla on that game version, and check if a given CfgPatches entry is in there

pliant stream
#

_result = 1 ++++++++++ 2 for when you really gotta add them numbers together

native hemlock
#

I guess I could just check if it was "3DEN", "A3Data", or "Map_VR", or if it contained either "A3_" or "CuratorOnly_"

#

But that method isn't ideal

pliant stream
#
{
    class A3_MyCheeckyModHehHehHeh
    {
    };
}```
native hemlock
#

Someone is bound to do that, so I think the first method of just having a list for that game version is probably best

#

I wish CfgMods had a list of CfgPatches or something

pliant stream
#

what do you even need it for

native hemlock
#

lol I don't really have a practical purpose for it

little eagle
#

configSourceMod (configFile >> "CfgPatches")

#

will report "" for vanilla configs

#

but it will also report "" in case you move the addon directly into the \addons\ folder ...

native hemlock
#

Nah, I'll link the script in a minute

#

It's just part of a function that copies the loaded CfgPatches

#

I think commy's method will work beautifully

#

My previous solution was just to have a function that returned a static array that would have to be manually updated between game versions

#

And then I set the variable it was assigned to nil

#

It's only supposed to be used as part of debugging

#
smt_vanillaCfgPatches = [] call smt_fnc_getSavedVanillaCfgPatches;
_configs = "!(configName _x in smt_vanillaCfgPatches)" configClasses (configFile >> "CfgPatches") apply {configName _x};
smt_vanillaCfgPatches = nil;
#

configSourceMod should do the trick though

little eagle
#

just use a local variable for smt_vanillaCfgPatches. no need to delete it then

native hemlock
#

But it's in a different scope when used with configClasses, and I couldn't get the format to work properl

little eagle
#

no it isn't

#

all local variables carry over in the string of configClasses/Properties

native hemlock
#

You're right...

little eagle
#

well except for _x, which is overwritten just like in forEach

native hemlock
#

I must have messed something else up initially

little eagle
#

in is case sensitive

#

But I think smt_fnc_getSavedVanillaCfgPatches reports the "config case" anyway

lone glade
#

isn't in case insensitive and isEqualTo case sensitive ?

little eagle
#

no, both are case sensitive

#

I think == is the only case insensitive command for strings

lone glade
#

:facepalm:

little eagle
#

always use toLower. toUpper is slower because it has to change way more chars on average

native hemlock
little eagle
#

animationState is all lower case

native hemlock
#

I guess those have delayed execution

little eagle
#

does it?

native hemlock
#

"amovpercmstpsraswrfldnon"

little eagle
#

all lower

#

in config it's mixed case, yes

#

well, use toLower

#

or apply {toLower _x}

#

I want a case insenstive in command too

#

in [_needle, _haystack]

#

case insentive for strings

#

made in 10 minutes

#

maybe an uppercase command
hahaha

#

Proably. Can't remember. I sometimes make suggestions like that.

#

Making it a unary version is the only way to get it done without changing the commands name.

native hemlock
#

A much prettier solution to my previous question using configSourceMod

_vanillaMods = ["", "curator", "dlcbundle", "expansion", "heli", "kart", "mark"]; 
_configs = "!(configSourceMod _x in _vanillaMods)" configClasses (configFile >> "CfgPatches") apply {configName _x}; 
little eagle
#

Good job naming the addons "expansion" and "dlcbundle" :facepalm:

#

I wonder if you can also auto generate the _vanillaMods array with the same method using CfgMods

#

Depends on where CfgMods is located.

#

nope they are scattered it seems

native hemlock
#

Couldn't you do the opposite?

_nonVanillaMods = configSourceMod (configFile >> "CfgMods");
_configs = "(configSourceMod _x in _nonVanillaMods)" configClasses (configFile >> "CfgPatches") apply {configName _x};
little eagle
#

CfgMods has Heli, Kart, Mark, DLCBundle etc.

native hemlock
#

Nevermind, it returns a string

#

I was only running CBA and configSourceMod (configFile >> "CfgMods"); was only returning @CBA_A3

#

Jeez it's not my day

little eagle
#

yeah, because CfgMods itself was edited by CBA last

#

by adding, well CBA

native hemlock
#

I should have used configSourceModList

little eagle
#

This method doesn't work for CfgMods itself

#

because multiple addons can edit that

#

And the "" is always overwritten, even by the List version

#

it's all half assed. it only works for CfgPatches, because you never reuse the sub classes there anywhere

versed willow
#

'ello again, addAction is behaving weird for me. The following call works fine:
_trader addAction [format ["Buy %1 [%2$]", getText (configfile >> "CfgWeapons" >> _x select 0 >> "displayName"), _x select 1],{_this call buyItem}, [_wepname, _price], 1.5, false, false, "", "true"]
but this one doesn't:
_trader addAction [format ["Buy %1 [%2$]", getText (configfile >> "CfgWeapons" >> _x select 0 >> "displayName"), _x select 1],{_this call buyItem}, [_wepname, _price], 1.5, false, false, "", "true", 5]
"Error 9 elements provided, 3 expected"

#

According to the wiki all the arguments should be fine

#

_trader, _wepname and _price are coming from code above and are working fine

little eagle
#

The radius parameter is not implemented yet

versed willow
#

ohhhhh

#

I see

#

Damn I'm really unlucky with this kinda stuff recently

little eagle
#

The game is trying to tell you, that you gave one argument you shouldn't. The error message is just garbage as usual

versed willow
#

So I guess I have to work in the radius in the condition yea?

little eagle
#

for now, yes

versed willow
#

oh well could be worse

#

thx

little eagle
#

Since Arma 3 v1.63.136787, two new params are available: radius and unconscious.

#

Current stable is 1.60 and APEX will be 1.62

native hemlock
#

I think that'll be in 1.62 as well

little eagle
#

So this will be first patch after APEX

native hemlock
#

As it's probably used by the new revive system

little eagle
#

I think that'll be in 1.62 as well
No

#

The new revive system isn't in 1.62 either

#

Well parts are, but setUnconscious doesn't work fully

native hemlock
#

I thought they said they were doing it for the new co-op?

little eagle
#

It can't bring you back

#

IDK, its not finished in the current 1.62

versed willow
#

out of curiousity, wouldnt giving too many arguments not matter usually though?

#

Since the n-th field never will be called in a func?

#

or isit different with engine funcs?

little eagle
#

It wouldn't, but Arma

#

It doesn't matter for SQF functions, but commands are anal about parameters

#

you can't even pass nil when you want to use the default value

#

which means you have the write down the default values for argument 4,5,6 and 7 if you want something different for 8

#

...

versed willow
#

yup

#

already gone through that for my addaction

little eagle
#

Yeah, it's really bad there

versed willow
#

also is there a reason addAction wants the condition to be code passed as string?

#

as opposed to just code?

#

like in While, WaitUntil etc

lone glade
#

nevermind, what I said

little eagle
#

Not for the condition, alganthe

lone glade
#

the reason is that it's an old command

little eagle
#

I think it is because it was made during SQS times. There was no CODE type back then. The statement was eventually updated, but not the condition ...

lone glade
#

yep

versed willow
#

ahhh k

little eagle
#

Apparently addAction is OFP 1.1 and execVM is A1.0

versed willow
#

ahh damn, there is a distanceSqr, but no distance2DSqr

#

not that it matters too much, but would be handy to have anyway

little eagle
#

wouldn't that just be x1 * x2 + y1 * y2

versed willow
#

I think it'd be the differences of it

#

like

#

(x1-x2)^2+(y1-y2)^2

little eagle
#

distance and distanceSqr are weird. I think they use AGL position and actually calculate the terrain heights

versed willow
#

AGL = ATL?

native hemlock
#

The new version of addAction is on 1.62 RC

#
z is the same as in PositionASLW when over sea and is the same as in PositionATL when over land. Most commands either take or return PositionAGL.
little eagle
#

AGL is not ATL

#

AGL z=0 is rock surface or building roofs

#

ATL is just the terrain

versed willow
#

ahhh k, the wiki didnt put much explanation to it

#

not that it matters too much for my purposes

little eagle
#

what I end up doing is to ALWAYS convert to ASL via AGLToASL

#

and only convert back if the command needs it

versed willow
#

Yeah, best to have one consistent system for most stuff

#

I think ATL is mostly relevant for airborne stuff

#

like landing choppers n stuff like that

#

innit?

little eagle
#

idk, I always use ASL.

versed willow
#

Is it a smart idea to attach actions to players for stuff like "send money" or should I do that one as a chat command instead?

#

I guess it would be evaluating alot of conditions etc

tame portal
#

Me and a friend are working pretty much on a plug and use chat command thing

#

Where you simply type in for example /sendmoney name amount to execute it

versed willow
#

I would like to avoid having to use that, but idk if adding around 3 action buttons would affect performance

little eagle
#

that depends entirely on your condition

#

if it's a boolean it won't be noticable

versed willow
#

it's just a radius check p much

#

I'll keep balance checks in the action code itself

little eagle
#

I don't think it really matters

versed willow
#

hmm k

little eagle
#

You'll probably be able to upgrade it to using that distance parameter in 2 days anyway if that syntax really comes with 1.62

versed willow
#

yeah

tough abyss
#

Hello, is someone could send a good script for allowing all units to wear civilian clothes without Arsenal. I mean player finds a civilian clothes on ground or a civilian corpse, he can grab the uniform (as he can with enemies ones!). Thanks

native hemlock
#

In vanilla Arma 3?

#

It could easily be done by configs, but if you are opposed to that it might take a hacky solution using forceAddUniform

little eagle
#

there is no script to do that, only config

#

forceAddUniform cannot move the uniforms content into the players inventory and there are no inventory commands to handle for example attachments on weapons

tough abyss
#

Yes forceAdduniform on a typeOf cursortarget which will return "Item_U_C..." instead of "U_C..." class, + an addAction. It's just a little bit boring. Just because someone decided civilian clothes are not for other sided units.

native hemlock
#

@tough abyss
Alternatively if you are desperate to get the class name from the "Item_U_C..." name you can do the following to get the respective uniform model

_itemName = ""; //for example Item_U_I_C_Soldier_Bandit_4_F
_uniformConfig = ("getText (_x >> 'displayName') == _itemName" configClasses (configFile >> "CfgVehicles")) select 0;
_uniform = (("true" configClasses (_uniformConfig >> "TransportItems")) apply {getText (_x >> "name")}) select 0;
#

A small example using that

myFunc = {
    private _idc = ctrlIDC (_this select 0);
    private _selectedIndex = param [1];
    private _text = lbText [_idc, _selectedIndex];
    
    _uniformConfig = ("getText (_x >> 'displayName') == _text" configClasses (configFile >> "CfgVehicles")) select 0;
    _uniform = (("true" configClasses (_uniformConfig >> "TransportItems")) apply {getText (_x >> "name")}) select 0;
    closeDialog 602;
    [_uniform] spawn {
        params ["_uniform"];
        waitUntil{isNull (findDisplay 602)};
        player forceAddUniform _uniform;
    };
    false;
};

player addEventHandler["InventoryOpened", {
    params ["_unit", "_container"];
    [] spawn {
        waituntil {!(isNull (findDisplay 602))};
        ((findDisplay 602) displayCtrl 632) ctrlSetEventHandler ["LBDblClick", "_this call myFunc"];
    };
}];
#

It's not fully complete, but I'll leave that to you. I only tested it with uniforms on the ground. When you double click the uniform in the inventory dialog it force adds that uniform to your player.

#

You would need to save and add the equipment that was in the uniform before switching uniforms and remove the picked up uniform from the ground

#

And a small note, calling forceAddUniform while the inventory dialog is open seems to crash your game

#

In hindsight that could be better optimized by looking at the selected index by the double click and then getting the corresponding classname for that index in the container that the inventory dialog is opened for.

runic heart
#

Is there a good example of the custom difficulties around?

pliant stream
#

i imagine you could just have your custom difficulty affect stuff like number of AI, their skill, etc?

tough abyss
#

@native hemlock - Thanks a lot for your answer! i 'll try that. I like the idea of an EH when inventory is opened. On my side I scripted al little code, working in all cases but less smart than yours and probably more CPU demanding.

sleep 1;
call {
if (cursorTarget isKindOf "man" && {!alive cursorTarget} && {uniform cursorTarget != ""} && {isnil {cursortarget getVariable ["aUniform",nil]}}) exitWith {
cursorTarget addAction ["Wear civilian clothes", {
_unit = _this select 1;
_g = createVehicle ["weaponHolderSimulated", (_unit modelToWorld [0,-1,1] ), [], 0, "CAN_COLLIDE"];
_g addItemCargoGlobal [uniform _unit,1];
_unit forceAddUniform (uniform cursorTarget);
removeUniform cursorTarget}, 1, 1, true, true, "", "uniform cursorTarget != ''"];
cursorTarget setVariable ["aUniform",true]
};
if (!isnil {itemCargo cursorTarget} && {count itemCargo cursorTarget > 0} && {isnil {cursortarget getVariable ["aUniform",nil]}}) exitWith {
if (["U_C",(itemcargo cursortarget select 0)] call BIS_fnc_inString) then {
cursorTarget addAction ["Wear civilian clothes", {
_unit = _this select 1;
_g = createVehicle ["weaponHolderSimulated", (_unit modelToWorld [0,-1,1] ), [], 0, "CAN_COLLIDE"];
_g addItemCargoGlobal [uniform _unit,1];
_unit forceAddUniform (itemCargo cursorTarget select 0);
deleteVehicle cursorTarget;
}, 1, 1, true, true, "", ""];
cursorTarget setVariable ["aUniform",true]};
};
if ((getText (configfile >> "CfgVehicles" >> typeOf cursorTarget >> "vehicleClass") == "itemsUniforms") && {isnil {cursortarget getVariable ["aUniform",nil]}}) exitWith {
cursorTarget addAction ["Wear civilian clothes", {
_unit = _this select 1;
_unit forceAddUniform ((typeof cursorTarget) select [5]);
deleteVehicle cursorTarget;
}, 1, 1, true, true, "", ""];
cursorTarget setVariable ["aUniform",true]};
};
}
}
native hemlock
#

You can surround code blocks with ``` at the beginning and end to make it look a bit better

tough abyss
#

OK

tough abyss
#

Yes. Thanks. Is there some wrap code to pass the 2000 character limitation?

native hemlock
#

I don't think so, but that length it's probably better to pastebin it or put it on a similar site and link it

tough abyss
#

OK

vital onyx
#

has someone tried creating brdige objects from tanoa?

#

createVehicle returns "Cannot create Non-AI vehicle", createSimpleObjects states shape cannot be opened

native hemlock
#

They probably don't have configs, but I was able to create one with createSimpleObject

#

What path were you using for the bridge?

vital onyx
#

they do

#

I use path from config

#

"\a3\blablabla"

#

that worked for other models previously

#
    class Land_BridgeSea_01_pillar_F: Infrastructure_base_F
    {
        author = "Bohemia Interactive";
        mapSize = 11.05;
        _generalMacro = "Land_BridgeSea_01_pillar_F";
        scope = 1;
        scopeCurator = 0;
        displayName = "BridgeSea_01_pillar";
        model = "\A3\Structures_F_Exp\Infrastructure\Bridges\BridgeSea_01_pillar_F.p3d";
        DLC = "Expansion";
        icon = "iconObject_3x1";
        editorSubcategory = "EdSubcat_Transportation";
        editorCategory = "EdCat_Structures_Tanoa";
    };
ionic bobcat
#

Hey guys, how does one init a script on fire of weapon or throw of grenade?

native hemlock
#

And here is just a hint that displays that information for you

player addEventHandler ["Fired", {
    params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile"];
    hint formatText [
        "%1%2%3%4%5%6%7",
        parseText format ["<t align='left'>unit:</t><t align='right'>%1</t><br />", _unit],
        parseText format ["<t align='left'>weapon:</t><t align='right'>%1</t><br />", _weapon],
        parseText format ["<t align='left'>muzzle:</t><t align='right'>%1</t><br />", _muzzle],
        parseText format ["<t align='left'>mode:</t><t align='right'>%1</t><br />", _mode],
        parseText format ["<t align='left'>ammo:</t><t align='right'>%1</t><br />", _ammo],
        parseText format ["<t align='left'>magazine:</t><t align='right'>%1</t><br />", _magazine],
        parseText format ["<t align='left'>projectile:</t><t align='right'>%1</t><br />", _projectile]
    ];
}];
#

@vital onyx I was able to spawn that bridge with createVehicle with no issues. However, it appears you can't use the path "\A3\Structures_F_Exp\Infrastructure\Bridges\BridgeSea_01_pillar_F.p3d" for createSimpleObject, instead you need to remove the leading \ and then it would be "A3\Structures_F_Exp\Infrastructure\Bridges\BridgeSea_01_pillar_F.p3d"

little eagle
#

createSimpleObject is one of those commands who have to not have the leading slash

native hemlock
#

Do you know of any configs or commands where a leading slash is required?

little eagle
#

model

#

picture

#

commands: execVM, preprocessFile(LineNumbers)

#

^ if you don't use the leading slash with those commands, the files are taken from the mission folder

#

same with ctrlSetText for RscPicture

#

playSound3D on the other hand has to not have the leading slash either

#

my favourite example of this inconsistency is CfgSounds

#
NOTE: Since Arma 3 v1.49.131710 it is possible to define AddOn sounds in mission config. In order to make engine look for the sound in AddOn, the sound path must start with @ (instead of \) for example:
#

sound[] = {"@a3\Ui_F_Curator\Data\Sound\CfgSound\visionMode", 0.8, 1};

tame portal
#

Really Bohemia

#

Really

native hemlock
#

Is the leading slash really needed for models? I've never had an issue with not using it

vital onyx
#

@native hemlock @little eagle thanks for heads up about leading backslash

#

trying it now

coarse ocean
#

Is there a limit of how many elements an array can hold?

zealous solstice
#

yes

#

999999

coarse ocean
#

Nice lol

unique pollen
#

Does anyone know of a simple way to add just radio static to a chat message? In arma 1 if you didnt specify a sound it just used the blank radio static while the text was displayed, any ideas on how to do that in A3?

native hemlock
#

@zealous solstice It's not 999,999, it's 9,999,999

zealous solstice
#

they changed it in a update

vital onyx
#

@native hemlock is there an actual use case for having in array more than 100k elements?

lone glade
#

nine millions nine hundred ninety nine thousand nine hundred ninety nine

vital onyx
#

only unitplay comes to mind

native hemlock
#

Well for the all in one config dump you run into something larger than that

#

No, not in day to day play

vital onyx
#

put entire configFile to array?

native hemlock
#

Yes, but it's not as simple as _allConfigs = configFile;

#

The original script just had each line in the config as another element in the array, and then at the end joined it into one giant string

#

However there was a limit to strings introduced in one of the recent updates so that no longer works

vital onyx
#

hmm, and that mission posted here previsouly which uses dll extension to dump it to file - is not it a better approach?

native hemlock
#

That is the new approach

#

And you might be referring to my post

#

Going to update them once 1.62 is actually out

#

Oh lord I just noticed the forums destroyed the line breaks on the script

vital onyx
#

most likely

#

I have not seen this post

#

grabbed file directly from this thread

zealous solstice
#

@native hemlock the scriΓΌt you posted will never work

#
  1. in a script file it is just 1 line am all commented out
  2. the debug console dont allow Comments πŸ˜ƒ
native hemlock
#

I fixed the formatting.
@zealous solstice

  1. Read my previous message...
  2. Of course not, but that's like me pulling a script from CBA github with comments and saying how it doesn't work
zealous solstice
#

i more connected the points why its not work πŸ˜ƒ

native hemlock
#

And arrays definitely can still be 9,999,999

#
array = [];
arrayHandle_ID = addMissionEventhandler ["EachFrame", {
    while {!(count array isEqualTo 9999999)} do {
        array pushBack 1;
    };
    hintSilent (count array call BIS_fnc_numberText);
    if(count array isEqualTo 9999999) then {
        removeMissionEventHandler ["EachFrame", arrayHandle_ID];
    };
}];
#

Once it has reached 9,999,999 if you do array pushBack 1; you will get an error saying "Max array size would be reached. Current size: 9999999, wanted size: 10000000"

pliant stream
#

that seems stupid i wonder who came up with that limit

lone glade
#

complain to the assholes that loved creating massive arrays to fuck up other people's game

pliant stream
#

what like PV spam massive arrays?

lone glade
#

yep

tough abyss
lone glade
#

type the func in debug console and check if supportInfo has anything on it

native hemlock
#

Scripting help shows exactly what is on the wiki

pliant stream
#

it still seems to me putting such a limit on array size is a poor solution, they might have added server options for limiting PV frequency and size instead

vital onyx
#

strange why one may need so big arrays, use databases instead

pliant stream
#

oh i'm not saying there exists a real need for arrays larger than 10e7-1 in SQF, just that the limit seems completely arbitrary and makes no sense whatsoever

lone glade
#

cough, 4 byte numbers cough cough

#

cough shitty engine cough cough

pliant stream
#

4 byte*

#

32bit integer goes up to 2^31-1

lone glade
#

fix'd

pliant stream
#

and 2^32-1 unsigned

#

2^24-1 might have made sense, it's the largest integer 32 bit float can represent

#

that's something like 16.6m

#

iirc

lone glade
#

what is also hilarious is that somehow you STILL have to convert RGBA values manually

#

because apparently the engine can't divide by 256

#

(more like it's too late to change now)

pliant stream
#

what, having to give RGBA values in [0,1] range?

#

since we're dealing with floats to me that makes far more sense than [0,255]

lone glade
#

it's a pita

pliant stream
#

only reason RGBA is usually represented by values in [0,255] is because that's the range of an 8 bit byte

lean tiger
#

I believe I'm fighting a locality issue here, but I have something of a target range with randomly spawning targets owned by the server, and I can't nullify damage by returning 0 on a handleDamage eventhandler local to the unit

#

Is damage applied by the damage dealer, or does the damage receiver acknowledge it's received damage and apply it to itself?

shrewd lichen
#

Hello fellow scripters

#

Is there a way to place P drive on other disk than C?

pliant stream
#

@lean tiger use handleDamage on the client that owns the object, i.e. on the server

turbid jolt
#

@shrewd lichen yes, you choose P:\ drive location in the tools options menu

#

preferences\Options\Path to your P drive

#

Register it to the settings, then mount it

sacred fox
#

im trying to override a modelOptics with blank. it used to work before APEX but not now, any clues?
modelOptics = "";

#

i have tried the "-" from ther wiki, but that doesnt seem to do the trick either.

native hemlock
#

Probably more of a #arma3_config kind of thing, but could you post the whole config

#

Also check and see in the config browser what the value is

#

My guess is that your config is loading before what it is overwriting

lone glade
#

Any info on the new action menu magic used in the co-op campaign ?

#

(the spiny circle), it's probably the same tech from revive but in engine.

native hemlock
#

Check out a3\functions\holdactions\

#

There is a holdActionAdd and holdActionRemove

lone glade
#

πŸ‘

native hemlock
#

lol 15 possible parameters for holdActionAdd

lone glade
#

oh nice they learned to use params, finally

lone glade
lone glade
#

for those that wonder:
setUnconscious break units inside vehicles, you cannot eject the player from it.

ruby spoke
#

Hi, I just need a real quick confirmation. Using a local variable won't work inside of a 'for loop' if it's defined outside of the loop scope right?

lone glade
#

it will.

ruby spoke
#

Okay thanks

rancid ruin
#

is it possible to detect a key press in 3den? e.g when delete is pressed, call this function

lone glade
#

use the keyDown EH

rancid ruin
#

i'd need to find 3den's display idd right? how would i go about that?

lone glade
#

no need to, pretty sure there's a command to check if you're in 3DEN

#

is3DEN or something like that

indigo snow
#

yea but you might be typing in your mission name for example

lone glade
#

uh oh good luck

rancid ruin
#

but don't EHs need the ctrl or display ID?

lone glade
#

gimme a sec i'll try to find it

rancid ruin
#

you da man

lone glade
#

can't find it :/

#

found the purhcase button and select island tho πŸ˜›

rancid ruin
#

lol

#

i wonder how many arma modding man hours have been wasted on things BI could have documented in about 3 seconds

#

do you literally have to dig through vanilla configs to find display ids? there's no better way?

lone glade
#

you wish there were better ways

#

unfortunately, there isn't

split coral
#

I see a class Display3DEN with the idd 313? Is that it?

#

I have the whole game extracted (or at least the relevant parts) + all readable files dumbed to a couple of big text files + windows search enabled for .sqf .cpp etc.
Makes searching through the vanilla stuff much easier.

rancid ruin
#

oh nice one, let me check

#

that's it, thanks very much!

turbid jolt
#

@sacred fox you should use modelOptics = "\A3\Weapons_F\empty"; if you want blank modelOptics

vital onyx
#

has anyone got a chance to enable BIS revive after recent update?

native hemlock
#

@rancid ruin does the IDD show up from allDisplays?

rancid ruin
#

why yes it does, good to know, thanks

native hemlock
rancid ruin
#

i already did what i was trying to do

#
    _key = _this select 1;
    if (_key == 211) then {
        _pos = getMousePosition;
        _wPos = screenToWorld _pos;
        systemChat format["%1%2", str _this, str _wPos];
        _nearObjs = nearestTerrainObjects [_wPos, [], 15];
        if ((count _nearObjs) > 0) then {
            (_nearObjs select 0) hideObjectGlobal true;
        };
    };
}];
vivid eagle
#

Can anyone best explain the value limits in setVectorDirAndUp? I understand their values in relation to 3d space but what are max/min values? Is it in degrees - 0-360 or is it -1 to 1?

coral pasture
#

Since it is vectors, -1 to 1.

#

You can also use trig to convert from degrees to vector

vivid eagle
#

Thanks, just found Killzone's blog post about it too.

queen cargo
#

Since it is vectors, -1 to 1.
invalid practically ...

they are vectors
their practical range is from (∞, ∞)

coral pasture
#

Well πŸ˜›

tough abyss
#

anyone here know if disableSerialisation is not supported in functions?

lone glade
#

afaik serialization doesn't apply to functions / unscheduled

tough abyss
#
    disableSerialization;
    myHintC = _myDisplay createDisplay "RscDisplayHintCEx";```
this code gives me this error...
`19:11:12 Warning Message: Variable 'myHintC' does not support serialization and should not be stored in the mission namespace.`
lone glade
#

use spawn instead

tough abyss
#

will try, thanks

lone glade
#

or do with missionNamespace <- better

tough abyss
#

well its not executed in a mission but in buldozer so.. merkel would say thats "neuland" πŸ˜„

#

hmm spawn does not work

lone glade
#

you can use uiNamespace instead then

tough abyss
#

same error...

halcyon crypt
#

myHintC is a global var

#

it's probably not allowed to disable serialization on those

#

just a guess though ^^

marsh storm
#

Yo dudes, I'm using F3, trying to get the gearscript to give different colour smokes to different players depending on squad

#

I'm trying to do this by if statements checking the group _unit

#

But I can't get it to work

#

Anyone got any tips?

indigo snow
#

show us your code so far

marsh storm
#

if (group _unit == "GrpNATO_CO") then {_unit addmagazines ["SmokeShellBlue",2]};

#

I can handle the necessary if tree, it's getting the logic statement correct that I'm having problems with