#arma3_scripting

1 messages ยท Page 261 of 1

lethal ingot
#

Okey, I guess I confused everybody ๐Ÿ˜„

little eagle
#

(conditionA AND conditionB) OR ( conditionC AND conditionD )
would be
(conditionA AND {conditionB}) OR {conditionC AND {conditionD}}

#

Ramon, you need to split your big problem into smaller ones

#

divide and conquer

lethal ingot
#

The question is how to address to this player

austere hawk
#

thx

little eagle
#

So you wanna know this basically:

how to get the nearest other player from a group leader?
?

lethal ingot
#

Well, basically yes, thank you

#

My head is boiling, sorry

vague hull
#

@little eagle thx a lot :)

little eagle
#
_fnc_getNearestOther = {
    private _others = (allPlayers select {_x != _this}) apply {[_x distance _this, _x]};
    _others sort true;

    _others param [0, [-1, objNull]] select 1;
};

player call _fnc_getNearest
lethal ingot
#

other player
Except dogs aren't players, they are AI units

little eagle
#

this should report the nearest other player from the local player

#

I thought you're searching for players and not dogs

#

What did I do, Senfo ?

lethal ingot
#

Dogs have to go after nearest player if he is in the minimal distance radius.

little eagle
#

So you want to get the nearest player from a dog that is not the group leader of the dog?

#

are the dogs in the leaders group?

#

Or do you only want to get the nearest enemy?

#

Dogs have to go after nearest player if he is in the minimal distance radius.
that is too big of a problem to solve at once

tough abyss
#

Not really.

#

Wait? @little eagle Is that affected by if the dog is a animal FSM?

lethal ingot
#

I feel awkward now, too much confusion for a short period of time.

  1. There is a pack of dogs. They are in group. Doing their buisness, walking around.
  2. If a player walks into defined radius, they start to run after him.

I need to detect if a player is this radoius (from a group leader) and get his position.

tough abyss
#

or a non-animal FSM?

little eagle
#

No idea

tough abyss
#

like if you createUnit ["Alsatian_F"];

little eagle
#

Ramon, you really have to go through this step by step

tough abyss
#

The AI created is actually a soldier AI and you can command it like a human AI

little eagle
#

otherwise the task is overwhelming

#

Dogs have no AI in Arma

#

They just stand around

tough abyss
#

They do if you put them down using createUnit

#

They also radio-chatter back to you..

little eagle
#

But they don't behave like dogs at all

tough abyss
#

No they don't...

little eagle
#

that's just stuff coming from the group

lethal ingot
#

I am describing the situation, I am writing this AI and it works ๐Ÿ˜ƒ All I need is to detect if a player is in predefined radius (from a group leader) and get his position.

little eagle
#

well to get a position of a unit just use
position _unit

#

And to check if the unit is near enough to the leader, just use
_unit distance _leader < 50

#

50 being the predefined radius

lethal ingot
#

How do I put nearest player into _unit?

little eagle
#

I think we are going in circles

lethal ingot
#

Guess so

#

Like my dogs

little eagle
#

dunno how to link comments in shitty discord

#

but

#
_fnc_getNearestOther = {
    private _others = (allPlayers select {_x != _this}) apply {[_x distance _this, _x]};
    _others sort true;

    _others param [0, [-1, objNull]] select 1;
};

player call _fnc_getNearest
tough abyss
#

Do you have to use allPlayers?

little eagle
#

just replace player with the dog to get the nearest player to the dog

tough abyss
#

Why not that ^

little eagle
#

well if that works

#

as I said, these commands tend to be very dodgy

#

and dogs probably don't have valid "targets"

#

since they have no real AI

tough abyss
#

Yes, you need to be very defensive with your scripting

lethal ingot
#

Let me give you an example that doesn't work:
_wilddogs move (getPos ((leader _wilddogs) nearEntities ["man", 300]));

"man" doesn't seem to work

tough abyss
#

Making your own FSM might be the better way to go

#

Maybe.

little eagle
#

of course it does not work

#

group move position

#

but

#

(getPos ((leader _wilddogs) nearEntities ["man", 300]))

lethal ingot
#

Maybe nearTargets will work, really?

little eagle
#

reports an array

#

not a position

tough abyss
#

So you need to select the first index occurrence of "man" type

lethal ingot
#

_wilddogs move (getPos (((leader _wilddogs) nearEntities ["man", 300]) select 0) );

Sorry, that was old code. This doen't work

little eagle
#

line is too long

tough abyss
#

@lethal ingot For the sake of your sanity

#

Don't concatenate all code on 1 line

#

It makes it harder to debug.

little eagle
#
_fnc_getNearestOther = {
    private _others = (allPlayers select {_x != _this}) apply {[_x distance _this, _x]};
    _others sort true;

    _others param [0, [-1, objNull]] select 1;
};

private _nearest = (leader _wilddogs) call _fnc_getNearestOther;

_wilddogs move position _nearest;
#

you'll probably will have to ammend that to filter friendlies etc

lethal ingot
#

Okey, thanks for you help. I will vanish and leave you in calm now ๐Ÿ˜ƒ

tender fossil
#

Can you disable simulation (in A2) on server selectively for different clients?

#

In other words, to limit sync of unique combination of units for each client

little eagle
#

I don't see why not

#

you can't do it "on server", as the command has local effects and has to be executed on the client machines

tender fossil
#

The point is to decrease the server workload, so I'm afraid it doesn't help to run it on clients only @little eagle

#

Unless the A2 netcode is smart enough to inform server to stop sending useless updates as long as the simulation is disabled

little eagle
#

enableSimulation has to be executed on every machine

#

local effects. "server only" won't work here

tough abyss
#

@little eagle So whats the effect if enableSimulation is run on the client

#

but AI reside on the server?

#

Whats that do?

tender fossil
#

@tough abyss Yes, I'm interested in corner cases just like that

tough abyss
#

I was too exploring such a concept

#

as the server sends update for every thing on the MAP

#

and I mean EVERYTHING

#

Why do I need to simulate AI thats 4 - 8 KM away?

little eagle
#

well duh. otherwise the game wouldn't be synched

tender fossil
#

@tough abyss You got the point ๐Ÿ˜‰

tough abyss
#

or even enough distance it doesn't matter?

#

Reminds me of what Dual Universe is doing.

#

As you get further and further away for other players

#

the simulation tick rate decreases with distance

tender fossil
#

@little eagle That's what we're trying to achieve here... Disable/limit sync of units out of area of interest

tough abyss
#

TO clients

little eagle
#

every machine can send updates for any object to any other machine

tough abyss
#

Ezcoo there is a way to scan through all units on the server side

little eagle
#

client to server

tough abyss
#

and disable their simulation loop.

little eagle
#

server to client

tender fossil
#

@tough abyss That's what I'm about to do

little eagle
#

doesn't matter which machine owns the object

tough abyss
#

But just get ZBE_cache

little eagle
#

Arma 2

tough abyss
#

Ugh...

#

Right.

#
{_x enableSimulation false; } forEach allUnits;
#

ArmA 3 adds enableSimulationGlobal

