#arma3_scripting
1 messages Β· Page 201 of 1
(fun fact: I agree factually, I just disagree aesthetically π I myself write + ""\n+ ""\n+ "" strings)
Truly superior would be using image and setAttributes, bet its faster than parseText format
i agree with Lou
Is there a command to "attach" a waypoint to a unit, that update waypoint positon when the unit moves?
waypointAttachVehicle didnt work, or I have to use setWaypointPosition in a loop?
waypointAttachVehicle should work, maybe there is a script mistake?
The visual position of waypoint do changes, but the unit still goes to original position
_enemyGroup = createGroup [west, true];
_enemyPos = player getPos [50, random 360];
_enemyClass = "B_Soldier_A_F";
_enemyUnit = _enemyGroup createUnit [_enemyClass, _enemyPos, [], 0, "NONE"];
[getAssignedCuratorLogic player, [[_enemyUnit, player], false]] remoteExec ["addCuratorEditableObjects", 2];
[_enemyUnit] joinSilent _enemyGroup;
_enemyWp = _enemyGroup addWaypoint [[player], 0];
_enemyWp waypointAttachVehicle player;
player setPosATL (player modelToWorld [0, 100, 0]);
try perhaps another type of waypoint? Search And Destroy to track, Get In for a vehicle, etc
there is also https://community.bistudio.com/wiki/BIS_fnc_stalk
changewaypoint type have no effect, BIS_fnc_stalk worksπ
Is there a way to get the turret of a vehicle as an object / prop? I tried just using the tank and setting the object textures for the hidden selections to "" but that doesn't hide the tracks :(
You'd need to destroy the tracks to hide them mostly likely
But no, you can't separate out the model like that
Destroying the tracks does not seem to do it :(
when i use addEventHandler does it adds globaly or i need to remoteexec it? and CBA_fnc_addEventHandler too?
and how does the Killed event triggers? only where object is local?
Event handler added by addEventHandler fires on the machine where event is local
Cba event handlers run on the machine where you add them
Normally you would just add it on each machine, rather than (for example) remoteExec'ing it from the server
what if i execute code locally and need to add killed event, killed event contains code which should be executed localy, so how to properly add event? for everyone with remoteExec and then killed will fire on client on which the object is currently local (becuase its transport so locality as i know can change)?
or can i use MPKilled added with addMPEventHandler, and than just check locality?
Local to where, the machine running the rest of the script? Local to the object itself?
i run script on client, which manipulates object that is not local to client and it adds killed event, so object can be local but in most cases it will not, and locality might change later (cuz other player will use it for example). so how do i properly add event handler?
Probably just add an event handler to object on all machines and just exit if it's not local
got a bit of a problam with a script that lets the unit continuously fire for as long as they still have more than 10 rounds of ammo left
for "_i" from (_number) to 10 step -1 {
//code for continuous firing dependent on the _number of ammunition left
}```
The above works fine and the units shoot away very happily, but I somehow want to be able to manually stop their firing (i.e. "break the loop" via addaction) if needed - but how best to achieve it? I thought I had it just using ```disableAI "FIREWEAPON"```, which stops the shooting of course, BUT I did notice that the ```for from to``` loop continues on, because as soon as I switch ```enableAI "FIREWEAPON``` back on for those guys, they will immediately pick up where they have left off in that loop and continue their shooting from before. So I need to find a way to somehow end that loop.
Hope that made sense.
If somebody struggles with BE (BattlEye) Filters, just create a script.txt file on the same directory as your BEServer.cfg & BEServer.dll with the following content inside of it:
1 ""
It will now enable the filters, and start logging exceptions from which you make the filters.
@thin fox - Thanks mate, exitWith did the charm!
I hate when discord doesnt load the recent chats properly and I comment on something super old XD
this stops that stupid stuck Anim when you Para Drop into the water, i found you only get stuck sometimes
if (surfaceIsWater getPosASL _player) then
{
_player SelectWeapon "arifle_SDAR_F";
sleep .5;
_player switchMove "amovpercmstpsraswrfldnon";
};
//or this whatever your ueing for player
if (surfaceIsWater getPosASL player) then
{
player SelectWeapon "arifle_SDAR_F";
sleep .5;
player switchMove "amovpercmstpsraswrfldnon";
};
i use it at the end of my ParaDrop Script, Or just after player enters water from ParaDrop Script:
on this page
https://community.bistudio.com/wiki/HashMap#Unsupported_Key_Types
where its talking about hashing a object, is it possible for two differnet objects to hash to the same value?
Only keys must be unique
Maybe he is asking if hashValue can return same value for two different objects
I dont think I understand, lets say I have two units could their hashValue be the same?
or say two projectiles
Hm I think I didn't understand your point. No it won't (it likely not to be exact)
Even if it can return same value. Chances of that are likely very slim
It will happen, it may happen, there is a chance, are all different topic
I am using an eventhandler on the player to see if his animation is "weapon raised" (i.e. aiming and ready to shoot) and wanted to automatically adjust his stance (CTRL+W) with playmoveNow. While this does work and the stance is adjusted accordingly, I ended up with a few seconds of being unable to move or do anything each time this adjustment happens?
Thought that this is weird, because if you manually adjust your stance, you are always able to move/do stuff right away. Could not really be the animation itself, as it is very short? So why is it happening, what is causing this and can this short "delay" be fixed or prevented?
Generally yes, hash collisions are a thing.
More likely the larger the input data is (you're squeezing more data down into a smaller space, there has to be collisions for it to fit)
But, objects are turning the creator and id (netId), two 32bit numbers, into a 64bit number.
So there isn't much squeezing going on
And it could somewhat easily be tested out by just running a couple thousand creator id's and object id's through it and seeing if there is a collision, or where the first one happens
In practice in multiplayer you maybe have a hundred, or couple hundred creators.
And couple hundred objects each.
Okay cool I understand now ty
i don't like squeezing data, WooHoo Arma 3 hell yeah π
At that point one could copy bits from these two 32 bit IDs into one 64-bit number and use that as a key.
IDs are unique don't they?
I've shown how to handle potential hash collisions in this sample code:
https://community.bistudio.com/wiki/HashMap#Unsupported_Key_Types
you were already talking about it tho 
but anyway, I think Dedmen added some kind of unique string ID to objects? (was it netID?) I haven't been following the development recently
NetID is the best way to go for objects which are not players imo. For players I like to use getPlayerUID instead as then data isn't reliant on unit slot but that's just personal preference- also kinda just depends on what you're building too.
yo
how do I make players who join the server for the first time, to load in with the loadout I set the unit with without defeining the loadout?
or do I have to define it..
just came back to arma after couple of years so go easy
If you've set the unit's loadout in the Editor, then it should still have that loadout once a player takes control of it. If it changes, you have a mod or script interfering with it.
Otherwise, it'd be handy to know what you mean by "defining the loadout".
by defining I meant like export the loadout, but I don't want to do this, I stumble upon the same issue over and over this is what I have so far:
initPlayerLocal - I assume that I need this, because I wanted to do unit deletion after respawn but gives me error message in game after respawn
Those 2 I assum they work because I do spawn with the loadouts I gave them but, when you first spawn the spawn selection is not showing and just spawns where unit is
onPlayerKilled
onPlayerRespawn
and
description.ext
These are all script (or config) files which can contain almost anything. It's nice that you have them, but that doesn't really tell us what they're actually doing.
If you're working with respawn, you should look at this: https://community.bistudio.com/wiki/Arma_3:_Respawn
and this: https://community.bistudio.com/wiki/Description.ext#Respawn/Revive
You need to set a number of settings to make respawn work how you want - that's up to you.
By default, units don't keep their loadout when they respawn. The new unit is...a new unit, and is created with its base class loadout. If you want the loadout to persist across respawn, you'll need to script it, and how you script it depends on how exactly you want respawn to work.
Imma be honest, it's all gibbrish for me right now, can I share the sqf so you can peek at them and see what I am doing wrong...?
@brisk lagoon Can you tell us how you are tring to save the loadOuts on the playable Units, ?: and also why not just let the games corpseManagerMode get rid of the dead uints
So you define x loadouts to units in editor?
Or do they select those themselves via arsenal?
he wants them to respawn at base with the same loadout i think But i think maybe NikkoJT may have already helped him
that would be some explaning i wounder if he has a mic
Does anyone have any idea how to realise a script where civilian player only get opfor aggro when they enter different trigger areas around the map or if the enemy ai see them with weapons? I would appreciate every help. I am a good mission designer my but scripting skills are worse. π
giving the Civ player a Opfor loadOut would be the easy part , but the other part hmmmm id have to think about that
Change his side and his setCaptive when needed
Unit's side depends on side of his group
So can put civ in blufor group and he will be treated as blufor unit
Use setCaptive true to make other units ignore him and then set it back to false to make them shoot him again
don't hate me for using chatgpt as a helper cause as I said, i have no idea about scripting. But this chatgpt gives me:
// initPlayerLocal.sqf
// Liste aller Zivilspieler (optional: oder einfach [player])
private _civPlayers = allPlayers select { side _x isEqualTo civilian };
// PrΓΌft Sichtbarkeit und Waffenbesitz
[] spawn {
while { true } do {
{
private _player = _x;
// Standard: Zivilisten sind unsichtbar fΓΌr OPFOR
_player setCaptive true;
// Wenn Spieler bewaffnet und von OPFOR gesehen
private _hasWeapon = (primaryWeapon _player != "" || handgunWeapon _player != "" || secondaryWeapon _player != "");
private _spotted = false;
if (_hasWeapon) then {
{
if (side _x isEqualTo east && { _x knowsAbout _player > 1.4 }) exitWith { _spotted = true };
} forEach allUnits;
};
// Spieler wird angreifbar
if (_spotted) then { _player setCaptive false };
} forEach _civPlayers;
sleep 2;
};
};
I know that gpt often writes bullshit
Just don't use it
If you're trying to do something, try just going through the logic in your head
Then you can come here and ask about writing the actual sqf
You're just one of many people who have already tried to teach me how to do scripting myself. I couldn't do it back then, and I'm not going to be able to do it now at my age. I've been doing missions since Arma 2, including some very good ones. My strength has always been designing missions rather than the scripting behind them. I will continue to rely on the helping hands of others in the future.
read a lot and look for examples/samples, that's how I've learned
like I've already said in the other channel, some stuff you need to learn to be able to do other stuff, indirectly
Don't you think that after 16 years of mission building, I've read enough? I've never really understood scripting. These kinds of answers don't really help. No offense intended.
It doesn't matter, you still can learn.
Just come here and ask, ppl will help you.
And no one can just give you a speech here and you suddenly start scripting stuff, you will need to read and test it out stuff
so say in a trigger if the condition to activate if a unit is dead is !alive, then what do i put in if i want the trigger to activate if a unit is still alive?
basically for context, i got a scripted thing where a jet gets shot down by a SAM system, but testing reveals that sometimes the SAM miss, so i put in a failsafe where an explosive charge detonates and destroys the jet but i don't wanna make it overkill if the thing does get hit
wait im stupid
just remove the ! lmao
I'm trying to create a random air patrol with a Loiter WP for a helicopter/plane but it seems as to be an issue if there are more than one loiter waypoint for the given unit it only sees the first one even when i have the wp completed on a timer. Maybe I'm doing this wrong but how would i go about creating a random loiter patrol on different locations
can someone help me with a little code? i have been trying to find it and i cant do it
@thin fox would u be free? u seem to be active and educated
@thin fox thank you i didn't know that's how the Loiter wp worked, I'll have to use a script to get the result i want.
with ur comment regarding an eventhandler with the weapon being raised,By any chance can you use an eventhandler to trigger a chat.sqf after a task is completed,Even tho the trigger would be activated by the player even without the eventhandler?
I now know that if a waypoint is added after a loiter waypoint it becomes a move wp, so how do i get this unit to move to the next loiter waypoint.
_wp setWaypointType "MOVE";
_wp1 = group F4E_1 addWaypoint [[68301.5,135312,0], 0];
_wp1 setWaypointType "LOITER";
_wp1 setWaypointLoiterType "CIRCLE";
_wp1 setWaypointLoiterAltitude 2000;
_wp1 setWaypointLoiterRadius 8750;
_wp1 setWaypointTimeout [120, 180, 200];
_wp2 = group F4E_1 addWaypoint [[55000,154608,0], 0];
_wp2 setWaypointType "LOITER";
_wp2 setWaypointLoiterType "CIRCLE_L";
_wp2 setWaypointLoiterAltitude 4000;
_wp2 setWaypointLoiterRadius 15000;```
Hello. Just ask what you want to do that ppl will help you.
It's best to just remove all current waypoints and then add the loiter wp afterwards, like in this function of mine
https://github.com/PiG13BR/PIG-CAS_Menu_Beta/blob/beta/Missionframework%2FCAS_Menu%2Ffunctions%2Ffn_createLoiterWaypoint.sqf
@thin fox it's about a chat.sqf file being triggered after a certain task is finished and then the trigger gets activated by Blufor
Idk if it's an eventhandler or waituntil
I'm not the best at scripts
Is there a way to show/hide the USS Liberty? The module for it isn't working, just on the things on the boat.
Liberty and Freedom are done by using multiple objects. The "core" object should have a variable that stores all parts
Syncing a hide module directly to the core object doesn't seem to do it. Maybe a trigger area instead?
Use script
I'm not sure where to start, sorry ^^; My immediate thought is something to do with a forEach loop?
I'm mostly a config monkey not a scripter sorry
I can't tell what it was called rn, but systemChat str allVariables this in USS's init to see which variable is used in it
"bis_carrierparts" showed up
But that doesn't make sense because it's not the carrier
It doesn't matter
It uses same function to spawn parts
Use liberty getVariable "bis_carrierparts" and forEach and hideObject
liberty being a variable I assign to the ship in the editor?
Ye
can someone please explain to me what _grp means in deleteWaypoint [_grp, 2]; and is it referring to the callsign that is assigned to a unit when its placed in the editor or the variable name?
Haven't tested in game yet but thinking
private _bigBoat = liberty getVariable "bis_carrierparts";
{ _x hideObject} forEach _bigBoat;
It's a group.
Local variable refering some group. Example you've sent will remove waypoint of index 2 from the group
In this picture the group would be Alpha 2-3?
look at the syntax of hideObject again
its string name would be that, but Alpha 2-3 isn't a group datatype. You need to reference the group datatype
can you send me the wiki link as a refference, please
Right click Alpha 2-3 and open properties window and give it a name
@stable dune No I ment a reference a group datatype
Thank you Iβll give that a try
That name is gonna be global variable and you can use it anywhere you wish
I think i just had some reading comprehension problems initially, tho i do wish there was like a bis fnc for that sample code or in cba
with playSound3D I can give a path to a sound to play, is there something where I can pass in a soundset?
There is not π¦

so what's the problem?
How can I set a flag texture and have it show up for all clients? Previously I tried to use setFlagTexture but it only seems to show up for the client who triggered it.
I have a feeling it has something to do with remoteexec but maybe someone can answer this before I'm done trying to figure it out myself. 
[flag_var, "flag/texture.paa"] remoteExec ["setFlagTexture"]; maybe?
Thanks!
I was gonna say, setGlobalTexture doesn't work on flags
Yeha, i know , pasting before reading.
_grp //is a local variable where _grp can be used in scripts
//over and Over again
//like this here
while {{alive _x} count (units _grp) > 0} do
{
{_x setSpeedMode "LIMITED"} forEach units _grp;
{_x setBehaviour "SAFE"} forEach units _grp;
};
WooHoo im totaly Re-vamping all my Missions with call and spawn WooHoo Arma 3 hell yeah, and also my Chopper Command WooHoo π
i was using to much execVM and after NikkoJT explane alot of stuff, i got jiggy with it WooHoo π man i love this game its so much fun π
Hello guys, is it possible to consume a return value like this:
0 = [a, b] call aFunction;. Thanks.
[a, b] call aFunction; nil;
Hi guys, does anyone know if it's possible to make a function with a button for CBA to change RVMAT and texture on a certain hide selection on a helmet model?
I want to try to make the Helstar strobe change texture and RVMAT so that I can turn on the lights at night. Or maybe it's possible to do this somehow in the config? Or a proxy, I don't know what options are acceptable at all?
I dont think you can control the rvmat of helmets and nvgs in real time like the uniform since they are not vehicles per se (uniform is), you might have to do variants with the corresponding RVMAT and colors and make then swap using your function most likely
Ah, I can make 2 different RVMAT and textures, for me it is clear and easy. And all this can be changed through a function?
you can swap the classname that the unit is wearing (for that classname to have its different rvmat and texture), yes, what im not sure about is that you are able change the rvmat of a same classname in real time for helmets, as that ability is limited to CfgVehicles classnames afaik
Yeah you can't change what texture/rvmat a helmet uses like you can with uniforms (or rather the unit wearing it) / objects.
Best you could do is multiple helmet classes and just equipping a different one.
Oh π I got it, thank you very muchπ«Ά
i am trying do breaching with ace how to i lock doors on building that already in
for modelToWorldVisualWorld is the modelPos argument relative to the model centre with rotation? I'm trying to get a point in front of a projectile as it's travelling
or should I use velocityModelSpace, does that have the same caveat?
Model space coordinates are in model space. The X, Y, Z axes are the X, Y, Z axes of the model. So yes, rotation is included.
thank you
Just through vanilla
I believe 3den enhanced has a module for locking doors?
It may also be from cba or ace, been a long time since I've used it, one of those mods should have it though
Hi folks ive been really struggling to get a reinsert via C47 script to work for a pole what will happen is I can get the plane to spawn and move me into the plane with a parashute but the plane just tries to land at an airfield instead of flying off and self deleting
in addition im trying to get it so I click on the map and the plane flies in that direction with the player in the back
im able to get the plane to fly spawn with me in it once i use the pole but the damn pilots keep flying to the corner of the map or try to land
can anyone help me to find my syntax problem?
setAggroFlag = {
params ["_unit", "_state"];
if (!local _unit) exitWith {};
_unit setVariable ["zoneAggro", _state, true];
};
player addEventHandler ["Fired", {
params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile"];
if (!isNull _projectile && isPlayer _unit) then {
_projectile addEventHandler ["Hit", {
params ["_projectile","_target"];
if (!isNull _target && side _target == east && isMan _target) then {
missionNamespace setVariable ["civForceAggro",true];
};
}];
};
}];
[{
[player] call wlz_aggro_fnc_checkAggro;
}, 2] call CBA_fnc_addPerFrameHandler;
I get the following error:
1:35:18 Error in expression <target && side _target == east && isMan _target) then {
missionNamespace setVari>
1:35:18 Error position: <_target) then {
missionNamespace setVari>
1:35:18 Error Missing )
1:35:18 File C:\Users\LiquidBlaze\Documents\Arma 3 - Other Profiles\Walzmine\mpmissions\widerstand_in_niedersachsen_wlz.gm_weferlingen_summer\initPlayerLocal.sqf..., line 90
1:35:18 Error in expression <target && side _target == east && isMan _target) then {
missionNamespace setVari>
1:35:18 Error position: <_target) then {
missionNamespace setVari>
1:35:18 Error Missing )
1:35:18 File C:\Users\LiquidBlaze\Documents\Arma 3 - Other Profiles\Walzmine\mpmissions\widerstand_in_niedersachsen_wlz.gm_weferlingen_summer\initPlayerLocal.sqf..., line 90
Maybe I have a logical problem or how I use something. tried using () or {} doesn't helped
isMan is not a command that exists
You can use https://community.bistudio.com/wiki/getEntityInfo or isKindOf "CAManBase" to find out whether an object is (approximately) a man
like this?
player addEventHandler ["Fired", {
params ["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile"];
if (!isNull _projectile && isPlayer _unit) then {
_projectile addEventHandler ["Hit", {
params ["_projectile","_target"];
if (!isNull _target && {side _target == east} && {_target isKindOf "CAManBase"}) then {
missionNamespace setVariable ["civForceAggro", true];
};
}];
};
}];
I don't think you can have {code} on both sides of &&, only on the right side
You could do it like this: (!isNull _target && {side _target == east}) && {_target isKindOf "CAManBase"}
You can, because in this context left argument is already a bool
If there is something I miss
Depends how the order of operations shakes out, I guess
this addAction ["βοΈ Reinsert via C-47 Paradrop", {
params ["_target", "_caller", "_actionId"];
private _spawnPos = [getPosATL _caller select 0, getPosATL _caller select 1, 1000];
private _dir = random 360;
private _planeClass = "SPEX_C47_Skytrain";
private _pilotClass = "B_Fighter_Pilot_F";
private _plane = createVehicle [_planeClass, _spawnPos, [], 0, "FLY"];
_plane setDir _dir;
_plane flyInHeight 1000;
_plane setVelocityModelSpace [0, 150, 0];
private _pilotGroup = createGroup west;
private _pilot = _pilotGroup createUnit [_pilotClass, _spawnPos, [], 0, "NONE"];
_pilot moveInDriver _plane;
_pilot disableAI "TARGET";
_pilot disableAI "AUTOTARGET";
_pilot disableAI "WEAPONAIM";
_pilot allowDamage false;
private _waypointPos = _spawnPos vectorAdd [0, 2000, 0];
private _wp = _pilotGroup addWaypoint [_waypointPos, 0];
_wp setWaypointType "MOVE";
_wp setWaypointSpeed "FULL";
_wp setWaypointBehaviour "CARELESS";
_caller moveInCargo _plane;
removeBackpack _caller;
_caller addBackpack "B_Parachute";
hint "You're aboard a fresh C-47! Jump when ready.";
[_plane] spawn {
params ["_plane"];
sleep 120;
{if (!isNull _x) then {deleteVehicle _x};} forEach crew _plane;
if (!isNull _plane) then {deleteVehicle _plane;};
};
}];
this works but i need to ai pilots to just fly straigt
Well, you're giving them a target waypoint that isn't in the direction that they're facing.
If you want them to fly in the direction they're facing then something like this instead:
private _waypointPos = _spawnPos getPos [2000, getDir _plane];
Been trying to use findIf to check several group arrays for one specifically named soldier in each group, that for example has the string "devil" in his variable name (so for example "Devil_01" or "Devil_02" or "Dan_the_Devil"). Want to prevent having to edit the code for each and every group so I thought that findIf might do the trick, but how can I search for a "partial" match in the variable name?
[thislist] findIF {_x == "devil" }
```The above, as I understand it would only get me a guy named devil, but using this is combination with ```typeOf``` would not work as it does not look for strings, right?
What kind of code would you write if you use it with typeOf and how it would work (at least on your brain's end)? Just because I can't think how these two ideas can combine into one
Oh brilliant thanks @tender fossil that is exactly what I have been looking for, thought I had to use findIF or typeOf but that is a LOT better!!! YEY! :)
Do note that the comparison is case-sensitive though π
https://community.bistudio.com/wiki/toLower
That's why it's good to integrate that directly into the script to avoid these issues.
oh thanks for the headsup! but it does look for partial names and can compare and that is exactly what I wanted :)
@sharp grotto oh that is neat, thanks!
Is there any way I can create a progress bar that's displayed by the Draw3D eventhandler?
Hello all: how can i send a hint to All on the server of the player name
that activated this addaction function
_object = _this select 0; // Replace with your object name
_object addAction ["", {
params ["_target", "_caller", "_actionId"];
["functions\fnc_sabotage.sqf", [_caller, _target, _actionId]] remoteExec ["call", 0]; // Execute function globally
}];
private _text = format ["This player just did an action: %1", name _caller];
_text remoteExec ["hint"];```
oh wow cool thx NikkoJT your Awsome
["functions\fnc_sabotage.sqf", [_caller, _target, _actionId]] remoteExec ["call", 0];```
This is wrong, `call` cannot call a script file directly
If you have functions, you should define (if you arent) in functions ->
https://community.bistudio.com/wiki/Arma_3:_Functions_Library
So you could just remoteExec function/ use functions (if you use somewhere else those)
(it's also backwards - for call, the left parameter is the arguments, and the right parameter is the code or function name)
oh no can you fix it for me
No. It would be much better if you learned how to fix it yourself.
Your script file appears to already be intended to be used as a function rather than being called directly. You should see if the function exists in CfgFunctions, and if not, you can set it up using the information at Prisoner's link.
Fixing the order of arguments/function name is SUPER EASY, it's literally just switching left for right, you do not need help with this.
ok ill try thx you man
Do you actually understand the purpose of any of the things you're writing?
Do you know what a file path is?
So when I said "you can't directly call a file", and "you need to switch the order of the function name and the arguments", why did you just change the file path to be even more wrong?
ok yeah i see lol dam
@pallid palm you need to add the function path in description.ext as CfgFunctions subclass I think ....
then just call it by the name
SCO_fnc_theName;
//SCO is from Scotty :slight_smile:
@pallid palm this is how is looking from the mission I am editing
class CfgFunctions
{
class KIB
{
class buymenu
{
file = "path\to\category";
class maxVeh
{
file = "func\maxveh.sqf";
};
};
};
};
yeah i like the Functions Library
class cfgFunctions
{
class KIB
{
class buymenu
{
file = "func" //Path to function folder (missionROOT/func/)
class maxVeh {}; //file "missionROOT/func/fn_maxVeh.sqf"
};
};
};
So you can define by class your functions in x folder , and you don't need define path for every single function separate
oh wow awsome man thx alot @stable dune
@stable dune nice din't know this, I will try it π
So it was a big idea in your small head?
yeah lol π
sorry i'm not so good, iv been playing more then scripting and i forget things all the time
i guess thats from my age of 64 maybe
but as long as i have you great guys around to help me i should be ok
oh and this great program Discord too
Hello! I am having some issues with remoteExec. I want to send a remoteExec to an array of players, but when I do, it does not send...
My code looks something like this:
copsArray = [];
copsArray pushBack player;
"test" remoteExec ["hint", copsArray];
copsArray has the following value: [civ_1]
Where are you running this code?
@stable dune mhh ... I made simple function just to test and nothing happens, no error
class cfgFunctions
{
class KIB
{
file = "func"
class maxVeh {};
class simpCheck {};
};
};
to execute I use
call KIB_fnc_simpCheck;
this is the function itself
_message = "tralala";
hint _message;
player has a different value on each machine so it doesn't make sense to use it to create an array of players.
@split ruin your missing 1 thing
Well, the whole category level
what I missed ? Maybe the path ?
On my arma3 server as Local exec
Dedicated server?
Yeah
player is just objNull on a dedicated server usually.
If you wanted to send that hint to all players then this should work:
"test" remoteExec ["hint", allPlayers];
The problem is that I only want it to reach a specific group of people who are in an array.
Which is fine if you have an array with a specific group of people in it.
But the code you pasted is not making any attempt at that.
So I can't say what you're doing wrong.
There's a whole level (category) missing. You can't exclude that even if you're not doing anything with it.
class CfgFunctions
{
class TAG
{
class Category
{
class functionName {};
};
};
};
oh I see
And how can I add a player to an array so I can send them a remoteExec? Or should I do a forEach with all the players in the array?
@granite sky everything working now, thanks
class cfgFunctions
{
class KIB
{
class SimpleFunc
{
file = "func" //PATH TO your script (missionROOT/func/)
class maxVeh {}; //file "missionROOT/func/fn_maxVeh.sqf"
class simpCheck {};
};
};
};
can I define functions in two different folders ?
i think you can, but im not sure, cuz im not that good
The typical way to do it would be to make a category for each folder. For example:
class KIB
{
class soundFunctions
{
file = "soundFunctions";
class function1{}; // mission/soundFunctions/fn_function1.sqf
};
class guiFunctions
{
file = "guiFunctions";
class function2{}; // mission/guiFunctions/fn_function2.sqf
};
};```
totaly killer WooHoo Arma 3 hell yeah
Shameless promo (this can be deleted if considered as spam): I've made a Visual Studio Code extension that automates generation of CfgFunctions / Functions Library to make the life of scripters a bit easier https://discord.com/channels/105462288051380224/1302325492556369920
@tender fossil this way they will never learn π
i perfer to wright it my self, with the help of others ofcorse
I don't recall using file = thingy at all in my CfgFunctions
You talk like 10 year old
It's possible to go without it - file paths will be autodetected based on the category path. But I usually prefer to use it to avoid adding extra folder layers that I don't need.
Ah, so you don't have it functions folder
I think I'll leave it at default
Only weird thing is file name has prefix fn, but function name is gonna have prefix fnc
Just Arma Things
how to find out if the projectile is a hand grenade ?
CfgAmmo simulation/type entry?
There is some command to get projectile info, ammoInfo? Something ammo?
shot info?
(https://community.bistudio.com/wiki/getShotInfo) it doesn't appear to have any super useful information for this
I am using the "Fired" event handler, I have the projectile as object, but I need to exit the script if the prejectile is a hand grenade
Try exiting if the weapon is Throw instead
configOf to get it's config.
And then either type or simulation entry
Checking for Throw is probably cleaner because there are a few different simulation types for "hand grenades" (e.g. frags vs smokes)
Bear in mind that if you want to support ACE then that might use a different weapon for their fancy throwing logic.
I don't think they do, because all mods register grenades with throw weapon. But they might be use any weapon at all and not trigger fired
I resurrected a wind ballistics script form a2, its working in a3 π₯³
params ["_bullet","_weapon"];
if (_weapon == "Throw") exitWith {};
_wind = wind;
sleep 0.01;
while {alive _bullet} do
{
_windX = wind select 0;
_windY = wind select 1;
_windZ = (wind select 2) + random (2) - random (2);
_velX = velocity _bullet select 0;
_velY = velocity _bullet select 1;
_velZ = velocity _bullet select 2;
_bullet setVelocity [_velX+(random _windX)/10, _velY + (random _windY)/10, _velZ + (random _windZ)/10];
sleep 0.01;
};
probably has things to polish but its working
I don't know how strong should be the effect in a stormy weather
are 5.56 rounds flying way along the crosswind at 700 m ?
I am thinking how to lower the wind deflection π€
Well, if you read the script you can see there are numbers which act as divisors, controlling the magnitude of the velocity change. Increase those numbers to make the velocity change smaller.
You could also substantially simplify this script by using vectorAdd and vectorMultiply
is it true that wind is always horizontal like stated in biki?
https://community.bistudio.com/wiki/wind
Well, you can only set it with 2D vectors, so yeah, probably
It still triggers fired with Throw
does anyone know why when some paa images i've converted from png, show up in game INCREDIBLY dark, to the point where they don't really show at all?
I never did much scripting in the editor much, but i guess like this.
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
{
deleteVehicleCrew _x;
} forEach (synchronizedObjects _unit);
}];
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed
https://community.bistudio.com/wiki/synchronizedObjects
The reason it wasn't working before is because in most contexts, _this contains all the arguments that were passed to the current scope. For example, if you do "string" call { hint _this };, then _this contains "string" - and if you have an array of arguments, then _this contains that array. e.g. ["string", 2] call { hint _this } would fail because _this contains ["string", 2].
Event handlers always have an array of passed arguments. Their _this variable is what params parses to get all the things like _unit, _killer etc. So you were trying to use synchronizedObjects not on a single object, but on an array containing the EH unit, the killer, etc., and that doesn't work.
As in, black?
Hey, this is fairly urgent, so if anyone can help, please do. My Unit is trying to run a scaling script that we used like.. 2 months ago. It's not working anymore and we are completely out of ideas
It's in a dedicated server as well
and you don't post the script?
and no rpt? 
so dark that it appears black, yes.
Is there a way to make the character break reload ? I'm working on a melee system and usually on modern weapons, you don't need to break reload because it only take 2 seconds to reload. But with muskets it takes 15 seconds to reload, that's a bit a lot without a way to break reload to switch on melee
when you say break reload do you mean Cancel reload
i wish there was away to Knife kill Enemy in Arma 3 with out using Mods
Hello all: is this the correct way
[_caller, _target, _actionId] remoteExec ["functions\fnc_sabotage.sqf", 0];
No. remoteExec cannot directly execute a script file. You need to make the script file into a function, then execute the function by name. https://community.bistudio.com/wiki/Arma_3:_Functions_Library
ah ok now i understand
thx you
ok how about now is this correct
[_caller, _target, _actionId] remoteExec [[] spawn SFA_fnc_sabotage, 0];
Yes that's what i mean
i'm working on a melee system right now
well the only way iv found to Cancel reload is buy scripting my own reload script, and i exec it from a radio trigger
so i have 2 reloads like the default one and my radio trigger one
and the only reason i made the radio reload was so i could get rid of a the old mag that only had like 3 bullets in it when i reloaded: i could not seem to make that happend with the Reload EH
and i made that radio reload script into a funtion so i use [] call because theres no sleep in the script
im much more awake now i was half asleep earlyer
sorry about that
gestures break reloads, do note they 'break' it. the weapon animation will be stuck at whatever point it was at and the magazine that was going to be loaded gets lost
what's a gestures ?
type of animation
ah ok i see
ah copy that
Is it possible to detect when specifically a missile-type projectile enters a trigger area, and then to destroy that missile either by prematurely detonating it or by just deleting it if I can't do that?
I have a use case where I want a trigger in a near-future scifi scenario to appear that it was intercepted missiles by a laser APS system on an aircraft. I plan to make the trigger attached to the plane and following it around.
I know games like Antistasi have a way of somehow preventing people from throwing grenades or shooting rockets at spawn but I don't know if this detects the projectile and deletes it or just somehow interrupts the weapon firing code.
detect & delete.
It's about six different event handlers because it deals with ACE as well.
Thank you very much ! Didn't check switchGesture ^^
Hi all,
Anyone have a handy init to make a prop pickup-able?
Trying to make a flag able to be picked up for a CTF style mission.
Thank you!
[_caller, _target, _actionId] remoteExec ["SFA_fnc_sabotage", 0];
Will run a function on each client and server machine in a scheduled event
https://community.bistudio.com/wiki/remoteExec
why only one patrol is spawning ?
params ["_uberPos"];
for "_i" from 0 to 2 do
{
private _ptrlgrp = createGroup [west, true];
_ptrlgrp setCombatMode "RED";
_ptrlgrp setSpeedMode "FULL";
_ptrlgrp setFormation "LINE";
_ptrlgrp allowFleeing 0;
private _spos = [_uberPos, 100, 200, 0] call BIS_fnc_findSafePos;
for "_i" from 0 to 6 do
{
private _runit = selectRandom KIB_infUnits;
private _unit = _ptrlgrp createUnit [_runit, _spos, [], 0, "NONE"];
};
{_x linkItem "NVGoggles_OPPFOR";} forEach units _ptrlgrp;
{removeGoggles _x} forEach units _ptrlgrp;
[_ptrlgrp, position (leader _ptrlgrp), 100] call BIS_fnc_taskPatrol;
sleep KIB_tskTime;
private _wp = _ptrlgrp addWaypoint [flg,0];
_wp setWaypointType "SAD";
[_ptrlgrp, 1] setWaypointSpeed "FULL";
[_ptrlgrp, 1] setWaypointBehaviour "AWARE";
[_ptrlgrp, 1] setWaypointCombatMode "RED";
};
Try if you change "_i" in 2nd for loop like "_j"
I assume your _i is changing when you use the same var
@kiba βοΈ
for is supposed to be immune to that
Try adding some systemChat logging to see at what point the script stops
Yeh, reading wiki. And
For loops can be safely nested. This means that there should not be any problems with recursion.
_array = [];
for "_i" from 0 to 3 do
{
for "_i" from 0 to 3 do
{
_array pushBack _i;
};
_array pushBack _i;
};
hint str _array;```
And you are using scheduled environment, spawn or remoteExec,
Because you have a sleep used there.
oh Man i got it to work correctly i added a groupChat message also: thx you so much @stable dune @hallow mortar
man that was the hardest thing i had to do in Arma 3 scripting
i think theres smoke coming out of my ears π
make sure they have a resultion that is 2^n x 2 ^ m, where |m - n| <= 2
512x512
64*256
etc.
you have reached the average state of SQF users - congrats!
@winter rose you really don't want to see the bottom π
I had a friend who made one map a day π
quality out of the roof
I've been to all the extents of the SQF mindset!! πΉ π€ͺ
quick question, how would I create a string file in my mission folder that I can refer to using a script in a trigger
I currently have multiple triggers that perform a selectRandom function, and I want them all to refer to a file to pull the array of options so that I don't have to update the code in every trigger's init
this is the array that I want to use and update down the line inside a .sqf file
// Define the teleport points
["teleport_1", "teleport_2", "teleport_3", "teleport_4", "teleport_5"];
and this is the trrgger that I want to have pull from this array file
execVM creates a new scheduled thread, which (currently) cannot return a useful value to the parent scope.
You need to turn the script file into a function, so you can call it.
BAC_magicTeleports = ["teleport_1","teleport_2","teleport_3","teleport_4","teleport_5"];
publicVariable "BAC_magicTeleports";
\\then
{
if (!isPlayer _x) then
{
_x setPos (getMarkerPos (selectRandom BAC_magicTeleports));
};
} forEach thisList;
I cannot imagine the context of this magical portals ? π€
ahhh that's really enlightening, I wasn't SQF literate enough to think of that alternative method, thank you!
the function is this ? π
selectRandom ["some markers"];
I don't really know how to properly write up the function yet but that's got me looking in the right direction at least
@warped igloo just use global variable name for the marker names
A lot of this fancy terminology is beyond me unfortunately
@warped igloo you name the markers array to be something like BAC_rTeleport (whatever name u choose), then broadcast it ( with publicVariable command ) and use it when u need to select random teleport
this is a way not to have to define a function
and what exactly do you mean by "broadcasting it" ?
just write
publicVariable "the_name"
and u can use it in all scripts in the mission
from all scopes
right, and that would be defined in an .sqf file
which can then be called by the script in a trigger?
you don't need .sqf file
just define it initServer.sqf and that is
BAC_magicTeleports = ["teleport_1","teleport_2","teleport_3","teleport_4","teleport_5"];
publicVariable "BAC_magicTeleports";
then you can reach it from the trigger script
ahhh that's what I wasn't fully grasping, so you are indeed setting it up in an init file such that it can be reached by triggers
you don need to use call or execVM , just the global variable name
its a "container" for your markers array
now I get you
I think you can define it wherever you want (in a trigger for example) but after this you broadcast it and you will have it everywehere
yeah that does the job I was looking for, I was just looking the wrong direction.
global variables, gonna keep that one handy in the future π§
most of the magic is here -> https://community.bistudio.com/wiki/Variables
@stable dune and @hallow mortar oh man it works so Great woohoo, i love it, thx you so much again guys, i'm really happy you guys helped Me, thank you: thank you: thank you:
oh btw thx @winter rose for saying so
WooHoo i made it to average: π
lol i turned off the enemy and went around blowing up the stuff : to make sure it all worked: π
has anyone used the addMagazines function in a way that automatically picks the relevant magazine for the weapon? I'm trying to make it a universal rearm function that works for any weapon the player may have
Based on what magazines they already have, or just the weapon?
You can try compatibleMagazines.
This is difficult to reliably do fully automatically though, because some mod weapons can have a variety of fake/weird/etc magazines available to them
e.g. partial magazines for bolt-actions, magazines with blanks, spotting rifle mags for launchers
The first element of compatibleMagazines is almost always reasonable.
but yeah, not guaranteed. Depends on the mod.
yeah, ideally it's to reload your weapon based on the magazine that you already have, if you're plain empty, then any compatible magazine would do
the important thing is that it's able to execute regardless of the weapon of the player
so the idea is
player addItem ([currentWeapon player] call BIS_fnc_compatibleMagazines);
where you call the function, which should return an array of options, and then select the first option in the array to use in addItem
I am unfortunately not sure how to properly write out the syntax to be correct
Generally prefer to use the command version rather than the function, it's more efficient
how far off am I with this syntax? π
_compatMag = player compatibleMagazines select 0;
player addMagazines _compatMag, 3;
I'm trying to get it to select the first result in the array, and then use that to give it to the player
https://community.bistudio.com/wiki/compatibleMagazines
Syntax:
compatibleMagazines weapon
private _compatMag = (compatibleMagazines currentWeapon player) select 0;
player addMagazines [_compatMag, 3];```
The command pages' description of the syntax is generally quite literal.
Anyone know why it suddenly doesn't like my addaction condition params? When I test it manually by adding it in the debug menu with the condition being hint str items _this it works just fine. I attached an image of the error
WAG_medicalSystem_fnc_addMedicalAction = {
params ["_unit","_interactionText","_code","_priority","_condition","_range"];
_unit addAction
[
_interactionText,
_condition,
nil,
_priority,
false,
true,
"",
_condition,
_range,
false,
"",
""
];
};
///===--- Heal Unit ---===\\\
//-- Self Interaction
_interactionText = "<img size='1.5' image='\Battery\Circle.paa'/><t color='#0CD61A' size='1.2' font = 'PuristaSemibold'> Heal</t>";
_code = { params ["_target", "_caller", "_actionId", "_arguments"]; [_caller,_caller,"Health_Syringe","BODY"] call WAG_medicalSystem_fnc_healPart };
_condition = "
('Health_Syringe' in items _this) &&
(_target getVariable 'WAG_MS_health' < WAG_MS_SETTING_HEALTH) &&
(_target == _this) &&
!((vehicle cursorObject) isKindOf 'MAN')
";
[_unit,_interactionText,_code,10,_condition,-1] call WAG_medicalSystem_fnc_addMedicalAction;
You're using _condition where you should be using _code
_unit addAction
[
_interactionText,
_condition, // <<<
nil,```
I clearly need to sleep. Thank you for pointing that out
any clue as to why I'm getting the undeclared variable error?
_mk20 = player addPrimaryWeaponItem "arifle_Mk20_F"; player addWeapon "arifle_Mk20_F";
_m79 = player addPrimaryWeaponItem "vn_weapon_arifle_m79"; player addWeapon "vn_weapon_arifle_m79";
selectRandom [_mk20, _m79];
sleep 0.2;
private _compatMag = (compatibleMagazines currentWeapon player) select 0;
player addMagazines [_compatMag, 3];
addPrimaryWeaponItem doesn't return anything, unless the item failed to add.
Also, you're doing addPrimaryWeaponItem with the weapon classname, not an attachment classname, and I'm pretty sure that doesn't work
Your selectRandom isn't doing anything useful (it chooses one of the two items in the array, but does nothing with the result)
I really recommend reading the documentation for the commands you're using
Did you mean to do this?
private _weapon = selectRandom ["arifle_Mk20_F", "vn_weapon_arifle_m79"];
player addWeapon _weapon;```
that was the initial goal yes, but addWeapon and addWeaponGlobal weren't equipping, or adding anything to the inventory, so I stumbled upon a post that mentioned adding the magazine prior to the weapon in order for it to be equipped
I tried a few combinations, and this
player addPrimaryWeaponItem "arifle_Mk20_F"; player addWeapon "arifle_Mk20_F";
did the trick, likely by accident lol
I think you should read those commands, and the classnames you're putting into them, and think a bit harder about what's happening here
how to make it to check for every blufor unit instead of player?
while {true} do
{
{
if (player distance (getMarkerPos _x) < 500) then
{_x setMarkerColor "ColorYellow";
} else {_x setMarkerColor "colorOPFOR";};
} forEach KIB_redMrk;
sleep 5;
};
//KIB_redMrk is array of markers
Also this trick isn't necessary for the weapon to be equipped, it's just a way of making the magazine be loaded into the weapon immediately upon adding the weapon (rather than having to manually reload to grab a mag from inventory)
findIf, probably (and units west)
right, I updated the script to use addMagazine instead of addPrimaryWeaponItem , the logic is that with selectRandom, it randomizes which weapon gets equipped with the process above
I know for a fact that a weapon won't be equipped to the player without first adding the magazine, so it has to be a two-part execution, hence why I put it in a variable, so that they can be sorted in the selectRandom function
addPrimaryWeaponItem works fine for adding a magazine directly to the weapon...after you've added the weapon. You can't use it when there's no weapon to add a thing to. It also works for adding a magazine when you give it the magazine classname, not the weapon classname.
a) You do not need to add a magazine first in order for a weapon to be equipped. Fundamentally and factually not true. You can add a magazine first, but all that does is make the magazine automatically load into the weapon when you add it, and doing addPrimaryWeaponItem afterwards has the same effect.
b) You're not saving anything useful to a variable. You're just saving the return from addPrimaryWeaponItem, which is either...nothing, or a not-very-helpful boolean value (false). Even if you were saving something useful to the variables, you've already done the weapon-adding. Doing selectRandom on the result doesn't change what's already happened.
@warped igloo what are trying to do actually ?
equipping a random weapon with ammo to the player with a trigger π
so far I have the weapon equipping part working, but I'm getting a undefined variable error when running the script, so only the first option works
@warped igloo do you have the classnames of the weapons you want to use ?
indeed I do,
_mk20 = player addMagazine "30Rnd_556x45_STANAG"; player addWeapon "arifle_Mk20_F";
_m79 = player addMagazine "vn_magazine_ugl_40mm_m381_he"; player addWeapon "vn_weapon_arifle_m79";
selectRandom [_mk20, _m79];
sleep 0.2;
private _compatMag = (compatibleMagazines currentWeapon player) select 0;
player addMagazines [_compatMag, 3];
just not sure what's throwing the undefined variable error
private _weapon = selectRandom ["arifle_Mk20_F", "vn_weapon_arifle_m79"];
player addWeapon _weapon;
private _compatMag = (compatibleMagazines _weapon) select 0;
player addMagazines [_compatMag, 3];
player addPrimaryWeaponItem _compatMag;```
I promise you I have some idea what I'm talking about.
@warped igloo first add the weapons, then the magazines for this weapos as @hallow mortar already showed in his script, end of the story π
I told you what's causing the undefined variable error π
In some detail :/
the only thing you have to do is substitute player with (thisList select 0) if you want to use it in a trigger
Depends on the trigger
I'm trying to find a way to make AI stay inside damaged vehicles, specifically tanks, when they are partially damaged. For example if the engine is damaged but the turret is fine, they just leave.
I found
"allowCrewInImmobile" function that stops them from leaving if the tracks are dead. So thats something, but not everything
Anyone know?
allowCrewInImmobile works on engines too IME?
if activation is any player
Only time it doesn't is when the vehicle is about to explode.
I guess that might conflict with things like ACE advanced vehicle damage.
You could try locking the vehicle as well, although that has an obvious secondary effect
Nah they definitely just get out
It's a bit more complicated than that.
Using player will do fine for initial testing. Once the adding functionality is confirmed working, the rest can be sorted out.
No mods?
can he check that its working, thats the question ... @warped igloo just use the debug console and paste the code, then execute it locally
Just CBA,ACE,RHS
ACE advanced vehicle damage enabled or not?
its off
locking didnt work either, but i found this checkbox and it does work!
Now i just gotta figure out what variable/function this goes to.... (3den enhanced)
Inspect it in the Config Viewer and look for the attributes (...I think is the name) subclass
or event handlers might actually be where the function is called from
hmm. Which allowCrewInImmobile syntax did you use?
this allowCrewInImmobile true;
Possibly the expression of that attribute is happening after the init field and overriding it
thats true..
Works fine here? Did basic test with M136 vs M2A3 engine.
i'll try adding a delay after spawn then to see
With this allowCrewInImmobile true they stay in the vehicle otherwise they jump out.
they also have 3den Enhanced running and I'm pretty sure that's where this checkbox comes from
It's probably just running allowCrewInImmobile though. Different timing is possible.
Yeah i forgot it had that in too, didnt think it would matter
yep adding a delay fixed it. They arent getting out. Thanks fellas
Well, there is also the question of how you're applying engine damage. I assumed you were shooting things :P
~~It ended up working with this section from Nikko
private _weapon = selectRandom ["arifle_Mk20_F", "vn_weapon_arifle_m79"];
player addWeapon _weapon;
and my existing ammo script at the end to add magazines (in reserve only, not instantly loaded in the weapon)
private _compatMag = (compatibleMagazines currentWeapon player) select 0;
player addMagazines [_compatMag, 3]
I appreciate the patience and help to get it to work without errorsπ~~
edit: the randomization still doesn't work, I'll sleep on this problem π
using that entire code by itself throws this error message π€·ββοΈ
should be private _compatMag = compatibleMagazines _weapon select 0;
oh right
I forgot what the select 0 was doing in there when I changed it from currentWeapon πΆ
π arma is still not happy
for reference:
private _weapon = selectRandom ["arifle_Mk20_F", "vn_weapon_arifle_m79"];
player addWeapon _weapon;
private _compatMag = compatibleMagazines _weapon select 0;
player addMagazines [_compatMag, 3];
player addPrimaryWeaponItem _compatMag;
Are you sure "vn_weapon_arifle_m79" is the correct classname?
_compatMag will be nil if compatibleMagazines _weapon is an empty array.
looks like it
nah that's the CfgVehicles one.
Equip one and run primaryWeapon player
Or go find it in CfgWeapons
CfgVehicles has weapon holders you can place that have weapons in them, but those are not weapon classnames.
So why so many parameters like _killer and _instigator and _useEffects?
That's just all the ones that the EH provides. It's the "default" setup. You can remove any you don't need from the end of the array. (Parameters you do need must remain in their correct index in the array, so no removing ones from the middle)
You could use empty stings for not needed parameters in the middle
Someone just asked us if we could add something to allow them to change their FOV in-game for the server because he uses NVIDIA Cloud Gaming. I informed him it wasn't possible and he sent me an entire zip file saying "this is how it's possible". This being the most notable file:
params ["_top","_left"];
if (!hasInterface) exitWith {};
if (isNil "_top" || isNil "_left") exitWith {};
setCustomFOV [_top, _left];
// Persist for future sessions
profileNamespace setVariable ["JTF_fovTop", _top];
profileNamespace setVariable ["JTF_fovLeft", _left];
saveProfileNamespace;
ChatGPT go brrr
I was really trying my best not to crash out
There was also an entire AI generated README.md which was pretty brutal too
Where do you display these images? UI? Texture?
Hey there folks, is it possible to use an animated (preferably looping) texture with CutRsc?
Is there anything for detecting if something is an airfield?
I know the auto land can find them so Iβm assuming but idk if functionality like that is useable in SQF
private _mainRunway = configFile >> "CfgWorlds" >> worldName;
private _otherRunways = "true" configClasses (_mainRunway >> "SecondaryAirports");
Then ilsDirection and ilsPosition under each of those.
what are u up to? π§
Thank you!
Tried this on Malden and it only gets the Pegasus airbase, is there a way to get the main airport as well? Couldn't find on config
There's one in secondaryAirports so that makes two?
_mainRunway there is just the root config for the world but that has the ilsXXX parameters too.
ah okay, thanks
It's the usual config horror, like where the base weapon class can also be a fire mode.
Can someone please share the build script for the engineer slot?
what build script?
construction of fortifications for engineers from loaded materials in Trucks
Also recently seen a Arma mission on workshop. AI generated description saying one of the features is it can change the game language mid game. Open the script, yeah its there, its using the setLanguage script command.
The amount of bullshit I'm seeing lately is just too much. And somehow, in all of it AI is involved.
I want to get back to the good old days when the top-level of bullshit was scripts by Quiksilver
Bro setLanguage haha π
Brutal how made up it all is
Also very right about AI always being involved. Before AI there was always bad written code but at least it didn't just entirely make up the names of random commands and functions so blatantly π€§
all the REAL devs have one file with 2426 lines of remotexec
Or loops on every frame with network commands like setMarkerColor- very performant 
So much sickening stuff 
people think they can make good mission or mod without their brain taking part of it
WebKnight's 17 thousand line preInit
i need to change marker color if whatever bluefor unit goes too close (< 500 m )
{
{
if (_x distance (getMarkerPos _x) < 500) then
{_x setMarkerColor "ColorWEST";
} else {_x setMarkerColor "colorOPFOR";};
} forEach KIB_redMrk;
} forEach units west;
gives error array instead of object
im trying to set up a script for training where I can delete all units of opfor attached to a button, anyone able to help?
im trying to use deleteVehicle but I cant seem to get it to actually delete anything
You're trying to use two different _x at the same time. Read this in isolation:
if (_x distance (getMarkerPos _x) < 500)```
How do you think the game is going to interpret this?
how can i override a function from a mod? I tried to make my own .sqf file at the correct path in the mission, and in the function viewer i see my code instead, but calling the function runs the old code.
also tried funcName = {mycode} in the init file, but same there
{
private _marker = _x;
if ((units west findIf { (_x distance getMarkerPos _marker) < 500 }) > -1) then {
_marker setMarkerColor "ColorWest";
} else {
_marker setMarkerColor "ColorOPFOR";
};
} forEach KIB_redMrk;```
Depends on how the function is defined
If it's in CfgFunctions, you can just make your own mod and modify the CfgFunctions config.
If it's just like function = compileScript "...", then you need to have your script run before the mod's and use compileScript / Final
hello @tulip ridge i wanted to thank you again for helping me with my Chopper Command, i have now made all the Chopper Command into Functions Works Awsome
@hallow mortar you deserve a drink π»
I have 2 objectives, ~100m apart. I engage objective 1, and enemy from objective 2 is running towards objective 1 engaging. How to prevent, or keep units from objective 2 keep on place. Note, units are should remind patrolling assigned sector, usually by marker.
@real tartan wanting the enemy not to engage from distance less then 100 m ? wtf
I set group to defend sector, but they run out to engage enemy. want to prevent them to leave defending position, but still able to move in designated area
@real tartan just make them unable to move but they will be able to shoot
this disableAI "PATH";
//place this in the unit init
thanks!
i tried using this in the init:
mod_fnc_name = compileScript ["myOverride.sqf", true];
but it did not work, perhaps the mod runs before the init.sqf? or do the path and name of "myOverride.sqf" need to match the original, not just the variable mod_fnc_name?
I also tried adding a matching path and "fn_functionName.sqf" file in my mission folder, it seems to override in the function viewer but not working when called. is there something else i need to add for it to override correctly?
this is a mission specific change i want to do, so I need a way to embed all the changes into the mission.
that will make them stay on spot, I want them to patrol in designated area, and keep defending without fleeing to enemy in other side of map
You can't override mod CfgFunctions with mission CfgFunctions
@real tartan first you say there are 100 m between them (obj 1) and you (attackin obj 2 I guess). Then you say they somehow run across to the whole map the engage enemy they don't know about. I am confused. π΅βπ«
oh ok, that's a shame. thanks for the help
@real tartan you can try with guard waypoint https://community.bohemia.net/wiki/Waypoints
that does not sound like something i can do on all players machines π i'll find some workaround for my issues somehow, just wont be as efficient
Well, how are you making them patrol?
If you're giving them move waypoints then they'll roughly follow them. However unless you use disableAI "TARGET" they will send some members of the squad towards contacts.
usign BIS_fnc_taskPatrol, setting distance between waypoints ~ 1/3 of radius I want them to patrol
Ok no idea then, haven't read that code.
@real tartan AI forgets waypoints when in contact with the enemy, the FSM kicks in and you don't have control what they will do, but they will resume patroling after they kill you or they lost info about you for 2 minutes
with @CBA you have fnc_taskDefend you can use if you want them to defend an area
mind that part of the enemy will garrison buildings with this function
They don't forget waypoints while in contact. If the group has a move waypoint they'll still be making an attempt to travel in that direction. It just slows down and can get a bit roundabout, depending on cover. However there's a mechanic where the squad leader sends one or more units in the direction of the contacts instead, which you can disable with TARGET.
Guys, I got a question and need urgent help. I'm making a south african border war server and want to split the map im using in two. Each halve of the map will have its own town which will have capture points. Now each team has to capture each other's points and whoever captures all points wins. I need the ai commanders to automatically take the points and garrison it. And if the ai gets killed it respawns in 10 minutes and continues to capture points. Will someone please tell me how i can do this or maybe help me to set it up? I would really appreciate! Maybe with scripts or modules? Thank you!
@austere tartan basically you want someone else to script your mission 
No i just need help scripting it or using modules. Im recruiting devs for my server. Im a noobie and have no idea how to code at all. I hope im not angering people
I can be a fun project and anyone can join it
then start learning here -> https://community.bistudio.com/wiki/Category:Arma_3:_Editing
normally people help in this channel after you have some script already and its not working for some reason
what is your arma 3 experience in hours ?
I understand. Thanks man
About 60 hours. Most of the time i try to make servers but fail miserably. Thats why i ask the community for help
@austere tartan you need to play the game a lot more and then you can start thinking about missions and servers
Yeah i agree. Anyways thanks for the help. I will check the link for info
how would you pull items from nested arrays?
i tried
(_array select 0) select 8;
(pull the 9th item from the 1st array of the array of arrays)
but that just gives me the first array
Nah, that's correct.
thats what I thought
Your arrays probably aren't what you think they are.
testing it with hint str and its returning the whole first array
Well, hint str (_array select 0) select 8; would return the first array, because precedence. But you're not doing that, right :P
no i would never do that it would be silly of me to even think of it
gimme a sec to delete that exact line
cackles
they were out of parentheses at the store
how to open the rugged comms terminal open with a script ?
RuggedTerminal_01_communications_F
this
@exotic flame Checked it out and indeed its impossible with simple objects, collision damage can randomly apply before EpeContact* events, even if you know which object you expect to hit you can't add EpeContact* to it as its a simple object
this only does the progress bar no?
i believe its something like Terminal_source
Does it?... Prolly yes, I might misremember it
Yes its Terminal_source just tested, no idea what the upper limit is tho, probably 100
@exotic flame
vehicle player removeAllEventHandlers "EpeContactStart";
vehicle player addEventHandler ["EpeContactStart", {call epec}];
arr = createHashMap;
epec = {
_obj = _this select 1;
if(hashValue _obj in arr) exitWith {};
arr set [hashValue _obj, createHashMapFromArray [
["obj", _obj]
,["damage", damage _obj]
]];
systemChat format ["%1: Obj=%2 | EpeContact initial damage=%3"
,diag_frameno toFixed 0
,_obj
,damage _obj
];
};
onEachFrame {
if(count arr > 0) then {
{
private _obj = _y get "obj";
private _old = _y get "damage";
private _dam = damage _obj;
systemChat format ["%1: Obj=%2 | Old=%3, New=%4, Delta=%5"
,diag_frameno toFixed 0
,_obj
,_old
,_dam
,_dam - _old
];
} forEach arr;
arr = createHashMap;
};
};
```My test script
Sometimes it works, Car->Obj triggers first and it works properly
But other times Obj->Car collision triggers first (which you can't add event for at all) and object is already damaged
I noticed that it all comes does to order in which objects are inserted into EPE scene
If you spawn a car and hit something, its always Obj->Car collision event first
If you drive car somewhere other objects are inserted into scene after the car and its always Car->Obj collision first
Basically you can use this approach but its not always reliable
Also its better to use EpeContact for this method, I just did EpeContactStart to see less chat spam
This might indicated that this method will be mostly reliable
Indeed when its not a terrain object, damaged event fires after but it doesn't work for terrain objects and unfortunately collision damages are mostly dealt to terrain objects not spawned objects
This collision order issue applies to all objects really
And for simple objects your only option is comparing damage (maybe hit points if you really want to complicate it)
This looks like a bug to me, if collision order applies properly on spawned objects it should be applied on the same way to terrain objects
I'll make a ticket for that too
im just trying to use the respawn system with parameters and it seems to be bugged. using respawnTemplates[] = {"MenuPosition","Tickets","EndMission"}; but mission does not end when run out of tickets or all dead in mp hosted server environment. anybody an idea?
it just says 0 tickets in respawn system instead of failing the mission
how to put agents in vehicle as driver, they don't care about moveInDriver command?
@next kraken in a trigger condition
[west] call BIS_fnc_respawnTickets <= 0
activation field
["win", true] remoteExec ["BIS_fnc_endMission", 0, true];
description.ext
class CfgDebriefing
{
class win
{
title = "Mission Completed";
subtitle = "RAF liberated group Brand";
description = "RAF dorces liberated group Brand from enemy hands.";
pictureBackground = "";
picture = "b_inf";
pictureColor[] = { 0.0, 0.3, 0.6, 1 };
};
class fail
{
title = "Mission Failed";
subtitle = "RAF forces faled to liberate group Brand";
description = "Without Brand's military expertise RAF will have heavy times wining in west Germany.";
pictureBackground = "";
picture = "b_inf";
pictureColor[] = { 0.0, 0.3, 0.6, 1 };
};
class ZeroTickets
{
title = "Mission Failed";
subtitle = "No More Reinforcements";
description = "RAF has no more fighters to continue this operation.";
pictureBackground = "";
picture = "b_inf";
pictureColor[] = { 0.0, 0.3, 0.6, 1 };
};
};
β
What is the best way to have a script execute on each player every 5 seconds ?
Also the goal is to work on dedicated server.
Thx in advance for the answers π
@granite moat run it from initPlayerLocal.sqf, also look for event handlers before writing** while** loop
For now I had in mind init player with PFH.
@split ruin what color is that in the pictureColor[] = { 0.0, 0.3, 0.6, 1 }; ?
how to move or spawn an agent as driver ? π€
this doesn't work, they spawn but stay around the vehicles
_agent = createAgent ["B_Soldier_F", [3040.13,7992.61,0], [], 20, "NONE"];
_agent setVariable ["BIS_fnc_animalBehaviour_disable", true];
_agent assignAsDriver veh;
_agent moveInDriver veh;
oh nice awsome m8 thx @atomic niche
@split ruin ```sqf
_agent assignAsDriver _veh;
_agent moveInDriver _veh;
Is there a reason why I cannot set a PFH in the initServer.sqf ?
[
{
missionNamespace setVariable ["TEST", time, true];
},
5,
[]
] call CBA_fnc_addPerFrameHandler;
this does not make it run every 5 secs. But if later I run the cmd manuualy on the server it works
How can I execute this at server start if not in the serverInit ? :/
is there a "paper flip page" / "document read" / "write on paper" sound in game that I can use ?
Dedicated server? it should work
what are you trying to achieve?
currently testing on local multiplayer :/ Maybe it only works on dedicated ? (want to avoid to go on dedicated to test while developiing)
something sweet, basically track some variables on the server, in short
and update them every 5 seconds according to some conditions
from what I've learned actually is better to test things on dedi
yeah but takes way more time
hmmm but it should work, maybe is something with the host... did you try with init.sqf file?
nope, will try now
Omg I might be dumb... let me test something
can be both, but looking for vanilla mostly
My bad, it works, I did a human error :/
Was editing mission called "test" but I am actually in "test2" ...
CfgSounds Orange_Leaflet_Investigate_01 ..._02 ..._03
a3\sounds_f_orange\missionsfx\orange_leaflet_investigate_01.wss
[]spawn{
_initialLoc = getPos floatyMan;
while {true;}do{
yPos = [((getPos floatyMan) select 2),((_initialLoc vectorAdd [0,0,2]) select 2),0.5] call BIS_fnc_lerp;
newPos = [(getPos floatyMan) select 0, (getPos floatyMan) select 1, yPos];
floatyMan setPos (newPos);
sleep 0.01;
};
};
Looking to move 'floatyman' up 2 metres gradually. With this script he just vibrates on the ground. Any ideas?
, use setPos and getPos are 2D onlysetPosATL/getPosATL
Much obliged!
Cannot believe I missed that
Np, it happens π
They aren't 2D only, they just have a "snapping" behaviour where if there is a surface nearby, the position will be adjusted to the surface
(They're also slow and have compatibility issues because of using an inconsistent altitude format, but they are 3D)
Thanks for the correction π
Is there a way to make an empty vehicle hostile towards a faction? For example, OPFOR will always shoot at BLUFOR vehicles even when empty?
iirc AI can attack empty vehicles when they've been added to an opposing group with _group addVehicle _vehicle, though i might be wrong on that
Thank you, Iβll look into it
Ai will attack empty vehicles, i found if you get in the vehicle and drive it, and then get out, enemy Ai will attack the empty vehicle, Enemy Ai always attack my (Mobile Respawn Truck), and then i always have to call the extraction chopper to get back to base to get the Truck again after it respawns
i think when you get in a vehicle it becomes your side:
even if its a enemy vehicle
exsample: steal the car mission
correct me if i'm incorrect
Does anyone know when doing a ParticalArray, what does the size numbers represent? Like is it [X,Y,Z] or [base width, top width, height] kinda like a light cone?
Im trying to do a thick black oily smoke like out of Desert Storm
Array of Numbers - particle size along its lifetime, in meter
Each number is particle size relative to its lifetime
So if lifetime is 9 seconds and size is [0,5,6,10] means it will be
size 0 at 0s
size 5 at 3s
size 6 at 6s
size 10 at 9s
For example if you want size to grow and then stay large you can do something like [0,3,10,10,10,10,10,10,10]
Growth from 0 to 10 in first 1/4 of lifetime and then staying 10 rest of 3/4 of lifetime
oh, I thought size could only be 3 numbers. Didnt know I could do more
Basically its a multi point linear graph
thanks, thats been really helpful
color and animationPhase work the same way btw, you can slow down or speed up particle frames over time and make it change color\transparency over time
oh, ok. Thats cool. I was reading over the wiki and I just couldn't comprehend what was being said. Thanks again for the help!
Yeah its all hard to get until you start testing it
mhhh
is it possible that there is a limit on how many units can be created in a single group or in general?
accidently created 877 units with some script (btw. nice way to kill your SP FPS ^^ had like 0.01FPS)
and after that: "nil" variables everywhere
ahh
found the problem
i think at least i did ...
not for the 877 units spawned
but for the nil
((stupid random select ... forgot a floor :/ )
Hey folks, I keep getting a 'GIF pre stack size violation error' with this chunk of script
while {(_object getPosATL select 2) < _targetZ} do {
private _currentPos = getPosATL _object;
private _currentZ = _currentPos select 2;
private _newZ = _currentZ + _riseSpeed;
if (_newZ > _targetZ) then {
_newZ = _targetZ;
};
_object setPosATL [_initialX, _initialY, _newZ];
sleep 0.03;
};
It reckons I'm missing a (. I've read up and apparently this error is for very subtle syntax issues. I'm at a loss. Any ideas?
Usually missing or mismatched bracket can cause it
Checking it out in notepad++, highlighting each of the brackets brings up the correct closing bracket
Are you sure its in that chunk? Not before/after it?
Ah there
_object getPosATL select 2
That code is nonsense
Ah
Ahhh, the _object needs to go after the getPosATL, right?
getPosATL _object is the syntax
None of scripting command can go X command syntax, but command command X or X command Y
Sweet, I'm such a doofus, much obliged!
I am currently using diableUserInput in combination with an EventHandler while playing a defined gesture in order to stop the players from moving around (have all that in the player's init field). While this works just fine (i.e. stopping players from doing anything), I kind of want the players to be at least able to look around (but not move forward/backwards, left/right). Is there a way to still allow that?
Use an animation that doesn't allow people to move is much more reliable and safe. disableUserInput is incredibly hrash way to do so
Hmmm but would that animation not interfere with the gesture?
Depends on what you want them to do
Acts_AidlPercMstpSloWWrflDnon_warmup_1_loop is one thing you can use
Well the gesture is a "reloading" gesture that still should play (which it does when using the disableUserInput way -> but I totally agree it is a harsh way to do things). Never tried mixing animation with gestures so I have no idea if they interfere with one another.
Oh while I am at it: Is there a way to have the "action menu" (i.e. where all the addactions etc. show up) display more than the ~5 or so entries before one needs to scroll? Or is that something hardcoded?
Likely hardcoded
Thanks, feared as much.
Has anyone reported issues of players randomly receiving BIS_fnc_endMission success with a fade?
I'm thinking more than likely a cheater instead of an Arma issue but figured I'd ask
i have not seen this,,, randomly receiving hmmmmm
i don't understand cheaters, they have such useless lives i guess
Yeah, cheat devs have zero issue ruining the game for everyone if it means making a little bit of coin. Pretty scummy stuff.
I did look through the guys RPT files and couldn't find any diagLog that would've typically trigged through BI's BIS_fnc_logFormat. Meaning probably the endMission command being ran. Shouldn't be possible though, so still not sure what's up.
yeah i do remember one guy cheated and put all of us players in a Halo jump: it was so stupid
i had to close the server pissed me off cuz we were having so much fun
In case of a cheater: Did you try blocking endMission via https://community.bistudio.com/wiki/Arma_3:_CfgDisabledCommands ?
Nope- we use it for existing areas in our mission so haven't disabled but honestly might be what we need to do if this turns out to be a cheater thing. Very bizarre, we haven't had issues with cheaters abusing it in years.
At least from what I've seen- we got a cheater expert who knows more about this stuff than I do but seems all very bizarre to me
But a cheater running the endMission command directly, would not run BIS_fnc_endMission.
What do you mean "receiving" how do players receive a function
Is it not you guys doing an anti-cheat check and running endmission if those fail and a scripter finding a way to trigger those checks?
I've seen some servers do that
Would be nice to be able to turn on logging for network script commands on dedicated servers.
Maybe with a filter array ["hideObjectGlobal"]
That would make it much easier to catch such cheaters (if they use network commands).
Apologies I am an SQF native so my code explaining literacy might be a little bad. I guess what I am trying to say is I suspect endMission is being ran not the BIS_fnc_endMission function.
Although I could be mistaken if it's obfuscated from standard text searching- I don't think we end with any success states anywhere in mission like what the guy was being kicked with.
I thought doing that in my anticheat. But its so much effort.
And its not just script commands. Script commands are not sent over network. And the network messages they generate are not always a 1-to-1 mapping. And very often also used by non-script command functionality
Is there anything by default that would stop remoteExec of the endMission command if not added to cfgRemoteExec?
isnt endMission and BIS_fnc_endMission way diff ?
The BIS_fnc_endMission is the function created for ending missions with capabilities of logging and other stuff. It's a function that can be viewed and is SQF code like anything else you'd find in your mission. The endMission is a command which is something we can't see. Commands are engine solutions to stuff so they are always gonna be faster than functions.
hmm really
For example π
i remember using endMission back in the day but i changed to BIS_fnc_endMission cuz well i don't know why π i guess cuz it BIS ---- and i only use vanilla
In short BIS_fnc_endMission also uses endMission, so blocking it via CfgDisabledCommands should also block BIS_fnc_endMission
Sorry another dumb question- deleted. Speaking before I am thinking this morning.
join the club m8
//in most cases i have 2 triggers that end my missions
//win
["end1"] remoteExec ["BIS_fnc_endMission"];
//lose
["end2",false] remoteExec ["BIS_fnc_endMission"];
//in the Description.ext
//Debriefing
class CfgDebriefing
{
class End1
{
title = "Hostiles Eliminated";
subtitle = "MISSION COMPLETE";
description = "All Enemy K.I.A";
backgroundPicture = "";
picture = "b_inf";
pictureColor[] = {0.0, 0.3, 0.6, 1.0};
};
class End2
{
title = "MISSION FAILURE";
subtitle = "USMC KIA";
description = "Failed To kill All Enemy";
backgroundPicture = "";
picture = "b_inf";
pictureColor[] = {0.0, 0.3, 0.6, 1.0};
};
};
i don't know but i feel: Simple is better then Complicated
holw cow @Milo thats a big script
not Milo's script, thats the SQF forBIS_fnc_endMission(https://community.bistudio.com/wiki/Category:Arma_3:_Functions)
i don't know but i feel: Simple is better then Complicated
Their mission is thousand(s) of SQF files, "simple" doesn't work there lol
i see holy shit 1000s of SQFs holy shit lol
i see what you mean my missions only have 109 sqf files
maybe i can use something simpler then BIS_fnc_endMission
BIS_fnc_endMission is perfectly fine to use, even preferred instead of endmission
It all depends on your needs βοΈ
i saw a part in that BIS_fnc_endMission script that i may use
If you just wanna exit from the server fast
(finddisplay 46) closeDisplay 0
I used that to DC in a admin tool, because i didn't wanted to wait the 10 second escape menu timer all time.
oh cool thx @sharp grotto
yeah the alive check part in the BIS_fnc_endMission script looks cool
I do appreciate all your guys help and for bearing with me. If I figure out anything more on the issue I'll keep you guys posted. Thanks again 
ill just do what Crumble said its all good π BIS_fnc_endMission is perfectly fine to use
and that script is not really that big
You run that at the end the mission, it ain't gonna hurt performace π
ok thx @hushed turtle i always take your advise, cuz i know your good
if there's no command for it, you can instead script a UI element to act like a button and do whatever you want with it
i'm so happy everything in all my missions is working so good, Thx to all you guys helping me, im really having lots and lots of fun in Arma 3
now that i learned about functions π
my missions are running so fast, i had to raise my view distance, so i didn't over control my guy π
What type of UI element?
anything that accepts mouse clicks, like an RscPicture
or you can even group multiple ones in a controls group and script them to make them work together
Any scripts that allow a medic to drag either a injured or dead soldure and then revive the soldure ?
If dead you would need to TP him
TP?
TP ?
im having an odd issue that i hope someine can help me with
diag_log str _bodyPartColor;
diag_log str _selected;
private _ctrlBodyPart = _ctrlGroup controlsGroupCtrl _bodyPartIDC;
diag_log str _ctrlGroup;
diag_log str _bodyPartIDC;
_ctrlBodyPart ctrlSetTextColor _bodyPartColor;
diag_log str _ctrlBodyPart;```
I have this snippet of code from ace, that updates a body parts color based off of damage and bleeding,
However, for some strange reason, when i call it from one script it breaks and fails, but when i call it from another script, it works fine
https://github.com/Cplhardcore/KAM/blob/INDEV/addons/gui/functions/fnc_displayPatientInformation.sqf
https://github.com/Cplhardcore/KAM/blob/INDEV/addons/gui/functions/fnc_menuPFH.sqf
https://github.com/Cplhardcore/KAM/blob/INDEV/addons/gui/functions/fnc_updateBodyImage.sqf
Scripts for reference, along with the results of a diagLoag for both the menu
```0:08:39 "[0.52,0.73,1,1]"
0:08:39 "true"
0:08:39 "Control #6000"
0:08:39 "6031"
0:08:39 "Control #6031"```
and from the DPI
``` 0:08:04 "[0.52,0.73,1,1]"
0:08:04 "true"
0:08:04 "Control #6000"
0:08:04 "6031"
0:08:04 "No control"```
Hey all im looking for lights out script. Basically you drop the script into a breaker box and it cuts off lights around an area.
You will need two pieces of code:
- for turning off the lights in the area,
- for adding the use action to the breaker box.
This is a code you may use for the lights. Create a marker in the Eden that will cover the area (a circle preferably) and give it a name, then call this script:
private _markerPosition = getMarkerPos "YourMarkerName";
private _markerSize = getMarkerSize "YourMarkerName"; //[X,Y] size in meters
private _radius = sqrt(_markerSize#0^2 + _markerSize#1^2); //Turn it into a radius.
private _objects = nearestObjects [_markerPosition, ["House"], _radius]; //Get the nearest objects. House should also include lamps, I think.
{
_x switchLight "OFF";
} forEach (_objects);
For the breaker box action, you can use this function:
https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
and pass the code I wrote above (either as a function or a literal block of code) into the codeCompleted argument of the BIS_fnc_holdActionAdd.
This will allow the player to use the breaker box, which will then turn off the lights. But you will have to adjust it for multiplayer.
So the result could look like this:
[
yourBreakerBoxObject,
"Kill The Lights",
"\a3\ui_f\data\igui\cfg\actions\beacons_off_ca.paa",
"\a3\ui_f\data\igui\cfg\actions\beacons_off_ca.paa",
"_this distance2D _target < 3 && alive _target && alive _this",
"_caller distance2D _target < 3 && alive _target && alive _caller",
{ },
{ },
{
private _markerPosition = getMarkerPos "YourMarkerName";
private _markerSize = getMarkerSize "YourMarkerName";
private _radius = sqrt(_markerSize#0^2 + _markerSize#1^2);
private _objects = nearestObjects [_markerPosition, ["House"], _radius];
{
_x switchLight "OFF";
} forEach (_objects);
},
{ },
[], 5, nil, true, false
] call BIS_fnc_holdActionAdd;
Neat, thanks
private _position = getPosATL object;
private _distance = 500;
private _lights = _position nearObjects _distance select {(isClass(configOf _x >> "Reflectors"))};
Should return all lights.
Hi, im trying to get a sound to play on an object for a mission im making but im having issues. Im testing on a locally hosted listen server.
this works:
playSound3D ["\lxWS\sounds_f_lxWS\ambient\civilian\muezzin_long1_lxWS.ogg", Muezzin_Player_01, false, getPosASL Muezzin_Player_01, 5, 1, 1500];
but this doesnt work:
"\lxWS\sounds_f_lxWS\ambient\civilian\muezzin_long1_lxWS.ogg",
Muezzin_Player_01,
false,
getPosASL Muezzin_Player_01,
5,
1,
1500
] remoteExec ["playSound3D", 0, true];```
Any idea why remote execing it doesnt work?
Well, playSound3D already has global effect, so you don't need to remoteExec it
If you were to remoteExec it (again, you don't need to), you probably wouldn't want JIP set to true, because that would cause any joining player to immediately play the sound again the moment they join
ah okay thank you
The reason the remoteExec didn't work is this:
remoteExec expects its left argument, when it is an array, to be an array of the subject command's original arguments, like this:
[_left, _right] remoteExec [ ...```
Your left argument for remoteExec is an array, so remoteExec is trying to apply that logic to it. But it _isn't_ a `[_left, right]` array - it's just `_right`, which happens to be an array itself.
So you would need to show remoteExec that this array isn't a whole mess of left, right, ??? etc arguments for the command, it's just one argument. The way to do that is to put it in another array, so that you have an array of one argument which is itself an array.
tldr: you have `_right remoteExec ...`, you would need to make `[_right] remoteExec ...`
(But you don't need to remoteExec it)
@queen cargo Noob π
well ... developing XInsurgency 2.0 with OOS ... so
Exsample:
[_target, _caller] remoteExec ["SFA_fnc_sabotage", 2]; // Execute function on the server
Does arma 3 have a limit of objects per scenario ?
depends on your PC really
It has a limit of groups but not objects as far as I know.
Hmmm good then
Do note that having a lot of objects can affect performance, especially if many of them are close together, and if they're placed in the Editor it does affect the size of the mission file
With the caveat that different types of objects have very different performance costs.
I'm just asking because i've already heard about someone working on a 100kmx100km map and who said he reached A3 object limit when he was at 50% of the map
Hello, I'm not sure if this is where I'm supposed to ask this, but how can I turn a server-side script into a workshop mod, so it can be just added to a mod pack rather be added as separate file in every mission file?
It is a "Mod" though - https://community.bistudio.com/wiki/Arma_3:_Functions_Library
This is basically it
@exotic flame In any case using createSimpleObject or createVehicleLocal where possible will be more performant for network. If you are creating a bunch of objects you could also create a script to dynamically spawn / delete them based off player proximity too to reduce the amount active on the client at a given time. Although that may be a little overkill depending on how many you intend to have and what your mission looks like. If that helps though π
Hello All: can we disable the minimap: so no one can use it: or maybe only the host can use it
i wounder is that in the game settings
minimap?
yes i mean the miniMap
There is no minimap, do you mean the GPS panel you can open by pressing [ or ]?
i guess you mean the gps
no i mean the miniMap

do you have a screenshot?
you know the littel map at the far bottom right

that's not game ui
just send us a screenshot
i dont know how to do a screenshot
press print screen and ctrl+v here
I think you mean the gps but let's see
Usually
C:\Users[YourUserName]\Pictures\Screenshots
you have options, the easier one is by just removing the gps from the inventory or the means to get it
i see ok cool
thx man i was thinking that was the miniMap
So can i do this in the Description.ext ```sqf
ShowGPS = 0;
i guess that wont that stop the user
thxs guys i was thinking that was the miniMap all this time π
so its like the gps in your car lol π or the Tom Tom
or like the gps on your Phone π
i see now thxs m8's
i kinda remember a gps that just showed numbers, way back in Arma 2 or was it OFP that was a small box like thing and the minimap was diff, i guess that shows my age π or maybe that was a mod thing hmm no wounder i dont use mods any more
im going to make it so you must steal the gps from the dead enemy if you want the gps
but ofcorse i have a param that removes all from dead enemy so it may not be available woohoo Arma 3
im just crazy about Arma 3 π
thx again guys @stable dune @thin fox @atomic niche @exotic flame
sometimes the simple things are the hardest, and the hardest things are the simplest: like the Golf Swing π
How do I make a trigger activate when all players enter a zone?
Idk if this is right, but maybe something like this, on trigger's condition
{isPlayer _x} count thisList == count allPlayers
Use
BIS_fnc_listPlayersor see Example 1 to only get human players.
Just a quick argument we have: Is it possible to extract your system specs via scripts?
You can get some very basic info with https://community.bistudio.com/wiki/productVersion and https://community.bistudio.com/wiki/getVideoOptions. Otherwise no. An extension might be able to, but that's not exactly pure SQF.
Got it, thanks
The RPT log file contains more extensive information, but as far as I know scripts can't read that
Yeah, that's what I thought too. We just stumbled across a server that says they gather all the info about players to "prevent cheating" whatever that means.
As a server, they may be able to record the IP address of connecting clients (not through scripting, through out-of-game network tools) and they can record the Steam UID of connecting players.
Also, if they're requiring BattlEye, then your BattlEye client is almost certainly collecting that information, but I don't believe their records are directly accessible to server owners.
Its also possible to record what mods players run. But i've never heard of collecting system specs
thank you sm, I didn't see that until now 
Sa-matra, in a hint with parsetext
Is there a way to select the same position within an array from two or three different arrays? For example the long way round would be to do
_array1 = [Man1, Man2, Man3, Man4];
_array2 = [Green, Blue, Yellow, Brown];
_array3 = [a, b, c, d]
_array1 select 1; // Man2
_array2 select 1; // Blue
_array3 select 1; // b
but is there a simpler function to achieve this?
Something like this myb:
_array1 = [Man1, Man2, Man3, Man4];
_array2 = [Green, Blue, Yellow, Brown];
_array3 = [a, b, c, d];
private _arrays = [_array1,_array2,_array3];
private _seconds = [];
{
if(count _x > 1) then {
_seconds pushBack(_x select 1);
};
} forEach _arrays;
hint str _seconds;
oh neat - thanks @fleet sand did not even think about being able to form an array out of several arrays! That is pretty clever :)
Quick question, how do I change the abort button text + its action
I need to call a function when someone hits the abort button.
I know which class it is under, would it affect anything if I overrode that class, changed the text and added an action= field?
Found something weird. I have set up the following two 'MissionEventHandlers' within a simple repeatable trigger to test their functionality for MP:
hint "Click movement location on map";
addMissionEventHandler ["MapSingleClick", {
params ["_units","_pos","_alt","_shift"];
if !(_shift or _alt) then {
{
_MoveMarker1 = createMarkerLocal ["MoveMarker1", _pos];
_MoveMarker1 setMarkerTypeLocal "hd_dot";
_MoveMarker1 setMarkerColorLocal "colorOPFOR";
_MoveMarker1 setMarkerTextLocal "Move here";
_x doMove _pos;
} forEach units Teleportsquad;
};
addMissionEventHandler ["Map",
{
params ["_mapIsOpened", "_mapIsForced"];
if(!_mapIsOpened) then {
removeMissionEventHandler [_thisEvent, _thisEventHandler];
deleteMarker "MoveMarker1";
removeMissionEventHandler ["MapSingleClick", _thisEventHandler];
};
}];
}];
While the above does seem work fine, I get an odd behaviour on the first time it is used: The unit moving walks to the point clicked, but then returns to its original location. On the second try it works as it should, the unit walks to the indicated location and stays there. Can not really explain why that happens (i.e. why the unit does not stay on the indicated point on the first time the trigger and all is used).
A second question is that the above script gives me one "waypoint" that the unit uses, but can I tell him to use a 2nd waypoint too? To do so do I just need put another '"MapSingleClick"' EH within the first one? Or do I have to set things up differently?
You need to pass in _args mapsingleclick eh into the Map eh , it doesn't delete it with map eventhandler Id.
And behaviour why it is not working, I don't have an answer
thanks @stable dune can you elaborate a bit how to utilize _thisargs correctly?
use the third parameter of https://community.bistudio.com/wiki/addMissionEventHandler to pass arguments (like the MapSingleClick event handler - ID) into the Map EH like Prisoner said.
And in the expression code of the Map EH, use _thisArgs to get the arguments from the third parameter using params or select / #.
_thisArgs params ["_myArgument1"]; or
_myArgument1 = _thisArgs # 0
for the behaviour problem we need more details on how your mission is set up and if there are mods been used, like AI mods that could change the entity's behaviour
addMissionEventHandler ["MapSingleClick", {
//Your code..
addMissionEventHandler ["Map",
{
params ["_mapIsOpened", "_mapIsForced"];
_thisArgs params ["_singleEH"];
if(!_mapIsOpened) then {
removeMissionEventHandler [_thisEvent, _thisEventHandler];
deleteMarker "MoveMarker1";
removeMissionEventHandler ["MapSingleClick", _singleEH];
};
},[_thisEvent]];
}];
Hello, are there internally any differences between setPos and setPosATL except for that the first is for AGLS, when used on units? Thanks
setPos has a snap-to-nearby-surface feature. It's also slower. The use of AGLS is a serious issue in itself because it's very difficult to get an AGLS position to feed to the command, and that format is difficult to be vertically precise with.
You should almost always use setPosATL or setPosASL instead, and the same goes for getPos and equivalents.
Thanks, I am aware of the surface issues. I meant it more like, whether setPos shifts units when they collide with something at the target position or other special case behaviors.
the alt syntax of getPos is so useful π
In principle it's useful, but it's still slow and it still returns an AGLS position, which can't be reliably converted. If possible you should use getRelPos (AGL) or vector commands (ASL) instead
true, I always forget about getRelPos
what is AGLS ?
The third syntax? It's not AGLS, docs just kept that incorrect part for some reason.
small question:
is the code on the biki have a specific license?
i am making a mission for unit use and i want to be sure i credit people properly
The wiki license is here https://community.bistudio.com/wiki/Meta:General_disclaimer
thank you so much...
I didn't realize this before. But that also means any modder creating mods for pay, is not allowed to use the wiki π€£
so crediting the specific user is not strictly necessary, but is polite to do?
It is also probably hard to find the specific user. As many scripts are edited by several users. Cleaned up/optimized over years
What is it then?
It's none of them. The description after that is correct.
I guess it could be described as the terrain surface position in AGL coords.
Ah no, because it doesn't adjust with waves.
I'm trying to add units / modules to zeus through script, after looking at a few examples am I correct in guessing that both modules and units need to be added through config, and that I cant attach a script to a placeable unit (e.g. executing a script instead of placing a unit down)
I guess I could do the latter by having my own init event handlers on a specific class, to be fair. Just exploring the options.
Hello. I have a strange problem. I'll mark with |#| where Arma says something's wrong.
(units alpha2) commandGetOut;
(units alpha1) commandMove (getPos wp1);
(units alpha2) commandMove (getPos wp1);
uavholder commandMove (getPos wpuav);```
It tells me that ; is missing.
https://community.bistudio.com/wiki/commandGetOut
The target or array of targets is the right-side argument for commandGetOut, not the left-side
Fuck
I'm dumb
Thank you
what do Type_128 and Type_134 network messages mean?
so doing unitCapture for an airstrike using Firewillβs F-18s andβ¦sadly unitcapture doesnt capture laser designators π
anyone has any ideas how i could work around this? or should i just do a dive bombing run with dumb bombs?
What are you trying to do is the first question
so basically, Iβm trying to script an airstrike that will happen in the background of a mission using unitCapture, planes come in, drop bombs, and fly off, without having to rely on waypoints and stuff
however, unitCapture as far as Iβve tested, doesnt record when the plane turns out it laser designator, and when the LGBs are locked on to said laser, so when my plane actually drops the bomb when using unit play it drops them βdumbβ (unguided)
Iβm not sure if I did anything wrong but since unitCapture records βfiring dataβ I would assume the laser designators is not something that fires
so my current workaround is probably going to be dropping dumb bombs
Btw, just a headsup: Visual Studio Code's AI code completion tool has become really useful for the first time even in the case of SQF. I'm not sure whether it's due to the just released GPT-5 or not, but it can really guess your intentions based on my testing. Would be interesting to hear other's thoughts about it as well. (NOTE! I'm not talking pure code generation but rather autocompletion/suggestions when you're writing SQF in VS Code.) Edit. It can also write proper comments in code
Because unitCapture doesn't capture laser fire, turret movement, etc. What you need is a scripted designated laser point and fireAtTarget command to scripted bombing
interesting, Iβll give that a shot, thank you!
Writing comments and log statements is the most consistently useful application of AI for me. Been doing that for ages now.
Code gen is sometimes useful when it generates boilerplate/repetitive things.
But it can also be distracting or sneak in mistakes at times. If i could turn off code completion for everything but log statements and comments i would.
Agreed. Although I think that the code completion indeed has become much better with GPT-5 so that it can do other stuff too than pure boilerplate. Still not perfect, but it's quite/surprisingly good for LLM already in my honest opinion.
I consider myself as a somewhat sloppy coder, making small mistakes here and there. It's not as big issue as it was earlier, since GPT nags almost always instantly if I make a mistake (like missing comma or something), so it increases productivity noticeably in my case at least
I have been using Claude which was ok. Considering GPT-5 has more context it is not much better imo. Its a bit more all over the place. Claude gives more precise results generally and is way faster. That being said i am using GPT-5 currently and honestly both are fine π€·
Mostly using GPT-5 because its cheaper.
GPT-5 imo did not suddenly unlock AI for SQF. If you think Claude wasn't good enough for SQF then GPT-5 experience didn't either. Its not a big step up from that. Mostly just different.
Haven't used Claude myself (although I did hear that it used to be better than GPTs)
But yeah like i said. I usually just get distracted by the code generation suggestions.
Logs statements and comments is definetly best use case.
And documentation. I always have function headers that explain the function (similar to wiki) within the .sqf file for that function. Mine are 90% AI generated and then a bit adjusted. Results are good enough for me.
I'm looking at this page on structured text in sqf:
https://community.bistudio.com/wiki/Structured_Text#Special_characters
is there a list of special characters that are supported in arma? a lot of these html entity codes display a ? symbol ingame
it worked! thanks polpox!
can someone help me with a little weird problem? it includes a chat.sqf file
just ask
tl;dr, just saying "can someone help" gets you less help because you don't give details
Shocking
does someone know how to concatenate a variable into the debrief text?
_lastRound = BAC_RoundCount;
_printLastRound = format ("you lasted %1 rounds"), _lastRound;
class CfgDebriefing
{
class End1
{
title = "you won";
subtitle = "";
description = _printLastRound;
pictureBackground = "images\endScreen.jpg";
picture = "";
pictureColor[] = { 0.0, 0.3, 0.6, 1 };
};
};
no matter what I put in there, it reads it as literal text, not a variable to pull from
Guessing its doing of ChatGPT?
Anyway, check out the wiki: https://community.bistudio.com/wiki/Arma_3:_Debriefing#Custom_Sections
no, that was my own flawed reasoning
I was trying to get it to show in the title box/ main debrief window
oh it doesn't work like that
yarp, it's a shame it doesn't, would have made for a nice visual flair
I'll work around it by fading to black and having a custom cutText before the debrief window
@warped igloo it very simple to make custom end screen
//use it from trigger or script
["win", true] remoteExec ["BIS_fnc_endMission", 0, true];
//description.ext
class CfgDebriefing
{
class win
{
title = "Mission Completed";
subtitle = "RAF liberated group Brand";
description = "RAF dorces liberated group Brand from enemy hands.";
pictureBackground = "";
picture = "b_inf";
pictureColor[] = { 0.0, 0.3, 0.6, 1 };
};
};
just put your class or change the class I pasted - title, subtitle, description, marker, etc.
oh that's not really my issue, I already had a custom debrief setup in description.ext, I was just looking to add a custom variable to display in the title when the mission ends.
I got around it by triggering a fade to black and displaying a custom title right before starting the debrief.
Thanks for the help and suggestions!
yes
oh nice thx m8
that's cool: i can limit who calls the chopper cammands, you must be a officer to call the chopper commands in my missions WooHoo
so, I'm trying to get firewill's F-18's afterburners to come on via a trigger, and if I'm guessing correctly, it's activated via a function, (FIR_fnc_aws_Afterburner)
so I put in the trigger Hornet1 call FIR_fnc_aws_Afterburner, and it gives me this error, thoughts?
I've tried remoteExec, also another error
I don't think it's a problem with the function, I probably am executing it wrong, if so, then what? I wonder
I've also tried spawn, same error
You're passing the object, it expects an array with the object
oh dang it, where do I find the array now π
ah, I see, well thank you!
If they'd used params this wouldn't even be a problem >:|
Hello all: Is it possible to tell witch _player activated a Radio trigger: and send a system message to the server: ofcorse
my _player(s) var names are ["p1","p2","p3", and so on ];
something like this maybe: this would be in the script that gets called by the radio trigger ofcorse
would this be correct
player will be local on player client.
So you only need ->
private _allowedPlayers = [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10];
if (player in _allowedPlayers }) then
{
[format ["%1 Activated the Radio Trigger", name _player]] remoteExec ["systemChat", 0, false];
};
Noup, because you dont need define
private _player = player
when player is player.
awsome thx man your the best
@stable dune yes Sir, it works perfectly: thx again
i made it a call function its fast as heaven Woohoo Arma 3
If I got a relative position - for example [5, 3, 0] - is there a command to transform that into the current world position? I know there is getPosWorld but according to the wiki that only works with an object as reference, not just with a relative position.
but modelToWorld uses an object as reference, I am trying to find out if there is a likewise easy way to use a relative position as a reference, to transform that relative position as worldposition (hope that made sense and things a bit clearer)
so something like RelPosToWorld (which of course is not a real command)
So vectorAdd?
Why vectorAdd? Does that not just add vectors together?
What I am asking is if I know the relative position to an object, can I get the world position of that relative position somehow. Yes it would be easy if there was an object at that relative position (that way one could use modeltoWorld) but what I wonder is if there is no object but one only has that relative position as reference.
Then why not vectorAdd doesn't work in this context? Do I miss some context?
getPosWorld player vectorAdd [5,0,0]```means 5m away in the North of the player
ahhhhh ok I now get what you mean - it takes the world position of the player and then adds the relative position to it -> thus getting that position as worldposition! Totally did not think about doing it that way! (I thought there was a way to somehow transform the position itself without any object reference, which probably was dumb)
More trick
posY vectorDiff posX```returns the relative pos from `posX`
am still such a complete noob that knows squat apparently ;) thanks mate!
(NOTE! Arma 2: CO) Is there a large difference in performance between constant usage of setVariable with global flag set vs. constant usage / ping pong of targeted publicVariables (i.e. using publicVariableClient and publicVariableServer whenever possible)?
I'd like to replace global setVariable calls with more secure solution so that the variables in question get moved to server side completely
this channel is for Arma 3 scripting: don't know about, Arma 2 Combat Operations, i did have that game years and years ago,
Are there modes such as TWS, RWS, SRC, and PDV in arma 3??
@muted crystal hell yeah there's like 100,000,000 mods for Arma 3
Where did you get the idea that they don't know the difference between private and global variables? That wasn't the question at all
sorry about that my misstake
I'm assuming you mean radar since I know some of those abbreviations from that. If not then never mind.
There might be some insane mod that fully scripts simulation of advanced radars, but in the engine there is only active and passive radar. Passive radar can be set to act only as RWR.
https://community.bistudio.com/wiki/Arma_3:_Sensors_Config_Reference
https://community.bistudio.com/wiki/Arma_3:_Sensors
There are some config options for setting the radar's field of view and other limitations, but it's not super complex. Radar is always TWS for example, there is no separate tracking mode.
i like when you are hard on me KikkoJT: it makes me sharper: and faster: thx you
Is there a ready-made mode you can recommend?
lol that's funny lol good one lol
Hint command
remoteExecCall
oh right roger that mate
oh yeah WooHoo
sending to everyone?
yes sir
(in English? :p)
ummm huh?
just toying with you, translating over network can be a bit tricky
that way i can see who called for the chopper and i can send the chopper to them
from anywhere on the map ofcorse
so if i just wanted it to be on the server would i use #2 ?
remoteExec target 2 (not #2) is always the server, yes. (https://community.bistudio.com/wiki/remoteExec)
Keep in mind that doing systemChat etc on the server is not very useful on a dedicated server, because there's no player to read it. This will only do anything worthwhile if the mission is hosted on a player machine.
oh cool thx NikkoJT
Yyou can check false with !
if !(_player in _allowedPlayers) then {
//Do stuff if condition return false
};
oh cool roger that @stable dune
oh man you guys are making my missions Awsome WooHoo
thx so much
ok i think i have it all together now thx so much guys @stable dune @hallow mortar @winter rose
omg i just realized how Lame: my missions would be without you guys omg π
I refuse to believe that! you're the fuel to your missions, we only nudge in the direction / smooth the corners π
edgy!
man i really truly love you guys π
Hey folks, any ideas why the overlay seems to flash, then work properly, when it's activated?
SQF
params ["_thisUnit"];
TAG_fnc_camON = {
while {true} do {
11 cutRsc ["cameraOverlay", "PLAIN DOWN", -1, false, false];
"filmGrain" ppEffectEnable true;
"filmGrain" ppEffectAdjust [0.05, 0.5];
"filmGrain" ppEffectCommit 0;
uiSleep 1;
11 cutRsc ["cameraOverlay2", "PLAIN DOWN", -1, false, false];
"filmGrain" ppEffectEnable true;
"filmGrain" ppEffectAdjust [0.05, 0.5];
"filmGrain" ppEffectCommit 0;
uiSleep 1;
};
};
TAG_fnc_camOFF = {
11 cutRsc ["Default", "PLAIN", -1, false, false];
"filmGrain" ppEffectEnable false;
};
_thisUnit addEventHandler ["OpticsSwitch", {
params ["_unit", "_isADS"];
if ((weaponState _unit) select 0 == "Bro_Camcorder") then {
if (_isADS) then {
terminate _handle;
_handle = [] spawn TAG_fnc_camON;
hint " Aiming down sight of Camera!";
} else {
terminate _handle;
_handle = [] spawn TAG_fnc_camOFF;
hint " Not aiming down sight of Camera!";
};
};
}];
P.s. I've been trying to fix this for the past hour. Every rewrite of the script I've done has had the same result. A real head scratcher for me
P.p.s. I know that terminating handle on turning off the effect is probably unecessary, but at this point, if it doesn't break it, it's not worth worrying about for me :(
are you aware that _handle doesn't exist when you go to terminate it?
It had crossed my mind, though it doesn't throw any errors so I hadn't taken a look. I'll define it and see if that fixes the issue
save the handle to a variable, then pull that variable to terminate it. you have to save it out of scope as each time this event is called, its a new scope. and it won't throw an error currently, because terminate silently failed
MyMission_scriptHandle = [] spawn TAG_fnc_camOFF;
_thisUnit setVariable ["MyMission_scriptHandle", MyMission_scriptHandle];
_thisUnit addEventHandler ["OpticsSwitch", {
params ["_unit", "_isADS"];
if ((weaponState _unit) select 0 == "Bro_Camcorder") then {
if (_isADS) then {
_handle = _unit getVariable ["MyMission_scriptHandle"];
terminate _handle;
_handle = [] spawn TAG_fnc_camON;
_unit setVariable ["MyMission_scriptHandle", _handle];
hint " Aiming down sight of Camera!";
} else {
_handle = _unit getVariable ["MyMission_scriptHandle"];
terminate _handle;
_handle = [] spawn TAG_fnc_camOFF;
_unit setVariable ["MyMission_scriptHandle", _handle];
hint " Not aiming down sight of Camera!";
};
};
}];
This is how I wrote it, is this roughly correct? (Pardon my poor scripting and slightly changed variable names. I plugged the code into an AI to see if it could spot the issue. It couldn't but changed some names)
If you're declaring a global variable then you may as well use that instead.
Which is a perfectly fine solution as it looks like this is per-player not per-unit functionality?
This is indeed per player, though it will be working on a dedicated server with numerous players having access to a camera, which I want to create overlays when they zoom in independantly of one another
hmm, I guess it depends whether the EH is inherited on respawn.
Previous testing makes me believe they are
Some of them are, some of them aren't. Not all are documented.
Ahhh
but yeah, if it's respawn-inherited then just use a global variable.
MyMission_scripthandle is a terrible name though :P
How would this work with multiple players having access to Camcorders and aiming down sights independently of one another?
It used to be _handle. When I plugged the script into an AI in a last ditch attempt to fix it, it changed the name for some reason. As I said above though, if it ain't broke, don't fix it lmao. I'll suffer with the bad naming until I can be bothered to fix it
This is all player-local code, right.
You run it separately on each client.
From initPlayerLocal or whatever.
Server doesn't even need to run it.
hence everyone has their own global variable.
If I make it global, will it not then update across all players? Also, we are talking about 'MyMission_scriptHandle' variable right?
Ahh, well butter me up and call me randy, I did not know that!
Each machine has their own variable namespaces. If you wanted to publish them to other machines then you'd use publicVariableXXX commands, or the third parameter of setVariable.
Simply using MyGlobalVar = X will only set the variable on the machine that the code is run.
Ah, gotcha. For some reason I associated public and global as the same thing
Network locality docs: https://community.bistudio.com/wiki/Multiplayer_Scripting#Locality
Global vs local variable scope is a separate thing.
also if using the array syntax of getVariable, you really should give it a default fallback. But in this case, nil is a fine fall back so you can use the non array syntax and do a nil check after.
@granite sky
May have made a mistake making "handle" global. Testing shows it's creating a new occurance of the functions each time
params ["_playerUnit", "_didJIP"];
handle = nil;
_playerUnit addEventHandler ["OpticsSwitch", {
params ["_unit", "_isADS"];
if ((weaponState _unit) select 0 == "Bro_Camcorder") then {
if (_isADS) then {
terminate handle;
handle = [] spawn TAG_fnc_camON;
hint " Aiming down sight of Camera!";
} else {
terminate _handle;
handle = [] spawn TAG_fnc_camOFF;
hint " Not aiming down sight of Camera!";
};
};
}];
Noticed that when it started screaming at me in the error log. Oopie π
Ahhh, that's an embaressing mistake
Also you need a proper starting value.
Ay ay captain π«‘
What would you suggest? I can spawn 'TAG_fnc_camOFF' and assign it as it should have no effect
should be fine.
actually I guess you can just do MyTag_handle = scriptNull here. Makes more sense.
As the off script just clears the effect.
scriptNull rather than nil though. Referencing a nil var doesn't work and may prevent execution of following statements.
params ["_playerUnit", "_didJIP"];
TAG_fnc_camON = {
while {true} do {
11 cutRsc ["cameraOverlay", "PLAIN DOWN", -1, false, false];
"filmGrain" ppEffectEnable true;
"filmGrain" ppEffectAdjust [0.1, 1.25, 2.01, 0.75, 1.0, false];
"filmGrain" ppEffectCommit 0;
uiSleep 1;
11 cutRsc ["cameraOverlay2", "PLAIN DOWN", -1, false, false];
"filmGrain" ppEffectEnable true;
"filmGrain" ppEffectAdjust [0.1, 1.25, 2.01, 0.75, 1.0, false];
"filmGrain" ppEffectCommit 0;
uiSleep 1;
};
};
TAG_fnc_camOFF = {
11 cutRsc ["Default", "PLAIN", -1, false, false];
"filmGrain" ppEffectEnable false;
};
overlayFuncHandle = scriptNull;
_playerUnit addEventHandler ["OpticsSwitch", {
params ["_unit", "_isADS"];
if ((weaponState _unit) select 0 == "Bro_Camcorder") then {
if (_isADS) then {
terminate overlayFuncHandle;
overlayFuncHandle = [] spawn TAG_fnc_camON;
hint " Aiming down sight of Camera!";
} else {
terminate overlayFuncHandle;
overlayFuncHandle = [] spawn TAG_fnc_camOFF;
hint " Not aiming down sight of Camera!";
};
};
}];
I believe I've done everything yet still the 'Camera on' effect flashes when I ADS, disappears, then appears and plays out properly
As show previously; #arma3_scripting message
And this occurs no matter what 'weapon' is equipped. It isn't a bug with the particular 'camera' weapon i'm using

