#arma3_scripting
1 messages · Page 764 of 1
should this code not simply add and remove the silencer of the the player?
player removePrimaryWeaponItem "muzzle_snds_shield_black_m";
hint "Silencer off";
}
else {
player addPrimaryWeaponItem "muzzle_snds_shield_black_m";
hint "Silencer on";
}
}
as a toggle
for some reason it does not but also does not give an error
because of the {}
it doesn't execute at all
outermost
what you wrap in {} becomes a code
a code never executes unless a command executes it
e.g. in {} forEach array, forEach executes the {}. or in if (bla) then {} then executes the {}
ah, i understand
thank you
i changed it to..
player removePrimaryWeaponItem "muzzle_snds_shield_black_m";
hint "Silencer off";
}
else {
player addPrimaryWeaponItem "muzzle_snds_shield_black_m";
hint "fuck";
}```
now it adds a silencer to the player but never removes it
if ("muzzle_snds_shield_black_m" in primaryWeaponItems player) then {
is this valid?
it's valid
but in is case sensitive
so it never succeeds
because what you have is all lowercase and the actual item class name most likely isn't
but the name of the item is all lowercase
try primaryWeaponItems player in debug console
see what it gives you
no
at least not always
depends how it was defined in config
that solved it!
it gave me something different in the debug
now it works
primaryWeaponItems player => can i use this command to get the loadout of an AI unit in my group?
if ("muzzle_snds_shield_black_m" in primaryWeaponItems player) then {
player removePrimaryWeaponItem "muzzle_snds_shield_black_m";
hint "Silencer off";
}
else {
player addPrimaryWeaponItem "muzzle_snds_shield_black_m";
hint "fuck";
};
^ You were missing a ; in this code, in case that was breaking it
you can, what are you trying to achieve?
he wasn't 
loadout? it's only for primary weapon items
yes
ok
an how?
in other words, how can i address a certain unit (eg F2) in a script?
groupSelectedUnits player
sorry, i meant without actively selecting it
if i understand correctly
_myUnitCount = count units player;
gives me an array with units in my group
now how can i access the 4th member in the player group from the array?
I guess (units player - [player]) select 3
But I noticed that Arma could drop that kind of request or trim it.
Arma should never drop anything, if it does its a bug
order of precedence is wrong
I meant units group player...
fixed
but your code is still wrong
oh ok, and from your arma programmer point of view : what is best practice to you in order to send huge data? [var, {data = _this}] remoteExec ["call", _client] statement or missionNamespace setVariable ["var", any, _client] ?
we discussed about that and we have a conclusion but it is interesting to have your pov too
ok thanks
maybe we finally need a compress/decompress command
that would be great
Thank you!
remoteExecCompressed 😛

this would be extremely useful
for like a dozen people sure
Couldn't this already be done (kinda) using the HashValue command?
wat
ohh wait nvm
the idea was [array of values] -> convert array to hash -> send through remoteExec to unhash function -> unhash the data -> run code
but there's no way to un-hash values which have been hashed with https://community.bistudio.com/wiki/hashValue
Yes, hashes inherently cannot be unhashed, that's like, the definition of a hash
I am working on a shoothouse and I have nearly everything working except the final evaluation tally. Part of the final evaluation is to count targets hit, targets missed, and maybe save those numbers to do some math with them like time penalties.
I am using the pop-up target objects from Vanilla. I've broken them out into arrays named as "S1Shoot" and "S1 NoShoot" so I've got something like this already.
private S1Shoot = ["S1_01","S1_02","S1_03","S1_04","S1_05","S1_06","S1_07","S1_08","S1_09","S1_10","S1_11","S1_12","S1_13","S1_14","S1_15","S1_16","S1_17","S1_18","S1_19","S1_20","S1_21","S1_22"]
private S1NoShoot = ["NS1_1","NS1_2","NS1_3","NS1_4"];
According the forums on individual targets I can apparently using this line to return the state of an individual target where a returned value of 0 means the target is up and a returned value of 1 means the target is down:
private _state = _target animationPhase "Terc";
Where I am completely lost here is how to take that line, and work it into a "ForEach" Command to iterate through array ultimately returning values to count the number of targets up and number of targets downed.
forEach (units player - [player]) group player;
can someone tell me the correct syntax?
what are you trying to do?
running a command for all units in the players group excluding the player.
_shotValid = {_x animationPhase "Terc" == 1} count S1Shoot;
_shotInvalid = {_x animationPhase "Terc" == 1} count S1NoShoot;
_notShot = count S1Shoot - _shotValid;
then just ditch the group player part
Tyvm
THanks
I have been trying to set up this script for multiplayer yet it never works as intended. Here is how it is called:
weaponGod's init
[this] execVM "scripts\weaponDealer.sqf;
weaponDealer.sqf
params ["_weaponGod"];
[_weaponGod, "Miłosz the Weapon Dealer"] remoteExec ["setName", 0, this];
_weaponGod_actionId = _weaponGod addAction [
"<t color='#FFC800'>Demand STG-44",
{
params ["_target", "_caller", "_actionID"];
_target removeAction _actionID;
_target globalChat "You have found me, stranger.";
sleep 4;
_target globalChat "Ah, I see you want the best.";
sleep 2;
_weapon = [_target, "rhs_weap_MP44",1] call BIS_fnc_addWeapon;
isNil { _target selectWeapon _weapon; };
sleep 3;
_groundWeaponHolder = createVehicle ["GroundWeaponHolder", getPosATL _target, [], 0, "NONE"];
_groundWeaponHolder addMagazineCargo ["rhsgref_30Rnd_792x33_SmE_StG", 6];
_target action ["DropWeapon", _groundWeaponHolder, primaryWeapon _target];
sleep 5;
_theFlashbang = "ACE_G_M84" createVehicle (getPosATL _target);
sleep 1;
[_theFlashbang] call ace_grenades_fnc_flashbangThrownFuze;
deleteVehicle _target;
}
];
The issue occurs when the _target tries to select the weapon. It never does so so I try to force it with an isNil yet it still bypasses it and runs the rest of the script without selecting the weapon and dropping.
In singleplayer, the weapon is successfully selected and dropped. Running this script in the debug console on a dedi does work, but only when it is run in global execute.
Any advice is appreciated
your isNil does nothing special. it only contains a single command
a single command is always unscheduled
maybe you're calling the addaction expression on a client separate from the server where the ai is local?
Where should I be calling the action in an MP environment? Server? Globally? Currently, it is in the init of a unit, meaning it should be global + JIP.
if that is in the init, you need to worry about the first line remoting to every client every time a client joins (globally, globally lol)
do we have a command to take distinct elements from an array?
[1,1,2,3,3,3,3,4,4,5,5] becomes [1,2,3,4,5]
https://community.bistudio.com/wiki/pushBackUnique
This can do the trick
I'll remove the remoteExec once I figure out how to properly execute it. The code has been switching between localities so often, I left that in there
_uniqueArray = _array arrayIntersect _array
I know a friend of mine currently has a working script for it that runs while in mission
automatically does it mid mission, hes sick
https://cdn.discordapp.com/attachments/951949245445984296/970444430119174285/unknown.png
Is it possible to remove this kind of warning message and put it in systemChat instead ?
(pbo is obfuscated, we can not fix the error)
that kind of message is generated by arma itself so probably not, best bet is to just fix the issue or if you are not the creator let them know there's a problem so they can fix
idk how performant arrayIntersect is but here is an alternative you can try if it's too costly
_unique = [];
_input apply {_unique pushBackUnique _x};
^ This is slightly more than 2x as fast as arrayIntersect using the example dataset and the code performance checker on the ESC menu
worth considering if you need to do that operation a lot
I get the arrayIntersect version as 4x faster.
You have an addaction which is applied to everyone in the server but iirc the expression is going to be called locally for whoever hit the button
so just remotexec the ai command and call it a day I’d say
odd, I wonder why the discrepancy?
I'd have expected arrayIntersect to be faster as it's a command, even if it's a dumb algorithm :P
Not sure why our systems say different things...I get 0.0022ms for 10k runs with arrayIntersect, 0.0009ms for 10k runs with pushBackUnique
0.0024 vs 0.0099
Oh yeah, diag_codePerformance doesn't complain about errors :P
Greetings everyone. I was wondering if any of you is familiar with extDB3 ? I am trying to work with it but am hitting a couple points that are confusing to me. I also am new to scripting in general. Which also doesnt exactly help 😅
I just have a couple questions when it comes to setting up the extDB3 and how to check if it can actually make a connection succesfully.
No. It's never faster
SQF is never faster than engine
it was an error in the test
Is there a way to remoteExec the createVehicle command and have it create a vehicle once in a multiplayer lobby? The createVehicleLocal does the job fine but I couldn't get that object be added to the curator list.
createVehicle is global
createvehicle is global, remote exec it will spawn several vehicles depending on number of connected players
you want to add something to zeus list?
Ye, I understand createVehicle is global hence I wanted a similar solution to (A) Create the vehicle and (B) Add it to the curator list
you know that adding an object to the curator list will crash the game?
jk
use
[[_CreatedObject], {
params ["_object"];
{ _x addCuratorEditableObjects [[_object], true]; } foreach allCurators;
}] remoteExec ["spawn", 2];
create a vehicle with createvehicle, then replace the _CreatedObject with the variable storing the vehicle
pretty easy
the problem is the createVehicle command itself is run inside a remoteExec'd sqf script
may you post the code?
ye
Init:
[[_object_class],"\create_object.sqf"] remoteExec ["BIS_fnc_execVM",0,true];``` create_object.sqf: ```sqf
_my_obj_class = _this select 0;
/* other variables and code arguments and such */
_my_obj = _my_obj_class createVehicle _designated_position;```
read this please
Yes exactly
there is no point in having this then so you must change it
I replaced createVehicle with createVehicleLocal
why
your end goal is to do what exactly?
just so it will execute once locally and probably have it added to the curator list 
hmm but the problem is players won't see the vehicle the zeus is editing
and every player will have their own version of the vehicle
- Create a vehicle based on the object class passed
- Have it editable by zeus
all while running globally for players in remoteExec
yes, but you are creating it only local for the zeus here, which means the players playing won't be able to see what the zeus is doing
...why does this script have to be remoteExec'd to all players?
it will not be on their screens
Also you don't need BIS_fnc_ExecVM, you can just use execVM
yep that too
why would you give zeus an editable object that other players can't see?
I don't think that's the intention, just a misunderstanding of what createVehicleLocal does
so my only way is to have it created first in the init file and then pass it to the remoteExec'd script?
I'm not sure exactly what that means but I think the answer is no
you just want a vehicle that can be seen being edited by zeus by everyone on the server right?
yes
yea i learnt it the hard way xd
it gives every player a vehicle that is only visible to them on their side
yep so
no need for remoteExec here
do
init :
[_object_class] execVM "\create_object.sqf";
create_object.sqf:
_my_obj_class = _this select 0;
/* other variables and code arguments and such */
_my_obj = _my_obj_class createVehicle _designated_position;
/* BELOW adds object to curator interface*/
[[_my_obj], {
params ["_object"];
{ _x addCuratorEditableObjects [[_object], true]; } foreach allCurators;
}] remoteExec ["spawn", 2];
because
the command is global
locally executing it will still give a global effect
ah ok ty
anyone ever run into an issue where sound sources created with createSoundSource cannot be heard after respawn?
it could be the complexity of the sounds coming through as well. i'm not really finding much on when could stop a sound source from playing (the same function works on different maps for me)
for the curious, this is my script. it's not doing much
#include "script_component.hpp"
if (!isServer) exitWith {};
private _logic = param [0, objNull];
_logic spawn {
private _sound = _this getVariable "SoundEffect";
_eval = format ["getText(_x >> 'sound') == '%1'", _sound];
_soundref = configName((_eval configClasses(configfile >> "CfgVehicles")) # 0);
createSoundSource [_soundref, position _this, [], 0];
};
... i think it's the respawn screen... on the wiki it says...
"For some unknown reason if at the moment of command execution the player is in first person view and is inside a vehicle, the sound created is greatly attenuated."
does the respawn screen put players in some sort of pseudo vehicle when they first connect?
i guess a trigger with setSoundEffect is a better answer to this problem
is creating and deleting a trigger after its use a good practice? (The trigger won't be running for long)
I like to. Less objects.
Have you noticed any impact from doing this?
generally it's good practice to dispose of objects when you're done with them
i say that from a general programming point of view (not as an arma scripting expert/authority - which im not)
Where are my arma 3 experts/ authorities I miss them
Not sure what you mean, but you should make sure your stuff is cleaned up. Especially things that run in loops (even more so with infinite loops - like a repeatable trigger that never gets deleted). One trigger maybe won't matter, but it's bad practice.
yes I'm specifically wanting to use a single trigger to avoid doing more than one loop
i can proclaim myself an expert
may we hear the answer dear sir
this is below my pay grade
ok
Troalinism setdamage 1;
delete triggers when theyre no longer being used
is there a method for rejecting updates for Units?
as in, rejecting network replication updates sent by the server
i have a scenario with possibly hundreds of agents at once and im thinking that it might cause issues when the server population increases
so i was thinking of fetching updates for only the agents which are within actual render-distance
although, i think this might work more in the way where the server pushes updates to the clients from the networking point of view
so if i can stop the inflow of data and also hide the said agent on the local client until the agent is within render distance
how would I add a loop to a play3D script
class CfgSounds
{
sounds[] = {};
class music1
{
name = "music1";
sound[] = {"\sounds\pa.ogg", 1, 1};
titles[] = {0,""};
};
class music2
{
name = "music2";
sound[] = {"\sounds\generator.ogg", 1, 1};
titles[] = {0,""};
};
};
what i have so far
This sounds a lot like dynamic simulation
dynamic simulation is not per-client, but per-scenario logic
there already are no agents present when players arent present, but sometimes ýou dont want to send the network updates of an agent to a client that is 5km away from that agent just because another player is nearby that agent
but wait...
Each client have it is own dynamic simulation manager, all script commands do affect the local simulation manager.
this would lead me to believe that they are local effect?
well, this is easily tested
just by disabling the player's ability to trigger dynamic sim and then dynsiming the agents
need to try that when i get home
yes
thats why I mentioned it
needs to be tested
although im pretty sure dynamic simulation wont block packets
but we SHALL see
i might be wrong
nope, here it says then
To achieve best results it is suggested to manage dynamic simulation on one place - ideally on server.
so who knows
we need Dedmen in here
Does dynamic simulation disable simulation of far objects client-side or server-wide or both?
from what I have observed (this is like 1.5 years ago so I might be recalling the wrong memory) I was the client-server and things were static for me when they are far away from any player, but I'm not sure about dedicated servers
this is the problem. Im not trying to disable something when theyre far away from ANY player, but that their disabled for a client that cannot possibly see them
im alrady optimizing my mission to the extent where the agents are not present when there are no players around, so that part doesnt benefit me at all
a client that AI can not see?
no
If client B is 200m away from Agent A and client C is 5km away from Agent A, i want A to be enabled and behaving for B, but not C
but Arma 3 sends positional updates for players (for obvious reasons) even on units they would not be interested in
so yeah you need a better way
I dont need this part of Arma 3 for my scenario
so i was wondering if there was an engine commmand or similar to discard pushes made by the server concerning certain units
the closest person I know about knowing something about such a thing is @hollow thistle
I'm actually not sure your question is about dynamic simulation or even scripting at this point
no he is doing a splendid idea
but its execution is too far from my level
he needs someone high tier lol
Not saying its a bad idea. But that's really not even about simulation ranges, but what the server packages in each frame to clients
i dont think the server hands out packages per frame
there's probably an internal time-condition to keep the packets-per-second limited to some reasonable range
I would have tagged dedmen if its not for the rules
Yeah per frame is a bit too much on the bandwidth innit
could be, depending on server performance
Have 60 players, server just dies
rather it would be the server Dossing the clients
the client end would probably freeze
not the server
Well say its a crappy server that runs like 20 fps
Its not going to ddos but its going to die
yeah, but if it runs at 20fps, then that's perfectly reasonable
20 updates per second is reasonable
Yes
but if youre swapping between 20 updates per second and 3600 updates per second
then that's just unreasonable
anyway, BI has this part handled which is evident from the server-traffic
Depends on the architecture. But generally there is a tick rate and updates are sent out at that rate
but returning to topic, there doesnt seem to be a way of discarding updates of a particular agent server side
There is good info there
depends on the software-design
the server doesnt need to update clients of the information it processes on every frame
that would be silly
It talks about each frame in that link
Yes I'm trying to figure out a way but I don't seem to have reached something
it says the maximum number of packets per frame
so when the server needs to send packets, how many packets does it send before it moves to the next frame
No it contains the definition and flow of each frame.
not how many packets it sends every frame
where?
Ctrl f, then type "frame"
do you mean this?
this post from 2009
with no source
yikes
ok, lets go over some basics
No, I sent the Biki article with a lot of info
if you have the cycle-time, you would really want to run your physics simulation at a higher framerate
but you dont want to send updates of that physics simulation on every frame
so you send updates to clients, for example on every 3rd frame if you simulate at 60 cycles per second
that's when you get 20 updates per second
then on the client-end, you interpolate between the updates sent by the server
and do some prediction as to where the unit would be moving if it continued moving in the same way
and bam
you have fluid movement and fluid simulation without running some ridiculously high update-rates from server to client
downside is that the position isnt always super precise and if packets fall behind or theyre not handled correctly in order, you get rubberbanding and what we usually call "desync"
That's a nice wall of text, but you're talking about achieving this with the internal scripting engine
Soooo
Yes
that doesnt relate to the topic
also, this topic is INCREDIBLY old
It does? Updates are send less the further you are away as client
i would not be surprised if things have changed since then
ah, it was already dealt with
my bad
Ey what?
He has cometh
POLOX may you also please help us here
im not sure if polpox knows
Give it a shot
is there a way to stop the server from sending updates to clients of objects that are too far away from the clients
That's a bit broad give more details
either by some internal logic or by simply discarding all updates of specific objects
i'd be able to do the logic myself

ok, simply put, i want to tell the server not to send updates from a specific object to a specific client
He basically wants units updates to be sent to the players that are close to the units only not players that are far away
I... don't think I can say I know it
some combination of createVehicleLocal and publicvariable?
but vehicles are not agents
and i have specifically agents
What kind of server side objects you don't want to sync?
agents
And is that even necessary? Do you have a LOT of agents that would kill the performance?
i have A LOT
He has the nato altis invading force
Ah... 
I'm still confused why there is doubt the server doesn't do this per the previous info sent (albeit old)
i have from 1200 to 2400 agents server-wide
Perhaps just enableSimulation in server side?
maybe, but i'd still want to send packets to some specific clients
because some clients are close to the agents and the updates are relevant, but some clients are so far away that the updates are just spam
i understand that from the design nature of arma there comes a need to keep every player on the server updated on every object and agent, but i would like there to be a way of changing this behaviour if the scenario calls for it
since it's not strictly necessary to all scenarios
just even a command to tell the server "Dont send updates of this object to this client"
and then being able to reverse that change
Hmm. I don't think I can solve it, or I can tell it is even possible or not
i dont think that should be awfully difficult to solve
if there are the necessary people working on the game anymore
I'm certainly not a big person and my request is not big, so it would most likely never be added
but one can always hope
Yeah its too big of a framework thing
this would be a huge help to people trying to optimize their missions for LARGE amounts of units
Yep
it's really not a big deal to do
well, i dont know how RV4 works internally on that department
but if it's well designed, it would not be a big deal
Well I think its either dedmen or killzone kid or veteran29 who might have an idea about this
whatever way you use to collect updates or determine the receiver of the updates, in that method check if the receiver of the update is paired with the target of the update in this ignore list/hashmap/whatever data structure you prefer and if so, ignore the update
there, done
then a method of removing pairs from this ignore-"list"
yeah, but we cant tag people
and im not looking for a ban right now
all of this would be done in engine-side, ofcourse, a fool would do it in an interpreted script engine...
looks at panda
oh no...
This would have greatly helped in my biggest mission that I have made, darn
I'm also wondering about the performance impact of evaluating and filtering through each entity in the update rather than just taking it from the server (client or server)
Tbh, I'm not even convinced it's a good idea
the performance impact of sending data over the network is astronomically higher than that of a simple hash lookup
we're comparing peas and planets here
yeah, well, that's just like your opinion, man
Its a stupid idea but did you try enablesimulation false on a client in a server?
Yeah we are lacking it here
opinions backed up with facts make it a valid argument. Otherwise it's just that... an opinion
I was just about to ask you for numbers on your assumptions.
Come on elon just bought Twitter chill guys
assumption of what?
Well, that the documentation is wrong, and that it is necessary to circumvent the server updates with something in the scripting engine, and so much more
i never said the documentation is wrong
But honestly. You're being a bit confrontational about it for some reason, and I have no skin in the game. So I'm just gonna let ya go
Have a good night
it IS necessary to block engine updates from script engine in this case
and so much more
im confrontational about it because youre not making any valid arguments
just launching baseless assumptions
I dont think that's fair to say when I provided documentation related to how the server determines what is a necessary update and what isnt
but that is not nearly important in this case and no you didnt
ok, go sleep
good night, sleep tight
My case still stands
In my humble opinion, there should be a way to ignore network updates of specific objects to specific clients
this should probably be a BI forum post at this point rather than a discord discussion
we should have created a thread
cant create threads
Good day. What are advantages of functions-as-files in compare with Inline functions?
https://community.bistudio.com/wiki/Function
well in general in-file functions are easier to edit
and you can add comments without using comment command
that very slightly affects performance
in-line can be directly called, in-file needs a set of commands to be called
but overall in-file are easier to deal with
more clean code
it depends if you have access to mission files too
Thank you. Any other opinion?
well
please do check this
and
check this
when you do execVM repeatedly for a file, you will make the game read it each time, which is slow
so you can for example do
My_fnc_Cool = compile preprocessFileLineNumbers "myScript.sqf";
and whenever you want to use it you can do
call My_fnc_Cool; //or spawn My_fnc_Cool;, depends on your use case
more efficient
do that when you want to run the same sqf file more than one time, if one time just use execVM
Sorry, there is a little misunderstanding, I know how funcs work and how to write and use them, it's just that I walked functions-as-files route from day one (the first thing I saw in tuts and examples I guess), and now was struck by question why would I do that in the first place? A good question indeed, because I have no answer to that, it's just how it is. I was asked why don't I just write them as global variables inside one large sqf file instead of building 'functions' folder tree - no answer to that either. I tried biki - it just says 'well, you can do that or that' without explaining the difference. That's how I ended up here (=
Now I do know that functions-as-files are compiled firsthand and that it is compileFinal, is that it? Anything else maybe? Why would one prefer functions-as-fiels over inline code variables then?
Maybe I underestimate these advantages?
no
and now was struck by question why would I do that in the first place
Better organization.
Now I do know that functions-as-files are compiled firsthand
what do you mean by "firsthand" ?
Before other scripts, before init.sqf run for example
well it really depends on your use case mate
Thats just a preInit eventhandler, you could add your own eventhandler and compile your scripts there, before init.sqf and others
you can write them all in a single sqf file
then execute that sqf
so that they become global variables
that you can execute in game
it just depends on your use case
and that's "bad" 😄
if you have a 1000 line function however
That is my question (+ "bad' why?
Bad organization when everything is just thrown together in the same bucket.
Bad modability (CfgFunctions you can replace single functions if you want to mod something, if its all in one large file not so much)
they may be local only if you f-up
they may be overwritable if you f-up
they may become illegible if you f-up (or keep them piled-up)
etc 🙂
And in terms of perfomance? no difference?
no performance difference
Got it, thank you
Well unless SQF bytecode maybe, depending on how the compilation happens.
But if you are thinking about putting your scripts into a single file, you are not thinking about bytecode
Yeah, gotta keep that in mind, thanks
Thanks, everybody,
If you are really persistent
About putting everything in one place
Put only small functions in one place
Give large functions their own files
They deserve it
I assumed he expected this
why persist in going the bad way when the good way is shown 😛
A single missing ; will disable a lot of functions potentially
Gotta know what you're doing instead of blindly following 'good practice' xD
And also I'm working with 'dark side' 'just go an easy way' colleague who asks smart questions and has a point. Just wanted to sort things out for myself.
Good practice is always good
Gotta know what you're doing instead of blindly following 'good practice'
I concur! 👍
yes but "why" is important 🙂
Bad practice is only worth it if you going to ensure it will be fun
And worth it
we spoke with Zeus this year, and we agreed on that
"you should not inline things"
yeah… """but why?"""
so you know and don't blindly follow indeed - or repeat the same "bad practice" in a different way 🙂
just split all of your functions into their own files and define them in CfgFunctions
There is no reason to otherwise than for testing
i dont care what CBA says
also, i think the security aspect of CfgFunctions needs to be brought up too
Like, here @ebon citrus ?
nica you must read this first
.
i meant the finalcompile feature of CfgFunctions
as in, you cant replace CfgFunctions scripts from runtime
or so im told
they can be recompiled if you enable it, exactly
but an inline function can be replaced just by assigning the function variable again
as such, much more prone to exploit
but i am me, i put my functions religiously in CfgFunctions
Hello, who has a script for the infantry spawn during the spawn trigger so that the infantry fills in the houses on the first and second floors
how you put your functions is really irrelevant. whichever way is more efficient for your workflow (and the workflow of anyone else you want working on the project) is best
inline functions should perform a tiny bit better since they are located in a namespace with less data
so your getVariable would produce a result tiny bit faster
so the points made by the functions library biki article are irrelevant?
No they don't perform better.
Functions don't know where they are.
What do you mean namespace with less data?
so your getVariable would produce a result tiny bit faster
You mean namespace with fewer values == faster? No thats not quite how hashtables work. Adding more values might even make the lookup faster, if you get over the threshold to get more buckets allocated.
in a way they do perform better tho
not related to what QuikSilver said
but because CfgFunctions also create _scriptName and _scriptNameParent variables... 😅
basically these lines:
private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'BIS_fnc_GC'} else {_fnc_scriptName};
private _fnc_scriptName = 'BIS_fnc_GC';
scriptName _fnc_scriptName;
Can you disable them with CfgFunctions entry?
initFunctions has a check for different header "types" so I assume there's also one without that?
Never actually tried to do that
¯_(ツ)_/¯
So namespaces (missionNamespace, localNamespace... etc) are based on hashtables rather than on plain arrays, interesting, thanks, that's nice to know.
I think you can based on a quick look I had:
headerType = -1
yeah it was also documented on the wiki 🤣
I read the file 
is there a way to check currentweapon of the vehicle in gunners position like cannons and such, i tried currentweapon gunner vehicle player but it returns the gunner side arm
because you ARE getting the weapon of the unit...
gunner vehicle player gives the gunner itself...
I don't think it's possible to know which vehicle weapon they have selected tho 
@versed widget use currentWeaponTurret
thanks that will do
Hey everyone, I am trying to figure out, if it's possible to add a music track into the SOG "player", using mission side scripts.
Anyone has any idea if it's possible? I would normally script it to the heli, but the SOG has such a nice menu for it
Is it possible to check the status of animateSource?
animationSourcePhase
Sweet, thanks
Hi, my AI squad members have a laser/light combo attached to their rifle. Is there a way to activate their laser or light via script?
Many thanks guys
Hmm, it looks like the AI cannot switch between laser and lights mode on an attachment
I am using a laser/light combo where I as a player can press a button to switch between modes but it seems for the AI it can only activate one mode with the attachment. Is that correct or am I doing something wrong?
Just for clarification, I try to switch between light and laser for the AI in my squad. Those units have a laser/light combo equipped on their rifle.
laser/light combo is not a vanilla equipment, so maybe the mod is doing something special here
oh, i see. i guess in this case it is not possible to alter the function of the attachment from laser to light.
It might be possible by calling the function the mod uses to switch, but it might take a bit of investigation to figure out what that is
hello there, i have this command:
**this setUnitLoadout (missionConfigFile >> "CfgRespawnInventory" >> selectRandom ["UA1", "UM1","UE1", "UE2", "UE3", "US1"]); **
I want the AI to execute this command on it's init, when they respawn, so AI will be like changing classes.
And i also want to make so that this only work for one side (the other side, will have other classes to select).
Can someone help me on how to do this?
Any idea how to find out which function it is calling?
It could be mentioned somewhere in the config of the weapon or the attachment. Alternatively, you might be able to find it by just browsing all the functions added by the mod (or any of its dependencies) using the function viewer.
Keep in mind there's no guarantee this will result in finding something that works. It's only a possibility.
Ok, thank you. I'll give it a try.
how do the AI respawn exactly?
i have the multiplayer respawn modules named as respawn_side_x
This way, both players and AI can respawn on them.
If it's multiplayer, then make sure only the server runs that code
Whether it be a local server or dedicated
You can check with isServer
Otherwise it runs for every client and the server
The init field runs on every device where the object gets initialized
The only difference of inline AFAIK is less jumps and larger compiled file.
_unit = "I_Soldier_AR_F" createUnit [[9142.09,21661,9.53674e-007],createGroup[resistance,true]];
sleep 10;
selectPlayer _unit;
Is this supposed to work for taking control? It is not working for me. It works if I console myself into an editor placed unit.
https://community.bistudio.com/wiki/createUnit the syntax you're using does not return the unit, use the first one
A mod a group I'm in using has a vehicle that doesn't have a cargo variant. So I made one you can spawn in as a composition on a dedicated server
this removeWeaponTurret ["LIB_M2", [0]];
this setObjectTexture [2, ""];
this lockturret [[0],true];
getPos this nearestObject "Building" attachTo [this];
this lockCargo [4, true];
this lockCargo [5, true];
this is the init of the car
it works
The attach to attaches a box in the back to make it look like a cargo vehicle
how would I modify this, to allow it to work it multiple boxes if I wanted to decorate it further
I can't just name the boxes because then it wouldn't work on a multiplayer server if more than one was spawned at ones, right?
is EachFrame supposed to target 50hz sim rate in all cases or does it use graphic rate in some cases?
netId is for MP, though I'm not sure what range of objects are included
wat?
it literally runs every frame
It's easier to name the vehicle and then do ...
if (isServer) then {
this attachTo [MyVehicle, ...];
this setDir 123;
};
```... in the decorative object's init. Bonus points if you make it a function and call that 🙃
there's no guarantee that MyVehicle is defined before this object
According to wiki there is a different frame rate for simulation and graphics. For servers, there is no graphics, so...
it always means simulation frame
Never had that problem; probably because I place MyVehicle first 🤷♂️
also there's no different frame rate. there are different timings
What is the difference? I read that server is capped at 50hz. I don't know what is for client.
you can remove the server FPS cap
What is the difference?
objects have different simulation frequencies. if your FPS is higher than object update frequency the game skips the simulation and extrapolates the object position for rendering based on their velocity, which is the render time scope position.
Okay. That clarifies how the sim vs render time scope works. The wiki page on it is very vague.
Is there any way to get the view distance defined in graphical user config instead of viewDistance command ?
no
would i need to know how to script/code to create a particle system? or is it doable by tweaking some template and making 2d images or 3d model parts?
if you want to create and spawn your own particles you need both
if you want to spawn the vanilla particles scripting is enough
if you want to modify the vanilla particles you need config and model making
also now sure what you mean by "particle system"
like.. if a plastic box is shot at, or whatever object. it destructs, and delete the original object "source of particles" and sprays/bursts its "part1, part2 etc.p3d" on the floor.
basicly an explosion of premade parts if its 2d billboards or 3d models..
allready made the models, but atm it doesnt matter if it bursts cubes, just so i could tweak something to make it fit the item.
if you have your own object, object destruction effects is pretty much config only
no need for scripting
so just in the config.cpp and CfgCloudlets?
yeah. I think some stuff should be added to CfgAmmo too
I don't remember very well
hmm
you can ask in #arma3_config for help
ok, well thanks for your time. appreciated
this might be a dumb question but is it possible to add a keyDown event handler that works in the arsenal? I'm not quite up to speed on GUI stuff and the event handler doesn't fire for display 46 while in the arsenal. I see a bunch of controls get added to Display # -1 but adding an event handler to findDisplay -1 does not seem to produce results.
Should I assume that if I want something similar I need to modify the function itself?
add it to the arsenal's display i guess
arsenalOpened scripted EH gives you the display
oh my goodness gracious does it?
i skimmed that page but didnt see it gives the display
thank you
The example doesn't use it but it's in the table.
yep there it is _display
Hello. I have a condition:
a3a_var_started && (([east,0] call BIS_fnc_respawnTickets) < 1 or ([west,0] call BIS_fnc_respawnTickets) < 1);
Activation:
"SideScore" call BIS_fnc_endMissionServer;
But, for some reason, when the tickets run out, the game sometimes gives a defeat to the team that is the winner.
How can I do this in one trigger to add points to the winning team without creating a second trigger?
display should also be stored in uinamespace getvariable ["RscDisplayArsenal",displayNull];
because SideScore doesn't look at tickets, but actual ingame score, you can do a hacky approach and just add some big number to the winning side (you'd have to find that out yourself, with the tickets) https://community.bistudio.com/wiki/addScoreSide, or you can make your own "endMission" function that ends based on tickets
Yes Yes. I understood it. I don't understand how to add a sidescore to a team that has tickets left with a script. It would be desirable to make it in one trigger.
I need something like this...
if ([east,0] call BIS_fnc_respawnTickets) then (west addScoreSide 9990) or if ([west,0] call BIS_fnc_respawnTickets) then (east addScoreSide 9990);
oh wow the scripted event handler did exactly what I needed.
[missionNamespace, "arsenalOpened", {
private _display = _this # 0;
_display displayAddEventHandler ["KeyDown", {
//stuff
}
}];
}] call BIS_fnc_addScriptedEventHandler;
Should I go through the effort of removing the event handler after the arsenal is closed?
disregard I got it in the state that I want it
I have this code: sqf { _bodyPart = ["Head", "RightLeg", "LeftArm", "Body", "LeftLeg", "RightArm"] selectRandomWeighted [0.47,0.69,0.59,0.55,0.61,0.58]; _dmgType = selectRandom ["backblast", "bullet", "explosive", "grenade"]; if (typeOf _x != "VirtualCurator_F") then { [_x, _damage, _bodyPart, _dmgType] call ace_medical_fnc_addDamageToUnit; _tip = selectrandom ["04","burned","02","03"]; [_x,[_tip,200]] remoteExec ["say3d"]; } else { [_x] call ace_medical_treatment_fnc_fullHealLocal; }; } forEach (_nearentity);
When I run it - I get this following error in the server log without any damage being done to the player:
[ACE] (medical) ERROR: addDamageToUnit - badUnit [Z1,0.01,"RightLeg","grenade"] [local false] Here Z1 is the variable name of the player.
you have syntax errors, also i suggest you just end yourself manually, e.g
if ([west, 0] call BIS_fnc_respawnTickets <= 0) then {
[east, west]
} else {
[west, east]
} params ["_winner", "_loser"];
["GroupLost", false] remoteExec ["BIS_fnc_endMission", _loser];
["GroupWon"] remoteExec ["BIS_fnc_endMission", _winner];
Thank you!
What does GroupLost and GroupWon mean?
IDK, that's what BIS_fnc_endMissionServer uses
Understood. Thank you.
We have a multiplayer game, is it better to use BIS_fnc_endMissionServer ?
well
if you read the biki
it will tell you the difference
between endmisison and endmissionserver
check CfgDebriefing
in config viewer in eden editor
Hey, is there any way to access 3den Editor comments from within a scenario? E.g. writing comments in 3den Editor which are visible to Zeus
you have a random bracket forEach (_nearentity])
and _damage is not defined
the _damage is defined in the code above it
I fixed the typo of forEach (_nearentity)
are you running this on the server?
if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_2("addDamageToUnit - badUnit %1 [local %2]", _this, local _unit); false};
if the unit isn't local then it will give you this error
[_x, _damage, _bodyPart, _dmgType] remoteExecCall ["ace_medical_fnc_addDamageToUnit",_x];
this will call the function on the player's machine
if you have code that affects a player unit expect it needs to be run local to the player
still check the documentation
ah ok
ace devs are doing you a favor by giving you an error code, you can always open up github and ctrl+F to find why it's happening
badUnit being the error code in this case
In A3, isn't there a way to get the index of the current event handler?
_thisEventHandler
_thisEventHandler
what i wrote should be ran on the server only
hmm
I thought
there was a way
to create keys
using a function
is it not possible to create a key?
What's with "BIS_fnc_findSafePos" sometimes returning only the first element of a position instead of an array?
I was using it in an attempt at a foolproof way of finding a totally empty position. It seemed to work in A2, but in A3, in sometimes returns just the first element in a position array, instead of a whole array.
Anybody have advice for finding an empty position with 100% success? Devoid of any map or editor objects, or objects spawned in during the game, including vehicles, men, and buildings.
you are sure there are empty positions available?
you mean it only returns the x coord?
yes
I tested a mod a while back that turns a backpack into a tent. I had no problem with the placement unless there was no actual place to fit it.
it only happens like 1 out of a hundred times
maybe try findEmptyPosition instead
How come the "fired" event handler sometimes has a "_thisEventHandler" of "any", thus causing an error?
Are you sure you're not modifying it elsewhere?
Are you sure it's returning a number to you?
If you pass an object as center it could be returning the object (when it doesn't find a safe pos)
according to the docs, it returns the center of the map
you can decide what it returns when no pos is found by using the parameter #8
or param #9 if you start counting from one 🙂
ugh so one of the mods we use (R3F Logistics) that has been dead for a bit is now broken... yay. With our unit so dependent on it for our logistics system I may need to just make a new one. Can anyone point me in the right direction of scripting a gui with a money system that spends money when a vehicle or object is created. Pretty advanced ik it's just never attempted something like this on this scale, and any help is appreciated.
R3F logistic is just a collection of mission scripts no? Can't you just fix whats broken in the script?
It does a lot more than the factory, and I am very inexperienced. Apologies idk why I called it a mod. The current issue is when players use scroll wheel to drop a item they are using it stays attached to them.
Not at my computer so I can't check for you rn. But can't you just look through the code for a bit and try to find where a detach somewhere and see what's broken?
Logs might even be telling you exactly what is wrong.
Will try we haven't touched anything besides the normal config, and even then we haven't touched it in months. It just started out of the blue.
It also does it randomly one op a player can drop items, and the next he can't, but someone else can
If R3F hasn't changed you might have changed a mod or setting and created an incompatiblity
Be sure to also start checking logs next time it happens. (Some people do disable logs for better performance so keep that in mind and turn em back on)
5:41:47 Scripting function 'advlog_fnc_detach' is not allowed to be remotely executed
5:41:47 User Comm. Jonah (76561198133665042) tried to remoteExec a disabled function
that's related to your server setup
not the function itself
how do I allow it?
how can I apply it here?
nvm I see what you mean
you chads ty for the help @little raptor @steel fox
I will ask the scripting guys if they know anything. But we used it daily on our serveur without any issue.
it wound up being a mission side error
👍
We had to put this in our description
class CfgRemoteExec
{
class Functions
{
/*
Operation modes:
0 - remote execution is blocked
1 - only whitelisted functions / commands are allowed
2 - remote execution is fully allowed, ignoring the whitelist (default, because of backward compatibility)
*/
mode = 2;
/*
JIP:
0 - JIP flag can not be set
1 - JIP flag can be set (default)
*/
jip = 1;
class BIS_fnc_someFunction
{
/*
Allowed targets:
0 - can target all machines (default)
1 - can only target clients, execution on the server is denied
2 - can only target the server, execution on clients is denied
Any other value will be treated as 0.
*/
allowedTargets = 0;
//Override the global setting (defined in class Functions) for this function:
jip = 0;
};
};
class Commands
{
mode = 1;
class setDir
{
allowedTargets = 2;
jip = 0;
};
};
};
might be something to put in a doc to do for setup we have been using r3f logistics for nearly a year, and never had to do that till now
if you put that exact thing, it's nonsense
all you needed was:
class CfgRemoteExec
{
class Functions
{
mode = 2;
jip = 1;
};
class Commands
{
mode = 1;
};
};
ah
class BIS_fnc_someFunction
that was just an example and no such function exists
ight ty
I managed to get it working using an even simpler example.
I managed to get it working. No $PBOPREFIX$ was needed, nor was the P drive~!!!
did I say it was?
hey, do i need to remoteExec setAnimSpeedCoef
if i want to "freeze"a specific player ?
yes thank you, i see that is says GA but its LE so i guess it needs remoteExec?
Yes
Setting animSpeedCoef to 0 might have strange effects. You should also consider attaching the player to a static object or disabling simulation on them (note: disabling simulation might make them immune to damage)
Sigh... you dont need to use p drive, you WANT to use it
someone told me it was not optional, but it does appear to be optional. I was able to use the "file" attribute at the FUNCTION level to specify the location of my functions as files individually.
also, the name of the folder in which the addon resides seems to be irrelevant
👍 thank you for the help
love this
umm I just got my P drive working, so far as I can tell I think it's useful to: 1) enable you to recompile functions in-game 2) have all assets pre-unpacked to make loading times faster
not sure what else it's really needed for
it's not really needed for scripting. but for model and terrain making it's a must have, otherwise some tools can't find the assets you use
you can recompile functions if you simply put them in a mission folder and build your scripts in that mission
that's how I personally make my mods
Could someone help me out? Im not good at coding. The function for open my doors/hatches (vehicle) is not working properly. If I turn out or in nothing is gonna happen but if i open the door manually (from outside per user action) it is opening but will close immediately after it opens.
fn_openHatches.sqf
params["_v"];
_v = _this select 0;
while{alive _v} do{
if (isTurnedOut (_v turretUnit [8])) then {
if (_v animationPhase "door_left" < 0.5) then {
_v animateSource ["door_left",1];
};
} else {
if ((_v animationPhase "door_left") >= 0.5) then {
_v animateSource ["door_left", 0];
};
sleep 0.5;
};
};
Config:
class AnimationSources: Animationsources
class door_left
{
source = "user";
animPeriod = 1;
initPhase = 0;
};
model.cfg:
class Animations
{
class Rotation
{
type = "rotation";
memory = 1;
minValue = 0;
maxValue = 1;
angle0 = 0;
angle1 = 1;
};
class door_left: Rotation
{
type = "rotation";
source = "door_left";
selection = "door_left";
axis = "door_left_axis";
memory = 1;
sourceAddress = "clamp";
minValue = 0;
maxValue = 1;
angle0 = 0;
angle1 = -3.05;
};
};
class UserActions
{
class Open_Door_Left
{
displayName = "Open Left Door";
position = "door_knob_left";
radius = 3;
onlyForPlayer = 0;
condition = "this animationPhase 'door_left' < 0.5";
statement = "this animate ['door_left', 1]";
}; ```
use ```sqf and ```cpp for syntax highlighting of scripts and configs respectively
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
(also please edit your message, don't make a new one)
uh sry yes
your sleep is inside the else scope, not while
also don't do it that way
you're keeping a while loop always active
you can just run that script when the user opens the hatch
for example, you can add TurnIn and TurnOut event handlers to your vehicle:
class EventHandlers {
class JakeEatsASteak {
TurnIn = "[_this#0, 0] call jake_fnc_turnInOutTank1";
TurnOut = "[_this#0, 1] call jake_fnc_turnInOutTank1";
};
};
jake_fnc_turnInOutTank1:
params ["_vehicle", "_phase"];
_vehicle animateSource ["door_left", _phase];
ofc you only need the function if you need to do more than animation
if that animation is all of it no need for that small function
just do:
class EventHandlers {
class JakeEatsASteak {
TurnIn = "_this#0 animateSource ['door_left', 0]";
TurnOut = "_this#0 animateSource ['door_left', 1]";
};
};
Looking for a recommendation here on a good way to call custom functions in-game as a player. Use case is admin-functions to be called to do various things on a moment's notice (e.g. "teleport player") etc....
I could build a UI but that seems like overhead... binding to custom keys also seems inflexible and non-robust
you can use actions or communications menu
comms seems interesting..
I recommend comms menu
radio trigger, some object with addAction, links in diary on the map...
yep that seems good
Leopard
so then the admin would press 0, 9 and see the custom script commands I've got
only thing would be how to pass parameters into it
I'll read your suggested Wiki articles.
@marsh drift also if you want to customize script to handle all doors for different turrets, you can do:
params ["_vehicle", "_turret", "_phase"];
private _anim = call {
if (_turret isEqualTo [8]) exitWith {"door_left"};
if (_turret isEqualTo [9]) exitWith {"door_right"};
//etc.
};
_vehicle animateSource [_anim, _phase];
class EventHandlers {
class JakeEatsASteak {
TurnIn = "[_this#0, _this#2, 0] call jake_fnc_turnInOutTank1";
TurnOut = "[_this#0, _this#2, 1] call jake_fnc_turnInOutTank1";
};
};
aahh ok im understanding this right now. I have added emissive light rvmats and im doing it the same way with hide/unhide and while loop... So i can use it the same way here?
class JakeEatsASteak
{
TurnIn = "_this#0 animateSource ['door_left', 0]";
TurnOut = "_this#0 animateSource ['door_left', 1]";
isLightOn = ""; ?
};```
what do you mean with customize? I have another door and a front hatch
I don't think there's an event handler for lights
I mean you can use that single function to handle both hatches for you
based on the turret path
how do you hide and unhide the lights?
and what is your current script?
config
class Eventhandlers: Eventhandlers
{
class lightstoggle
{
init="if (local (_this select 0)) then {[(_this select 0), """", [], nil] spawn jzra_sb_fnc_lightToggle;}";
};
};
class CfgFunctions
{
class jzra_sb
{
class scripts
{
file = "\jzra_sb\scripts"; // file path will be <ROOT>\My\Category\Path\fn_myFunction.sqf";
class lightToggle
{
file = "\jzra_sb\scripts\fn_lightToggle.sqf"; // file path will be <ROOT>\My\Function\Filepath.sqf";
};
};
};
};
fn_lightToggle.sqf
params["_v"];
_v = _this select 0;
while{alive _v} do{
if (isLightOn _v) then { _v animate ["lights_hide",1,true]; } else { _v animate ["lights_hide",0,true]; };
sleep 0.01;
};
well looping is very bad.
but anyway afaik there's no event handler for lights
idk if there's a native engine solution for that, but if there isn't, you can use user action event handlers.
see:
https://community.bistudio.com/wiki/addUserActionEventHandler
for example, create a post init function that does this:
if (missionNamespace getVariable ["jake_headlights_action_EH", -1] != -1) exitWith {}; //don't add the EH if it was already added
_EH = addUserActionEventHandler ["headlights", "Deactivate", {
_v = vehicle player;
if (isLightOn _v) then {
_v animate ["lights_hide",1,true];
} else {
_v animate ["lights_hide",0,true];
};
}];
jake_headlights_action_EH = _EH;
ofc it only works with player controlled vehicles...
you can ask in #arma3_config to see if there's a better solution. I personally don't know of any, but I'm not a model maker either 
thank you for all of this will try it out now 😄
np.
also this is a list of all event handlers:
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
if you need an event handler for lights you can make a feature request on Feedback Tracker: https://feedback.bistudio.com/project/view/1/
Actually, the problem was I was using _thiseventhandle inside of code spawned during the event handler.
However, now my problem is the method I was using in A2 to force AI to fire their grenade launcher, isn't working in A3. _unit selectWeapon _muzzle; _unit fire [_muzzle,_muzzle,_mag]; Any suggestions?
[aaaa, "GL_3GL_F"] call BIS_fnc_fire;
aaaa forceWeaponFire ["GL_3GL_F", "Single"]; both seem to work in my (limited) testing
I'm going to try that. But also, right now I'm setting the velocity of the projectile to get it to go where I want them to shoot it. Is there any simple way to get Ai to fire upon a specified position?
_unit fire [_muzzle, _mode, _magazine];``` seems to work (at least to some extent) for me 🤔
this works in A3
if not that then try forceWeaponFire
I want them to shoot at a position, not at an object.
invisible object
:)
make them shoot at a grass cutter
given that official tracers module spawns an agent, disables its animation and just rotates the entire model...
I can't get them to successfully shoot at invisible targets. Also, the ones built into arma 3 block both bullets and unit movement, so they're useless.
yez, because I am not talking about actual invisible object
like i said
grass cutter, helipad (invisible)
grass cutter?
invisible helipads are seen and used by AI. It's better practice to use createVehicleLocal and hideObject if you absolutely need an object
or check the box in the editor to hide it
can either of those objects have a side so that ai automatically can detect them and fire upon them on their own?
you can set your own variable to them
thank you
thanks
I don't get it
what's the point of it
It's a separate question related to my suppression system, which I haven't mentioned yet.
I've got an awesome suppression system I was using in A2, but it uses invisible targets with a side that AI can detect and fire upon on their own.
Tried using CBA invisible targets, but they don't seem to work.
I think CBA or ACE3 have a suppression module already
Mine's better. Presuming I can get it to work in A3.
Ok, so I've got them to shoot smoke grenades like this: isNil { _unit setVariable ["SMOKE_EVENT_CONSTANTS",[_vel,_vv] call func_VEC3_scale]; _unit addeventhandler ["fired",{ (_this select 6) setVelocity ((_this select 0) getVariable "SMOKE_EVENT_CONSTANTS"); player sideChat format["shooter: %1, projectile: %2, event handler: %3", (_this select 0), (_this select 6),_thisEventHandler]; }]; _unit selectWeapon _muzzle; [_unit, _muzzle] call BIS_fnc_fire }; However there's a problem. They don't fire the nade immediately, meaning the fire event is capturing other projectiles apart from the intended smoke grenade.
filter by ammo/magazine? params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; so _this select 4/5
Oh my god, nade rounds are absurdly bouncy.
@drifting sky https://community.bistudio.com/wiki/doSuppressiveFire have you seen this command introduced in a3
I want control over the size of the area they fire upon
also over the length of time they're firing
you can give each unit a random pos within a radius to fire upon
yeah looks like time is always going to be random
is the fourth element of the position parameter its size?
also, will they fire grenades and rockets?
my A2 version they fire anything they got, grenade rounds, hand grenades, rockets. The works.
i don't think doSuppressiveFire takes 4-element arrays, docs ask for PositionASL. I believe they meant "assign a different targets with random offsets from the center to different units". Also i don't think bots would use everything, at least in my (limited) testing grenadier was only shooting his rifle. And with the rifle mags removed he refused to shoot;
I really need to find a way to get invisible targets to work correctly.
Tell me, is it possible to make it so that the players in the north of the Arma 3 game have the same nickname in Discord, Team Speak and in the game itself? Something like a white list, but I need to implement a discord.
My players use out-of-game communication between themselves, although we use TFAR. I can't find these players in my Discord channel because their username is different from their in-game and Team Speak nicknames
An automatic integration between Discord and Arma is not something I've ever heard of and I think it's unlikely to be possible.
As a Discord server admin, you could change the players' server nickname to match their ingame name, after asking them.
Or just ask people to use the same name.
You could just enforce your rules and tell them to conform
Sounds like an organizational issue
This does not work. There are rules, but it is not always possible to track everyone. I'm thinking about the procedure for registering and manually adding player names to the white list of the server.
Possible? Yes, but it would be much more effort than just enforcing your rules as the above said
But I would like to know if there is a discord bot that can do this?
that can do what, precisely?
Add player names to whitelist
yes
He wants to automate name recognition across all three platforms. TS, Discord and Arma
you can make a bot to add names to a list pretty easily
Yes Yes. right.
it's getting that data from elsewhere that's the hard part
No
You should have enforced your rules from the beginning
Oh, I'm glad it's possible!
They've been fixed right from the start.
The fact is that a lot of people come every day.
Then I really don't know what to tell you
You could find a bot that enforces or changes names on Discord and maybe extract the data. You could do a server whitelist that looks for specific names
But you're going to end up making people pissed no matter the decision you decide
Why will they be angry? They violate the rules of the game project, and the rules have long indicated everything and they are.
Because your people are not following the rules and want to do what they want
There are problem players everywhere, this must be accepted as a fact. My task is to minimize their number. Thanks for the reply, I'll try to come up with something.
The only way I can think to do that is by requesting steam id's from discord users and pulling profile name data from the server to be sent back to the bot. On the other hand, you can require users to submit their arma profile name upon joining your server and turn off the ability to change nickname. One of these is the better choice.
You can make them having permissions to join your discord server/game contingent on them providing you this data if it's that important. This is not something that should involve arma scripting. @lapis ivy
you can either sacrifice dozens or more hours of your time coming up with an "automatic" system that needs upkeep or enforce your rules.
So I’m trying to make a wave combat scenario for some people and I’m struggling at keeping the wave part of it. I have the teams set up and the tutorial I watched gave me a script that I put into a trigger synced to a show/hide module, but the OPFOR still all spawn in at once
You need to send the script if you want help
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Do not quite understand. That is, can you make it so that when a player connects to the server, his nickname in my discord server will automatically change to the one he has in the game?
YOU HAVE TO INVENT THIS YOURSELF
it's not worth it dude
just enforce your rules
you're thinking of what teamspeak does with plugins. discord is not teamspeak.
It's a pity, of course, I'm just familiar with one project where they have automated registration. BUT, they don't have Discord, they use site registration.
literally
OK I understood. Thank you.
just take away the ability to set nicknames
it's that simple
you don't need anything that automatically updates
make a google form or a python bot or something
//({ alive _x } count units W1G1 == 0) && ({ alive _x } count units W1G == 0) && ({ alive _x } count units W1G3 == 0) && ({ alive _x } count units W1G4 == 0) && ({ alive _x } count units W1G4 == 0) && ({ alive _x } count units W1G4 == 0) && ({ alive _x } count units W1G5 == 0);
This is my code
W1G1 stands for the Wave and Group
The units have this as their variable names too
That’s pretty much what I did when it didn’t work
And I think the video is already 4 years old?
literally don't know what they're doing and giving advice, like me but worse
So is there a better way?
let me decipher that mess and go from there
Alright
looks like a trigger/whatever condition "if all members of all groups are dead", i suppose?
Yep
yeah
it's done in like the worst way though
im sorry it's really not that bad i'm just offended by that code for whatever reason
are the variables units or groups
i'd call that a surprise effect
3 man units
Or groups
Not very sure on the difference
and you want the condition to be that they're all dead?
can you send all the trigger statements
That's the only trigger
yeah but what's in the activation field
Nothing I believe
so the trigger fires and then what?
It is synced to a show/hide module
They're originally hidden, then once the trigger is done, the second synced show/hide sets the wave to show
And you're supposed to repeat this for every wave
are there specific units that you placed down or did you just place a group from the editor
It's a modded group, each group has their leader synced to the show/hide
what do you mean modded group
did you place down a pre-made group or not
Yes
what mod is it?
COXHOUND
if I had that addon downloaded I'd just write a script to spawn the group but we can stick with your hideObject method
I'll dm you because i got a plan
Ok
just asking: "write a script" as in "a bunch of createUnits" or is there a better way of working with groups?
greetings everyone. I am trying to work on a simple create a unit on top of a specific marker. I have placed this marker in my mission. Which is called spawnmarker_01. However it throws back an error at me. This is my code: ```_spawnPos01 = getMarkerPos "spawnmarker_01";
_createAttackGroup = createGroup [west, true];
_unit = "B_Soldier_lite_F" createUnit [position _spawnPos01 , group _createAttackGroup];
if (alive _unit) then{
//move unit to waypoint marker 01
// move unit to waypoint marker 02
// move unit to attack marker 01
};``` and the error i get thrown back at me is: Error position: Type Array, expected Object,Location. I am not sure as to what i am doing wrong here.
could it be because i am using Empty markers that dont show up on the map when i start the mission?
you are getting marker pos, then are getting the pos of the pos
ahh i see. so it should just be _spawnPos01
bingo!
That code's also using the wrong createUnit. That one doesn't return a unit reference.
and similarly to the position, group _createAttackGroup should just be _createAttackGroup
yea i saw that and changed it aswell. It spawns the unit now and now i can go further with the if statement which is throwing an error now
Probably because it's using the wrong createUnit so _unit is nil.
which is saying: undefined variable in expression: _unit
_unit = group player createUnit ["B_RangeMaster_F", position player, [], 0, "FORM"]; this one?
yes.
got ya thank you!
so what does the "FORM" do ? I thought it was part of the rank string but it doesnt seem to be?
I'd venture to bet that it deals with the formation of the group
I believe it's supposed to create a unit in its place in formation this way
yea looks like it indeed. am just reading through the wiki to make more sense of it
So, looking on the wiki now for createUnit, I don't know what "FORM" specifically does, but the section is pretty much meant to decide how the unit is spawned to some extent. I agree with artemoz that it likely spawns them on the location of where that unit would be in formation but you could also do "CARGO" if you wanted them to spawn in a passenger seat of the player vehicle.
i am going to see if it's the case by testing something right now
Can I limit availability of custom communication menu items to Admins only? https://community.bistudio.com/wiki/Arma_3:_Communication_Menu I want to put admin script commands in the communication menu instead of making a GUI or keybinding...
Depending on how your script is structured, you could use https://community.bistudio.com/wiki/admin on the server to instruct admin clients to create the menu (i.e. remoteExec a function on admin clients), or use https://community.bistudio.com/wiki/serverCommandAvailable on the client to determine whether it's an admin. Alternatively, if it's only for use on a server you control, you can keep a list of admin Steam IDs and check whether the client is one of those, which would allow access for admins other than the logged-in admin.
If you use a method other than Steam ID whitelisting, bear in mind that admin status can change mid-mission, so if you'd like the script to account for that you'll need to check multiple times over the course of the mission - otherwise only the admin who was logged in at mission start will have the option.
Also keep in mind that the communication menu may not be available to players in spectator mode or Zeus, whereas a custom GUI & keybind will be.
^^^ pin that +100
I will do whitelisting since it is the simplest for me to personally accomplish. I am the admin and it's just for my own streaming and fun
Hi, I need to accurately get the unit name of the local player even in mp on a dedicated server. I don't have access to this kind of server to test if just using "player" works. I've seen some stuff online that suggests it can work in certain scenarios, but my general understanding was that "player" doesnt work in mp.
My goal is for the player to press a button and then I get a list of all the units in their group.
Any help is greatly appreciated!
player works fine, if there is a local player (client for example). name player would give you their name.
name player would give me like their profile name? Where as player would give me the unit name right?
However in multiplayer name always returns profileName
There's no difference for MP apparently.
hmm
player is the object. It converts to the object's name (if any) in debug console output but in script it's still an object.
so if it returns profileName, can I still use that for like "units" as the type parameter?
hmm, I guess str _unit is potentially something else.
No, you have to keep the object to use it for commands that require an object as input.
So "player" would not work in a multiplayer setting is what you're saying
No...
My goal is for the player to press a button and then I get a list of all the units in their group.
units player works fine for this. Then you can do units player apply { name _x } or units player apply { str _x } depending on which you want.
player works in multiplayer, it just does a very specific thing. check the wiki page for player, it returns the player unit belonging to the machine executing the command
if the script is not executed local to the player unit you want then use another method
Thanks for the help, ill look into it some more
Hi I'm new here there's a way to move whit acceleration an object to point A to point B?
Does anyone know the display IDD or even if there is one for being in the virtual arsenal, im trying to get a keybind to trigger when the users presses enter in the VA and it isnt working for display IDD 46?
actually came up yesterday if you search for "arsenal"
"arsenalOpened" has a display parameter.
@left coral setVelocityTransformation probably.
You can also use setVelocity or even addForce for increasingly manual control but I suspect that's not what you're after.
thanks had a look does exactly what i need, turns out there is no IDD for arsenal, RIP 2 hours of my life
relatable
you will get used to it 
If you make a Discord Bot you can do anything you want.
I have a system that connects our website accounts with TeamSpeak, Arma, Discord.
It can see names on all platforms and could enforce same name everywhere if we wanted to (but we don't bother).
If you have time and know programming theres little stuff you can't do 😄
Every player has a account in our system, and the server has a discord bot and a teamspeak bot to interface with both.
And Arma I could make but didn't have any need to do so, so far it can only read the logs.
The discord bot could change their nickname, the teamspeak bot could poke/kick them if they join with wrong account, Arma side could also kick if name doesn't match.
But so far I didn't bother, telling people to be reasonable mostly works fine
Can we have renaming players in mp environment, please?
no
Hi I'm new here there's a way to move whit acceleration an object to point A to point B? I Find that i can use KeyFrameAnimation to move the object, but it need to start when the player reach certain point (like a spot on the map) , there's a way to combine the start of the animation whit a trigger on the terrain?
i tried
Dont repost your question. It was already answered
And yes, you can use triggers. If youre going to use 3den keyframes, then a better place is #arma3_editor
Wow! Can I somehow ask you for this system? I can even pay you.
No. Would need alot of time to make it adjustible and I don't have that time
Does setVelocityTransformation velocity interpolation in MP work for static objects? Or only for physx objects
I would say static objects do not have velocity, so no?
you can fake it by attaching them to other velocity-friendly objects
Is it scheduled to make findIf command compatible with hashmaps in the next Arma update?
why do you want to use findIf with hashmaps? 
for stuff
a hashmap already does finding
use case plz (or no effort will be made this way)
if you want to iterate through values use forEach
yeah but still less efficient than findIf
use case please
what do you mean by case?
a case where it would be useful
I don't have such case, it was just a random question
not really. findIf performance is nearly the same as forEach
then no
😄
I was aiming to use it but as it is not available, I have chosen another way to do it
if you want findIf convert to array first 
{
if (_condition) exitWith { _result };
} forEach _hashMap
is it possible to have multiple drawIcon3D in a single Draw3D missionEventHandler ?
yes. use arrays
@drowsy geyser here's an example 👆
i need to display different icons on different objects and i guess it wouldn't be good performance wise if i added multiple missionEventHandlers for all the objects?
yeah
though performance is not the only concern here
you shouldn't add too many event handlers, because event handler IDs are limited
because numbers in SQF are floats, and any ID greater than ~16.7M becomes meaningless
okay thank you, i noticed fps drop after i added like 7 missionEventHandler
let me guess. do you use getPos/position/getPosVisual?
yes some of them
they're slow
for drawing, use ASLtoAGL getPosWorldVisual _obj
or unitAimPositionVisual for units
i just looked im using these getPosWorldVisual/modelToWorldVisual
ok they're good
you shouldn't notice FPS drops with just 7 EHs tho
there's probably something else wrong here
Maybe if they were drawing something huge :P
you shouldn't add too many event handlers, because event handler IDs are limited
because numbers in SQF are floats, and any ID greater than ~16.7M becomes meaningless
I'd say you have another problem before you reach that value 😄
well IDs are always incremental and don't reset 😛
even if you delete all of them you still run out 
for many objects, maybe thats why?
but you said 7 EHs? were you drawing more than 1 obj per EH?
idk here an example (sry for bad scripting)
allBatteries = (allMissionObjects "Land_BatteryPack_01_battery_black_F");
{_x setVariable ["batteryEmpty",false,true];
} forEach allBatteries;
batteryIcons = addMissionEventHandler ["Draw3D", {
{
if (!(_x getVariable ["FlashActive",true])) then {
alphaText = linearConversion[1.9, 2, player distance _x, 1, 0, true];
drawIcon3D [getMissionPath "images\BatteryIcon.paa", [1,1,1, alphaText], _x modelToWorld[0.04,0,0.02], 3, 3, 0, "SPACE", 0, 0.04, "LCD14","center",true,0,-0.02];
};
}forEach allBatteries;
}];
You had me scared here until you pulled 16 mil out of your pocket
I'd say maybe getMissionPath is the thing slowing it down
no it's fast 
alphaText
don't use global var
I guess as John Jordan said maybe your icon is too big 
also you can just not draw if alpha is 0
How many batteries is this?
50 xD
and you were doing 7 EHs? i.e 50 * 7 = 350?
oh, the alpha 0 optimization is looking pretty strong here.
actually maybe do inAreaArray on the things first...
not for the batteries , i have different objects
If you don't care about stuff >2m away, pre-cull it.
yeah this is the best solution
Or jsut look for batteries within 2m inside the EH
Eliminates inAreaArray and makes it a bit more dynamic
you do that in the EH
not outside
nearEntities or whatever was the fast one
it's already dynamic
that won't work with "batteries"
The array doesnt include nrw added batteries
or static objects
oh wait, is the allMissionObjects inside the EH...
No
god no 🤣
the game would probably be at 1 FPS at that point...
Tbh, i just recommend looking for the items within 2m raidus inside the EH
Much faster than iterating and measuring area distance over an array of 50 objects
Oh, inAreaArray is surprisingly fast. Probably not much different there.