tender fossil
#

Yup

#

But the A2 netcode... Does everything go through server or is there also P2P/from client to client sync?

tough abyss
#

Client server architecture I think

#

A2 uses the MP framework...

#

I think...

little eagle
#

there is no P2P afaik

tough abyss
#

It can be done though

#

A client to a client message

#

At least in arma 3

#

remoteExec from my client to remote client

tender fossil
#

@tough abyss But it's an exception, not done by default? (And the remoteExec could be broadcasted via server anyways, but dunno how netcode works in that case in reality)

#

@little eagle Thanks for info

tough abyss
#

I as I was saying looking for a way to shutdown simulation

#

of AI local to client

#

If they are a certain distance I mean why do even send updates where there is no one nearby?

#

Sounds like a waste?

#

@lavish ocean Do you have any input on this? As you said part of the AI brain could be offloaded using headless clients, is there a way we could disable the other part of the brain if not near them?

#

I mean it says what has to happen on the server everything needs to be simulated even when not nearby

#

Why bother?

#

Sounds like a waste of resources to me...

tender fossil
#

@tough abyss It's the famous network bubble that's been a hot potato for years, since DayZ at least

#

I remember talking with Dwarden about it some time ago

little eagle
#

pretty sure remoteExec goes through the server when the target is clientB and it's called from clientA

tender fossil
#

So there's no P2P

little eagle
#

the clients don't know the owner ids of objects

tender fossil
#

Just the effect is P2P then

#

Thanks for info @little eagle

little eagle
#

well there could still be some P2P in internal stuff that has nothing to do with SQF and remoteExec

#

but that would mean that you somehow can lose connection between clientA and clientB and both still are connected through the server

#

that would be a common scenario in P2P situations

#

But I've never seen that. It's always one client that looses connection to the server and then rubber bands on every other machine

tender fossil
#

Mhm

little eagle
#

So I take that as evidence that there is no P2P

weak tiger
#

load (vehicle player) always returns 0... is there an equivalent for vehicles?

little eagle
#

no

weak tiger
#

how about a BIS_fnc or CBA

little eagle
#

Not that I know of. Cargo boxes use the x slots for weapons/items/magazines/backpacks system.

weak tiger
#

no they have a supply as well afaik

#

guess im doing it the old fashioned way

little eagle
#

I think the total mass thing is broken though

#

bar just goes over the maximum

#

doing nothing

weak tiger
#

thats if you load via script yes

#

but trying to drag wont work

#

so whats determining that condition

#

i assumed it was linked to its supplyrating (ie supply40 = 40kg)

#

like a backpack

little eagle
#

mass 40 does not mean kg

#

there is no kgs in the game

weak tiger
#

sorry 40 mass yes

little eagle
#

it's an arbitrary size number

weak tiger
#

40.. units

little eagle
#

yea

weak tiger
#

but yeh i assumed it was the same as it seems the same in game

little eagle
#

it probably is

weak tiger
#

but just no helper functions

#

all good thanks

little eagle
#

you can't get this correctly

#

e.g. attachments of weapons or items inside backpacks that are inside the cargo

weak tiger
#

my scripts empty backpacks where possible

#

reducing that problem

#

but yeh its a problem

little eagle
weak tiger
#

perfect

#

that should be all i need

#

cheers

little eagle
#

According to jonpas, it should work with ammo boxes

#

which is inconsistent...

weak tiger
#

it seems to be working on this jeep

little eagle
#

good

weak tiger
#

yep perfect

#

ammoboxes im less concerned with, am letting those overfill

little eagle
#

ammo boxes == jeep == vehicle cargo

#

all the same

weak tiger
#

cool

#

thx for your help

little eagle
#

yw

dim owl
#

how can i check if listbox is empty ? (lbSize _mylistboxctrl) isEqualTo -1 ?

broken forge
#

Trying to test this and it doesn't seem to be working:

_locationType = ["NameCity", "NameCityCapital", "NameMarine", "NameVillage"];
if (position player == _locationType) then {
    hint "Hello World";
};
dim owl
#

what is locationtype ? is it a marker ?

broken forge
#

Basically I'm trying to get a loop of the player's location on a map, and if the _locationType is met then it'll display the BIS_fnc_infoText function instead of every 5min regardless or not the _locationType is met.

dusk sage
#

If the location type is met?

broken forge
#

Here's what I have so far:

while {true} do {
    waitUntil {time > 5};
    _locationType = ["NameCity", "NameCityCapital", "NameMarine", "NameVillage"];
    _nearestCity = nearestLocation [getPos player, toString(_locationType)];

    _hour = floor dayTime;
    _minute = floor ((dayTime - _hour) * 60);
    _second = floor (((((dayTime) - (_hour)) * 60) - _minute) * 60);

    if (_minute < 10) then {_minute = format ["0%1", _minute]};
    if (_second < 10) then {_second = format ["0%1", _second]};

    _time = text format ["%1:%2:%3", _hour, _minute, _second];

    _month = date select 1;
    _monthToYear = ["JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY", "AUG", "SEP", "OCT", "NOV", "DEC"];
    _day = date select 2;

    if (_day < 10) then {_day = format ["0%1", _day]};

    _date = text format ["%1 %2 %3", _day, _monthToYear select (_month - 1), date select 0];

    [text(_nearestCity), str(_time), str(_date)] call BIS_fnc_infoText;
    sleep 300;
};
dusk sage
#

Oh my lord

broken forge
#

As you can see it'll always call BIS_fnc_infoText every 5min, and I want it to only call BIS_fnc_infoText when the player's nearestLocation matches the _locationType array. (And yes that script does work.)

#

this my work or at least be a little easier to convert:

if (nearestLocation [getPos player, toString(_locationType)];) then {
    [text(_nearestCity), str(_time), str(_date)] call BIS_fnc_infoText;
};
dusk sage
#

What do you mean match the locationType array?

#

And I don't see how that's working either. You're calling toString on an array of location classes

broken forge
#

would that edit work?

broken forge
#

thanks to HorribleGoat the script now works the way I want it to, here's the final resault:

while {true} do {
    waitUntil {time > 5};
    _locationType = ["NameCity", "NameCityCapital", "NameMarine", "NameVillage", "Airport"];
    _nearestCities = nearestLocations [getPos player, _locationType, 1200];
    _nearestCity = [_nearestCities, player] call BIS_fnc_nearestPosition;

    _hour = floor dayTime;
    _minute = floor ((dayTime - _hour) * 60);
    _second = floor (((((dayTime) - (_hour)) * 60) - _minute) * 60);

    if (_minute < 10) then {_minute = format ["0%1", _minute]};
    if (_second < 10) then {_second = format ["0%1", _second]};

    _time = text format ["%1:%2:%3", _hour, _minute, _second];

    _month = date select 1;
    _monthToYear = ["JAN", "FEB", "MAR", "APR", "MAY", "JUNE", "JULY", "AUG", "SEP", "OCT", "NOV", "DEC"];
    _day = date select 2;

    if (_day < 10) then {_day = format ["0%1", _day]};

    _date = text format ["%1 %2 %3", _day, _monthToYear select (_month - 1), date select 0];

//    hint format ["%1",_nearestCity];

    if (position player distance _nearestCity < 600) then {
        [text(_nearestCity), str(_time), str(_date)] call BIS_fnc_infoText;
    } else {
//        hint "DEBUG: NO LOCATION NEARBY";
    };
    sleep 300;
};
#

