#arma3_scripting
1 messages ยท Page 72 of 1
2nd, this just feels wrong but I can't see any other way to do it xD
params["_points","_ratio"];
_valid_points = []
{
// ...if point can spawn a turret successfully, add to valid points... //
}forEach _points;
// ...Scrable array... //
_valid_points resize (round((count _valid_points)/_ratio));
{
// ...spawn turrets.. //
}forEach _valid_points;
see selectRandom to get a random element, or BIS_fnc_arrayShuffle to shuffle an array
Alright. Does the code I put look decent? Basically, going over the array twice seems wrong to me xD
@jade abyss unfortunately I need some keybinds like F5 or F1, so sadly no option
Youre working with the the Eventhandler from Tonic?
_valid_points resize (round((count _valid_points)/_ratio)); does look very suspicious. What is it supposed to do? 
Separate loops for filtering the input array and spawning stuff from intermediate array seems perfectly viable 
Removed it about 2 months ago
I meant to do *_ratio but removes a certain amount of the valid points. so if 50 is given, only 50% of all the turrets that can spawn, will spawn.
eventhandler -> fire blablabla -> "true" when Var = true
Wait, I can override fire action in fire evh?
Nope.
Q: on WAYPOINT statements, what is the OnActivation code referring to? statement in the Syntax?
"The Condition code is evaluated on the group owner's machine. When condition returns true, for some strange reason, the condition is evaluated one more time. The OnActivation code is executed globally, a.k.a on every client! See Waypoints."
https://community.bistudio.com/wiki/setWaypointStatements#Description
Don't know where you posted it, but it wasn't here
I forgot about setAmmo :D thanks :P
per RHfront comment, I gather that is the case, in which case, how might I ensure it runs ONLY on the server in a MP...
however, would be better if that were more than anecdotal indication.
if (!isServer) exitWith {};
duh yes of course... thank you.
Otherwise delete the bullet (wich is a messy way)
But the weapon would still produce the shooting sound which would be a problem too
OR: Force the Weapon to the Back
good Idea, will do it this way
Everytime he wants to take it back in hand -> action bla
uh- how to convert to bool. Is there a thing already or
convert what to bool
anything x3
Boolean is true or false, you cant just convert anything to it
ah so can't do soemthing to make 1 be true like other langs
yes you can
well
_var isEqualTo 1
x != 0
1 true "true" -> true
what
private _bool = _x != 0;
i smell Javascript
eh well
oh wait-
I uh- I meant to ask, is there a way to compare bool to non bool. As in "sdkakasdkg" == true -> false
isEqualTo
just wait until your bool is a nil ๐คฃ that one is always fun.
oh I already got that :P
๐
if(isNil "_isLow" || {!(_isLow isEqualTo true)})then{
_isLow = false;
};```
So if nil or not true, set to false.
If it's already false, then eh, only being run at mission start so- shouldn't be TOO bad right? ;P
userInput array- I guess normalize
_isLow = [_isLow] param [0, false] ๐คทโโ๏ธ
:)
or if you want to trap the type also, _isLow = [_isLow] param [0, false, [false]]
opfor_static_turrets = opfor_static_turrets apply {
private _type = _x select 1;
private _offset = _x select 2;
private _isLow = _x select 3;
if(isNil "_type")then{
_x set [1,1];
}else{
switch (true) do{
case (_type == "heavy"): {_x set [1,3];};
case (_type == "medium"): {_x set [1,2];};
default {_x set [1,1];};
};
};
if(isNil "_offset" || {count _offset < 3})then{
_offset = [0,0,0];
}else{
_offset = _offset apply {if(typeName _x != "SCALAR")then{0}else{_x};};
};
_x set [2,_offset];
if(isNil "_isLow" || {!(_isLow isEqualTo true)})then{
_isLow = false;
};
_x set [3,_isLow];
_x;
};
what I had
the heavy, medium and light to number-
private _isLow = _x param [3, false]
or _x params [...] if you'd rather
anywho, good luck, good hunting ๐
I forget, if given non bool, will it error or use default
use default
Should just be able to do this right?
_x set [3,_x param [3,false,[false]]]; instead of defining islow and stuff
or no
I need to return _x b/c I'm applying the array
private _type = _x param [1, 1]
no. at top put: private _isLow = _x param [3, false];
you don't assign to _x when applying to array, you return the resulting value from the code block
but- huh?
apply is literally an array transformation
okay, i see teh example above, but your wording sounded sus
then why use apply at all?!
you use set
set modifies the array by reference
I'm going through the array of arrays.
Apply, you return the value you want in the place of the current
they return _x; in the last line here 
I mean use forEach
opfor_static_turrets = [
["vn_o_vc_static_sgm_low_01","light",[0,0,0],true],
["vn_o_vc_static_mg42_high","medium"],
["vn_o_vc_static_pk_high","light",[0.155,-0.76,0]],
["vn_o_nva_navy_static_v11m","heavy"]
];
yes I know. use forEach
true if you are just trying to ensure some defaults in opfor_static_turrets, then just opfor_static_turrets param [...] or ... params ....
Well, I do also need to conver the light medium heavy string to number
yep or in that case forEach
you do that already using set
What'd the different between apply and foreach be
ahh ok. So, shouldn't be a big deal if only doing this once, but preformance would be better with foreach
But apply could work here
could but there's no point 
since set is already modifying the elements for you
(again set modifies the array by ref)
no
_x is a ref to the current iterated element
if you modify it by ref, you modify what's in the array already
(but = doesn't modify something by ref)
๐ง hurts... just think it through. know you're goal, where you're headed, Occam's razor usually a good rule of ๐ simpler is better, complexity leads to breakages.
{
private _type = _x select 1;
private _offset = _x select 2;
_x set [3,_x param [3,false,[false]]];
if(isNil "_type")then{
_x set [1,1];
}else{
switch (true) do{
case (_type == "heavy"): {_x set [1,3];};
case (_type == "medium"): {_x set [1,2];};
default {_x set [1,1];};
};
};
if(isNil "_offset" || {count _offset < 3})then{
_offset = [0,0,0];
}else{
_offset = _offset apply {if(typeName _x != "SCALAR")then{0}else{_x};};
};
_x set [2,_offset];
}forEach opfor_static_turrets;
tbh, modifying inside-arrays in forEach makes my brain hurt as well 
yea-
I like how I've spent all day coding and 90% of it is just coding, not testing, so I'ma probably have a million errors when I get to testing, finally :P
I'm a wizard! :O
I ran it first time and no logic errors! I mean, syntax erros and I forgot to finish an if statement to check a number to be greater then 25, but eh
How do I rotate around a point again? ๐
or rather-
rotate thing, then offset thing.
offset is -1,0,0, need to get what that is if the original object is rotated
Greetings all.
We have gained access to GPT-4 and have been using it to generate Arma code. We are trying to see if it is more valuable than GPT-3 was.
what
Wrong generation... sec... looking for feedback.
// Get all players on the server
_players = allPlayers;
// Loop through each player
{
// Get the player's position
_pos = getPos player;
// Spawn a cube near the player
_cube = "Land_CargoBox_V1_F" createVehicle (_pos vectorAdd [5, 0, 0]);
} forEach _players;
We were originally trying to train GPT-3 using the BIKI pull that BI provided us, but I wonder if we should shift focus. 
Simple generations look good, but I would like to try more complex prompts. Not sure what to ask it.
make a whole addon
depends how complex you want to go 

Well, we are testing.
So it doesn't matter.
We can at least gleam info from it's capacity to understand logic, even if the overall code is bad.
ask it to create a serverside addon that detects when a civilian is killed and have it display a hint on only the killers screen telling it to cease fire
irl AI?
// Define the event handler function for when a civilian is killed
_fnc_civilianKilled = {
params ["_victim", "_killer", "_instigator"];
// Check if the victim is a civilian
if (side _victim == civilian) then {
// Check if the killer is a player
if (isPlayer _killer) then {
// Display a hint on the killer's screen telling them to cease fire
hintSilent "You have killed a civilian. Cease fire immediately!";
};
};
};
// Register the event handler function to the "killed" event
addMissionEventHandler ["killed", _fnc_civilianKilled];
That is missing a lot
Can you format the prompt for me like this.....
Generate an Arma 3 sqf script to do the following:
Output:
edit, actually its not missing as much as I thought
AI scares me :)
I think the code it generated is mainly missing a check to make sure it runs only on the server, as well as a remoteexec to make the hint appear on the killers screen. I might be missing more though
I asked it to adjust
// Define the event handler function for when a civilian is killed
_fnc_civilianKilled = {
params ["_victim", "_killer", "_instigator"];
// Check if the victim is a civilian
if (side _victim == civilian) then {
// Check if the killer is a player
if (isPlayer _killer) then {
// Check if the code is running on the server
if (isServer) then {
// Display a hint on the killer's screen telling them to cease fire
[_killer, "You have killed a civilian. Cease fire immediately!", "HintSilent"] remoteExec ["hint", 0, _killer];
};
};
};
};
// Register the event handler function to the "killed" event
addMissionEventHandler ["killed", _fnc_civilianKilled];
nope the remoteExec is wrong
What's incorrect?
So I can try once more.
Example prompts also increase efficiency. It's a main reason why the BIKI pull was critical for our initial project.
it's showing the hint to everyone
also, probably better to put the isserver check on the addmissioneventhandler
Even weirder, it's JIPing on the killer :P
Clearly has no idea what it's doing with remoteExec, which makes sense because most SQF-writing humans apparently have no idea either.
never used remoteexec in my life, never will ๐ฟ
It's not even using the right event, should be EntityKilled
Server check should logically be at the top. Kinda surprised it didn't figure that one when it's a common design pattern.
And the other side of the remoteExec is... wrong as well.
chatGPT4 is a lot better if you havent tried that
thats what they are using
probably doesnt work well for sqf because of it not being a standalone language
iirc it has some problems with roblox's luau too
Lack of proper killer/instigator handling is weak too. I think you could just shoot the civvie with a vehicle turret to dodge this.
That's also a common pattern but it doesn't seem to have enough data to understand good SQF vs bad SQF.
probably just looks at the bi forums all the time 
because it'll be 2030 at that time and they'll have taken us all over anyway?
no its a new language
GPT-4 has document reading iirc, wonder what'd happen if you gave it the BIKI's tutorial pages (code optimisation etc) and then asked it for stuff with that in mind
@simple ore ```sqf
private _civilians = allunits select {side _x isEqualTo civilian};
civKilledFnc = {
params ["_victim", "_killer", "_instigator"];
// if (isServer) exitWith {}; - this returns true in local environment
if (isPlayer _killer) then {
["You have killed a civilian. Cease fire immediately!"] remoteExec ["hint", _killer];
};
};
_civilians apply {_x addEventHandler ["Killed", {_this call civKilledFnc}]};
Won't work in MP.
with ai or actual players
mp involves multi players so what do you think 
well, I guess if all your civvies are on the server.
well if you want to run it on MP just add a onPlayerKilled function and on init add player addEventHandler ["Killed", {_this call your_function}
dont do that
This is the goal!
then do that ๐คท
Well, we don't have... real access for our discord bot yet like we do GPT-3.5
Frost if you need more help lmk, your answer is there ๐ค
Question: Is there any reliable way to get an AI infantry unit to fire a specific magazine from a specific muzzle at a specific target?
https://community.bistudio.com/wiki/fireAtTarget might work?
only works for vehicles says the wiki
doFire and doTarget seem promising then
I've tried them.
private _enemyObj = cursorObject;
_enemyObj doWatch player;
_enemyObj doFire player;
``` works in eden against two blufor
I'm not able to get them to fire at a specific target with a specific mag
is the target another unit or object?
i'm trying to get them to fire at an invisible target.
with a specific ammo and mag
sorry, mag, and muzzle
Mind you like UGL, or do you want ai to reload lets say tracer mag and then shoot
I mean couldnt you remove all their mags/guns before they fire. Then add the specific mag and gun. After they fire re-add them back. kinda hacky but only way
first, I'm trying to get them just to throw hand grenades at an invisible target, then I'll try to tackle HE underbarrel nade launchers. Then SMOKE for each of those. The invisible target doesn't need to be anything in particular, just some thing that I can use to have them fire at a precise (but arbitrary) location.
For tossing nades it aint that straight forward. its doable but not a 1 liner. You can check how its done in ZEN for example, it does exactly what you need, throw any type of grenade at arbitrary position (does not include GL):
https://github.com/zen-mod/ZEN/blob/b9264f686dd7775aa7fbd680b22ccb367a5dd1ca/addons/ai/functions/fnc_throwGrenade.sqf
Hmm. I found that doWatch/doTarget didn't work well because the units stand with a direction offset to the target due to weapon stance. Like you have to throw in a setDir.
// Define a function to handle the player's death
onPlayerKilled = {
params ["_victim", "_killer", "_instigator"];
// Check if the killer is a player
if (isPlayer _killer) then {
// Send a message to the killer
_killerSide = side _killer;
if (_killerSide == west) then {
hint "You killed a friendly unit. Please be more careful!";
} else {
hint "You killed a civilian. Please stop shooting non-combatants!";
};
};
};
// Add the function as an event handler for player deaths
player addEventHandler ["killed", {[_this select 0, _this select 1, _this select 2] call onPlayerKilled;}];
// Use remoteExec to execute the function on the server
if (isServer) then {
["onPlayerKilled", {[_this select 0, _this select 1, _this select 2] call onPlayerKilled;}] remoteExec ["addEventHandler", 2];
};
Did it do better this time? We toggled web access and told it to use the BIKI.
nope 
Worse?
than this? yeah much worse
Hmmm wonder what happened.
wait why is it even checking west?
it got side tracked a lot ๐
all it had to do was change this line:
[_killer, "You have killed a civilian. Cease fire immediately!", "HintSilent"] remoteExec ["hint", 0, _killer];
to
["You have killed a civilian. Cease fire immediately!"] remoteExec ["hint", _killer];
and it would've worked
oh wait no it wouldn't ๐
it has an extra argument for remoteExec...
the hintsilent shouldn't be there
and the _killer too...
fixed
I'm going to try to debug it and see if it can figure out the right way as you have explained it.
To fix the remoteExec in this Arma 3 script, you need to use the correct syntax for the remoteExec command. According to the Bohemia Interactive Community Wiki [1], the correct syntax for remoteExec is:
remoteExec [function, target, [paramsArray, isPersistent, isScheduled]]
In the script provided, the remoteExec command is missing the paramsArray parameter. To fix this, you need to add the paramsArray parameter to the remoteExec command. Here's the corrected script:
// Define a function to handle the player's death
onPlayerKilled = {
params ["_victim", "_killer", "_instigator"];
// Check if the killer is a player
if (isPlayer _killer) then {
// Send a message to the killer
_killerSide = side _killer;
if (_killerSide == west) then {
hint "You killed a friendly unit. Please be more careful!";
} else {
hint "You killed a civilian. Please stop shooting non-combatants!";
};
};
};
// Add the function as an event handler for player deaths
player addEventHandler ["killed", {[_this select 0, _this select 1, _this select 2] call onPlayerKilled;}];
// Use remoteExec to execute the function on the server
if (isServer) then {
["onPlayerKilled", {[_this select 0, _this select 1, _this select 2] call onPlayerKilled;}] remoteExec ["addEventHandler", 2, []];
};
In the corrected script, the paramsArray parameter is added to the remoteExec command as an empty array ([]). This tells the remoteExec command that the function being executed does not require any additional parameters.
I don't think it figured it out.
does gpt-4 even have conversations like chatgpt does?
its not a machine learning ai
It does.
try link specific biki pages like the tutorial ones for arma 3 and so on
Hey I tried to attach a flag to a vehicle, when I tried it on eden editor everything worked, but when me and my unit used the mission the flags didn't spawn at all for some reason
This ForceFlagTexture "flags\TMG.paa";```
that's what I use on the flag
I highly discourage the use of chatGPT for coding in SQF, you'll encounter lots of nonsense
i disagree. yes nonsense but you can work through that with better prompts and a little bit of SQF knowledge
YOU CAN USE GPT TO CODE FOR YOU?!
in a year or two it will likely be way better, so it makes sense to just get familiar with it
and a side bonus that GPT doesnt give snarky responses that you get when asking humans for help
is a tech in its infancy, but give it 2 years and the volume of โhow do i โฆโ in this channel will be far lower than the volume of people using GPT โhow do i โฆโ
unless it learns to give snarky responses when you ask it for help ๐
Hi
how can I recover the effect when a player has no more stamina (black contrast around the screen)
like reproduce it or get rid of it?
I would just like to reproduce the effect that there is on the screen, yes
you would have to know the name of the, what i belive to be RscTitles class.
And then simply display it it via cutRsc.
If its not something within engine itself.
(I accidentally hit enter)
thanks i will check that
dont worry xd
do you know where is the information about this titles ? on what a pbo
sadly no.
Hi guys, iโm looking for a way to play the sound of a distant battle in one of my missions without the use of the SOG audio module for warsounds in the distance: i want to avoid the SOG dependency in one of my missions just for a module. Is this possible by using the โsay3Dโ script?
yea true. if it does that then id agree to not use it ๐
guys, i'm trying to drawIcon3D over camCreate effect but it's not showing the icon. any advice?
will vest work on remote units?
and if not, is there away to get the vest of a remote unit?
https://community.bistudio.com/wiki/vest says Global Argument, so yes ๐
hey guys, im attempting to compile a script that lowers ai spottime and accuracy at night, I used the timemanager script @pulsar bluff and chat gpt helped me write and added in this script from the forums https://forums.bohemia.net/forums/topic/182390-how-to-turn-init-code-in-to-a-script/?do=findComment&comment=2877603
timemanager.sqf
https://sqfbin.com/hupasejodinuqiwexixo
Hi all, Im still getting acquainted with scripting, I have this code placed in the init box of a grouped unit, which works perfectly. { _x doMove getpos Attack; _x setspeedmode FULL; _x setbehaviour SAFE; _x setskill [spotDistance,0.1]; _x setskill [spotTime,0.1]; _x setskill [courage,1]; _x sets...
here is blindatnight.sqf
https://sqfbin.com/ehabeqidowajecuhurav
any suggestions?
so idk why, but for somereason the vest returns "", would using the mission event handler EntityCreated cause it to return empty string?
@warm sentinel please post your code to https://sqfbin.com/ and only post links here, not a wall of code thank you!
what is the context
maybe the entity is not entirely initialised, IDK
vest should work
yea sorry, ill fix that now, i realized that could be annoying after i posted it
_ https://cdn.discordapp.com/attachments/105462984087728128/1096430025504473209/image.png _
Lou Montana; Friday, 14 April 2023
please don't use chatGPT ๐
i dont anymore, but that timemanager works just fine lmao
for sqf that is
This is wat I got, https://sqfbin.com/yetosujoyivesasucode
basically I have the EH just on the server, and I want to do something with certain units vest
I thought id try a mission event handler
it might need a bit of delay, if you are certain the unit has a vest and vest returns ""
network, etc
looking at the wiki i dont think my idea will work anyways
can you not change ai skills during a mission?
You can, by scripting
theres a zeus module that does that
think its in zeus enhanced or something
try looking at that?
hmm i wonder if that note on the wiki specially concerns scenarios
trying to make ai spot skill and accuracy less at night time, this is what i got so far, i need to figure out how to set the skill back to original during daytime. probably need to make a second configunits command, one for day and one for night. https://sqfbin.com/ehabeqidowajecuhurav
people are going to use GPT for all languages more and more and no amount of pleading will stop it ๐ it will get better too
nothing wrong with learning how to use the GPT and seeing what it spits out
if it spits out garbage, well it didnt cost anything to use, and probably didnt mind responding to potentially embarrassing questions that could garner a witty/ridiculing response in here
i infact havent used it for sqf since you helped me with the skip time script, im trying to combined that script with another lol
nice!
Did I accidentally joined the chatgpt discord? ๐ค
the idea is for co10 escape mission ported to ifa3 ww2, since friendlies do not have night vision i wanted to script it to make them significantly less likely to spot or hit you at night time to essentially balance the fact you cant see very much
im having second thought, might just skip nightime with the original script altogether, just thought it was a cool idea, simulating ai not being able to see in the dark lol
that note says that if you change the difficulty setting, you have to restart the mission
setSkill is not involved here
ahh okay i understand, thanks
Final AI skill is combination of server skill (from difficulty settings) and mission skill (from setSkill).
so if i set setskill spotdistance, and spottime via script and the server had the aiskill level high they would still be able to spot relatively well? Is it an average of the server skill and mission? would scripting only be able to effect mission skill?
Scripts can only affect mission skill, but that is the more important one.
0 mission skill is 0 skillFinal. Server skill has its strongest effect at mission skill = 0.2.
ah okay, this has to do with the crazy looking chart that hurt my brain on the wiki ๐
Hello, I understand this is probably leaning a bit into modding, but I am trying to figure out what the proper start/stop conditions would be if I want to start/stop the music via a radio command (like Radio Alpha/Bravo in a trigger)
or some other way to do it on command instead of just having it say true and false
If you want it to change state when a trigger activates, you can use triggerActivated your_trigger_name
For activation by other sources, you could have your script set a variable, which the module condition checks. e.g.
// event script
kosand_var_startMusic = true;
sleep 90;
kosand_var_startMusic = false;
// Jukebox conditions
// Start
missionNamespace getVariable ["kosand_var_startMusic",false]
// End
!(missionNamespace getVariable ["kosand_var_startMusic",false])```
Alternatively, skip the jukebox module and just use playMusic yourself
Hello together,
I would like to equip all enemy units with tracer magazines in a mission port of Liberation Gamemode. The enemy units are created dynamically in the mission via script.
My thought was to avoid the extensive way of inherting each enemy class to use the "Entity created" Missioneventhandler and I just wanted to find out whether this works with script spawned AI or only with Zeus placed units?
And if the idea worked like that, a headless client shouldn't be a problem, right? The unit is created on the server, the MissionEventHandler should take effect immediately and then the unit is offloaded to the HC, right?
Thank you for your feedback.
A rather unusual request for help (actually scrap that, nothing is unusual anymore when it comes to Arma stuff)
I'm looking for a disco light script or even a simple multiple flashing lights script to give the illusion of a club atmosphere. Ideally something I can put in a objects init or run from the mission init.
anyone come across something like this? or know any code snippets i could use?
You could do it with https://community.bistudio.com/wiki/drawLaser
That will definitely help add to the scene, thank you is there a way to give random directions/vectors? or would I have to mess with creating an array of objects to choose between?
Just make random arrays by some algorithm
This may also be useful https://community.bistudio.com/wiki/Lightpoint_Tutorial (note that the intro note about not being able to direct lights into a beam is no longer true, see the helo spotlight example for use of lightreflector)
To make lights flash, just set their intensity every X ms
Then add some sparse smoke particles that sink to the ground and u r set.
Also as a side note, units have at least 3 dance animations
Yes, more what I'm looking for, I have some basic knowledge like messing around with description files, some basic commands from the init, executing scripts from triggers etc...but that's about it.
Would you be able to provide an example in context?
feed me, I'm poor ๐
Well it aint gonna be a simple "paste into init" script. But this for reference:
https://m.youtube.com/watch?v=PTZGmFd9-b4
Yeah checked that, This is going to be my 'fall back' as I could look into just creating this modded grenade by a script or trigger.
There are things such as the music and animations that are open to change, going to have to dig into if the length of effects can be changed.
Thanks for you help @stark fjord @meager granite & @hallow mortar
I'll have a mess around with the light point tutorial, suppose 'doing' is the best way to learn.
Also idk if old man scenario pbo has been decrypted. But in there you can also find disco at night in town next to main airfield.
I mean, you're collecting a huge number of objects by searching through a large area. That is inherently not great for performance.
as usual, depends
You'll be fine using it for low-frequency collections, but doing it a lot is not a good idea
They are probably not using nearObjects "ALL"
Well, have you tried running the mod? If their implementation causes the same hitching, it may be your PC. If not, you need to look closer at what they're doing.
Hi, I am using the following code on a trigger in my mission. It's supposed to be an ammo box where my AI squad auto-rearms within range.
{if(_x iskindof "CAManBase") then {_x setDamage 0; _x removeMagazines "15Rnd_9x19_GMag"; _x removeMagazines "CUP_30Rnd_556x45_Emag_Tracer_Green"; _x addMagazines ["15Rnd_9x19_GMag", 5]; _x addMagazines ["CUP_30Rnd_556x45_Emag_Tracer_Green", 30]; };} foreach thisList; hint "We got new ammo!";
The trigger gets activated on BLUFOR. My problem is that only one AI in my team rearms but not the others. I guess it is the first one which gets into the triggers range. How can I adapt the code to make sure that all AI within range rearms?
the code is fine, the trigger's condition may be at fault
set it to "repeat" and not "once"?
that or forEach units (thisList select 0) to apply it to all units in the first person's group's units
I have it on repeat with interval 2. Condition is set to: this. Shall I reduce the interval or do I need to use a different condition?
I will also change the forEach. 1 sec
This works. Thanks vey much Lou!
Hi, I am writing a script and I want to see what the _transmitterClass variable is. It changes and is give by the acre_api_fnc_setCustomSignalFunc.
[{
params ["", "", "", "_transmitterClass"];
if (_transmitterClass == "ACRE_PRC117F") exitWith {
[1,0]
};
_this call acre_sys_signal_fnc_getSignalCore
}] call acre_api_fnc_setCustomSignalFunc;
```Any suggestions
does anybody have any bright ideas for working out if the player is within a bounding box set out by 4 coordinates? i'm completely drawing a blank here, I cannot use inArea as it only has rotation in one axis
I am trying to detect if the player is in an area on an aircraft carrier that has rotation in all axis -- using inArea would mean when it is upside down the area would be inside the carrier
use inArea but in model space of object aligned with the box
you'd still need special handling for if it was upside down though as negative c is infinite vertical
its also not as simple as a lineintersectssurfaces in the direction of the surface as the object has no collisions ("aircraft carrier" is just to simplify it) and cannot be detected by it 
use the positive c, right? it's the z size
yeah, but if you'd end up with it going upwards into the carrier
one mo i'll draw a pic
with the triangle being the carrier you'd just end up with this
so you'd need to shift the center downwards by the amount of C varying on the angle its tilted by 
not if you use model space?
that is using model space there? inArea areas cant just be rotated upside down
not trigger, alt syntax lets you define center and sizes
yeah so you'd need special handling to shift the point further down so that the top of the box aligns with the carrier
as using just straight modelspace would cause the diagram because its the same position on the model
oh
inPolygon exists
news to me, that saves tons of effort
i could've sworn i tried to find it with no success earlier
if the carrier is upside down, then its model space is also upside down.
i know, but the trigger area is not
if you try use inArea with the red circle as the center w/ no special handling thats what'll be searched for
either way inPolygon is exactly what I was looking for it just required a bit of digging
You're not getting it, transform positions you check into carrier model space and do inArea there
Here is my snippet to do a check against bounding box
Change bounding box area to be area on your carrier entity in its model space, turn your checked position into carrier's model space position and do the check
_new_turret setPosASL (AGLToASL (_turret_point modelToWorld _tur_cent)); // not offsetting right, and on the ground.
Issue with placing the turrets from yesterday. I should be able to fix the only spawning on the ground part, but not sure about the offset being incorrect
Offset is basically b/c the red x is where the model origin is. I want the yellow X to be where the turret point is
wait a second
oh still no
modelToWorldVisualWorld?
_new_turret setPosWorld (_turret_point modelToWorldVisualWorld _tur_cent);
```should place the `_new_turret` spot-on
Model center isn't the same as object pos right?
both commands work with model centre
oh, you did PosWorld too
oh I'm an idiot
ignore the variable setting, that was for debug thing. Buuut...
whenever possible, avoid AGL ๐
yes. I wonder what's wrong. Surely it isn't "_tur_cent"
You know, I was also wondering why the position wasn't even seeming to change xD
uh- hmmmmm
hello, whats the highest possible value in arma?
9
that's not it...
float.MAX, which is about 3.40282e+038
know that the further away you are from 0, the more imprecise it gets
(also known as 340,282,346,638,528,859,811,704,183,484,516,925,440)
what about for int?
there are no int script-side in Real Virtuality
ok, end position is 6097.5, 4416.65, and 5.0005
ah yes, ok, so another issue is if the turret points are deleted, it will need to handle that.
mission.sqm shows the spot's position as {6098.2744,5.0005002,4416.71} which, swap Y and Z, should match.
Wait a second, this uses model center. So it also uses Z center.
โฆwhy do you bother so much with sqm?
oh, that was just to see what the ASL Z axis was
private _selectedObjects = get3denSelected "object";
private _firstObject = _selectedObjects select 0;
getPosASL _firstObject select 2; // ASL altitude
or
getPosASL (get3denSelected "object" select 0) select 2; // ASL altitude
wait no
the VR square has a different Z center
There is model center, model placing point
You can get offset for placing point from getModelInfo
Also many entities benefit from using XY from getCenterOfMass because XY from getPosASL\ATL is same as XY from getPosWorld which results in pretty useless coordinates when entity is not top right
getPosWorld - PlacingPoint is what you get with setPosASL\getPosATL when entity is top right (Vector Up = [0,0,1])
Visualized, getPosASL is higher than getPosWorld when entity is turned over
Some static have centers really weird too, like vanilla mortar, getCenterOfMass is the best way again there
what's the best way to invert a position? Multiply by -1?
Yes, ... vectorMultiply -1
Or vectorDiff instead of vectorAdd depending on where used
oh yea, subtraction is a thing
If you weโre referring to my question then I just copied it of steam workshopโฆ
Which also didnโt answer my question
Steam guide*
Not workshop
how did u get a bounding box for the vehicle?
No, i was referencing an older message. They were trying to get a script done by chatgpt and instead of manually correcting mistakes they would ask here what the issue was and then ask chatgpt to fix it. Leading to a never ending debugging loop
both attachTo and forceFlagTexture are global and should not be placed inside an init field like that
Oh didnโt know that
boundingBoxReal command gives you the bounds
you can create the lines yourself using modelToWorldWorld after getting the vertices of the BB in model coords
which are all combinations of [(x1,x2), (y1,y2), (z1,z2)] = 2 ^ 3 = 8 verts
your issue most likely comes from the fact you are providing a relative texture path
what do you mean by relative texture path?
e.g "MyTexture.paa"
so what am I supposed to do instead?
ah neat, is bounding box what gets used when doing ViV to determine if something will fit?
Managed to kitbash something together, rough, but it works. No scripting knowledge so I just threw different examples together lol.
_light = "#lightpoint" createVehicle getPos objectname;
_light setLightFlareSize 5;
_light setLightBrightness 1.0;
_light setLightIntensity 1000;
_light setLightColor [1, 0, 1];
_light setLightAmbient [1, 0, 1];
_light attachTo [object name, [0, 0, 0]];
sleep 2;
while {true} do {
_light setLightIntensity 3000;
sleep 0.5;
_light setLightIntensity 0;
sleep 0.5;
};
you mean internally?
Yea
the mystery of arma
not a mystery just need to read the docs ๐
and if it isn't there - just need to write the docs 
and if it's inconsistent - just need to write a ticket and wait a year or two
well I was correct:
https://community.bistudio.com/wiki/Arma_3:_Vehicle_in_Vehicle_Transport
just cause I am curious, lets say I wanted to do attachTo in the init field like he has, would only doing it on the machine that the object is local to be fine?
dimensions[] = { "BBox_1_1_pos", "BBox_1_2_pos" }; // Memory-point-based override of automatic bounding box
cargoBayDimensions[] = { "VTV_limit_1", "VTV_limit_2" };
that would be the thing that is carrying the other vehicle. I was saying for the vehicle that gets put inside. like how does it know that only 3-4 quadbikes can fit in the hemmit for example
// or
// dimensions[] = { { 0,0,0 }, { 3,2,1.5 } }; // alternatively, positions in model space (since 2.08)
if (local this)
```yes
Yes, the problem (theoretical, attachTo doesn't break too badly if executed on all machines) is that init fields are executed everywhere. So adding a locality check to limit it to one machine would avoid any problems.
okay cool thats wat I do anyways, just making sure
createVehicleLocal, see https://community.bistudio.com/wiki/Light_Source_Tutorial
getMissionPath "MyTexture.paa";
They mentioned it being fine in local testing and only breaking on DS. If the problem was relative paths, wouldn't it not work everywhere?
I got things mixed up with relative and absolute path, and it's better to try & check anyway ๐
at worst, the wiki will get a fix
I believe there was an issue with setObjectTextureGlobal when set in an init field too, so the issue is actually most likely the fact that the command is run by everyone and not just the owner
Cc @brisk lagoon wrap with```sqf
if (local this) then {};
// or
if (isServer) then {};
This is the init field problem for setObjectTextureGlobal:
execution may happen too early and fail to broadcast over the network and to be JIP compatible.
So it may need a more advanced fix.
I've only tested in singleplayer, but normally
this spawn{
_this setObjectTextureGlobal [......];
};
works for me
so this โ
Yea
AH HA! And I have it so it's spawning a temp vehicle when initializing and normallizing the preset turret types array, and adding the center of mass X and Y, plus PosWorld Z, and adding them to the offset position array I already had.
why create a temp vehicle tho? you already have those values for the new vehicle 
Is there a way for arma to pull a custom texture from a link or an ftp server instead of from pbos and for everyone to see that texture? I know I could use mission file but that would get too big too fast. Or does anyone know how arma 3 units get that to work. Basically I want people to be able to upload their custom texture for example and be able to use it in game and for everyone one else to see it too without having to put those textures in pbos or mission file. Or even if someone knows what the path to logos in units would be?
As long as it works ๐
Hi
Do you know why I get this error when I use the 'slotItemChanged' EH?
Error Erreur mod externe : Unknown enum value: "SlotItemChanged"
Even if I don't have a mod I get the error
The slotItemChanged EH is only available on dev branch until the release of Arma 3 2.14
late summer; ~2-3 months from now I guess
run a lopp and check the slot items
use the dev branch to actually use the EH
There aren't any particularly good ways, which is why it's being added
but if i want put the script on my server, i can ? or not ?
Using a loop to check the items is one of the better options, but it's not fantastic for performance.
Depending on what exactly you want to track, you might be able to get away with using inventoryOpened/inventoryClosed/put/take EH
no
ok
You could run the whole server on dev branch, but that would mean everyone connecting would also have to be on dev branch, and also stuff on dev branch isn't properly tested, so it's really not recommended
yes i will check with the EH of inventory and the put / take
when I saw this EH on the documentation of event handlers I was happy lmao it will make some scripts easier for me
thanks for your help Leopard and NikkoJT
by the way i had another question
I'm trying to reproduce the fatigue effect (that the effect that the player has on his screen) do you think it's possible to do it with the 'PostProcessEffect'? or is there another way to do it?
Maybe i'm just to stupid to find something about this but i was wondering if there is a way to use the squad logos in setObjectTextureGlobal? I can easily find the local path on a client via squadParams but i would like to use a global command for it as the squad logos should be distributed to everyone anyway.
So I have been asking chat gpt about how to do some stuff in arma 3 and It started giving me some scripting stuff and I saw something in here about not using chat gpt for scripting. Is this accurate?
it is accurate not to use chatGPT for scripting then coming here for debug
It looks easy to learn. I know several languages allready as well. What would be a good way to learn it?
It's in the pinned messages
One issue with this code, it shoots randomly even when there is no enemy
boundingBoxReal and then drawLine3D for each side
What would a thing look like that went "All AI on Blufor should have this one voice"
for each _x in blufor, set voice to no_voice...
I'd also take a way to just like, auto-change the voice of any AI that are wearing a certain uniform/mask...
You've got the right words, just gotta put them to music.
units west apply { [_x, "chosenvoice"] remoteExec ["setSpeaker", 0] };
Man, I always forget Apply...
This is a bit spammy. Probably better to do:
{ units west apply { _x setSpeaker "chosenvoice" } } remoteExec ["call", 0]
Also you'd normally want to JIP that.
Cool.
What's with the vehicle respawn module and not respawning helicopters that died from contact with water?
Also what's with helicopters exploding on contact with water, even if they have their damage disabled?
It might be an Engine issue
_hintName = (findDisplay 46) displayAddEventHandler ["KeyUp",
{
params ["_control", "_key", "_shift", "_ctrl", "_alt"];
if (_key == 57 && player == player) then
{
hint format ["Hello, %1!", name player];
};
}];
How would i remove this local keyUp eventhandler in another .sqf file?
you would need to store _hintName somehow, either as a global variable or storing it on the control or something.
Then you can use https://community.bistudio.com/wiki/displayRemoveEventHandler
okay thank you, i will try it
the player == player doesn't make any sense. what are you trying to do?
that was just an example code ๐
ok ๐
so i would do something like this:
_hintName = (findDisplay 46) displayAddEventHandler ["KeyUp",
{
params ["_control", "_key", "_shift", "_ctrl", "_alt"];
if (_key == 57) then
{
hint format ["Hello, %1!", name player];
};
}];
missionNamespace setVariable ["hintNameKeyUp", _hintName];
and then:
_hintName = missionNamespace getVariable "hintNameKeyUp"; (findDisplay 46) displayRemoveEventHandler ["keyUp", _hintName];
would this be right?
in another sqf file
ok just trying to understand what your trying to do
setMousePosition [safeZoneW - 0.1,safeZoneH - 0.1];
trying to put the mouse cursor out of the way
- it doesnt always work
- while this should not be at the edge (as i understand it), in 2d map it will move the view to SE (not in all situations; especially when you tab out tho)
seems i have the position wrong
but was also bugged? #arma3_scripting message
this is also funny and a "nice workaround" #arma3_scripting message
finally the "new" https://community.bistudio.com/wiki/ctrlSetMousePosition is probably safer to use
So ive been trying to get around a loadout save issue caused by a mod and I was thinking
Could I set a thing in initPlayerLocal.sqf that saves player loadout when inventory is closed?
Which could then be used as a reference for onPlayerRespawn.sqf to give the player their stuff back
The reason I've been having issues is because one of the mods I use removes player mags when in a revive state
Which means the player respawns without mags
Wouldn't it make more sens to change the script that removes the mags in the first place?
Well if you want to do what you described there is an InventoryClosed event handler^^
As of now ive had to turn off revive all together as this issue is too big
Its a mod that removes mags
And idk how id do that
Hm
I will look at it
As is it seems simplest to just have it activate on inventory closed. Since thats usually when players obtain new loot
Do you know which mod it is? I may can take a quick look ^^
Project injury reaction
Really stupid question incoming, but I'm trying to setup a simple teleport trigger, and when typing the following on the "on activation" part:
player setPosATL [getPosATL tpExit];
It tells me there's a missing ";"
I try adding a ; right after tpExit, and it gives me the same result
Any help would be appreciated
Nevermind, found the issue
you are trying to do
obj setPosATL [[posX, posY, posZ]];

yep
I made a typo and typed "getPostATL
well that too (that explains the ; error message
but your code remains wrong even after fixing the typo
@static furnace โ
wouldn't getPosATL take care of that though?
it takes an array of numbers, not an array of arrays
player setPosATL getPosATL tpExit;
```you could also use `setVehiclePosition` to not place at exact position but at _available_ position```sqf
private _radius = 5;
player setVehiclePosition [tpExit, [], _radius];
I've used a similar script before and it's worked fine though
what, that?
player setPosATL [getPosATL tpExit]; // error
Well the mod just runs clearMagazineCargoGlobal in some conditions so if you want to stop it from doing you could just overwrite the functions of the mod^^ But if you don't know how to do that your solution will also work ^^
you even gave me the answer 
player setPosATL (getPosATL tpExit);
Maybe like that? ^^
SELECTRANDOM
yaay for randomly inserting square brackets in the command
re read what I posted please
// you do
player setPosATL [getPosATL tpExit]; // doesn't work
// I do
player setPosATL getPosATL tpExit; // works
```period
Thank you. Any idea why they do that?
Also is there anything I could use to save the loadout just before entering the revive state?
there's a bunch of eventhandlers you could use I reckon
Mainly because the one issue that can occur with saving loadout on inventory closed is that it poorly tracks mags used. One can easily use up a bunch of ammo after last closing inventory
Well i don't understand Russian but they safe them to reapply them later after the revive or what ever ^^ Seems they don't want the unconscious or captured units to have the mags before the state gets reverted.
It just feels like a strange issue on their part. As mods like ace doesn't do that
Not sure but looks like a mechanic to make sure critical hit units don't can fight back if they somehow are able to glitch out the unconscious animation
hm
hmmm, eventhandler Respawn (that I use to play a wakeup animation on respawn) is local argument
but InventoryClosed is global argument
will this perhaps cause issues if I try to make it work within initPlayerLocal.sqf
If your are talking about MPRespawn it will still be triggered locally on the machine of the player respawning so that shouldn't be a problem
well I tried putting
//Save loadout on closed invenotry
player addEventHandler ["InventoryClosed",{
player setVariable ["Saved_Loadout",getUnitLoadout player];
}];```
into `initPlayerLocal.sqf`
`onPlayerRespawn.sqf` has the thing to restore loadout with
```player setUnitLoadout (player getVariable ["Saved_Loadout",[]]);```
should this work?
After respawning the player object has changed so you would have to get the variable from the dead unit
hm.
Well how would this information translate over to the next?
the old system was using:
onPlayerKilled with onPlayerRespawn.sqf
params ["_unit", "_corpse"];
player setUnitLoadout (_corpse getVariable ["Saved_Loadout",[]]);```
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
where would this be?
along with the old code that was in there?
params ["_unit", "_corpse"];
player setUnitLoadout (_corpse getVariable ["Saved_Loadout",[]]);
player setUnitLoadout (player getVariable ["Saved_Loadout",[]]);```
Nah the sqf player setUnitLoadout (player getVariable ["Saved_Loadout",[]]); isn't needed
alright
I will try
as for onPlayerKilled.sqf, im guessing that isnt needed anymore?
What is in onPlayerKilled.sqf ? ^^
player setVariable ["Saved_Loadout",getUnitLoadout player];```
Well i would keep it as this should make sure the Unit loadout gets saved the moment of death
and that wont reintroduce the issues I had earlier with players respawning without mags due to the revive state?
Well that depends if it's fired before the mags get removed or afterwards. But you could first try it without the onPlayerKilled and see if it works.
I will try with its current configuration
wait..
should I have
//Save loadout on closed invenotry
player addEventHandler ["InventoryClosed",{
player setVariable ["Saved_Loadout",getUnitLoadout player];
}];
in initPlayerLocal.sqf?
I forgot if I should have it there or รญf I just forgot to remove it
atm I have
initPlayerLocal.sqf:
//Save loadout on closed invenotry
player addEventHandler ["InventoryClosed",{
player setVariable ["Saved_Loadout",getUnitLoadout player];
}];
onPlayerKilled.sqf:
player setVariable ["Saved_Loadout",getUnitLoadout player];
onPlayerRespawn.sqf:
params ["_unit", "_corpse"];
player setUnitLoadout (_corpse getVariable ["Saved_Loadout",[]]);
Should work
don't forget a TAG_ for good practice ๐
what now?
always prefix your non-local variables with your own tag to prevent conflicts with other mods
like HMSH_Saved_Loadout
e.g CBA stuff have the CBA_ prefix
well I got my mags back but.
I added sleep to a body-removal thing
becouse if it retrives it from the body I wouldnt want the body to go into the shadowrealm too early
hello is there a way to make a nofly zone in my missions. I thought a zone that when players fly over temporarily spawn some SAM and AA vics to strike them and when they are out of the zone the sams and AA Vics disappear
if I set variables on the vics will the ones that get spawned a second or third time still despawn
okay yeah the script doesnt seem to work
can't use sleep there
Try to remove the onPlayerKilled.sqf
getUnitLoadout / setUnitLoadout has some annoying bugs
well that isnt the issue im running into
What is the issue?
here is me before going down
here is what I respawn with
It didnt save my loadout at all
ima see if the body removal thing was the issue
trying to disable that real quick
okay
I fixed it
Removing body thing did cause that
however
now the issue is its just the same as usual. Mags got removed when I went down and are still gone after respawn
had 3 mags before I last dropped my gear on the ground and got shot. Now I am back with none to spare
Maybe try some logging?
player setVariable ["Saved_Loadout",getUnitLoadout player];
diag_log str getUnitLoadout player;
And see if the mags are alr missing the moment onPlayerKilled.sqf: gets fired
you mentioned this. Is trying to bypass or turn it off maybe a better idea?
in onPlayerKilled.sqf?
Yes
got it
testing..
before death
after
funny enough the gear I want to have on respawn is on my body
so currently I want it to give me that gear and then for it to remove the body
yeah
since it puts the stuff back on the dead body
I think the optimal method would be for it to just give me the gear from the dead body and for it to them put that on me when I respawn. Then remove that body
Wait the dead body has the gear you want?
Just scrap the save loadout part and do in the onPlayerRespawn.sqf:
params ["_unit", "_corpse"];
player setUnitLoadout (getUnitLoadout _corpse);
so scrap the stuff in onPlayerKilled.sqf
And in the InitPlayerLocal if you just want the gear of the dead unit back ^^
would this be in onPlayerRespawn.sqf then?
ah
what may I do for body-removal?
Just call the body removal after you applied the gear on the new unit
yeah so far its done it too early
I used to have
player addEventHandler ["Respawn",{
params ["_newObject","_oldObject"];
deleteVehicle _oldObject;
}];```
inside of `initPlayerLocal.sqf`
okay I tried it
without body removal
ehh
I respawned without my gun
before
after
I mean that could sorta work for some survival themed stuff but
that would require me to be able to get just the gun from the ground and
well its not nearly as versatile as I want
Well your problem is: When unit is killed and had a weapon, the weapon is placed inside "WeaponHolderSimulated" and dropped together with the unit. so you could either use the onKilled.sqf to save your weapon or search for the weapon holder containing your corpses weapon and adding it back to your new unit
sounds like a dificult problem
any half-half solution where it only takes the firearm from when the unit was killed and the rest from the unit corpse?
I mean given it always respawns me now without a firearm it would atleast not have to replace anything that exists in unit inventory
onPlayerKilled.sqf:
player setVariable ["Saved_Loadout",primaryWeapon player];
So instead of saving the full load out as before you save the weapon and readd in the onRespawn
will I need to add anything extra to the onPlayerRespawn.sqf?
Well you would want to also get the weapon attachments and magazine and readd them in the onPlayerRespawn
so yeah you would have to add stuff ^^
so ```sqf
primaryWeapon
is just for the gun itself
it should then be
primaryWeaponItems
im okay if the unit looses the mag that is loaded. Its a small loss
Nope primaryWeaponItems is only the attachments not the weapon ^^
yeah but would I not need to do both somehow?
weaponAccessories```
?
weaponsItems```???
weaponState```???
man there are a lot of these
weaponState looks promising
onPlayerKilled.sqf:
params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"];
_primaryWeapon = [primaryWeapon player, primaryWeaponItems player, primaryWeaponMagazine player];
_secondaryWeapon = [secondaryWeapon player, secondaryWeaponMagazine player];
player setVariable ["Hmch_Saved_primWeapon",_primaryWeapon];
player setVariable ["Hmch_Saved_secWeapon",_secondaryWeapon];
onPlayerRespawn.sqf:
params ["_unit", "_corpse"];
player setUnitLoadout (getUnitLoadout _corpse);
_primaryWeapon = _corpse getVariable ["Hmch_Saved_primWeapon",["",[""],[""]]];
_secondaryWeapon = _corpse getVariable ["Hmch_Saved_secWeapon",["",[""]]];
player addWeapon (_primaryWeapon select 0);
player addWeapon (_secondaryWeapon select 0);
{
player addPrimaryWeaponItem _x;
} forEach (_primaryWeapon select 1);
player addPrimaryWeaponItem (_primaryWeapon select 2);
player addSecondaryWeaponItem (_secondaryWeapon select 1);
alright, giving it a go
im guessing im replacing what was previously in onPlayerRespawn.sqf
yes
got it
well got this first thing in the mission
got me gun back
dont mind the one on the ground thats from the dead body
Mhh guess should have set the default value to an empty array.(fixed)
mags check, gun check, attachments check
just have to deal with that message
and then body cleanup
if I could use the usual body cleaning method but delay it with a few seconds it could work as usual I belive
Should I be able to called hide object in postInit?
Function has postInit to 1 in description, and then does hideObjectGlobal
omfgggggggggggggggggggggggg i am loosing my mind, the civilian faction I made with Alive works and it appears but the OPFOR faction does not whyyyyyyyyy
same mod pack did not change shit
2 days ago it worked and now it wont appear at all
okay, How may I now remove the body?
my old method was
but I belive this would mess things up as it most likely removes the body before the player can get the stuff from it
I tried adding sleep to it but
thats where this came from
try
onPlayerRespawn.sqf:
params ["_unit", "_corpse"];
if (isNull _corpse) exitWith {};
player setUnitLoadout (getUnitLoadout _corpse);
_primaryWeapon = _corpse getVariable ["Hmch_Saved_primWeapon",["",[""],[""]]];
_secondaryWeapon = _corpse getVariable ["Hmch_Saved_secWeapon",["",[""]]];
player addWeapon (_primaryWeapon select 0);
player addWeapon (_secondaryWeapon select 0);
{
player addPrimaryWeaponItem _x;
} forEach (_primaryWeapon select 1);
player addPrimaryWeaponItem (_primaryWeapon select 2);
player addSecondaryWeaponItem (_secondaryWeapon select 1);
deleteVehicle _corpse;
Executed locally when player respawns in a multiplayer mission. This event script will also fire at the beginning of a mission if respawnOnStart is 0 or 1, oldUnit will be objNull in this instance
So add check !isNull to _corpse.
You got that when you spawned?
when I started
Yeah that should be caused by #arma3_scripting message
Oh my bad ^^
if that message only appears because it believes something isnt the case at the start thats fine
Try
params ["_unit", "_corpse"];
if (isNull _corpse) exitWith {};
player setUnitLoadout (getUnitLoadout _corpse);
_primaryWeapon = _corpse getVariable ["Hmch_Saved_primWeapon",["",[""],[""]]];
_secondaryWeapon = _corpse getVariable ["Hmch_Saved_secWeapon",["",[""]]];
player addWeapon (_primaryWeapon select 0);
player addWeapon (_secondaryWeapon select 0);
{
player addPrimaryWeaponItem _x;
} forEach (_primaryWeapon select 1);
{
player addPrimaryWeaponItem _x;
} forEach (_primaryWeapon select 2);
player addSecondaryWeaponItem ((_secondaryWeapon select 1) select 0);
deleteVehicle _corpse;
onPlayerRespawn.sqf?
yes
roger roger
The mags are also arrays as you could have gl grenades in your weapon^^
ah yeah okay so now it appears to work just fine
I am okay if it misses out on GL and that stuff but if it fixes that too then thats amazing
okay yeah seems to work well. Thank you very much I now have a more robust script that I will use for a long time
Thank you so much for your time this was vital for getting revive to work with this mod
If I want to use thisList to set the effect from a trigger on the people within it
how would I apply this to a remoteexec
like for example
["Music\Temp_Music.sqf"] remoteExec ["execVM",0];
["Music\Temp_Music.sqf"] remoteExec ["execVM", thislist];
thank you
Hi, is it possible to change the code when a waypoint is added to a unit when you are in the Zeus ? Because i don't understand why but when a unit is server side and is "Alone" in his group then the waypoint doesn't work. When the unit is not alone then it will work but otherwise, it's not working.
There is setWaypointStatements but it sounds like you want to fix the code in the first place, not just change it afterwards.
yeah but is there a way to "replicate" the waypoints ?
Not exactly sure what you mean. You can create and edit waypoints by script, yes.
thank you but i already know that
i wanted to know if it was possible to "replicate" the waypoints
so actually the waypoints are created but seems to be only on my computer and not on the server so i wanted to know if it was possible to transfer them directly to the unit owner so the server
addWaypoint is global arg global effect, so you shouldn't need to do that.
How about:
- What you tried.
- What you wanted to see.
- What you saw instead.
- Really simple, i wanted to move a group of one unit inside.
- I wanted to see the unit moving at the waypoint position
- The unit didn't move ๐
ah and actually it's why i asked if it was possible to change the "waypoint script" on the Zeus because actually the problem come from the Zeus and not from me
- What did you actually do? ie "I went in zeus, selected the unit, and right clicked inside a building"?
Remember 2 things, the unit is server side and is alone in his group.
- I went in zeus, selected the unit and right clicked on the floor
Is there any way to detect unit roles, as in detect if an unit is a machinegunner, medic, etc?
ok. some possibilities:
- sometimes it just takes a while for ai to decide to do something
- something affecting the ai like
disableAI "PATH" - Which building? might not have paths setup
- AI mods?
depends on criteria
- held weapon?
- unit editor name?
- selected respawn loadout?
- Not really logical actually because it's working perfectly when the unit is not alone in his group. I tried to put them all on the server and i tried to move only one guy and didn't work and i tried to link him to an other guy and it worked perfectly so if it's that then i don't understand.
- I thought it was something like that because i'm using this command but it's not automatic and i tried 4 times to be sure so i don't think it's that and like i said when i link to an other guy then it's working.
- I was wrong sorry, i meant "Ground" so i'm not moving them in a building, they are outside on the road or dirt.
- Nope
hmm. try:
- check that the unit can move w/o a waypoint
(curatorSelected # 0 # 0) doMove screenToWorld getMousePosition
- check that the waypoint is created, current
- with no/fewer mods. single unit waypoints seem to work fine here.
{
//... do stuff to normalize array, part of which is changing first position (select 0) to "NOT_A_VEHICLE" if no valid className exists...
}forEach opfor_static_turrets;
opfor_static_turrets = opfor_static_turrets select {(_x # 0) != "NOT_A_VEHICLE";};```
I feel weird making a new array to assign to the old array... Any ideas to make it better or?
- I did that ๐ and my command were
(curatorSelected # 0 # 0) doMove (getpos curatorCamera);
- It is but not on the server (I didn't check it on the server though).
- Then maybe it's coming from a mod i'm using. I'm using "Achilles" so maybe it's coming from that. I will try without to see if it's that or not.
do the CBA XEH_preInits of different addons run in the order of the addons being loaded?
(assuming the answer to that is yes, is that also the case in 3DEN?)
it depends when they get called
they run in the same order as whatever created them run
e.g. in CfgFunctions, in the same order as mod loading order
so basically to figure out the answer i have to go digging in CBAs code?
private _hee = "f";
_hee
Will that return "f" or
ye
ok so that's not my issue
you can use select instead of forEach
and combine their codes
e.g.:
_myArray = [["bla",2], ["ble",1]];
_myArray = _myArray select {
_x#0 != "bla" && {
_x set [1, "new data"];
true
}
}
so if the XEH_preInits of all addons in question are registered by having this ```c++
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

for that you need to see how CBA runs their stuff
my guess is yes
(it probably just does configClasses, which returns configs classes in addon load order)
thanks, imma go look at CBA then
why is the newly spawned object at level -88 :)
what level??
Anyone know a script where I can use a object like a laptop then use the scroll wheel menu to spawn in a helicopter?
MenuObject addAction ["Spawn MH-60M", {createVehicle [(_this select 3), (getPosATL MenuObject), [], 5, "NONE"];}, "vtx_MH60M"];
This is what I have but how do I make it spawn in on a object like a helipad?
configfile >> "CfgVehicles" >> "vtx_MH60M"
The getPosATL menuObject in the createVehicle is defining the position at which the vehicle will spawn. So if you want to spawn it on a helipad, you just need to reference the helipad instead of menuObject (maybe using vectorAdd to give it 0.5m of vertical height just in case)
Copy
For workshop vehicles how do I get the config code for them to spawn in the vtx_MH60M is not correct
For all vehicles (regardless of whether they come from a Workshop mod or not), createVehicle uses their classname. The classname is visible when you hover over them in the Editor, or be got dynamically from an existing vehicle using typeOf. For example, the vanilla Slammer's classname is B_MBT_01_cannon_F.
Thank you, you have been helpful
@digital hollow Hey. Hope you don't mind the ping, and I hope this is the right channel.
I am following along with your youtube video on file-patching. When you build the PBO it is just named "main", though most mods that I have seen have their PBO names formatted as "pfd_main" for example. Is there something I am missing to have the PBOs built with that naming format, or should I just be renaming my PBOs manually after they are built?
The prefix_component pbo names are made by build scripts. Addon Builder will just make a pbo named the same as the folder by default. You can manually rename them with no issue.
I have a question is there a way to make a kill logger script that saves what people kill in a txt file
without extensions, you could diag_log kills with server-side Killed Event Handlers on players
I have a script I tried to make
_killLog = "kill_log.txt";
// Add event handler to each unit
{
private _unit = _x;
_unit addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
// Check if killer is a player and instigator is a vehicle
if (isPlayer _killer && typeName _instigator in ["Air", "Land", "Sea"]) then {
// Check if instigator is destroyed by the killer or the crash/explosion
if (!isNull _instigator && (vehicle _instigator isEqualTo _killer || damage _instigator >= 1)) then {
private _instigatorName = displayName _instigator;
private _killerName = name _killer;
// Append the kill to the kill log file
private _logString = format ["%1 killed %2 at %3\n", _killerName, _instigatorName, time];
_logString call compileFinal preprocessFileLineNumbers "log.sqf";
};
};
}];
} forEach allUnits;
private _logString = _this;
_logString = format ["[%1] %2", time, _logString];
_logString = parseSimpleArray [_logString];
_logString = format ["%1\n", _logString];
_logString = parseSimpleArray [_logString, false];
_logString = format ["%1\n", _logString];
_logString = parseSimpleArray [_logString, false];
// Append the log string to the kill log file
_logString call compileFinal preprocessFileLineNumbers "appendto.sqf";
private _logString = _this;
// Append the log string to the kill log file
_logString call compileFinal preprocessFileLineNumbers format ["%1\n", _killLog];
It's for a plane mission and I had to take precautions cause AI likes to eject at slightly getting brushed from cannon fire
Your current script check if your unit isPlayer, so it wont affect to AI.
If you want attach eventHandler to object, your should add that to object, not for units.
To eject , you can use forEach crew YouPlaneVarName
So it's a kill logger for Player to Player kills?
typeName _instigator in ["Air", "Land", "Sea"] what
see https://community.bistudio.com/wiki/typeName please ๐
you are looking for isKindOf https://community.bistudio.com/wiki/isKindOf
i bet , 5$, chatGpt
here ๐ธ
I wish AI wouldn't eject with the slightest touch of damage
yes - apply it on all vehicles
Ok will do
Sorry for any dumb questions
Last question is there a way to attach mobility kills to players? Eg plane crashes in water after losing control after player mortally wounds it
I want them to show in the statistics tab of the map
Ugh. You could check damage inflicted and add score via script
quick and daft question
how do i stitch two values into a string in sqf?
trying to get minutes from date in a MM format
here's where I'm at:
if (date select 4 <= 9) then{
_mins = ????
}
else
{
_mins = date select 4
};```
I want to prefix a "0" to date select 4 if it is less than or equal to 9
01 02 03... 09 10 you mean?
yes
private _min = str (date#4);
if (count _min == 1) then {_min = "0" + _min};
_min```I'd say I would write like this
do you have a code that I could use that I could use as base
is there an alternative to using remoteExec?
I'm not an expert, but it really depends on what you're trying to do
my mod is entirely client side but I need to raise an event to the server to creative a weapon holder and add something to it so all players can see the same item on the ground.
i remember hearing remoteexec should be avoided? Cause possible exploits? but i cant remember the details from awhile ago.
Based on that scant info, I'll take a punt and point you to:
setObjectTextureGlobal
addWeaponCargoGlobal
Again, not an expert, but I'm not sure "avoided" is correct - I'd say more like "used accurately"
So what does used accurately mean in this case?
Only remoteExec stuff where stuff needs to be Executed Remotely
if you can make the server obtain/process the information instead of the client sending it, do things server-side
if only a client can send an info (e.g local information like something on player's screen) then make the client send that info to the server for it to process
Getting back into mission mmaking after a few years. Running a trigger on spawn to carrier deck and used to use trigger with condition call{this && (player in thisList)} & activation player setPosASL [56.770, 1569.65, 18.229]; but it now seems to toss me way far from the point? I fetched grid from object, yet it places me a few km away from the defined grid. Can someone advice? Mentioned method used to work no issues in the past so a bit lost
the location seems wrong, there's not much to it
eh, I could see a carrier being pretty close to the map edge
It does feel off, though it is what I get on eden XYZ and if a place a object it returns the same grid
I believe Eden XYZ are ATL
either that or you have something else somewhere interfering
but try that on an empty terrain, you'll see it works
Though if a place a object and grab that grid it should match the object grid, no?
no
ASL != ATL
ASL = Above Sea Level
ATL = Above Terrain Level
try setPosATL eventually
An ASL/ATL mixup, while wrong, wouldn't produce the symptoms described, though ๐ค it would result in wrong elevation but the horizontal position shouldn't be affected
yep
ye ASL places me at the right height, just a good 13km of on the X axis
Z is usually height :U
Ye meant X, typos
Are you getting this position from the Eden carrier object?
Carriers aren't actually one single object, they're a set of section objects. The Eden object is probably some kind of placeholder and may be being removed. Have you tried with a different (smaller) object?
Bottom left readout but also placed a object in the carrier deck level where I want them to TP to. Both XYZ matches. Unless the map is borked?
place yourself where you want to
start the preview
Debug Console: getPosASL player
that's your ASL position
WAITAMINUTE
are you trying to use grid map numbers?
I don't think the Eden bottom left readout displays grid numbers
I did read bottom-left as map 015423 location ๐ฌ
bottom-left is terrain ASL position, not "object intersection" position
hence the offset, depending on the camera's angle ๐
@drifting copper do this and you're covered
This is the method I usually get the grid
Hence why I am slamming my heado n keyboard right now ๐คฃ
So I just scripted a VIED that has a random chance of detonating on trigger, no issue
Scripted a random chance "flame out" for a fast mover, no issue
A bloody basic TP trigger sends me spinning. Though works now after a arma restar. FMl. Though thanks for the input @winter rose & @hallow mortar! No script change. Literally just a game restart.............
Is there a way to make an ai man aim precisely at a position? Or to just turn precisely toward a position? lookat and dowatch seem to cause the ai to rotate until they are within 30 degrees the direction they're meant to look. I'm looking for something closer than that.
youd have to check weapon direction vector instead of direction
Just aiming IDK, but you can make him fire at a specific position using
doSuppressiveFire
Maybe it is useful for you 
U can always control the direction of the fired projectile to hit something with precision through the firedman eh, this way u dont have to worry about the ai aiming precisely... Having it face the target should be good enough
params ["_unit","_mag_types","_weapon", "_loaded_mags"];
private _magazine = "";
private _muzzle = "";
private _reload = true;
.... snip ....
[_magazine, _muzzle, _reload];
};```
Can anybody tell me why the return from this function is always undefined? _magazine, _muzzle, and _reload are all defined.
The answer will be in the snip.
when a units locality changes, does the init EH run again?
by the end of the function, _magazine, _muzzle and _reload all have defined values, so why is the array returned undefined?
Probably because it's not getting to the end of the function. Either that or you're misinterpreting the calling code.
Even when I comment out everything else in the function, it still says the value returned from this function is undefined
calling code then.
i.e., when everything that is "snipped" is commented out
_mag_info = ([_unit, NADE_LAUNCHER_MAGS, primaryweapon _unit, primaryWeaponMagazine _unit] call func_has_mag);
all the arguments to the function are defined
but "_mag_info" is undefined
Is func_has_mag defined at that point?
yeah it's defined... the function is being called, I've confirmed that with hint inside the function. Plus all of the values in the returned array are also defined at the end of the function.
Is there some kind of trick about returning arrays from a function?
No.
any theories what might be wrong?
Remove the ; at the end
no
From
[_magazine, _muzzle, _reload];
yep, still no / useless
private _array = call { [1, 2, 3]; }; // _array is [1, 2, 3]
systemChat str the array just before the end
that or you are spawning your code :p
hello
I got dynamic spawning set up with TMF and put the "allowCrewInImmobile" since the wave spawner tmf has just copies the units and spawns them where the units were in map so now they don't eject now is the tracker time. is there a way to write kills on my players. At start I thought a script that if they do more than 40% damage the enemy plane dies but that would not grant them the kill right?
The reason I want to record almost all the kills it's for the rp element of the server and the plane shop I run in the server (like the one in ace combat games)
I thought either a score system like they kill a mig-29 and they get 100 points or a system where I do the math post op
sorry for the long text
โฆwhat is your question?
which is easier to implement?
you can kill with setDamage's alt syntax to set the killer
so with set damage with killer as player then that player will get a score with addscore?
as if he killed them yes
Can secondaryWeaponMagazine ever return an array containing magazines that aren't actually loaded into the secondary weapon?
waaaaaait a minute, first tell us if your earlier problem is solved :p
I think it is solved, but I'm not sure what the problem actually was.
ok, you pass
the wiki says it all, loaded
can a mag be loaded but for some reason unable to fire for reasons related to the state of the mag or the weapon?
For my script whenever you are free how will I set the condition of activation on the trigger
So when a player does x damage it suns the set damage thing
that's not how it goes, you need to use an event handler on spawned enemies, see the framework's documentation
Ok
So I'll do
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
}]; ```
For each vehicle
I'll modify it when I get home cause I'm on the phone
I found the tmf event handler as well
private _groups = _this select 1;
{
_x setBehaviour "AWARE";
_x setCombatMode "RED";
_x setSpeedMode "FULL";
} forEach _groups;
}] call tmf_ai_fnc_addWaveHandler; ```
Looks like I can put it in the spawner and it will apply to all
I'm having difficulty getting an ai unit to select his rpg and fire a mag from it. He seems a lot of the time to get stuck in a loop where he stands up, gets his rpg out, puts it away, and goes prone again. Doing that over and over. Anybody know a way to correct this?
What are you trying to have them shoot at? And what effect are you trying to achieve?
Is there a way to get a player object from the remoteExecutedOwner ?
You can request it from the server
Constantly apply the launcher stand/crouch animation yourself
What init EH? You mean init field?
Or the unit's init EH defined in its config?
But how ?
Without seeing the whole code no
Hi together, just a short basic question as a non programmer because I actual cannot refind an article in BI Wiki about Loadorder between Mods, Scripts and so on.
I want to change the Loadout (change mags to Tracermags for example) of a faction which comes / loaded by Mod.
The units will be spawned while mission by script and do not exist at beginning.
Normal way is to inheritant and include changes in a own Mod, I do understand.
But I wanna ask if there is annother and maybe easier way?
First tries:
- used MissionEventHandler "Entitycreated", Loadout is called (own Debug systemchat hint is shown at the end of the Loadout Script) but Units stays by their origin Mags
- used CBA_fnc_addClassEventhandler but same result as in 1.
So my basic question: Do you have any ideas for me?
I'm trying to get it on the server. So basically I send a remoteexec to the server and then trying to get the player object through remoteExecutedOwner. clientOwner btw only gives you the Machine Network ID which is a different ID to the ID you need for getUserInfo
Of course I can send the netID from the player or the PlayerID to the server but I thought it would be possible with the Machine Network ID from the remoteExecutedOwner to get the player object
Use allUsers, then check getUserInfo
yea I thought the same, but that way is meh
I will just send the netID with the call I guess
ty anyway
https://community.bistudio.com/wiki/Initialization_Order that's the page on init order.
i assume the entityCreated EH doesn't work cause the units get their items assigned after it fires, so if you really dont wanna make a mod try spawning some code through the EH that waits till the units have their items and then applies your changes
For that you should write a config patch
Using EHs will slow things down (unless you're making a mission and can't do config patch)
are there any data types that are not passed by reference?
No
Out of curiosity, how would you do this?
I mean, I can think of a couple options, but what would best-practice be?
How i can pick soldiers from a group and move them to driver, commander and gunner on a vehicle?
Im using a respawn system that respawns both vehicle and the crew, but crews variablenames dont seem to persist trough respawn so i cant use them directly
and when i use moveinany the crew sometimes bounces to cargo positions
MpRespawn EH, use the _corpse parameter to refer to the deceased, iirc.
oh and these are AI soldiers im talking about
... is it necessary to respawn the crew then, rather than generate new ones?
the way it is now is because im usign mgi advanced module ai respawn that respawns all the ai. I started this way because i thought it might be easier. Afaik the groups can be blocked form spawning too so maybe creating new crew would be good idea.
ill try that out next
thanks!
Just sounds like a lot of effort for an unclear reward - doable, but is it worth it, sort of thing.
hello I did all the stuff needed but how do I make the trigger that if a player strikes a vehicle and do x amount of damage the vehicle dies crediting the player for the kill
use an event handler, not a trigger
I think I said that before ๐ ๐
oh how would one normal one be cause the only thing it needs is to incorporate it within their EH by what I've found
so you can call the normal one in the one they have and it will be applied
a "normal one"?
does anyone know how 3CB vehicles work? those are vehicles ported from arma 2
I'd like to make this artillery piece fire, with or without crewmen in it, doesn't matter
like one that you could make for a plane if there was not TMF there
you said yourself that you cannot use the normal one because TMF copies the unit?
or can you adapt this
I adapt it
here is the doc ๐ https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed
thanks
if I put in _killer the player variable will it register the player that killed it or pass it to all players
question unclear please rephrase
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];```
if instead of _killer I put player
```this addEventHandler ["Killed", {
params ["_unit", "player", "_instigator", "_useEffects"];
}];```
will it register the kill to the player that killed the enemy or will it give the kill to all my players
it will trigger when *this * dies
code excerpts are identical
no it won't, that's not how it works
these are arguments provided to the event
and btw I realise now you should not use "Killed" but most likely "HandleDamage" event
oh
_enemy addEventHandler ["HandleDamage", {
params ["_unit", "", "", "_source", "", "", "_instigator"];
if (not alive _x || { canMove _unit }) exitWith {};
_unit removeEventHandler [_thisEvent, _thisEventHandler];
_unit setDamage [1, true, _source, _instigator];
}];
```this event must be added **on the server**
does execVM run in a global state?
I want to add both diarySubjects and diaryRecords to players through a file called "briefing.sqf", so Im considering just running the code with execVM.
but i dont know if it would work for newly joined players.
you can run code in init.sqf or initPlayerLocal.sqf for clients that start the mission
in init.sqf you would have to do hasInterface check
Iam stupid, how can i save a hashmap to profile namespace and retrieve it again ?
Wasted enough time so i just gotta ask since iam unable to find my issue ๐
profileNamespace setVariable ["whateverTheName",createHashMap]; //save
profileNamespace getVariable "whateverTheName"; //load```
_hashMap = profileNamespace getVariable "whateverTheName";
And _hashmap will be a hashmap ?
Yes
Thanks alot, i tried sh*t like that. 
Shouldn't code when tired
RW_COMMANDER_DoorNameIndex = createHashMapFromArray (profileNamespace getVariable ["CW_COMMANDERTOOGLEANAMES", []]);
what's _x doing?
By what I understand for the script checks if unit is dead or unable to move so it will not run if those things are true
If false it will set damage to 1 killing the unit and granting the kill
I did a small modification
if (not alive _unit || { canMove _unit }) exitWith {};
if (not canfire _unit) exitWith {};
_unit removeEventHandler [_thisEvent, _thisEventHandler];
_unit setDamage [1, true, _source, _instigator];
}];```
if ((damage _unit) < 0.4) exitWith {};
this should make it so the thing work if damage over 40%
mb, replace _x with _unit
ok
don't you want it to be killed only when it cannot fight anymore? that's what canMove check
you could also do a canFire check if you will
I see
_enemy addEventHandler ["HandleDamage", { params ["_unit", "", "", "_source", "", "", "_instigator"];
if (not alive _unit || { canMove _unit }) exitWith {};
if (not canfire _unit) exitWith {};
_unit removeEventHandler [_thisEvent, _thisEventHandler];
_unit setDamage [1, true, _source, _instigator];
}];```
you mean something like this?
yep
wait
_enemy addEventHandler ["HandleDamage", {
params ["_unit", "", "", "_source", "", "", "_instigator"];
if (not alive _unit) exitWith {};
if (canMove _unit && { canfire _unit }) exitWith {};
_unit removeEventHandler [_thisEvent, _thisEventHandler];
_unit setDamage [1, true, _source, _instigator];
}];
oh both checks to see if unit gets downed by missile impact as well
as in "if it can still fight, leave it be"
well yeah, target the object you want with it
using this I suppose
heyo, im trying to make the engine of certain vehicles indestructible but it doesnt seem to be working. Any Idea why? im using ACE as well btw, maybe hitpoints are named different?
this addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];
if (_selection isEqualTo "hit_engine") then {
_damage = 0;
};
_damage
}];
perhaps ๐ฎ
debug and see _selection values
yeah I do that, just didnt include it here. when I shoot the engine multiple hit points come up as strings including the hit_engine
that was a single shot printed with systemChat (str _selection);
im using ACE as well btw
only the last HandleDamage EH is effective
ACE uses A LOT of them, soooโฆ that's that
is anyone familiar with the arma 3 vanilla high command
am looking for a script (or any way at all) to disable enemy markers while using high command
hmm, any suggestions or ways to overwrite that?
its been a while since i worked with HC but this should do: sqf player setvariable ["MARTA_hide",_groupListHere];
il try it out 
ugly ones yeah, like removeAllEventHandlers
try the ACE Discord, they might have solutions
gotcha, I know I did it before but I cant remember how. Thank you
