#arma3_scripting
1 messages ยท Page 261 of 1
(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
The question is how to address to this player
thx
So you wanna know this basically:
how to get the nearest other player from a group leader?
?
@little eagle thx a lot :)
_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
other player
Except dogs aren't players, they are AI units
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 ?
Dogs have to go after nearest player if he is in the minimal distance radius.
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?
there is a dedicated https://community.bistudio.com/wiki/findNearestEnemy command, but from my testing it's pretty shit and unreliable
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
I feel awkward now, too much confusion for a short period of time.
- There is a pack of dogs. They are in group. Doing their buisness, walking around.
- 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.
or a non-animal FSM?
No idea
like if you createUnit ["Alsatian_F"];
Ramon, you really have to go through this step by step
The AI created is actually a soldier AI and you can command it like a human AI
otherwise the task is overwhelming
Dogs have no AI in Arma
They just stand around
But they don't behave like dogs at all
No they don't...
that's just stuff coming from the group
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.
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
How do I put nearest player into _unit?
I think we are going in circles
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
just replace player with the dog to get the nearest player to the dog
Why not that ^
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
Yes, you need to be very defensive with your scripting
Let me give you an example that doesn't work:
_wilddogs move (getPos ((leader _wilddogs) nearEntities ["man", 300]));
"man" doesn't seem to work
of course it does not work
group move position
but
(getPos ((leader _wilddogs) nearEntities ["man", 300]))
Maybe nearTargets will work, really?
So you need to select the first index occurrence of "man" type
_wilddogs move (getPos (((leader _wilddogs) nearEntities ["man", 300]) select 0) );
Sorry, that was old code. This doen't work
line is too long
@lethal ingot For the sake of your sanity
Don't concatenate all code on 1 line
It makes it harder to debug.
_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
Okey, thanks for you help. I will vanish and leave you in calm now ๐
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
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
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
enableSimulation has to be executed on every machine
local effects. "server only" won't work here
@little eagle So whats the effect if enableSimulation is run on the client
but AI reside on the server?
Whats that do?
@tough abyss Yes, I'm interested in corner cases just like that
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?
well duh. otherwise the game wouldn't be synched
@tough abyss You got the point ๐
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
@little eagle That's what we're trying to achieve here... Disable/limit sync of units out of area of interest
TO clients
every machine can send updates for any object to any other machine
Ezcoo there is a way to scan through all units on the server side
client to server
and disable their simulation loop.
server to client
@tough abyss That's what I'm about to do
doesn't matter which machine owns the object
But just get ZBE_cache
Arma 2
Ugh...
Right.
{_x enableSimulation false; } forEach allUnits;
ArmA 3 adds enableSimulationGlobal
Yup
But the A2 netcode... Does everything go through server or is there also P2P/from client to client sync?
there is no P2P afaik
It can be done though
A client to a client message
At least in arma 3
remoteExec from my client to remote client
@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
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...
@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
pretty sure remoteExec goes through the server when the target is clientB and it's called from clientA
So there's no P2P
the clients don't know the owner ids of objects
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
Mhm
So I take that as evidence that there is no P2P
load (vehicle player) always returns 0... is there an equivalent for vehicles?
no
how about a BIS_fnc or CBA
Not that I know of. Cargo boxes use the x slots for weapons/items/magazines/backpacks system.
I think the total mass thing is broken though
bar just goes over the maximum
doing nothing
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
sorry 40 mass yes
it's an arbitrary size number
40.. units
yea
but yeh i assumed it was the same as it seems the same in game
it probably is
you can't get this correctly
e.g. attachments of weapons or items inside backpacks that are inside the cargo
my scripts empty backpacks where possible
reducing that problem
but yeh its a problem
https://community.bistudio.com/wiki/canAdd
^ this is supposed to work
it seems to be working on this jeep
good
yw
how can i check if listbox is empty ? (lbSize _mylistboxctrl) isEqualTo -1 ?
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";
};
what is locationtype ? is it a marker ?
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.
If the location type is met?
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;
};
Oh my lord
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;
};
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
would that edit work?
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.
But why didn't you use the BI function to format the date?
hmm. I can't find it. I swear there was one for exactly this purpose
Is the captive from Apex official mission is a special script or simply an animation with generic objective script?
nearestLocations already sorts locations closest to farthest
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.
Err,anyone there?D:
yes, here. But I have no idea. Never done that. Never even heard about it
@broken forge Use this function to convert time [dayTime] call BIS_fnc_timeToString; Thanks to @little eagle mentioned it
I would use _time = [dayTime] call BIS_fnc_timeToString; but it returns with quotes wrapped around the time.
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?
x3 = [1,2,3,4,5] select {
if (_x == 3) exitWith {
false;
};
true
};
// x3 = false
bug, feature, bad design?
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;
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
Awesome!
note placed: https://community.bistudio.com/wiki/select
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?
Oh that works?
yep
I thought step 0 it might complain
from x to y step 0
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};
What does this select quirk have to do with while {true} do { ?
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
Yeah. select. It also works with Booleans:
[0,1] select true // 1
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).
Is that a question?
Don't put yourself down so hard, my god D:
hmmm that select is quite a nice alternative to the if else thing ^^
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
Very much so
The only reason you would use it is to have the local variable defined inside the main scope
This one is worse
I'd rather give the variable a meaningful default value:
_var = switch(condition) do {case 1: {//block//} case 2: {//otherBlock//} case 3: {//LastBlock//} } ;
Gross
private _var = objNull;
if (cond) then {
_var = player;
} else {
_var = cursorTarget;
};
same, I try to avoid the semi-ternary operator thing with SQF..
@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.
There is a huge trap when using switch like this, @tough abyss
switch actually returns true when no condition is met and no default block was defined
O_o
@little eagle I didn't realise you were an ACE3 dev. By the way as an offtopic thing.
_var = switch (1) do {
case 2: {};
};
// _var = true
wweeeiirrrddd
but what happens is tha player dies and his body lay on the ground.
then handleDisconnect doesn't fire. the player just respawns
handleDisconnect fires ONLY on the server last time I checked?
switch returns true in this case. No one knows why
handleDisconnect fires ONLY on the server last time I checked?
correct
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
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
Are you also a "genuine" programmer? As in it's your professional job?
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.
I just always liked logic and math (as long as it doesn't get too complicated)
What are you trying to do, Don?
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
Iirc the handleDisconnect return value thing was always wonky
no idea why you'd even use that
@little eagle to save players on data base if they use Alt + F4 or any other problematic disconection
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
I can't even remember what it was supposed to do in the first place
but... nothing that _player spawn {deleteVehicle _this;} can't solve;
You can also just return nil and it will do nothing
Oh, I think I get your confusion now
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];
well. if handleDisconnect was executed, then the client is gone. no way to remoteExec anything
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
@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.
handleDisconnect only works with addMissionEventHandler
^
it's not to be confused with onPlayer(Dis)Connected
Any particularly reason you are using HandleDisconnect
?
vs PlayerDisconnected
?
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
Apparenlty returning false does make it behave like disabledAI was 0
Well you could just kill the AI
But he wanted to be whatever was in the description.ext
then delete his body.
You can achieve DayZ SA like combatlog behavior
He doesn't want to override anything. He's making a mod I think and not a mission
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?
SS = ServerSide ?
Yes
So all your speciality code exists inside a @modfolder
vs just using the mission file
@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
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.
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
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.
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
that is and upcoming task for me thoug
Pretty sure it's not meant to save performance, but to simply have the clients not have to download and install a mod
well normaly, the Modquestion is a different one
Check out #headless_client to see what I did
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.
i actually don't get what you wanted to achieve with that
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.
yes
And with the HC's are they have unlimited bandwidth and no latency
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
It gave me access to a second single-threaded script executor
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
I mean the community I manage has a single Xeon. 12 thread CPU server
So utilising HC's
Is very useful.
that is an interesting choice
and you are right, you basically need to use HC to utilize all of it
One issue I can't seem to workout
AI + Lots of gunfire = low FPS
I am not sure why.
cause of the bullets flying
have you automated the install, update, restart of all of those HCs?
are you working with GIT or SVN ?
Linked to the HC's folder inside 1 folder
or even Maven ?
just copy and paste. No.
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
in my opinion, you should start using Version Controle like GIT. From a software engeneering standpoint, it only has benefits.
i don't like source tree its to complicated for me to be honest
I do like the snapshot feature of it.
i use gitkraken
I use crossed fingers and hope
googles gitkraken
o.o
lmfao
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
i guess everything is personel preference
Tutorials to click the branch button? ๐ค
No...
To not cause things to depend on others.
E.g branching can screw up an entire snapshot
What you on about D:
tut on how to add a remote, clone , fetch
basically how to set it up and get it running reliably, but never mind
Heh gitkraken actually has a better interface than SourceTree
Hows it's documentation?
and is multiplatform
Support bitbucket?
there are tips and tricks on theire twitter
yes
bitbucket and your own hosts like gitlab and such
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.
@BoGuu#1044 that actually looks better then what i remember from sourcetree
but im on linux so no sourctree for me
Don't really need any docs to use it
It's just git bash with nice buttons
Git bash command line scared me.
as allways, you need to dig into it a bit but then its easy
Or like most CL applications ๐
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...
Do you know C?
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.
Thought you were being told to learn ASM first ๐
both
ASM is what hacking the art of exploitation asks you to learn
you use i/x -b etc
memory inspection.
wait you are a hacker ? keep away from my server ! ๐
JK by the way, thx for the info that HandleDC is a missionEventhandler
another By the way, is anyone of you useing kyler renslows Intell J idea SQF Plugin ?
well do you want to miss syntax checking ?
i don't remember that there was a sqf lexer for NP++
Yeah there is.
I updated mine manually though.
To include all the new commands
It's upto Version 2.0 now.
do you mean "highliting" ? or also Syntax check for all the commands and such ?
like, expected array got bool ?
with that intelli J plugin of cause
Is there a problem with it?
I'm actually learning 4 different languages, the 4th is kind of forced because of playing FTB
Lua.
Python.
C
and ASM
Wow.
Neat.
the free community eddition
That would cut my coding time down a lot
I've often added accidentally syntax errors
it atleast cathces a lot of syntax shit
And gone why doesn't this work?
Some commands.
Does it pick up the embedded () problems?
yes
Nice.
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
Any idea why a trigger deactivation runs globally?
Because you have to specify if it runs globally
when you _trig = createTrigger ["EmptyDetector",getPos (ofThing),true];
I placed it down in the editor, anyway to disable that?
Ok, will it still hint to the player that triggers it?
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.
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?
Give us the code to look at?
Sure
activation:_exc = [vehicle (thisList select 0), "addonshop_2"] execVM "addonshop.sqf";
deactivation: hint "Thanks for visiting Adam's Auto Parts";
Grabbing script
Okay so what happens when a trigger is executed on the server only
Is it will be evaluated on the server only
addonshop.sqf
So any client-side operations won't show up
Its best to open the script in notepad++ to read the comments correctly
So what doesn't it do?
Run only on the client
if (isNil "AddonShop_Car getVariable ""Addons""") then {
^ this is borked. doesn't work like that
That was actually the only way I could get it to work
No.
this will always be true, so you'll always reset that "Addons" variable to []
^
I think you meant:
if (isNil {AddonShop_Car getVariable "Addons"}) then {
So was wondering if someone can help me out here, arma is saying my script isnt being found... https://gyazo.com/b10e38bceeaf3be3f6455ec223e1e5e9 https://gyazo.com/6648157a834c8b613484c7131d01e199
That makes sense, I noticed everytime I ran that it reset my addons for some reason
use my edited version
@spring kindle Make sure that you specify the path to the addon folder if it is in an addon
isNil now support code block conditional eval?
_Flush = execVM ""\RLM\Toilet\Flush.sqf""
isNil now support code block conditional eval?
it has always supported that
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";
What on earth would the flush.sqf do
Make sure addonbuilder is accepting .sqf in allowed file extensions
isNil string checks if a variable is defined (either local variable or a global namespace of the current namespace)
Use defaults!
isNil code checks if the expression has a return value that is not GameValueNil
missionNamespace getVariable ["varname", defaultValue]
@dusk sage I agree
ninja'd
How do params work?
wooow yeah addon builder wasent excepting sqf
I never understood them
You can do clever things like this
Your code with the [_var,_var] spawn {code}
you can do this
params is just a stack of the param command
to define them without using _this select #;
How come its wrong?
param is a glorified select and params assigns variables and sets them to private
they do different things
Well
Oh so I could do [1,2] spawn {params ["_a", "_b"]; hint format ["%1, %2", _a, _b];
e.g [_ExternalVar1,ExternalVar2] spawn { [_firstVar,secondVar] params ["_myNewVar",_myOtherNewVar"]; };
Yes
one is return value based, the other directly assigns the variables
Can also do it with script commands
param has the same functionality except it doesnt declare the variables by itself and it only works for one of the parameters given
AddEventHandlers make this really easy.
Thats why I said its kinda stacked ^^
Take all the variables of the addEventHandler feed it into [] params
so params is not just a stack of param's. thank you
which would be each _this select #
Everyone sounds so hostile here..
rip
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
it's a bad way to remember them, because it is wrong and leads to false assumptions
addMissionEventHandler ["PlayerDisconnected" { params [_id,_uid,_name,_jip,_owner] }];
Now you could use _id etc variables
you have to stringify the variable names
Well I know the difference but yes, for someone who doesnt know the difference its misleading
params ["_id", "_uid", "_name", "_jip", "_owner"]
derp. I've been away from ArmA 3 Code ๐คฆ I apologise if my syntax is wrong.
All gucci
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
I wonder if ``` _fnc_getDataLong = {
_longDate = date params ["year"," month", "day"," hour", "_minute"];
_longDate;
};
Ahhhh thats why that wouldn't work.
so if I want to set a default value on paramsI would do: params [["_myVar", 1], ["_myString", "asd"]];
So I'd have to do this.
yes
and if the variable is set when I call the script it wont use the default
So does params return false whenever atleast one parameter is not given or of the wrong datatype?
_longDate = date params ["_year","_ month", "_day","_ hour", "_minute"];
_longDateRet = [_year,_month,_day,_hour,_minute];
_longDateRet;
};
??
It's really weird. I think it only returns true if every variable was provided and they all match the required type
Fair enough
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
[1] params ["_num1", ["_num2", 0]]; // false
Preferablly without doing the server stuff
because it's a global trigger?
How do I make it a local trigger?
player in thisList or something
Oh in the condition
would check if the local player is inside the trigger
can someone spot the error? I'm having no luck. https://gyazo.com/24e2201c25882072dc0341e154edca55 https://gyazo.com/cc1f5c6b139f296fc1f759594132f9b3
_flush is undefined.
what is the point in that?
The script doesnt know what the value is unless you get the variable you passed it
how else does it know what '_flush' is?
Because it is not a global variable
arma still doesn't agree https://gyazo.com/044cfa506c7930a60e9179281d754a06
show the init event handler again
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";
so is select 0 like selecting that object?
select 0 is just selecting that value from the array
like _this[0] or _this.get(0) in other languages
okay well no more errors but now im not animating
Do AI & players activate triggers or can any vehicle activate it?
omg
tbh you kind of need to work things out yourself @tiny wadi
We can't hold your hand all the way...
@little eagle You able to help me with an issue in #server_admins ?
Or know of someone who can?
@tough abyss thanks for walking me through this issue i think maybe the this's cacled eachother out who knows lol but this fixed it. https://gyazo.com/ac9cc3d80882089d3d3058d679c5da72 https://gyazo.com/06693d8f6286b43f9965c0af45ff6b36
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.
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 ""
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
so how would i make a player go into a custom animation
call it?
i've looked around and haven't found anythjing helkpful;
Do you know the class name of the animation?
its a custom one i made
so that will animate a player as well?
That can animate anything
how would i make that work for a player?
player animateSource ["MyAnimationClass", 1, true];
or
player animateSource ["MyAnimationClass", 1,1];
true ending value == instant change
number 1 == smooth change
@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
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
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
i don't think animateSource works on units
that's for model config type animations (doors, wheels, etc)
I think you want https://community.bistudio.com/wiki/playMove or one of it's 'See Also's
allMapMarkers returns #user defined markers, is it possible to take an id that it returns and get a player name?
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
not sure how that would help
Here's something similar to what you want to do. I remember old wasteland servers in A2 added the placer's name at the start of the marker text: http://killzonekid.com/arma-scripting-tutorials-whos-placingdeleting-markers/
For the following marker. I'd use https://community.bistudio.com/wiki/onPlayerDisconnected to delete the marker. (or https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#PlayerDisconnected)
I'd also have the client run a tight infinite loop setting the marker position, creating it when they spawn.
oh wait, it's markerText not getMarkerText, okay, how did i miss that
that was helpful, thanks
Whats that command that allows you to return all valid scripting commands for arma 3? Returns it like B: somethingsomething
Nvm found it https://community.bistudio.com/wiki/supportInfo
there are no classes in SQF, so no
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?
@twilit nymph define class
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?
@thin pine Not experienced with ArmA scripting but like a function containing custom code that I can call from IG
@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.
@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
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
Can I put this in init.sqf and call from debug menu?
you can execute arbitrary code from the debug console
How?
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
I see, problem is though the code I want to run is 99 lines
then you save it in a function and call the function instead
my_fnc = { hint "some"; systemChat "lines"; }; call my_fnc
I got 99 problems but a function aint one
Hehe
medic1 addItemToVest "ACE_CableTie";
rifleman 1 addItemToVest "ACE_CableTie";
Is it possible to shorten this somehow?
Like medic1, rifleman1 addItemToVest "ACE_CableTie";
{_x addItemToVest "ACE_CableTie" } forEach [medic1,rifleman1];
Holy shit I'm new to this. How to best learn arma 3 scripting?
by doing
Because he uses forEach after. To run what is inside the brackets for the medic and rifleman
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
just wait until the attack helicopter lobby gets more funds
Thanks @indigo snow
What am I doing wrong? {_x removeAllItems} forEach [p1, marksman1, rifleman1, breacher1, medic1];
the _x need to go after items?
look at the syntax for that command
also read the note - it doesnt remove all items
It worked for me. I know
Is there an easy way to add custom music to zeus?
it might show up if you set up a cfgMusic inside your description.ext but no promises
_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.
Anyone mind helping me or providing an example of the params command?
[1,2] call { params ["_a","_b"]; hint format ["%1",_a+_b]; };
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.
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
You must provide default values
Very well.
The more advanced usage such as supplying default values and accepted datatypes is all explained on the wiki
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
params has the exact same functionalities
how is that better than params?
it's the exact same thing
sniped there @indigo snow ๐
:ninja:
No it's not.
it is
params is not the same as param
well obviously it's not the same
@little eagle Clear this up?
one is for one parameter, the other is for more
duh
I bet you are talking about this @tough abyss https://gist.github.com/commy2/46d26d9cff33fafec70e181d45a1ffb3
param can be used to eliminate illegal values passed to a function
so can params
I like to use params with. something like getPos
if you have more than 1 parameter, you should use params
I can use params directly with that to seperate the [(getPos player)] params ["_xAxis",_yAxis","_zAxis"];
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 ๐
Thats why you'll see private param in 1 line
for the use case we are talking about anyways
well obviously
so why exactly should he use param again?
The main use of this is to check the argument input of called (or spawned) SQF functions.
params [
["_markerName", "", [""]],
["_markerLocation", [0,0,0], [[], objNull], [2,3]],
];
you also don't need private ARRAY above it with that
Hmmm interesting
it's good code but his _markerLocation was index 0
i see
well then just swap it
One other key thing
Is the params is pass-by-order
Meaning whatever you pass into the function / spawn'd code
Tried that earlier. Doesnt work @indigo snow
will be the order the variables are arranged
it's always like that
if you use select or param you need to know the index as well
then it its non trivial Cisco
^
for params you can just do params ["_var1", "", "_var2"];
Exactly as I said pass-by-order
without knowing the order other than when it goes in
you need to know the order either way yes
unless it's a function that just passes through entire thing for whatever reason
no more fuggly _hardDefinedOrder =_this select 0
i do not understand the point you are trying to make
params is a lot faster than private _var = _this select X
Anyone done benchmark for param vs params?
param is faster
Feel free @dusk sage
it doesn't privatize
I'd love to know.
don't have numbers at hand
private param vs params more specifically*
params is almost as useful as sort and apply
single backticks for in-line stuff like this
is almost as useful as?
[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
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
well that's a rather bad test
instead of array pushBack array2
because param is not meant for more parameters ๐
^
fair, ez to amend
Test with a single parameter
pushBack has also not been around aslong as a lot of older code
"test" call {private _var = param [0, "default"]} -> 0.0027
"test" call {params [["_var", "default"]]} -> 0.0027 ms
You'd hope params and param is linear, though
We need a precision control for diag_codePerformance
But obviously more code etc with param for > 1 parameters
ah jonpas your example coverts "test" into ["test"] first
?
@dusk sage Exactly.
iirc param and params convert non-array inputs into a one element array
On the note of more code. I sometimes prefer to sacrifice a little bit of performance for the sake of readability.
forEach ^^
well you are talking about 2 commands that are pretty much the same for 1 parameter inputs
Negligible compared to the fluctuations you're gonna get testing that shit
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
As with everything coding related, make sure it works first ๐ @tough abyss
^
There isn't that many bizarre unreadable things you can do in SQF
Can always re-write it ๐
I'll ask again in hope; has anyone got ahold of those bitwise functions added?