The script now runs every 5min and will only call BIS_fnc_infoText if the player is 600m or less from a specified location type within the _locationType array.

little eagle
#

But why didn't you use the BI function to format the date?

little eagle
#

hmm. I can't find it. I swear there was one for exactly this purpose

random glen
#

Is the captive from Apex official mission is a special script or simply an animation with generic objective script?

meager granite
#

nearestLocations already sorts locations closest to farthest

jovial nebula
#

Hi all,anyone knows how to script correctly a 'hook' waypoint type?

#
_wp setWayPointType "HOOK";
_wp waypointAttachVehicle cargo;
_wp setWaypointSpeed "FULL";       
_wp setWaypointBehaviour "SAFE";   

I'm using this code,where _wp is the waypoint obtained through 'AddWaypoint' command, and cargo is the vehicle that the helicopter should hook.
As now, the helicopter is going near the vehicle,and then is flying at mid-air without doing nothing.

jovial nebula
#

Err,anyone there?D:

little eagle
#

yes, here. But I have no idea. Never done that. Never even heard about it

little oxide
#

@broken forge Use this function to convert time [dayTime] call BIS_fnc_timeToString; Thanks to @little eagle mentioned it

broken forge
#

I would use _time = [dayTime] call BIS_fnc_timeToString; but it returns with quotes wrapped around the time.

tender fossil
#

Hey, it's me again about the enableSimulation in A2

#

If i have (on dedicated server) clients with IDs 3-10, each having some units, can I disable their simulation on clients 11-20 locally?

#

In other words, does the disabling of unit simulation happen in the end of receiving client or on client that owns the units and computes their simulation on dedicated server?

little eagle
#
x3 = [1,2,3,4,5] select { 
    if (_x == 3) exitWith { 
        false; 
    }; 
    true 
};
// x3 = false
#

bug, feature, bad design?

noble juniper
#

holy shit, i never noticed that select has so many alternative syntaxes

#

@little eagle thx for asking that question

#

@little eagle as far is can read, you are using alternative syntax #5

#

that returns an array.

#

you should scrap the if, the == allready makes a boolean stement out of it. Maybe the exitWith fucks it up ?

#

Yes, the exitWith actually makes x3= false;

little eagle
#

it was meant to report:
//x3 = [1,2,4,5]

#

obviously there are better ways, but I removed the out of context code

#

I'll add a comment on the wiki that escaping the code block scope is not safe

noble juniper
#

Awesome!

little eagle
tough abyss
#

while {true} do {} in some instances is bad programming practice

#

overall.

#

Particularly if you can come up with a better way of doing it.

#

As quick said you could run an infinite loop using for

#

It's less "intensive"

#

Which is stuffed up logic in itself.

#

I think that works?

dusk sage
#

1 to 1?

#

Just step 0

tough abyss
#

Oh that works?

dusk sage
#

yep

tough abyss
#

I thought step 0 it might complain

dusk sage
#

from x to y step 0

tough abyss
#

k

#

for "_i" from 0 to 1 step 0 do {//Less CPU intensive code WTF // };

#

I still think that is weird

#

compared to while {true} do { with sleep inside it }; ?

#

@dusk sage Is this now frowned upon _value = if (condition) then {return value} else {other return value};

dusk sage
#

Ofcourse not

#

You could make that look a lot nicer with select though

tough abyss
#

Ah yeah you could

#

_value = [return1,return2] select _condition;

#

Now it's right.

dusk sage
#

Other way

#

If the condition was true, you'd get return2 there

little eagle
#

What does this select quirk have to do with while {true} do { ?

tough abyss
#

It was _value = if (condition) then {return1} else {return2}; asking if it was frowned upon

#

then @dusk sage suggested using select instead @little eagle

#

As it's "prettier" and probably faster as well

little eagle
#

Yeah. select. It also works with Booleans:
[0,1] select true // 1

tough abyss
#

if handleDisconnect return false and disableAI = 1 then the player must dissapears. It's obvious to me (but my iq is too low i know).

little eagle
#

Is that a question?

dusk sage
#

Don't put yourself down so hard, my god D:

halcyon crypt
#

hmmm that select is quite a nice alternative to the if else thing ^^

little eagle
#

it has one downside

#

if you actually do SQF inside the then and else block, you can't easily convert it to the select syntax

#

because both elements of the array are evaluated

halcyon crypt
#

true

#

and the swapped true/false might cause intuition problems

little eagle
#

I still use it when possible

#

the
_var = if
thing looks just strange

tough abyss
#

Very much so

little eagle
#

The only reason you would use it is to have the local variable defined inside the main scope

tough abyss
#

This one is worse

little eagle
#

I'd rather give the variable a meaningful default value:

tough abyss
#

_var = switch(condition) do {case 1: {//block//} case 2: {//otherBlock//} case 3: {//LastBlock//} } ;
Gross

little eagle
#
private _var = objNull;
if (cond) then {
    _var = player;
} else {
    _var = cursorTarget;
};
halcyon crypt
#

same, I try to avoid the semi-ternary operator thing with SQF..

tough abyss
#

@little eagle there is a mission event handler, the handleDisconnect that runs when player disconnect. If it return true, the player get owned by the server and stay as an AI. If it return false, default behavior, defined by disableAI = false/true; should occur, but what happens is tha player dies and his body lay on the ground.

little eagle
#

There is a huge trap when using switch like this, @tough abyss

tough abyss
#

#Atlis Life

#

xD

little eagle
#

switch actually returns true when no condition is met and no default block was defined

tough abyss
#

O_o

#

@little eagle I didn't realise you were an ACE3 dev. By the way as an offtopic thing.

little eagle
#
_var = switch (1) do {
    case 2: {};
};
// _var = true
halcyon crypt
#

wweeeiirrrddd

tough abyss
#

I would think it would just complain nothing

#

"Value in switch undefined, default"

little eagle
#

but what happens is tha player dies and his body lay on the ground.
then handleDisconnect doesn't fire. the player just respawns

tough abyss
#

handleDisconnect fires ONLY on the server last time I checked?

little eagle
#

switch returns true in this case. No one knows why

#

handleDisconnect fires ONLY on the server last time I checked?
correct

tough abyss
#

So if trying to add it to players

#

That won't work.

#

but I remember reading some legacy BS about requiring onDisconnect {}; requiring to be called before

little eagle
#

I didn't realise you were an ACE3 dev. By the way as an offtopic thing.
I also dev CBA and BWA3 : >

#

That was fixed @tough abyss

#

In 1.62 iirc

tough abyss
#

Are you also a "genuine" programmer? As in it's your professional job?

little eagle
#

No

#

I hate computers actually, lol

#

I'm a pen and paper guy

tough abyss
#

Eh only way to learn to design programs pen + paper

#

Everything you can code you can step manually.

#

If you understand the underlying language.

#

if you use handleDisconnect, all the players disconnecting are doomed to 2 destines: if alive 1 - turn into a AI, 2 - get killed and fall on ground / if dead 1 - stay dead.

little eagle
#

I just always liked logic and math (as long as it doesn't get too complicated)

tough abyss
#

With disableAI 0 or 1

#

Weirdly enough I enjoy Discrete math.

little eagle
#

What are you trying to do, Don?

tough abyss
#

More I've learned about computers more i've liked math.

#

All the really cool stuff requires Discrete math.

#

I'm just saying something is not working as it should be lol

#

No problem on my side since i delete the body

#

Get player state?

#

to be fixed on those next weeks of Arma 3

little eagle
#

Iirc the handleDisconnect return value thing was always wonky

#

no idea why you'd even use that

tough abyss
#

@little eagle to save players on data base if they use Alt + F4 or any other problematic disconection

little eagle
#

yes, I get that the eh is usfull

#

but the returning true or false thing is silly

tough abyss
#

ah yes

#

i don't need to the player turn into a AI and walk free on the map, so i return false. And what happens it that the unit (ex player) dies and stay dead on the ground

#

and i have disableAI set to true

#

so false must dissapears the unit

little eagle
#

I can't even remember what it was supposed to do in the first place

tough abyss
#

but... nothing that _player spawn {deleteVehicle _this;} can't solve;

little eagle
#

You can also just return nil and it will do nothing

tough abyss
#

ahhh!

#

Nice

#

I will try

little eagle
#

Oh, I think I get your confusion now

tough abyss
#

You could try that.

#

Not sure how you'd get it to execute on a single client though.

#

I can't delete the unit inside the handleDisconnect because it crash the server

#

Maybe remoteExec inside the HandleDisconnect

#

Add him to the GC

#

addToRemainsCollector[entity];

little eagle
#

well. if handleDisconnect was executed, then the client is gone. no way to remoteExec anything

tough abyss
#

i just believe false should behave acordingly to the setting disableAI in description.ext

#

but if nil makes it do nothing, its a solve ๐Ÿ˜„

#

I also write a lot on paper

#

help on think

#

even on real work, need to do that sometimes

#

sometimes need paper and pen... can't find.. sad

#

so i write in any free paper i find

noble juniper
#

@tough abyss did you get handleDisconnect working ?

#

i got an error from BIS_fnc_addStackedEventhandler that the event is not supported

#

and the documentation is forwarding to onPlayerDisconnected.

little eagle
#

handleDisconnect only works with addMissionEventHandler

tough abyss
#

^

little eagle
#

it's not to be confused with onPlayer(Dis)Connected

tough abyss
#

Any particularly reason you are using HandleDisconnect

#

?

#

vs PlayerDisconnected

#

?

little eagle
#

it reports the old body

#

onPlayerDisconnected does not

tough abyss
#

Ah.

#

Override: If this EH code returns true, the unit, previously occupied by player, gets transferred to the server, becomes AI and continues to live, even with description.ext param disabledAI = 1;

#

Theres your reason @tough abyss

#

So make it so

little eagle
#

Apparenlty returning false does make it behave like disabledAI was 0

tough abyss
#

Well you could just kill the AI

little eagle
#

But he wanted to be whatever was in the description.ext

tough abyss
#

then delete his body.

noble juniper
#

You can achieve DayZ SA like combatlog behavior

little eagle
#

He doesn't want to override anything. He's making a mod I think and not a mission

tough abyss
#

A question about performance of server-side communication missions vs the clienside + server-side systems used

#

Is there any performance benefit in making a mission SS only?

noble juniper
#

SS = ServerSide ?

tough abyss
#

Yes

#

So all your speciality code exists inside a @modfolder

#

vs just using the mission file

noble juniper
#

well

#

i think your mixing stuff here.

tough abyss
#

@tough abyss s version of I&A had mostly server-side components

#

Used a single mission.sqm and description.ext binding to server-side functions

noble juniper
#

well, if boil arma scripting down to the basics

#

the only thing of interest is how you get your code and how you get it executed.

tough abyss
#

So a SS system is really no better than the CS+SS hybrid used for most missions?

#

@noble juniper

#

CS -> Client Side

#

SS -> Server-Side

noble juniper
#

the only difference is how you get your code, "streaming" it from the server obvoiusly adds latency and network traffic

#

but i sadly don't have benchmarks / measurements on how much traffic and latency.

tough abyss
#

Quiksilvers system generated more Desync

#

and offered no real performance benefit

noble juniper
#

in my AL experience, you could offload pretty hughe scripts onto the server on 100 people servers, without problems

#

Well AL = problems but never mind

tough abyss
#

I did experimentation and got HC's to offload

#

Most code.

#

Not just AI

noble juniper
#

that is and upcoming task for me thoug

little eagle
#

Pretty sure it's not meant to save performance, but to simply have the clients not have to download and install a mod

noble juniper
#

well normaly, the Modquestion is a different one

tough abyss
#

The mod for QS's I&A wasn't client side

#

It was exclusively server-side

#

as you said it "streamed" the functions from the server.

noble juniper
#

i actually don't get what you wanted to achieve with that

tough abyss
#

HC in my perception was effectively a second script executer

#

which it was.

#

It was seeing I could specifically restrict code to specific HC's

#

Which it did work.

noble juniper
#

yes

tough abyss
#

And with the HC's are they have unlimited bandwidth and no latency

noble juniper
#

yep, whats so exciting ?

#

remoteExec is awesome

little eagle
#

You could also write code that doesn't slow down the clients... No unnecessary polling loops etc. Having it all on a server seems like a unnecessary limitation

tough abyss
#

It gave me access to a second single-threaded script executor

noble juniper
#

i know, i helped Secrets of Altis implement that like a year ago ๐Ÿ˜„

#

sorry im just an evil and old AL dev

#

But, nice that you made that experience and nice that it worked, congratulation

tough abyss
#

I mean the community I manage has a single Xeon. 12 thread CPU server

#

So utilising HC's

#

Is very useful.

noble juniper
#

that is an interesting choice

tough abyss
#

The HC's are also CPU pinned

#

to 2 cores

noble juniper
#

and you are right, you basically need to use HC to utilize all of it

tough abyss
#

One issue I can't seem to workout

#

AI + Lots of gunfire = low FPS

#

I am not sure why.

little eagle
#

cause of the bullets flying

noble juniper
#

have you automated the install, update, restart of all of those HCs?

tough abyss
#

Yes

#

Batch script

#

Being replaced by powershell

#

I use several symbolic links

noble juniper
#

are you working with GIT or SVN ?

tough abyss
#

Linked to the HC's folder inside 1 folder

noble juniper
#

or even Maven ?

tough abyss
#

just copy and paste. No.

noble juniper
#

interesting choice

#

how many devs are with you?

tough abyss
#

I used symbolic links to move, my entire arma 3 install to SSD without.

#

Just me...

#

I manage the entire server / scripting

#

I changed RDP ports

#

Locked down security

#

Setup firewall

#

IIS 8.5 ArmaA3Sync server

noble juniper
#

in my opinion, you should start using Version Controle like GIT. From a software engeneering standpoint, it only has benefits.

tough abyss
#

I have a SourceTree account

#

Haven't used it in a long time though.

noble juniper
#

i don't like source tree its to complicated for me to be honest

tough abyss
#

I do like the snapshot feature of it.

noble juniper
#

i use gitkraken

tough abyss
#

I use crossed fingers and hope

noble juniper
#

if it hasn't become so fucken buggy

#

xD

dusk sage
#

i don't like source tree its to complicated for me

#

i use gitkraken

tough abyss
#

googles gitkraken

dusk sage
#

o.o

tough abyss
#

lmfao

noble juniper
#

@tough abyss "crossed fingers and hope"

#

good one

dusk sage
#

GitKraken is a GUI mess

#

SourceTree is simplistic

tough abyss
#

I just have a lot of confidence in myself ๐Ÿ˜›

#

SourceTree had problems

#

When I tried to make multiple branches

#

actually speaking of confidence, I tried to make an arma mission and I have no fcking clue what I'm doing

noble juniper
#

i guess everything is personel preference

tough abyss
#

ยฏ_(ใƒ„)_/ยฏ

#

Probably because there was little to no tutorials about it

dusk sage
#

Tutorials to click the branch button? ๐Ÿค”

tough abyss
#

No...

#

To not cause things to depend on others.

#

E.g branching can screw up an entire snapshot

dusk sage
#

What you on about D:

noble juniper
#

tut on how to add a remote, clone , fetch

#

basically how to set it up and get it running reliably, but never mind

tough abyss
#

Heh gitkraken actually has a better interface than SourceTree

#

Hows it's documentation?

noble juniper
#

and is multiplatform

tough abyss
#

Support bitbucket?

noble juniper
#

there are tips and tricks on theire twitter

#

yes

#

bitbucket and your own hosts like gitlab and such

dusk sage
#

That's a simplistic UI

tough abyss
#

So uh, could someone help me out in the #arma3_scenario channel? I'd love to, ya know, make missions, but I have no fcking clue what I'm doing wrong.

#

Heh they updated it.

noble juniper
#

@BoGuu#1044 that actually looks better then what i remember from sourcetree

tough abyss
#

Same.

#

Hows the documentation now?

noble juniper
#

but im on linux so no sourctree for me

dusk sage
#

Don't really need any docs to use it

tough abyss
#

Eh I can use Gitkraken for my VMs

#

And SourceTree for windows 10

dusk sage
#

It's just git bash with nice buttons

tough abyss
#

Git bash command line scared me.

noble juniper
#

as allways, you need to dig into it a bit but then its easy

tough abyss
#

Almost as much as GDB when you call -gdb -h

#

:S

dusk sage
#

Or like most CL applications ๐Ÿ˜‰

tough abyss
#

I was using gdb to learn ASM

#

then wanted to know something to, do with decompiling

#

Was me with a wall and wall and wall of text.

#

And a omg...

dusk sage
#

Do you know C?

tough abyss
#

Learning it.

#

Was from a hackers book but.

#

I wasn't enough of an intro.

#

I had to buy a C programming book to fully understand it.

dusk sage
#

Thought you were being told to learn ASM first ๐Ÿ˜‰

tough abyss
#

both

#

ASM is what hacking the art of exploitation asks you to learn

#

you use i/x -b etc

#

memory inspection.

noble juniper
#

wait you are a hacker ? keep away from my server ! ๐Ÿ˜„

tough abyss
#

"Hacker"

#

Not

noble juniper
#

JK by the way, thx for the info that HandleDC is a missionEventhandler

noble juniper
#

another By the way, is anyone of you useing kyler renslows Intell J idea SQF Plugin ?

tough abyss
#

Never used it.

#

I use NPP++

noble juniper
#

well do you want to miss syntax checking ?

#

i don't remember that there was a sqf lexer for NP++

tough abyss
#

Yeah there is.

#

I updated mine manually though.

#

To include all the new commands

#

It's upto Version 2.0 now.

noble juniper
#

do you mean "highliting" ? or also Syntax check for all the commands and such ?

tough abyss
#

It auto-completes

noble juniper
#

like, expected array got bool ?

tough abyss
#

I know that.

#

No.

#

Doesn't do that.

#

Is there a way to do that.

noble juniper
#

with that intelli J plugin of cause

tough abyss
#

Is there a problem with it?

noble juniper
#

haven't noticed a gamebreaker jet

#

so i can recommend it

tough abyss
#

I'm actually learning 4 different languages, the 4th is kind of forced because of playing FTB

#

Lua.

#

Python.

#

C

#

and ASM

tough abyss
#

Wow.

noble juniper
tough abyss
#

Neat.

noble juniper
#

the free community eddition

tough abyss
#

That would cut my coding time down a lot

#

I've often added accidentally syntax errors

noble juniper
#

it atleast cathces a lot of syntax shit

tough abyss
#

And gone why doesn't this work?

noble juniper
#

catches *

#

what ?

tough abyss
#

Some commands.

noble juniper
#

still no idea what you mean

#

the only little thing is that it wants camel case

tough abyss
#

Does it pick up the embedded () problems?

noble juniper
#

embedded ()? do you mean macros ?

#

and yes there is macro support

tough abyss
#

e.g a getPos ((something select 0) select 1)

#

and adding too many ()

noble juniper
#

yes

tough abyss
#

Nice.

noble juniper
#

missing ;

#

it will in general look up what that command wants, and if you did syntactical shit like, a string instead of an array it should actually report that

#

in theory, damnit i cant make it do that now, damn. But ctr Q is wiki lookup , so in case you can look up the command in the IDE

tiny wadi
#

Any idea why a trigger deactivation runs globally?

tough abyss
#

Because you have to specify if it runs globally

#

when you _trig = createTrigger ["EmptyDetector",getPos (ofThing),true];

tiny wadi
#

I placed it down in the editor, anyway to disable that?

tough abyss
#

Double click it

#

Tick the "Execute on server only"

#

Or "Server only"

tiny wadi
#

Ok, will it still hint to the player that triggers it?

tough abyss
#

No.

#

It will be evaluated on the server

#

to hint the player

#

you'd have to do this.

#

in the onActivation field

#

"Message" remoteExec ["hint",owner(this)];

#

This way the trigger will be evaluated on the server

#

but state passed to the client.

tiny wadi
#

I feel like im doing it incorrect, what I ahve is a trigger that brings up a dialog and does some stuff to a car. Should the server be involved?

tough abyss
#

Give us the code to look at?

tiny wadi
#

Sure

#

activation:_exc = [vehicle (thisList select 0), "addonshop_2"] execVM "addonshop.sqf";

#

deactivation: hint "Thanks for visiting Adam's Auto Parts";

#

Grabbing script

tough abyss
#

Okay so what happens when a trigger is executed on the server only

#

Is it will be evaluated on the server only

tiny wadi
#

addonshop.sqf

tough abyss
#

So any client-side operations won't show up

tiny wadi
#

Its best to open the script in notepad++ to read the comments correctly

tough abyss
#

So what doesn't it do?

tiny wadi
#

Run only on the client

little eagle
#

if (isNil "AddonShop_Car getVariable ""Addons""") then {

#

^ this is borked. doesn't work like that

tiny wadi
#

That was actually the only way I could get it to work

tough abyss
#

No.

little eagle
#

this will always be true, so you'll always reset that "Addons" variable to []

tough abyss
#

^

little eagle
#

I think you meant:
if (isNil {AddonShop_Car getVariable "Addons"}) then {

spring kindle
tiny wadi
#

That makes sense, I noticed everytime I ran that it reset my addons for some reason

little eagle
#

use my edited version

tiny wadi
#

@spring kindle Make sure that you specify the path to the addon folder if it is in an addon

tough abyss
#

isNil now support code block conditional eval?

spring kindle
tiny wadi
#

_Flush = execVM ""\RLM\Toilet\Flush.sqf""

tough abyss
#

Fun fact

#

With arma SQF

#

You must provide the full path to a script file

little eagle
#

isNil now support code block conditional eval?
it has always supported that

tough abyss
#

Otherwise it has no idea where to find it.

#

So provide it the full path to the .sqf file

#

@little eagle Didn't know that.

#

I'd always seen it used in this context isNil "varable";

spring kindle
tame portal
#

What on earth would the flush.sqf do

tiny wadi
#

Make sure addonbuilder is accepting .sqf in allowed file extensions

little eagle
#

isNil string checks if a variable is defined (either local variable or a global namespace of the current namespace)

dusk sage
#

Use defaults!

little eagle
#

isNil code checks if the expression has a return value that is not GameValueNil

tame portal
#
missionNamespace getVariable ["varname", defaultValue]
tough abyss
#

@dusk sage I agree

tiny wadi
tough abyss
#

[] params

#

with defaults

dusk sage
#

ninja'd

tiny wadi
#

How do params work?

spring kindle
#

wooow yeah addon builder wasent excepting sqf

tiny wadi
#

I never understood them

tough abyss
#

You can do clever things like this

#

Your code with the [_var,_var] spawn {code}

#

you can do this

tame portal
#

params is just a stack of the param command

tough abyss
#

to define them without using _this select #;

little eagle
#

no

#

params is just a stack of the param command
wrong

tame portal
#

How come its wrong?

little eagle
#

param is a glorified select and params assigns variables and sets them to private

#

they do different things

tame portal
#

Well

tiny wadi
#

Oh so I could do [1,2] spawn {params ["_a", "_b"]; hint format ["%1, %2", _a, _b];

tough abyss
#

e.g [_ExternalVar1,ExternalVar2] spawn { [_firstVar,secondVar] params ["_myNewVar",_myOtherNewVar"]; };

#

Yes

little eagle
#

one is return value based, the other directly assigns the variables

tough abyss
#

Can also do it with script commands

tame portal
#

param has the same functionality except it doesnt declare the variables by itself and it only works for one of the parameters given

tough abyss
#

AddEventHandlers make this really easy.

tame portal
#

Thats why I said its kinda stacked ^^

tough abyss
#

Take all the variables of the addEventHandler feed it into [] params

little eagle
#

so params is not just a stack of param's. thank you

tough abyss
#

which would be each _this select #

tame portal
#

Everyone sounds so hostile here..

little eagle
#

really?

#

param and params sound very similar, but in reality they are not

tiny wadi
#

rip

tame portal
#

I was just trying to give a reason why I call it "stacked param" because thats the way its stuck in my head, I know it doesnt work the same why but they are both share the core functionality of processing parameters

#

Wasnt trying to prove you wrong

little eagle
#

it's a bad way to remember them, because it is wrong and leads to false assumptions

tough abyss
#

addMissionEventHandler ["PlayerDisconnected" { params [_id,_uid,_name,_jip,_owner] }];

#

Now you could use _id etc variables

little eagle
#

you have to stringify the variable names

tame portal
#

Well I know the difference but yes, for someone who doesnt know the difference its misleading

little eagle
#

params ["_id", "_uid", "_name", "_jip", "_owner"]

tough abyss
#

derp. I've been away from ArmA 3 Code ๐Ÿคฆ I apologise if my syntax is wrong.

tame portal
#

All gucci

little eagle
#

param is a super usefull command

#

mainly because it get's around the flaws of select with out of bounds

#

and handles default values really nicely

#

they even fixed the index being -1 in 1.64

tough abyss
#

I wonder if ``` _fnc_getDataLong = {
_longDate = date params ["year"," month", "day"," hour", "_minute"];
_longDate;
};

little eagle
#

BIS_fnc_timeToString

#

params returns a boolean

tough abyss
#

Ahhhh thats why that wouldn't work.

tiny wadi
#

so if I want to set a default value on paramsI would do: params [["_myVar", 1], ["_myString", "asd"]];

tough abyss
#

So I'd have to do this.

little eagle
#

yes

tiny wadi
#

and if the variable is set when I call the script it wont use the default

tame portal
#

So does params return false whenever atleast one parameter is not given or of the wrong datatype?

tough abyss
#
                 _longDate = date params ["_year","_ month", "_day","_ hour", "_minute"]; 
                 _longDateRet = [_year,_month,_day,_hour,_minute];
                 _longDateRet;
                  };

??

little eagle
#

It's really weird. I think it only returns true if every variable was provided and they all match the required type

tame portal
#

Fair enough

little eagle
#

that would do nothing , Geeky

#

that would be the same as just date

#

you split the array into it's elements and reassemble it immediately again

#

So even if you have one value being undefined it will report false

#

even if a default value was defined

tiny wadi
#

Any idea why that runs on every player?

#

I want it to just run on the client

little eagle
#

[1] params ["_num1", ["_num2", 0]]; // false

tiny wadi
#

Preferablly without doing the server stuff

little eagle
#

because it's a global trigger?

tiny wadi
#

How do I make it a local trigger?

little eagle
#

player in thisList or something

tiny wadi
#

Oh in the condition

little eagle
#

would check if the local player is inside the trigger

spring kindle
little eagle
#

_flush is undefined.

tiny wadi
#

_flush = _this

#

you passed the variable you just never defined it

spring kindle
#

what is the point in that?

tiny wadi
#

The script doesnt know what the value is unless you get the variable you passed it

vapid frigate
#

how else does it know what '_flush' is?

tiny wadi
#

Because it is not a global variable

spring kindle
#

so that will fix it?

tiny wadi
#

make sure you have a semicolon

#

_this is lowercase

spring kindle
tiny wadi
#

show the init event handler again

spring kindle
tiny wadi
#

_Flush = (_this select 0) execVM

#

Shouldwork

spring kindle
#

what does the select mean?

#

0

tough abyss
#

select this value

#

So the way execVM works

#

when you state [_this select 0] execVM "myScript.sqf"

#

It normally refers to A a parameter inside another script passed by another script

#

so if you were to [this] execVM "myscript.sqf";

spring kindle
#

so is select 0 like selecting that object?

tough abyss
#

the this

#

would be _this select 0 inside the myscript.sqf

vapid frigate
#

select 0 is just selecting that value from the array

#

like _this[0] or _this.get(0) in other languages

spring kindle
#

okay well no more errors but now im not animating

tiny wadi
#

Do AI & players activate triggers or can any vehicle activate it?

little eagle
#

omg

tough abyss
#

tbh you kind of need to work things out yourself @tiny wadi

#

We can't hold your hand all the way...

#

Or know of someone who can?

spring kindle
tough abyss
#

Oh yeah.

#

You didn't know that the statements?

#

have to be ""?

#

Some of ArmA 3 script requires ""

#

Supposedly not absolutely sure if you define code using quotes or {}

#

ArmA 3 treats them the same.

#

But that could be a VBS 2.0 / 3.0 only thing

#

As I said not absolutely sure.

paper rain
#

the "" is a double-quote escape, so double-quotes can be stored in config fields, like mission.sqm mission init fields

#

I.E. how do you store a " in a string? By escaping it as ""

tough abyss
#

Yeah in some other languages they use e.g

#

Python \ escape character

#

"my string with it's escape character" and it's not going to cooperate. with me using backslash between the it's

spring kindle
#

so how would i make a player go into a custom animation

tough abyss
#

call it?

spring kindle
#

i've looked around and haven't found anythjing helkpful;

tough abyss
#

Do you know the class name of the animation?

spring kindle
#

its a custom one i made

tough abyss
spring kindle
#

so that will animate a player as well?

tough abyss
#

That can animate anything

spring kindle
#

how would i make that work for a player?

tough abyss
#

player animateSource ["MyAnimationClass", 1, true];
or
player animateSource ["MyAnimationClass", 1,1];

#

true ending value == instant change

#

number 1 == smooth change

spring kindle
#

@tough abyss do you know how to set it up model side? i imported the rtm into the animations window but i dont know how to go from there since its not a selection

tough abyss
#

No never done modelling

#

This is the sort of stuff I read / do

#

I have done some modelling in the past

#

But it wasn't arma 3 related

#

It was Blender 3D CyclesRendering

spring kindle
#

alright ive been digging in the exampls folder and i think i may have figured it out im about to find out ill let you know

vapid frigate
#

i don't think animateSource works on units

#

that's for model config type animations (doors, wheels, etc)

lethal cave
#

allMapMarkers returns #user defined markers, is it possible to take an id that it returns and get a player name?

tough abyss
#

Whats this for?

#

the allMapMarkers for?

lethal cave
#

well it returns all placed markers on the map, i wanna use it my spectator thing to show markers for spectators

#

and show names of who placed the markers if it's a user marker

#

it probably wont work cause if player with this ID disconnects script wont be able to find his name anymore

tough abyss
#

HandleDisconnect?

#

event?

lethal cave
#

not sure how that would help

paper rain
#

I'd also have the client run a tight infinite loop setting the marker position, creating it when they spawn.

lethal cave
#

oh wait, it's markerText not getMarkerText, okay, how did i miss that

#

that was helpful, thanks

thin pine
#

Whats that command that allows you to return all valid scripting commands for arma 3? Returns it like B: somethingsomething

thin pine
twilit nymph
#

Is it possible to call a class from init.sqf while in game?

#

In multiplayer

little eagle
#

there are no classes in SQF, so no

median iris
#

Anyone willing to help me understand function creation? Or point me in the right direction? I have a good understanding just want to make sure I do it right?

halcyon crypt
#

add the last )...

thin pine
#

@twilit nymph define class

median iris
#

Thank you for that link it helped a lot but my next area of confusion is the call BIS_fnc_param I don't understand why this: _name = [_this,0,"",[""]] call BIS_fnc_param; is different from this _position = [_this,1,"",["",[]]] call BIS_fnc_param; any thoughts or recommendations?

#

why all the extra ]]] and such what do these define?

twilit nymph
#

@thin pine Not experienced with ArmA scripting but like a function containing custom code that I can call from IG

noble juniper
#

@median iris bis_fnc_param is an old way of making sure that a variable contains the right value and that there is always a value set on it.

#

param or params is the new engine based way.

thin pine
#

@twilit nymph It depends where/when you want that function defined. But you could just an in-line function. Define the in-line function init.sqf, call it IG using the 'call' or 'spawn' commands

twilit nymph
#

Like remove items and add new ones to a unit

#

Could you please write some example code or something?

#
removeAllItems rifleman1;
rifleman1 addItemToVest "ACE_tourniquet";
#

And as gamemaster I want to be able to call this mid game

#

For example

indigo snow
#

You'd use the debug menu as admin

#

or make yourself a menu to execute code from

twilit nymph
#

Can I put this in init.sqf and call from debug menu?

indigo snow
#

you can execute arbitrary code from the debug console

twilit nymph
#

How?

indigo snow
#

no need to put anything in init.sqf

#

if the mission allows it, the logged in administrator has access to the debug console in the escape menu

twilit nymph
#

I see, problem is though the code I want to run is 99 lines

indigo snow
#

then you save it in a function and call the function instead

#

my_fnc = { hint "some"; systemChat "lines"; }; call my_fnc

nocturne bluff
#

I got 99 problems but a function aint one

open vigil
#

Hehe

twilit nymph
#
medic1 addItemToVest "ACE_CableTie";
rifleman 1 addItemToVest "ACE_CableTie";

Is it possible to shorten this somehow?

#

Like medic1, rifleman1 addItemToVest "ACE_CableTie";

indigo snow
#

{_x addItemToVest "ACE_CableTie" } forEach [medic1,rifleman1];

twilit nymph
#

Holy shit I'm new to this. How to best learn arma 3 scripting?

indigo snow
#

by doing

twilit nymph
#

_x means local variable right?

#

Why using {}

#

Unlike anything else I have coded

tough abyss
#

Because he uses forEach after. To run what is inside the brackets for the medic and rifleman

twilit nymph
#

Ahh so you always have to do that when using forEach

#

Is the variable neccessary?

indigo snow
#

forEach executes the codeblock to its left for each element in the array to its right

#

_x is a magic variable with the value of the currently evaluated value of the array

tough abyss
#

What he said. ^

#

Sorry, I assumed your gender @indigo snow

#

Hahaha

indigo snow
#

just wait until the attack helicopter lobby gets more funds

twilit nymph
#

Thanks @indigo snow

#

What am I doing wrong? {_x removeAllItems} forEach [p1, marksman1, rifleman1, breacher1, medic1];

#

the _x need to go after items?

indigo snow
#

look at the syntax for that command

#

also read the note - it doesnt remove all items

twilit nymph
#

It worked for me. I know

twilit nymph
#

Is there an easy way to add custom music to zeus?

indigo snow
#

it might show up if you set up a cfgMusic inside your description.ext but no promises

tough abyss
#

_x is a local variable correct

#

but in the context of a forEach {}

#

It corresponds to the index that the forEach is currently operating on.

#

e.g

#
 {
    diag_log format ["%1",",_x]
 } forEach [1,2,3,4,5,6,7];
#

On the first run of that _x == 1

#

second _x == 2

#

third _x == 3

#

and so on.

median iris
#

Anyone mind helping me or providing an example of the params command?

indigo snow
#

[1,2] call { params ["_a","_b"]; hint format ["%1",_a+_b]; };

tough abyss
#

you can not use params

#

where values are undefined though

#

unless you provide a "default" value

#

so you can replaced _this select 0

#

with params

#

but.

median iris
#

Thank you for the reply but I think I need something more in-depth I'm trying to create a function that creates a great many markers for various scripts to use, I'm not sure what parameter configuration this script requiers

tough abyss
#

You must provide default values

median iris
#

Very well.

indigo snow
#

The more advanced usage such as supplying default values and accepted datatypes is all explained on the wiki

tough abyss
#

other wise params ["_someValue"] inside a function thats yet to be called.

#

The "_someValue" will say undefined variable in expression.

#

If you want to make a function robust

indigo snow
#

params has the exact same functionalities

warped thicket
#

how is that better than params?

#

it's the exact same thing

#

sniped there @indigo snow ๐Ÿ˜„

indigo snow
#

:ninja:

tough abyss
#

No it's not.

indigo snow
#

it is

tough abyss
#

params is not the same as param

warped thicket
#

well obviously it's not the same

tough abyss
#

@little eagle Clear this up?

warped thicket
#

one is for one parameter, the other is for more

#

duh

tough abyss
#

param can be used to eliminate illegal values passed to a function

warped thicket
#

so can params

tough abyss
#

Yes

#

But param is more readable than params

warped thicket
#

O.o

#

give me an example

tough abyss
#

I like to use params with. something like getPos

warped thicket
#

if you have more than 1 parameter, you should use params

tough abyss
#

I can use params directly with that to seperate the [(getPos player)] params ["_xAxis",_yAxis","_zAxis"];

warped thicket
#

also params is better because it privatizes the variable itself

#

param does not do that

#

that gist from commy even tells you params is better, so not sure why you are refferring to it to prove that param is better ๐Ÿ˜„

tough abyss
#

Thats why you'll see private param in 1 line

warped thicket
#

for the use case we are talking about anyways

#

well obviously

#

so why exactly should he use param again?

median iris
#

Here is what I'm doing

tough abyss
#

The main use of this is to check the argument input of called (or spawned) SQF functions.

warped thicket
#
params [
    ["_markerName", "", [""]],
    ["_markerLocation", [0,0,0], [[], objNull], [2,3]], 
];
#

you also don't need private ARRAY above it with that

tough abyss
#

Hmmm interesting

indigo snow
#

it's good code but his _markerLocation was index 0

median iris
#

i see

warped thicket
#

well then just swap it

tough abyss
#

One other key thing

#

Is the params is pass-by-order

#

Meaning whatever you pass into the function / spawn'd code

twilit nymph
#

Tried that earlier. Doesnt work @indigo snow

tough abyss
#

will be the order the variables are arranged

warped thicket
#

it's always like that

#

if you use select or param you need to know the index as well

indigo snow
#

then it its non trivial Cisco

tough abyss
#

^

warped thicket
#

for params you can just do params ["_var1", "", "_var2"];

tough abyss
#

Exactly as I said pass-by-order

#

without knowing the order other than when it goes in

warped thicket
#

you need to know the order either way yes

#

unless it's a function that just passes through entire thing for whatever reason

tough abyss
#

no more fuggly _hardDefinedOrder =_this select 0

indigo snow
#

i do not understand the point you are trying to make

warped thicket
#

params is a lot faster than private _var = _this select X

dusk sage
#

Anyone done benchmark for param vs params?

warped thicket
#

param is faster

tough abyss
#

Feel free @dusk sage

warped thicket
#

it doesn't privatize

tough abyss
#

I'd love to know.

warped thicket
#

don't have numbers at hand

dusk sage
#

private param vs params more specifically*

tough abyss
#

Yes, I'd like to know

#

Please.

dusk sage
#

I expect params to be faster, ofcourse

#

but would be interesting

tough abyss
#

params is almost as useful as sort and apply

warped thicket
#

single backticks for in-line stuff like this

dusk sage
#

is almost as useful as?

indigo snow
#
[1,2,3,4] call {params ["_a","_b","_c","_d"];};   
[1,2,3,4] call {
    private _a param [0]; 
    private _b = param [1]; 
    private _c = param [2]; 
    private _d = param [3];
};

0.0034ms vs 0.0052 ms

dusk sage
#

relatively, or what?

#

They do different things

tough abyss
#

relatively I know they do different things it's along the line of them being quite new and under used commands

#

I even still see a lot of code with

#

array + array = array3

warped thicket
#

well that's a rather bad test

tough abyss
#

instead of array pushBack array2

warped thicket
#

because param is not meant for more parameters ๐Ÿ˜›

tough abyss
#

^

indigo snow
#

fair, ez to amend

tough abyss
#

Test with a single parameter

dusk sage
#

pushBack has also not been around aslong as a lot of older code

indigo snow
#

0.0021 vs 0.0021 ms

#

negligible

warped thicket
#

"test" call {private _var = param [0, "default"]} -> 0.0027
"test" call {params [["_var", "default"]]} -> 0.0027 ms

dusk sage
#

You'd hope params and param is linear, though

tough abyss
#

We need a precision control for diag_codePerformance

dusk sage
#

But obviously more code etc with param for > 1 parameters

indigo snow
#

ah jonpas your example coverts "test" into ["test"] first

warped thicket
#

?

tough abyss
#

@dusk sage Exactly.

indigo snow
#

iirc param and params convert non-array inputs into a one element array

warped thicket
#

it does it in both param and params

#

so it doesn't matter ๐Ÿ˜›

tough abyss
#

On the note of more code. I sometimes prefer to sacrifice a little bit of performance for the sake of readability.

indigo snow
#

forEach ^^

warped thicket
#

it's even slower by 0.0001 ms if I do ["test"]

#

interesting

dusk sage
#

0.0001 ms

#

That is non deterministic

warped thicket
#

well you are talking about 2 commands that are pretty much the same for 1 parameter inputs

dusk sage
#

Negligible compared to the fluctuations you're gonna get testing that shit

warped thicket
#

you can't expect 0.1 ms differences

#

oh things like that can bunch up rather quickly if you do some very intensive shit

#

not worth thinking about in simple scripts though

dusk sage
#

As with everything coding related, make sure it works first ๐Ÿ˜‰ @tough abyss

tough abyss
#

^

dusk sage
#

There isn't that many bizarre unreadable things you can do in SQF

tough abyss
#

Can always re-write it ๐Ÿ˜„

dusk sage
#

I'll ask again in hope; has anyone got ahold of those bitwise functions added?

tough abyss
#

AN interesting question?

#

Can biflags?

#

be used for a binary network code?

#

As in create a code base for MP that communicates purely with binary values?

#

to correspond to messages?

#

[1001100] remoteExec ["New_FNC_something",-2,false];

#

?