#arma3_scripting
1 messages · Page 155 of 1
Hey guys, I have the problem, I have a wokring 60 second countdown script, but when i try to using format into mm:ss showing in the hint, I get the error that sleep 1; is not allowed in this context.
My working old script:
// Dauer des Timers in Sekunden
private _duration = 60;
// Schleife, um den Timer herunterzuzählen
for "_i" from _duration to 1 step -1 do {
// Nachricht an alle Spieler mit der verbleibenden Zeit anzeigen
{
hint format ["Zeit bis Detonation: %1 Sekunden", _i];
} forEach allPlayers;
// Eine Sekunde warten
sleep 1;
};
// Nachricht anzeigen, wenn der Timer abgelaufen ist
{
hint "Detonation!";
} forEach allPlayers;
my try to format the time showing in the hint:
private _duration = 60;
for "_i" from _duration to 1 step -1 do {
private _minutes = floor (_i / 60);
private _seconds = _i % 60;
private _formattedTime = format ["%1:%2", format ["%02d", _minutes], format ["%02d", _seconds]];
{
hint format ["Zeit bis Detonation: %1", _formattedTime];
} forEach allPlayers;
sleep 1;
};
{
hint "Detonation!";
} forEach allPlayers;
Why sleep is now not allowed? or I do where im wrong?
are you calling it differently?
i.e. spawn-ing the first one and running the second one from debug console
yep exactly that way.
calling it from sqf file working now, but shows me nothing in the hint except: d:d
format time i never used before
Why sleep is now not allowed?
Because you called your code in unscheduled environment: https://community.bistudio.com/wiki/Scheduler#Unscheduled_Environment.
but where is my logical problem to format the time correct?
%02d -- what's this? format doesn't support this: https://community.bistudio.com/wiki/format
Maybe he trying get
Format Data Result
%02d 1 01
%02d 11 11
Yes, but this is not C, this is unsupported in SQF.
Yeh, its
and yes, it's not 
like this?
hint format ["Zeit bis Detonation: %1 Sekunden", [_i, "MM:SS"] call BIS_fnc_secondsToString];
yes i already edited IT 😅
Yes.
so i dont need to define much just using a pre existing function ^^
Exactly.
i will Test it when Back Home in 1hour and give you a Feedback.
%1 will be filled with the following string place, right? in every situation?
If you provide a value.
in my case i have pre defined what is _i so this will be the Content of %1 (formatted with the function but in simple words)
correct?
I believe so.
Im not a scripting expert, so I will understand what I using. So next time its easier maybe without help
Of course, if you need help, read BIKI, ask questions...
BI wiki is my first way everytime, but sometimes there are not enough information to be handled by a noob ^^
I think it's at first glance. In my opinion, BIKI can almost always answer any question.
Hi ! I have question regarding the use of Function-as-files and Inline functions.
Which one should I prioritize ? Is there like a common practice to use ?
https://community.bistudio.com/wiki/compileScript is the fastest way to turn file into a callable script function. some people also use the CfgFunctions to run their script files into function, but that's more work
Not sure both Function-as-files and Inline functions mean, but I guess there is no literal difference. They are semantically same terms of how it works, so you better to pick either of them you prefer/easier to maintain
if you want to put several functions in one file you can do ```
myFunction = {
// Code here
};
You can also be lazy/fast and do that inside initplayerlocal.sqf / init.sqf / initsever.sqf / mod pre-init etc.
// Define functions
{
missionNamespace setVariable [(_x #0), compileScript [_x #1]];
} forEach
[
["XYZ_fnc_ABC","Code\XYZ_fnc_ABC.sqf"],
["XYZ_fnc_DEF","Code\XYZ_fnc_DEF.sqf"]
];
you can be even more lazy and define the functions inside init.sqf 
Anyone knows where can I edit that text that says SYSTEM? On my server it just says BattleEye
It's defined in game stringtables
Part of it
These ones most likely in dta/languagecore
some vehicles have special roles assigned to it (e.g HEMTT medical, HEMTT refuel, Medical tents, etc.), as it can be seen in CfgVehicles; is this modifiable on runtime? are there any commands that can make, for example, a MH-9 function as a medical, repair and fuel vehicle at the same time?
Are you talking about ace medical and repair/rearm/refuel or vanilla?
Vanilla, no.
ACE, yes.
What about modifying it ""non-runtime""?
Yes, you can do it by modifying the config values of whatever class(es) you want
so i guess no command exists to get the currently rendered display? maybe i should make a ticket for that?
You mean top most display?
yeah
It uses the Profilename of the server, just change it.
I'd like to have an object orbit around another object. Is there any function that exists which might fulfill this purpose?
I'm at work now so I can't poat the script, but it was pretty simple to make the AI use hand signals. I added an event handler CommandChanged for the group, and defined a table (array with key-value pairs) for each possible command and a hand signal animation from SOGPF. The good thing about those animations are they only affect the arm, so they work if the unit is standing, kneeling, or prone.
Nope. You would have to rotate an object each frame a little bit around an axis, like rotating a vector. Would maybe look pretty odd and glitchy I guess. What did you have in mind?
A sort of planetarium like display.
The way I would approach this is:
- add cba_fnc_addperframehandler, within that
- Get the objects up vector, the one that the other thing should be rotatet around
- Rotate the vector a tiny bit using the cba function to rotate 3d vectors (forgot name), then attach the object to the other using the rotated vector as offset.
Need links to funcs?
// initServer.sqf
addMissionEventHandler [ "onUserSelectedPlayer", {
params [ "_networkId", "_playerObject", "_attempts" ];
_playerObject spawn
{
params [ "_unit" ];
waitUntil { sleep 0.5; getPlayerUID _unit isNotEqualTo "" };
// do stuff
};
}];
I am getting false positives from getPlayerUID. What condition should I check, to wait server transfer player object to client ?
Hello, does anyone here use a linux based system and mod? I want to ask if there will be any differences or anything I'll need to set up via wine.
Make sure all the addon and folder names in your mod are lowercase, especially the addons folder.
How would i change the name of a weapon, not the display name but the other name?
Which other name?
(Chances are very good that this is a #arma3_config problem - most weapon properties are config-controlled only)
The name underneath when you hover over a weapon with ace arsenal
I don't have the game open right now, could you give me an example?
Like the display name would be like L192a1 and then the other name below it could be like sr_16_cqb_tan for example
Right, that's the weapon's classname, the internal name used to refer to it in scripts and config
Oh right, is that a pain in the ass to change?
In order to actually change it you would need to modify the original mod (can't and don't, even if it's your mod, changing classnames is not backwards compatible). The best you could do is make another mod that makes a new class with the name you want that inherits everything from the original, and then have your mod modify the original class to hide it in the Arsenal. That's an exercise that's technically possible, but pointless.
ah okay, thanks
It's just an internal name to refer to the weapon type. It's only important for use with scripts and mods, and even then it doesn't really matter what it is as long as you know what it is.
Yeah
Also init.sqf, initPlayers.sqf and any functions in cfgFunctions with either the preInitnor postInit flag set
immediatley when someone jips...
but that did not happen before...it starts about a week ago (1.54)
Yes the update might have broken a script
For example the alternative syntax of local got changed
Hey guys
Hope you are all going well.
Hoping someone can help me figure out a quick code.
When someone is killed a marker is placed and lasts for 5 minutes.
I'm wanting to timestamp each marker so I know what ones I need to hit first. What's the script for something like that?
You can use a killed event handler to tell when a unit dies https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed
Then you can use a CBA waitAndExecute https://cbateam.github.io/CBA_A3/docs/files/common/fnc_waitAndExecute-sqf.html to wait X amount of time, and then run some code
As for actually creating the markers, look at https://community.bistudio.com/wiki/createMarker
Make sure to read the note about multiplayer optimization
Finally if this returns nothing youll have to check your mods by removing and adding them back one by one.
Thats the script im running so far
Why check isServer twice?
They were done separately and then combined so just missed it haha
Anyways, I thought you were needing help with the whole thing
To get the mission date/time, just use https://community.bistudio.com/wiki/date
Also, you're using apply on an array, but you're never using the result. You can just use {} forEach [...]
You also create the marker if it doesn't exist, and then check if it exists just after.
Nevermind, I see what you're doing
So I realized today that 'init' fires literally every time a player joins the game. How can I make it only fire once? Or do I have to resort to other means of doing scripts at game start or when a unit gets spawned by Zeus? I don't want the script firing every time a player joins.
Or, I may have answered my own question. Is that what if (isServer) then {...}; does?
That just runs code only on the server
So isServer does what it says on the tin, it means the script will only be executed by the server (host)
Which may or may not be what you want
That said it will only execute once if it's in the init.sqf file if I'm not mistaken.
I don't think I've opened eden without eden enhanced installed since it was released, but is the init box in general from enhanced or vanilla?
this is perfect, cause I do want their to be an explosion
That is the hope but I also need something that will still trigger when spawned in by other means. Like if I place something in Zeus and I have a script attached to it that, let's say, spawns a unit with a randomly chosen gun.
My goal is to have a composition of AI who randomly spawn in with different equipment every time one of them gets placed, or at mission start if I place them in 3den.
I'm completely new to arma 3 scripting as whole, can anyone assist with a simple, if you open inventory of this item, it spawns mk82?
I'm confused with how to timestamp the kill.
Would it be
_marker setdate
Or maybe _marker diag_tickTime?
So that would be
setMarkerText diag_tickTime
?
Read the wiki
Vanilla
Thanks mate. I actually had someone write the script for me and have been using it for the last few months and love it when I'm running Antistasi.
Now I'm wanting to tweak it that last little bit and I just can't figure this bit out haha
What exactly are you wanting, like the in-game time when the marker is created or the number that shows how long the client has been running for
I'm wanting to have the marker show the time it was created so I can hit the earliest kill before the newest for gear
In game time that is also
Okay, so then use date, it gives an array of the day month year hour min etc.
date params ["_year", "_month", "_day", "_hours", "_minutes"];
Then you can just use format to format it how you want
For example:
private _name = format ["Surrendered Unit - %1:%2", _hours, _minutes];
Thanks mate
Im trying to get my head around the script and have slowly been trying things out myself.
This is the only script I haven't really messed with as it works haha.
would I have that under the section where I have
//individualize the marker name
It doesn't technically matter, as long as you do that before the setMarkerText
ahh ok easy.
Ill have a fiddle when I get home and see if I can make it work.
Thanks mate
👍
"Error: addVest: Type array, expected Object"
I'm not sure what's going wrong here. I put this in the init field of a unit and this error is the result. _this should definitely not be an array.
{
_handle = 0 spawn {
sleep 10;
_this addVest "HITMAN_47_Hidden_Vest";
_this addWeapon "CUP_arifle_AK47_Early";
_this addMagazine "CUP_30Rnd_762x39_AK47_M";
};
};```
Clearly I am not understanding something.
Your code in error and your code you've posted are not the same anyways, you're passing 0 or [this] that are definitely not an object
I grabbed the wrong screenshot but I suppose the hang-up is I'm not using spawn correctly. I'm trying to delay my code because I can't just type sleep in the init field without putting it in a spawn field and I have no idea how spawn works and reading the wiki didn't clear much up.
Still, 0 or [this] is not an object. this is
Okay, let me try that. I see the problem now.
Okay now I got it. Thank you.
{
_handle = this spawn {
sleep 3;
_this addVest "HITMAN_47_Hidden_Vest";
_this addWeapon "CUP_arifle_AK47_Early";
_this addMagazine "CUP_30Rnd_762x39_AK47_M";
};
};```
To clarify and future ref: [0] is an array, that has a number in it. You can retrieve 0 out of it using select or some other commands... but [0] is an array still
Same with this or [this] etc
Yeah I was trying to copy from somewhere else not fully understanding how spawn worked to begin with.
It is about _this more TBH
Is it normal for IncomingMissile event to fire twice? Was it always like this? 🤔
Not sure how long it's been, but I've noticed that behavior before.
It's not with all of them though. Unguided rockets (RPGs) only fire it once.
Looks like it's been the case since before the projectile param was added. https://feedback.bistudio.com/T165849
I also noticed this back in 2021. My theory was that it fires once for AI firing a guided or unguided projectile at the target and once more for a guided projectile as it starts tracking the target.
Then it also makes sense that players firing at the target only trigger the EH if they fire a guided projectile that has locked onto the target.
Question, is it possible to attach multiple objects to different parts of a rope
https://community.bistudio.com/wiki/ropeSegments
Do you mean this?
Essentially I want 6 or so objects to be attached to the end, than 3m higher than 3m higher than 3m higher than etc up the rope
uhh
I see
Are the segments always named the same?
Name? What it does mean
Okay I did some testing and I aint sure anymore
I did
[cl4, [0,0,0], 168075] ropeAttachTo MyRope9;
168075 is 3rd to last rope segment. But object is still attached to last one
168075 is just a number, not an object
I mean that command above did successfully do the attachment, just to the wrong thing
or not the thing I intended atleast
Which command above? Your code here is not even a working one
Well apparently it does
it attached rope end to the object cl4
Just executed it after your last comment
Then you are not running that code. The code should throw an error straight
No. They are objects, not numbers
They are objects
okay, how do I attach to, lets say, second to last one
Okay I stand correct. It seriously for unknown reason sqf [objNull, [0,0,0], 0] ropeAttachTo objNull;is not throwing an error. But that is not the code you want anyways. Seems the second argument is not even working correctly?
To get the second to last segment, sqf (ropeSegments _yourRope)#-2
I use that instead of rope name? at the end of ropeattachto?
No?
or in the third variable?
Once again, rope segments are objects. You can use one of the segment that is returned by ropeSegments to refer one of the segment object
Urm okay, I stand corret again. You want to use attachTo instead. Not ropeAttachTo
Hey guys
Does this look correct?
More importantly just the timestamp portion half way down.
So this is what I was working on and I'm quite proud of it.
Fot context I was wanting to modify the weapons that spawned with CFP civilians. The problem is you can't set loadouts because code attached to CFP civilians automatically randomizes their loadouts. That's great if you don't want your civilians to look samey, but bad if you want those unique looking civilians to carry guns.
Now I could have stopped at making sure they spawn with a gun by using a spawn and sleep to add the weapons I want, but you see, I am an insanely autistic person and so I hyperfixated on this for the past twelve hours pulling every single gun and all of the ammo variants I specifically wanted to use.
The way it works is...
- First, you define an array of arrays containing a gun and all the ammo types that go with it.
[gun,["mag","mag","anotherMag"]]Not literally all ammo types but specifically what you want to use. Sure I probably could have used something sane like pull all available mag types for that gun instead of doing it manually but this method lets me intentionally add duplicates of certain mags to increase their commonality like 20rnd 5.56 on old M16s, or to omit certain mags I don't want like 150 round double-drum mags. These guys I made are supposed to be militants, so they have a wide variety of possible mag spawns. - Once I have that array of arrays, I randomly choose one of those arrays. This assigns what gun will spawn.
- (Optional) Add a vest or backpack that allows the AI to carry more magazines, since civilian outfits tend to have bad inventory space. I used an in-house mod to add a cheaty invisible vest that allows me to do this without adding visible changes to the characters
- With that gun chosen, I then also check the next item inside that gun's array which is a sub-array containing the mag types I want to go with that particular gun. I randomly select one of those magazines each time we attempt to spawn a magazine. This assigns what magazines can potentially spawn.
- Repeat previous step about 30 times or whatever. You won't get extra magazines if you're unable to fit any more so may as well do it a whole bunch of times.
- Just as a fail safe because the AI is a little janky and sometimes still spawns with empty guns, try to reload in 7 seconds if you haven't loaded your gun yet.
Just plop this sucker in the init field and you're golden. Probably. I haven't tested it in multiplayer.
Mods included are CUP, GM, Aegis, and SOG guns, but you can repurpose this to whatever mod set you see fit.
Anyway, the sun is up, time for bed. 
If someone would care to proofread my work (you can skip the giant block of arrays) and let me know if this works fine in multiplayer I'd appreciate it.
I cannot test this, and I am not sure if this would work if I spawned the units with say, Zeus. Would the units get all their assigned gear on all players' screens or do I need to use different commands? if (isServer) should prevent the script from firing every time a player joins at least.
Short question because i cant test MP compatibility currently. Will this work well in MP? it works fine on eden testing sp and mp
[] execVM "scripts\ambient\countdown.sqf";
["sgmusic_2"] remoteExec ["playMusic", 0];
hatak hideObjectGlobal false;
shield_1 setdamage 1;
shield_2 setdamage 1;
[4] remoteExec ["BIS_fnc_earthquake", 0];
sleep 20;
[4] remoteExec ["BIS_fnc_earthquake", 0];
sleep 20;
[4] remoteExec ["BIS_fnc_earthquake", 0];
sleep 20;
[4] remoteExec ["BIS_fnc_earthquake", 0];
sleep 20;
[4] remoteExec ["BIS_fnc_earthquake", 0];
sleep 20;
[4] remoteExec ["BIS_fnc_earthquake", 0];
sleep 40;
hatak enableSimulationGlobal true;
sleep 20;
hatak setdamage 1;
It should, as long as it's executed only on the server
Your code block didn't format correctly because you used different characters at each end. You must use ` at both ends.
I call it via addaction: 0 = this addAction ["Reaktor überlasten!", "scripts\ambient\zpm.sqf"];
hideObjectGlobal and enableSimulationGlobal require server execution. If this is called from an action, then the script will only be executed on the machine where the action is activated. You would need to either remoteExec those two commands to the server (target 2) or remoteExec the whole script to the server. Personally I'd suggest the latter; handling this on a client means the sequence will be stopped if that client happens to disconnect partway through, whereas the server will never disconnect (without taking the entire mission with it, anyway)
Also don't use execVM, use functions.
execVM should be only used if you run/execute something once.
the whole Script I want to be used only one time. but the effects I want to be global.
is that possible?
this addAction ["Reaktor überlasten!", {
"scripts\ambient\zpm.sqf" remoteExec ["execVM", 2];
}];
right
Is there a way to stop an AI from going prone? I have one in a guard tower and when he sees players he does this making it hard for players to see him.
this I think: _soldier setUnitPos "UP";
Nice, I will trying putting in the init of the unit.
Is there way to use the trigger condition BLUFOR detected by OPFOR have a timer that satisfies the condition?
For example right now I have that condition in a trigger synced to a task that fails if BLUFOR is detected. But I want to give the player a chance to kill the sentries within lets say 10 seconds. If they do that then trigger wont fire and the "alarm" wont be raised.
Basically right now it is too punishing for the player. I hope this is making sense.
Quick question does anybody know how can i make it so Zeus cant delete specific object. or Respawn position. Even when he adds it to Zeus interface.
Hi guys question, anyone knows how to make a command to give all units a certain amount of mags or even give them grenades or certain items to start with? i tried to start with this to just add magazines to everyone but i keep getting error i even tried to add a debug but it still doesn't work
{ _primaryWeapon = primaryWeapon _x; systemChat format ["Unit: %1, Primary Weapon: %2", _x, _primaryWeapon]; if (_primaryWeapon != "") then { _magazines = magazines _x; { _x removeMagazine _y } forEach _magazines; // Correct usage: _y is each magazine, _x is the unit _magazineType = getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "magazines") select 0; \ for "_i" from 1 to 5 do { _x addMagazine _magazineType; }; systemChat format ["Added magazines: %1 to %2", _magazineType, _x]; } else { systemChat format ["No primary weapon for unit: %1", _x]; }; } forEach allUnits;
i made an action combat scene where everyone should already start with mags on them without the need to refill from a crate or something because it's not part of the scene, i just want everyone to start with mags and grenades
Your forEach is wrong
_y is not "each magazine"
It doesn't even exist
Is that chat gpt generated?
{ private _primaryWeapon = primaryWeapon _x; systemChat format ["Unit: %1, Primary Weapon: %2", _x, _primaryWeapon]; if (_primaryWeapon != "") then { private _magazines = magazines _x; { _x removeMagazine _x } forEach _magazines; private _magazineType = getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "magazines") select 0; for "_i" from 1 to 5 do { _x addMagazine _magazineType; }; systemChat format ["Added magazines: %1 to %2", _magazineType, _x]; } else { systemChat format ["No primary weapon for unit: %1", _x]; }; } forEach allUnits;
yes
do you know how to do it then?
i don't have time to learn arma coding i am already coding in java
Define the unit outside the scope, using another variable
I didn't really bother to read the rest of that code tho
what would you use for sqf then?
If a unit has a weapon, it already has magazines.
i would learn it but i want to invest every single hour i have into java
all my units start with a single mag in their weapon and that's it
and everyone scream no ammo no ammo when they start
and it's unplayable because they can only fight for like 10 seconds and then they run out of ammo and just run around
i don't know why would arma 3 makers make it so hard to just make units start with a certain amount of mags it should be just a basic slider or a value to set in the options
why do i have to know coding to give my units mags
it should be the most basic option \ slider
ill try to dig into the wiki but i hope i won't need to spend hours on hours to learn a new lang and code an entire script just to play a video game i just want to enjoy
this worked for me
{ private _unit = _x; private _primaryWeapon = primaryWeapon _unit; systemChat format ["Unit: %1, Primary Weapon: %2", _unit, _primaryWeapon]; if (_primaryWeapon != "") then { private _magazines = magazines _unit; { _unit removeMagazine _x } forEach _magazines; private _magazineType = getArray (configFile >> "CfgWeapons" >> _primaryWeapon >> "magazines") select 0; for "_i" from 1 to 5 do { _unit addMagazine _magazineType; }; systemChat format ["Added magazines: %1 to %2", _magazineType, _unit]; } else { systemChat format ["No primary weapon for unit: %1", _unit]; }; } forEach allUnits;
it wasn't that hard after all
Vanilla units have a sufficient number of mags. If your units don't, then they are most likely from mods, so this is a bug of mods.
Your brain.
oh i see, probably mods then. i do use a lot of them for the simulation i need
Gonna need some advice here.
Been trying to make two objectives for my mission.
Objective 1 is to locate a specific vehicle, and objective 2, spawned by completion of objective 1 is to secure the area around it.
Objective 2 I can make without issue, but I can't figure out how to make first objective complete when players (multiplayer) find the vehicle.
Been trying to figure out knowsAbout command, since that's what was suggested to me, but I can't figure out how to make it work.
Any help you be appreciated.
I would use https://community.bistudio.com/wiki/cursorTarget command.
Create a trigger and sync it with the vehicle. Then set up the trigger:
- Activation type: none
- Activation: none
- Repeatable: unchecked
- Server only: unchecked
- Activation condition:
cursorTarget in (synchronizedObjects thisTrigger) - On activation:
[cursorTarget] remoteExecCall ["createSecureAreaTask", 2];
I'm probably doing something wrong since it's not working.
Nvm, it just doesn't do it automatically, unless you are really close to it.
Thank you, that did what I wanted it to do.
There is a similar command, https://community.bistudio.com/wiki/cursorObject , that can be used by simply pointing the cursor on the vehicle. I would use cursorTarget since it requires you to "identify" a target either visually and/or by pressing T.
Mhhh, I have a script that runs when a player joins that uses local. What could I do now? (The script is actually IgiLoad...I know its outdated but it worked fine till now T^T)
I'm pretty sure a mod was just released for this
help me figure out my 3-person camera script
player addEventHandler ["GetOutMan", {
params ["_unit", "_role", "_vehicle", "_turret", "_isEject"];
if (cameraView isNotEqualTo "INTERNAL" && {(getPos _unit) distance (markerpos 'base0') > 500}) then {
_unit switchCamera "INTERNAL";
};
}];
addUserActionEventHandler ["personView", "Activate", {
disableSerialization;
if ((getPos player) distance (markerpos 'base0') > 500 && {((isNull objectParent player) || (["car","Motorcycle","truck","truck_F","plane"] findif {(objectParent player) iskindof _x} != -1 && ["Wheeled_APC","Wheeled_APC_F"] findif {(objectParent player) iskindof _x} == -1))}) then {
player switchCamera "EXTERNAL";
};
}];
findDisplay 46 displayAddEventHandler ["KeyDown", {
private _handle = FALSE;
if (((_this #1) in actionKeys "personView" || (_this #1) in actionKeys "curatorPersonView") && {(getPos player) distance (markerpos 'base0') > 500} && {((isNull objectParent player) || (["car","Motorcycle","truck","truck_F","plane"] findif {(objectParent player) iskindof _x} != -1 && ["Wheeled_APC","Wheeled_APC_F"] findif {(objectParent player) iskindof _x} == -1))}) then {
player switchCamera "INTERNAL";
_handle = true
};
_handle
}];
findDisplay 46 displayAddEventHandler ["KeyDown", {
private _handle = FALSE;
if ((_this #1) in (actionKeys "tacticalView")) then {_handle = true};
_handle
}];
findDisplay 46 displayAddEventHandler ["KeyDown", {
private _handle = FALSE;
if ((_this #1) in (actionKeys "networkStats") && {(getPos player) distance (markerpos 'base0') > 500}) then {_handle = true};
_handle
}];
addUserActionEventHandler ["MoveForward", "Deactivate", {
disableSerialization;
if (((isNull objectParent player) || (["car","Motorcycle","truck","truck_F","plane"] findif {(objectParent player) iskindof _x} != -1 && ["Wheeled_APC","Wheeled_APC_F"] findif {(objectParent player) iskindof _x} == -1)) && {(getPos player) distance (markerpos 'base0') > 500 && {cameraView isEqualTo "EXTERNAL"}}) then {
player switchCamera "INTERNAL";
}
}];
periodically, the player's camera flies off - that is, the camera freezes in place, and the helicopter flies away
Why is that?
The problem is only in MP
player remoteControl objNull;
switchCamera player;
```this kind of solves the problem and returns the camera to the player, but at the same time it is clear that the transition is taking place - sound settings and range visibility fly off
which is very annoying
the feeling is that the problem is with locality and its transition, because if you distribute different skins at the local level, then when the camera returns, the skin of the helicopter will change
That's why I asked why it doesn't work
player switchCamera "EXTERNAL"
```when setting thirdPersonView 0 or 2
[#dev_rc_branch message](/guild/105462288051380224/channel/105466812870713344/)
it's much easier to turn on the camera when I need to (on respawn) than to constantly monitor and disable it
doesnt Work after ai register Players or firefight and Change to Combat yellow or red for me
odd seems to work here. did you replace _soldier with something valid?
this in the unit init
ok
but its working, until the First AI combat modi
yeah AI mod could effect the behaviour
kinda funny inArea works with negative values. (getpos player) inArea [(getpos player), -5, -5, 0, true] returns true. but i guess there is some logic behind that?
I've done extensive single player missions and do quite a lot of scripting for them (I'm a Software Engineer in real life).
But I want to make a multiplayer mission, which I've only done super simple stuff for.
What's the usual dev cycle/testing for a multiplayer mission? What's a fast way to test things are working fine on a multiplayer scale?
create a .bat file that starts dedicated server on your PC then connect to that from the client. that's the fastest way I know. I sometimes run and automatically connect the client via .bat file as well
you can also use programs such as FASTER or TADS etc to setup the server
Can I run a multiplayer mission straight from the editor and have my friends connect to it too or no?
i think so, never tried that my self
Yeah, I'm just low key dreading having to rewrite a bunch of code to make it run correctly on multiplayer and testing it.
I use a lot of setVelocityTransformation for example for stuff like dynamic CAS and helicopter/osprey landings. And I'm not entirely sure how I'd have to rewrite that as server only on run on all clients.
https://community.bistudio.com/wiki/Multiplayer_Scripting
This page should have all the info you need
the wiki shows how each command must be used in multiplayer. the icons show if argument to the command is local/global and how the execution is like local/global
Oh I've read that before, I'm pretty familiar with game networking and stuff (I've made a couple web browser games with socks and all that + unity games)
But the dev cycle itself to do it fast and in a not annoying way cuz I'm assuming I'll have to rewrite a bunch of stuff
Nice
Well there isn't a better method than creating a dedicated server. It is a bit tedious but it's the only way to be sure that your stuff works
I'm trying to avoid tedious 😂 , I have thousands of lines of code.
I kinda recreated Dynamic Recon Ops but a bit different and map agnostic, and it's fun but I wanna play with my friend who is a retired Marine.
Well there is no way around it I'm afraid. If you only develop on a listen server then you might run into "works on my machine" because you'll be playing as the server while your friend will be a client.
Yeah that sucks, but it's ok, I'll look intot it tomorrow
The least tedious way I was taught is to test the mission in the editor (play as multi-player LAN) then alt tab and launch the game again and join on the hosted server. As long as you are testing on the client (the second launcher) you can trust the behavior you see.
you still have to make sure the server is working properly
Got it, thanks
hello, I have a question: how to change the spawning position of gbu ASL to be the position of an object, for example plane1? in this script [[4706.77,10185.1,500], "Bo_GBU12_LGB", tank, 100, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile; [5324.93,12317.9,0] are these first digits
[getPosASL plane1, "Bo_GBU12_LGB", tank, 100, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile;
Thank you very much
i have decided that i want to make a mod for use on my server, but i want to know if i can make it a servermod instead of a mod that all my players have to download. this mod may be subject to refinement for a while, and i dont want players to have to deal with it getting updated all the time.
i want to know if its possible to be a servermod, and not a client mod, becasuse im not adding any 3d assets, i want to use whats already available in the base game.
what i dont know will be fully possible is if i wanted to use the command menu in this mod, if it will be available on the clients side.
according to the documentation i have read, i havent seen anything stating that it must be a client addon,
but also i dont know if the defined class CfgCommunicationMenu will be properly defined on the client side.
for the actual menu, as required i would be adding the command menu options to the clients via remote execution and BIS_fnc_addCommMenuItem.
as far as the documentation for addCommMenuItem, i know the command expects the CfgCommunicationMenu class but i dont know how classes are applied, and i dont want to cause client crashes
In a server-only mod, you can do anything that can be done through pure scripting, because you can use remoteExec/publicVariable to send stuff, including functions, to clients for them to use.
You can't do anything that requires custom config on the client. You can use config stuff that already exists in the base game/mods the client has loaded, but any config in a server-only mod will only exist on the server.
one of the existing submenus available is "#USER:HC_Custom_0";
it doesnt appear to be populated at all and if i set a global array like so:
HC_Custom_0 =
[
["MenuName", false],
["Teleport", [2], "", -5, [["expression", "player setPos _pos;"]], "1", "1", "\A3\ui_f\data\IGUI\Cfg\Cursors\iconcursorsupport_ca.paa"],
["Kill Target", [3], "", -5, [["expression", "_target setDamage 1;"]], "1", "1", "\A3\ui_f\data\IGUI\Cfg\Cursors\iconcursorsupport_ca.paa"],
["Disabled", [4], "", -5, [["expression", ""]], "1", "0"]
];
and then i use showCommandingMenu "#USER:HC_Custom_0";
the commands assigned in the array appear to work.
would this technically be considerable to use the servermod to define the contents, make the command menu array variable public from the servermod, and then i should be able to use the commands on the client side without needing to have a client side mod?
Looks that way
It also looks like the #USER: prefix is what's important here and you can use any name that matches a global variable containing a correct array
i guess now my question is:
is there a way that i can add opening the HC_custom_0 menu to the supports menu
🤷
Solid maybe. I don't use the radio menu system very often.
how would i create a fire particle via script?
i currently have
"test_EmptyObjectForFireBig" createVehicle position firePos;
but it doesnt look vry good and doesnt have sounds
I did it like that
_fireeff = createVehicle ["test_EmptyObjectForFireBig",position _cheli,[], 0, "can_collide"];
_fireeff attachTo [_cheli, [-1, -3, -4] ];
_fireeff setDropInterval 0.1;
private _soundSource = createSoundSource ["Sound_Fire", getPosATL _cheli, [], 0];
can I destroy a hashmapObject from within itself?
is there any way to get the distance of the UAV turret laser mark controlled by a player?
private _uav = getConnectedUAV _player;
private _target = laserTarget _uav;
private _distance = _target distance _otherThing;```
(could be condensed into one or two lines, I just split it out into variables to show the working)
@still forum Can I ask for engine insight? How does UAV Terminal draws Follow waypoint lines? What position does it take as line destination?
No, it will be destroyed once the last reference to it is gone.
if you are inside it, then the script callstack has a reference to it
Is there some script command to set one of these waypoints?
Ah just waypoints probably
if the waypoint is on a "target", it uses last known AI position.
Otherwise just.. position.
And then it draws arrow from previous to next
Ooh, this answers why terminal draws the line to seemingly random spot
Btw there is zero info about follow waypoint on wiki 
Why I needed this, I'm drawing thicker lines over engine-drawn lines so they're move visible, maybe its a good idea to make the engine draw thicker lines in a first place
The arrow should draw to the waypointPosition 🤔
it should draw arrow from current position, to waypointPosition (I would expect waypointPosition command to do the same thing of using last ai known?)
are there actually multiple arrows? maybe I was looking at the wrong thing?
Thick arrow is script-drawn arrow to waypointPosition, thin arrow right of it is what engine draws and what I was asking about, the vehicle itself and return of waypointAttachedVehicle is shown in top left.
I haven't tried drawing scripted arrow to targetKnowledge yet
👁️
Could be easier to just do each frame checks
Since you only do it once for the client themselves performance impact each frame should be miniscule
I don't understand the very fact why a player loses his camera
Add lots of debug logs to see what happens
it seems to me that this is some kind of bug of the game
how do i attach a powerful flashlight to my gun
?
like
qq flashlight attaches a light cone to flashlight
CreateVehicle can create a light source which can be modified to mimic a flashlight and then attached to the user
ok
so i just spawn in a katiba in singleplaur
and then give it createvehicle code
and then some woodo black magic code i have a flashlight which lights up the entire map
@gloomy egret Check out this https://community.bistudio.com/wiki/Light_Source_Tutorial
Ok
Hello. Does anyone knows if "ArtilleryShellFired" MEH actually works? I'm getting this error if I add this EH on my mission: Error Foreign error: Unknown enum value: "ArtilleryShellFired"
(Is this only available in dev branch?)
v2.18
sure, but not ideal, I'm trying to add some "counter-artillery" stuff in my liberation
this EH is just perfect for that
Hi ! I have a question, can you interact with this marker via a script ? Like get it's position or set it ? The marker can be create with shift + left click
There's customWaypointPosition to get its position, and that's it. We don't have a setter for it.
Well it's enough, i don't really nead to move it often. Thank you for your help !
I am a bit confused how remoteexec works.
I am trying to make that a player takes place of another AI unit. Like Playable AI works where you just become them.
Is it smth like?
[selectPlayer AI_Variable;] remoteExec ["call",Player_variable];
Try [[], {selectPlayer AI_Variable;}] remoteExecCall ["call", Player_variable];
Oh it worked perfectly
AI_Variable remoteExec ["selectPlayer", Player_variable];
Tried that, didnt work. Or smth like that. What FireRunner wrote worked perfectly
So problem solved
Looks like the command isn't in CfgRemoteExecCommands, maybe you could add it in description.ext yourself
They have call in CfgRemoteExecCommands? :P
Wouldn't that make the whole thing pointless?
While Arma 3's main config may still have traces of it, CfgRemoteExecCommands is now obsolete. Originally used with BIS_fnc_MP, which is now also obsolete as well and is left for backward compatibility.
oh, I mixed up with CfgRemoteExec
Anybody knows how i can remove these text?
why doesn't execVM want to run in my trigger? . The old version of exec works but execVm does not
exec uses SQS syntax, execVM uses SQF.
Execute a script using (the deprecated but still available) SQS Syntax. SQF Syntax (and execVM) is the most recent scripting language.
https://community.bistudio.com/wiki/exec
yes, I know, dude. but no sqf works for me to activate the trigger :(. I enter "mysript.sqf" in the aon act in the [this] execVM trigger; and it doesn't work
and when I enter it in the units ini, it works
I enter "mysript.sqf" in the aon act in the [this] execVM trigger
w a t
That's not how execVM works, at all
Look at examples on the wiki, the right argument is the path to a script
ok thx
when I do without this i.e. execVM "myscript.sqf"; this doesn't work either :(,
and where is "myscript.sqf"?
mission folder
ok, I did it by simply entering [player] execVM "ammo.sqf" in the trigger; topic closed 🙂
I think it's coming from a mod you're using. It shouldn't show that in vanilla
question @still forum , what's the difference between unitBackpack and backpackContainer?
unitBackpack's older, right
I'm gonna guess that backpackContainer was added along with vestContainer and uniformContainer for consistency.
backpackContainer returns a container, "attached" to a backpack. unitBackpack returns the backpack itself.
A backpack and its container are the same object.
(unitBackpack player) isEqualTo (backpackContainer player); // true
Backpacks are objects, they do not need a separate container like uniforms and vests do.
Do they have the same class name?
They return the exact same object, they're the same class
A single object cannot be two different classes
Then it seems I got it wrong with uniforms and vests, they and their containers have different class names.
Yes, because uniforms and vests are weapons, and use separate container objects to actually store things.
typeOf uniformContainer player; // "Supply30" (for U_C_CBRN_Suit_01_Blue_F)
Then backpackContainer is a modern alias for unitBackpack.
backpack gives you the classname.
Another way would be making object a simple object
A common problem i see is people grabbing gear they arent supposed to on operations.
Has anyone come up with a script to lock an NPC's inventory on death?
Could just despawn them instantly but thats cringe
you either make an inventory opened event handler to immediately close it, or delete the inventory of the NPC
Oh that first one is smart
EDIT: Disregard - I forgot to define DEBUG_MODE_FULL
so some macros don't work in hashmapObject methods it seems:
Hemtt throws no flags. States everything processed correctly
["#create", {
params ["_checkpointManager", "_group", "_radius", "_maxDistance"];
_self set ["m_checkpointManager", _checkpointManager];
_self set ["m_assignedGroup", _group];
_self set ["m_radius", _radius];
_self set ["m_maxDistance", _maxDistance];
_self set ["m_activationRadius", _radius / 2];
LOG_1("%1:: New Object Created",str _self);
}],
after preprocessing:
["#create", {
params ["_checkpointManager", "_group", "_radius", "_maxDistance"];
_self set ["m_checkpointManager", _checkpointManager];
_self set ["m_assignedGroup", _group];
_self set ["m_radius", _radius];
_self set ["m_maxDistance", _maxDistance];
_self set ["m_activationRadius", _radius / 2];
;
}],
sqfc or not?
not sure, but would assume when hemtt packs, its converted to sqfc. the second is what is returned when when you reference the object array from ADT debug. when creating the object from the array, I get no messages in the log file either. Tested with some system chats after, which go through successfully.
looks like it does it futher down too: (raw copy from ADT debug)
Not sure if that's representative of what's running.
I would guess that with sqfc, it stores a link to the original code and that's what's displayed there.
It's not translating the bytecode back again.
it appears that QGVAR(Checkpoint) is doing it correctly, if you look at the #str portion near the beginning showing landnav_common_Checkpoint
Although I guess it runs the preprocessor first, stores the result and then converts it to bytecode...
If it's sqfc then it's a different preprocessor than what Arma is using anyway, so it matters.
What is a convenient/high performance way to detect if any AI group detects the player (group)?
GVAR series looks like it works fine, LOG is the one that is failing. Using dev and build so its not sqfc atm. Just building sqf files.
findIf + whatever you are checking
So I would use findIf to search through an array of all AI groups, to see if they are in combat with the player?
sure. and the search stops the moment its true. so if group 3 of 10000 meets it, it stops there and doesn't search through the other 9997
I suppose if I pack this into a trigger (loop every 5 seconds) this should be minimal impact on the server. Thank you.
This script works great:
groups blufor findIf { combatBehaviour _x == "COMBAT" } != -1 ;
Once. Even if the trigger is set to "repeatable". What am I missing of the FindIf behavior?
Only the alternative syntax was changed, not the normal one
local _a = 1; is now private _a = 1
In testing it seems, once TRUE, always true. Even if the groups are set to "delete when empty". Any way around this?
with some more findIfs!
instead of using the full group set, use select and filter out the groups that have no alive units (using findIf as well)
then do your final findIf based on that set
untested example theory:
private _groupsWithAliveUnits = groups blufor select {
private _group = _x;
units _group findIf {alive _x} != -1
};
_groupsWithAliveUnits findIf { combatBehaviour _x == "COMBAT" } != -1;
Arigato!
isnt it supposed to be "west" not "blufor"?
they are synonyms
I tried blufor in the past and it never worked
very weird.
blufor has always worked for me.
west/blufor, east/opfor, resistance/independent
all since Arma 3, never failed since
(perhaps you were writing bluefor? IDK)
Dont think so.
i got no idea why it didnt work. Could be the context i was coding it in.
[west, -1] call BIS_fnc_respawnTickets;
Group event handlers
unitBackpack pulls it out of the units weapons state. backpackContainer pulls it out of the units inventory state.
and… results are identical, correct?
Would take too much time to analyze the code to find that out. Certainly seems to be the case
thanks, that lifts a heavy weight from the doubt I had 😄
based on the code it seems that backpackContainer works on vehicles too but I'm not sure if unitBackpack will
Ok no it doesn't.
No I mean the code did something like primaryGunner stuff
So I figured it fetches the gunner and returns his backpack
got a real weird error here. cant see what im doing wrong
_controlTurret addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
{
_x fireAtTarget [objNull, currentWeapon _x];
} forEach (_thisArgs select 0);
},_turretArray];
error, 3 elements provided. 2 expected
values based on diag_log -
_controlTurret = port_3
_turretArray = [port_1,port_2,port_4];
addEventHandler doesn't support arguments
ah bugger
i guess i just tag the "control turret" with the array and retrieve it on the EH?
as unit can be accessed
tag it? You mean setVariable?
ye
Yes
is there any way to add a progress bar in a hint?
through hintSilent and formatted text yes
I have it, but I can only get it to work with #, is there any way to get a character like this to appear: █? Because it comes out as spaces
Use image tag
I created weapon using model as simple object but it has muzzle flash, how do I get rid of that?
You cant, its apart of the model as a proxy. And creating a simple object loads all proxies
no hide selection thing possible?
try "zasleh" perhaps
that worked! thx man 🙂
have to ask is this really the current only way to get weapon current magazine ammo count ? ```sqf
_cmd = currentMagazineDetail player;
_ammoInfo = _cmd splitString "([ ]/:)";
playerAmmoCount = parseNumber (_ammoInfo # 5);
sorry gencoder, I made an assumption you were creating a supersimple object, thats my bad
no worries. There's super-simple objects? 
wait.. you said "model".. are you using the p3d path for the simple object or the classname?
this: createSimpleObject [_model,[0,0,0]];
hm... that is a supersimple object then... I understood the wiki to imply that that sort of thing wasnt possible with them. I guess I need to do some more testing. This is the wiki btw which explains them https://community.bistudio.com/wiki/Arma_3:_Simple_Objects
I guess hideSelection, is only for simple objects https://community.bistudio.com/wiki/hideSelection
weaponState
I am still confused how to attach an object midway though the role somewhere
nice thx!
I've never used ropes myself but try:
_segs = ropeSegments _rope;
_mid = _segs#floor((count _segs-1) / 2);
_obj attachTo [_mid, [0,0,0]]
It's kinda naive tho. But still let's see if that works at all
Variations of calling those segment variables, I dunno, a lot of things
Alright let me try
Okay, so it just teleports to probably correct part of the rope.....maybe. And stays there in the air. If rope moves, the objects doesnt follow
I might do a work around and use multiple ropes, maybe
But for some reason objects seem to get unattached from the rope at speed. I wonder if its possible to change that
I guess rope segments don't support attaching then
You'll have to move the object every frame
has anybody tried to subscribe to BIS_fnc_kbTellLocal_played by BIS_fnc_addScriptedEventHandler? is kbTell in general called when radio commands are issued?
which radio commands? its probably only going to fire when the kb functions fire, not the engine commands
_npcPos = getPos transportNPC;
_offset = [10, 0 , 0];
_vehicleLocation = _npcPos vectorAdd _offset;
_truckType = "B_Truck_01_f";
_truck = createVehicle [_truckType, _vehicleLocation, [], 0, "NONE"];
I tried to create this vehicle on trigger of a addaction, the hint properly displays however the vehicle does not.
Used vector addition to offset spawn location so that isn't the issue.
Anyone have any idea?
Have you checked that transportNPC is a valid object in context and that B_Truck_01_f is a valid vehicle classname?
hey if i wanted to do a whole bunch of "fired" event handlers, would it be better to do
A: a single event handler with conditional statements (IF)
B: a single event handler with switch statements to handle the different categories for the code of each event i want to control
C: seperate switch statments for each possibility
i have a lot that i want to do that is unfortunatly only picked up on by the fired event handler such as grenade throwing, specialized secondary weapon handling, or even mine placements, so i want to find a suitable means of having a way to handle all that jazz.
or should i use a function since they coud be called multiple times in the span of a mission
Its fine. For what I am doing apparently using multi ropes isnt bad.
But now other issue: rope snaps.
As in i had am object attached to helo via rope. Once hwlo picked up speed about a minute later cargo geta detached from rope
if you want the ability to remove specific ones later, I would do them in individual handlers
It was the vehicle classname, thank you.
The only way to know for sure is to profile/benchmark it, especially when you're optimizing at this level.
But... here's my general rules of thumb:
- If it's only a couple if/else/ifs, just keep the if else ifs, and order the execution from fastest to slowest with short circuiting.
- If it's more than that, consider how you can use a hashmap's O(1) get for faster operation.
A switch is simply an if/else/if put in a pretty way that can be understood easily, and my understanding is arma doesn't actually do a lot of heavy optimization other languages (like how Java/C++ use jump tables, but I might be wrong here). If your case is at the bottom, it's going to run all the conditions from the top of the switch statement til your actual case, so it's got the same considerations as if/else/if. In actual use, it might be slower than if.
tldr: profile, profile, profile.
The general rule of thumb with SQF is the less scripting commands you have the better (with exception of heavy commands of course)
But in general I'd recommend prioritizing code maintainability and coherency rather than saving on peanuts of performance
Though depends on what you'll have in the event code too, of course
Having function code right inside event handler or declaring it elsewhere and then calling it should make no difference
There used to be some quirk with mission event handlers compiling each time but I think this was fixed ages ago
hashmaps?
Here is an example of how a hashmap helps. Imagine you're checking Fired event for mines. If the player places down a type of mine, I want to kill them instantly. And imagine we have 10 or so types of mine. Here's the most obvious way you do it with if/else/if.
if (_ammo == "MineClass1") then {
player setDamage 1;
} else {
if (_ammo == "MineClass2") then {
player setDamage 1;
} else {
//...
};
};
You can improve that readability with:
if (_ammo == "MineClass1") exitWith { player setDamage 1; };
if (_ammo == "MineClass2") exitWith { player setDamage 1; };
//...
if (_ammo == "MineClass10") exitWith { player setDamage 1; };
But those two are functionally the same. You can write it in a switch similarly, and it'll perform roughly the same. For something that's not a mine, you need to go through every check. That's unavoidable with that approach.
With hashmaps, you can optimize it to a single check.
// (consider putting this in a global var, not construct it every fired event)
private _myMineClasses = createHashMapFromArray [
["MineClass1", true],
["MineClass2", true],
//...
["MineClass10", true]
];
// on fired
if (_ammo in _myMineClasses) then {
player setDamage 1;
};
As hashmap operations are O(1), this kind of check is likely much faster than using your if else statements or checking against arrays. And obviously, the more checks you need to do, the more this second approach will pay off. The fewer checks, the less likely it is to significantly outperform (or at all) the first.
As an example, I use this for an APS type script, and when I have like 30+ different kinds of projectiles to check against, it is much, much faster with this approach.
But also, as @meager granite said, prioritize code readability. The efficiency of your script literally does not matter until you hit some barrier (I think it's almost a millisecond?).
got it so use hashmap to do something like
myhashmap = createhashmapfromarray [
["muzzlename" , {code}],
["othermuzzlename", {code}]
];
and in the eventhandler i could use
myhashmap get "muzzlename";
``` to run the code?
Hm...
If you only have 2 or 3 muzzles, I wouldn't do it like that, I would do it with an if/else for simple readability. You're not saving much performance (if at all) with a hashmap there.
But say you have more muzzles (way more), that may be one way to do it. Putting Code types in a hashmap data structure like that awakens something ugly in me but I don't see why that wouldn't work?
I mean, missionNamespace can effectively be considered a hashmap as well. And if code can be stored in missionNamespace - what's wrong with storing it elsewhere? 😛
according to the structure calling from a hashmap WANTS;
mymap call ["myMethod", [arg1,arg2,arg3]]
[arg1,arg2,arg3]
should be accessible with params which i would have already done if each had a individual event handler
As I will keep repeating, you can't optimize code at this level without profiling and benchmarking. First make things work, find out how long that takes in a loop, then make things work with an "optimized version", measure how long that takes.
well im currently looking at a special handler for all the mines and remote explosives, 76 rifles, 4 launchers, 6 handgun weapons, and 1 grenade. i gotta go to bed but i will follow up tomorrow on how to run diagnostics
Hashmaps are indeed faster switch
call (myhashmap getOrDefaultCall [hashValue [...properties...], {
switch(true) do {
case complex_condition1: {{...code1...}};
case complex_condition2: {{...code2...}};
default {nil};
};
}, true]);
properties should be values that you're checking inside complex conditions
but this is really useful if you have vastly different code for vastly different conditions
For readability sake it might be better to do class check in a runtime instead, the performance impact will be a drop in an ocean for your case
Or checking for if single string is present in big array/set of strings
What counts as "big" needs further testing
Better wording: i don't know what counts as big in this context without further testing
Yeah, hashmaps are also faster for that too for larger arrays
If properties are key-able, hashValue is unnecessary
I had a suspicion that for these types of commands different system is used, but does it have any entry points?
Anyone good with AI scripts? I could use some help
I think I know the answer to this ,but will attachto work on cfgAmmo entries? from my tests it doesnt just wanted to confirm
As in spawning etc.
What are you getting stuck on?
Trying to attach to ammo that is created? Like when shooting? To spawned missile?
Or what you are trying to achieve?
Well... What do you reckon an ai script would NEED ?
Also
I don't know if this is correctly made
Gimme a sec, i'll put it on github
spawn ai, give them waypoints, cache them, delete dead bodies
From what I see in the code it should support attaching
Yeah even when I test in game it works
You can't attach an ammo to something tho if that's what you mean
Is "KnowsAboutChanged" used to show units that have been spotted on the players map that fade over time?
hi guys, its posible to change the displayed name of a player ?
it seems that this handler doesn't work how it's supposed to. When unit icons fully fade away from the map, knowsAbout value changes from 4 to 0 (as stated in the wiki), however - we don't get a handler call for it, which is weird
I see! That is odd, I'll have to do some testing. Thanks for confirming!
Do you know if the "Fired" event is supposed to work with AI?
Doesn't seem to be triggering for some reason
But it does for my player
And every 3 seconds it runs the loop, which calls functions for all the groups
I just realised that it might be bad
That is for hash map objects, a special kind of hashmap.
For non-objects it would just be
call (myhashmap get "muzzlename");
because the get returns a piece of code, that must be called to be executed.
I also see what you noticed but found the workaround through CBA -
["CAManBase", "fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_projectile"];
// your code here
}] call CBA_fnc_addClassEventHandler;
It does
But you probably want FiredMan if the AI is in a vehicle
No (if you mean the green name when you hover over them, e.g. "AT soldier")
I mean the “name” of the unit, like “flyingtarta”
Is this the wrong way of going about this? I feel like I fucked it up
Sometimes ppl uses other profile, and I’ll like to change the name to an already defined one
Hello. Does anyone knows if there is a particular config path do get HE or Smoke shell from a magazines array?
every element is a cfgAmmo iirc, so you can search in the config of the ammo if smoke or he
Yes, I've managed to get only artillery shells (artilleryLock = 1) and from that get LG shells (laserLock = 1), but I can't find a specific parameter to id HE / Flare / Smoke
I wonder thats why the antistasi scripts had to grab every possible magazine class for every possible artillery into a script
maybe class parent?
Check its simulation type or the simulation type of its submunition. Flares and smokes have their own types because of how they work.
Ok, the LG shell has a specific type of submunitionAmmo.
If modded, the smoke shell has differents types of submunition, but the simulation of them is the same "shotSmoke"
I think I can work on that, thank you
You could not call for every group every 3 seconds
But only a subset
So 1-6 once, then 7-12, like that
holy shit my eyes
100 groups is quite a lot though
you spawn a PFH and try to halt it..........
How do I halt it?
oh wait that's before the PFH
Lol alganthe
In the end 100 groups is quite a lot
Its why system like ALiVE offload to .dll
It means calling at least 100 functions in a single frame
144 seemed to be the group limit for a side
It is, but not always the practical limit
Btw, does PFH just run as in a call loop?
Does anyone know is there a way to prevent rope from breaking? I though maybe there are different rope types. (Because rope type can be defined in createrope script), but apparently there is only one
Its unscheduled
thus it's unscheduled and can't be halted even if you spawn the code.
I count ~6 functions in the EH
(not inside it ofc)
So with 100 groups thats 600fncs in a single frame
You need to delimit that to gain fps
no biggie.
unscheduled should be faster, correct?
Not nevessarily
How do you delimit?
Running this kind of code unscheduled would be unwise
Itd end up not executing after a while
oh.....
I see that engine commands go through RadioProtocol which sadly doesn't seem to have any events (accessibly by scripting that is)
I see
eeerm, no it'll keep executing
I suggest selecting only a few groups to run functions on
Unscheudled will clogg up the engine, as in scheduled only gets 3ms, keeping the engine running?
scheduled runs for 3ms for each script and then goes on the next
and in this case it's not possible to run scheduled unless you spawn / execVM inside the PFH, which wouldn't be advised
allowDamage
Uhh, does.....does that work on ropes? Okay....I will try. Didnt think of it, cuz I dont think ropes take "actual damage". According to (https://community.bistudio.com/wiki/Arma_3:_Ropes), they run a script to determine when to snap it. But I will try
They do, they die from explosions for example
Huh, okay I will try. Didnt know they get destroyed by explosions either
if your script doesn't eval fast enough the condition / variables can change before it start to run again
I can switch the PFH to a while loop, I guess...
Also I have the heavier functions running only on active groups, and only running cache script for the cached groups
you could keep that but increase the time between the PFH ticks
I used to have it on 1 second
RIP frames
It executes it all in a single frame still with a PFEH?
Doesnt matter what frame you pick
doesn't matter if you're still processing the previous tick
Better only evaluate a subset of groups every time
10s or 30s might be better.
Handle it in batches of 10
or yeah.
Is there a way to check how long this script takes to run?
ohh nvm... I can diag_log the tick
perf check in debug
How that?
Stupid question, I just pasta all the code in there?
use the button on debug or call this
what im tryna do is when a mine is placed to use createSoundSource to have a sound continuously play afters its been activated and then ofc delete when it explodes
Okay I will try again, perhaps I missed something
Maybe sounds don't support attaching
Man, I never learned to debug...
I had the empty debug console
and clicked the debug button
They do, I attach them to vehicles when doing sound effects since otherwise they would only be heard for a moment if moving quickly (i.e. planes and helis)
😄
that + watch fields and diag_log = never miss an error
also note that PFHs don't return errors, if you have an error in it the PFH won't run but won't error out
very important to know when working with them.
What?
I literally spent hours trying to figure out the PFH, because it wouldn't work....
😄
that's why you should diag_log them if they don't work
it's easier to spot the errors that way, checking if your args are passed properly / incorrect expression
Well.. thanks a lot for that tip 😄
Nop didnt work. At increased speed cargo (people) just get unattached
Try on all segments?
scalar NaN ms
Hmm no I didnt, just on entire rope
I will try segments. But I doubt it will work, because the reason it breaks is "scripted", and not related to rope health
"Rope Type
A rope stretches and breaks following the formula:"
if (currentLength > maxRopeStretchLength) { /* breaks */ };
also PFHs should be self terminating, unless it's a very specific case.
So, using PFH for this loop is wrong. Which loop should be used instead?
no it's fine in this case
Ahh, I guess it's not as bad as I thought at first
Okay will try again then maybe skill issue since it was ahhhh 4am 
[QGVAR(say3d), {
params ["_object", "_sound", ["_distance", -1], ["_type", 0]];
if (_sound == "" or {player distance _object > _distance}) exitWith {};
private _source = _object say3D [_sound, _distance, 1, _type];
// if object not a unit, attach sound to object itself
// Primarily meant for vehicles in motion
if !(_object isKindOf "CAManBase") then {
_source attachTo [_object];
};
}] call CBA_fnc_addEventHandler;
PFEH is in a way like while {true} do { uiSleep 3; call my_fnc}; and alganthe is going to hate me for saying it this way.
Simulation wise createSoundSource and say3D sounds are different
I think both of them can get attached. But the sound from createSoundSource doesn't update with its position
@edgy dune try moving it manually using setPosWorld too
I'm guessing this is the issue
I vaguely remember doing it with createSoundSource too
It's not that, at all
it's not even close
and while {true} do loops are bad, just plain bad
why are those bad?
unending loops
while {variable} do {} ?
better.
So, I have a recon mission I'm building that includes using binoculars to see if there are units in a town. Now this is easy if there's actually units in the town, detecting them alone does the trick.
However, how would one go about looking at an area and checking detect that there are no enemy units there? 🤔
invisible units???
idk turn model off and maybe make them careless
Finally! Now it will be possible to throw bodies a dozen meters away from the explosion\other Hits and not return them to a living state!
2.18 will be one of the best updates with a lot of features. Especially the presence of a number of command improvements for throwing grenades and some eventhandlers.
There are no more cans that are created locally in the game that beat the player at high speed so that he himself would fall.
@little raptor @digital osprey Yeah, I was definitely not getting any fired events for AI during a firefight, although my player was triggering the event. I will explore what you've shared there @digital osprey thank you. @little raptor , do you have insight into why that could be?
Is it because the actual player isn't nearby so it's not firing the event?
I assume this is what determines showing the enemy groups icon in high command as well?
It would help if I could read
I cannot for the life of me find a good example or tutorial on how to limit what object classes can be placed in zues ie: zues can only place B_Story_SF_Captain_F (Miller)
addCuratorAddons to add mods
CuratorObjectRegistered event to add classes
ah thanks!
See this page for more info
https://community.bistudio.com/wiki/Arma_3:_Curator
i took a look but I couldn't figure it out lol
But that implies you still have to detect something
How are you checking for units currently?
You could use something like a trigger in the area
I just check that player reveals units, so if there are enemy units in said area, and the user reveals any of them, then the area has been recon'd.
But I also want to make sure that the player can check if the area is empty, but how can you tell if an area is empty by looking at it?
What I had thought about was something like, when user pulls out the binoculars and look at a point of interest, automatically check that the map coordinates at crosshairs are within the area for x amount of time. Which is very doable and probably the best alternative, but wondering if you guys have better ideas.
I'm not asking for a solution, more like, do you guys have any recommendations or better ideas to do this?
I hate to be the dum dum but I cannot figure out how to use CuratorObjectRegistered even with the examples given XD
This is a thing, but you'd need to describe the case a lot better.
The only machine where Fired events trigger everywhere is the server.
Curator events need to be added locally to players, not to the curator object.
I'm not sure if it's a hard rule that curator objects only function when server-local, but that's usually where they end up anyway.
Huh, can I get an example using a random class? Might me a language lesson
I dunno, CuratorObjectRegistered seems to be sub-minimally documented.
Ah, it's in here:
https://community.bistudio.com/wiki/Arma_3:_Curator#Manual_Assigning
Apparently it just dumps every CfgVehicles class (surely scope-limited?) into the input array.
so that's gonna be a very slow EH.
Hmm, this doesn't seem to be the case when attaching fired events on a player hosted server rather than dedicated server. Unless there is a way to force the adding of that event in the server context?
gonna sanity check that.
I have this on mission init
if (isServer && missionName != "introExp") then {
diag_log text "attach fired event";
// Adding a "Fired" event handler
_unit addEventHandler ["FiredMan", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
_unitID = str _unit; // Unique ID of the unit
_message = format ["eventFired %1", _unitID];
"a3wc" callExtension _message; // Send to C# extension
}];
};
};
this is a merged snippet, but there is a function:
private _attachEventHandlers = {
params ["_unit"];
diag_log text "attach fired event";
// Adding a "Fired" event handler
_unit addEventHandler ["FiredMan", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"];
_unitID = str _unit; // Unique ID of the unit
_message = format ["eventFired %1", _unitID];
"a3wc" callExtension _message; // Send to C# extension
}];
};
and then in that "isServer" block I have
addMissionEventHandler ["EntityCreated", {
params ["_entity"];
if (isNull _entity || !(_entity isKindOf "Man")) exitWith {};
[_entity] call _attachEventHandlers;
}];
Fires for my player entity but not any AI that have moved off screen
Fired EH works fine at 6km with localhost here, both SP and MP.
I am very confused then
oh, you have a scope issue there.
_attachEventHandlers doesn't exist within the EH scope.
you'd need to declare it as a global or pass it into the addMissionEventHandler args.
🤦♂️
It doesn't throw any error because unscheduled :/
(dedmen plz throw undefined var errors in -debug)
Thank you for catching John, I will amend and do some testing after work
That would explain a lot
And I do have an initial allUnits loop which would be assigning it to the player that already exists in the server context which has access to the function
which explains why player and not AI
execute by holder box
{
_box disableCollisionWith _x;
[_box,_x] remoteExeccall ["disableCollisionWith",_x];
} forEach allPlayers;
It is interesting that someday developers will finish synchronization on the network for all users to disable collisions. Otherwise, it turns out that I will have to send each client something that each client does not have a collision.
What see other me 2 and other me 3

by disabling the collision, I want to remove the moment when a player at speed crashes an attached box into another player and he falls off his feet. (often dies from it)
The standard approach to this is to reduce the mass of the box to a tiny amount.
However, setMass has slow propagation so you need to remoteExec it, even though it's a local-argument command.
Hmm. Maybe this is the way out of the situation.
Now it happened that the weight of the box remained 0.01 and there are no ways to find out what the weight was originally. Other than waiting for 2.18

For some reason, the 'remoteexeccall' call does not work in mode 0 for clients.
But it only works when the server executes code to all clients in mode 0...
For client ->
But if you make a call from the console, then setmass is immediately applied. But it is not executed from the function code which is in addaction.
For some reason, the 'remoteexeccall' call does not work in mode 0 for clients.
Probably a CfgRemoteExec file.
i no have this file (class) in mission
remoteExec 0 is normally valid from clients.
If you need to reset the mass at the end then just store it on the object with a setVariable.
saving in a variable does not cancel the fact that the mass was not applied. And because it was not applied, it cannot even return back. I already simulated that the mass was applied when I took the box. And when I let go, the mass did not return to 500. (For example, for a large box. Or 200 for a small one)
shrugs
I'm not browsing through a dozen pngs to find out which one has anything relevant in it.
Check out the ACE carrying code. It works and it's relatively readable for ACE.
Yes. I agree. It's a very difficult topic when something that should work... DOESN'T WORK. (((
By the way, this is the second time I've encountered the fact that remoteexeccall does not execute command in mode 0. But I can't remember with which command.
Are you using ace / fine with an ace dependency?
ACE Dragging just uses setMass and CBA events to broadcast it
https://github.com/acemod/ACE3/blob/73ed46d36b5e5c1fc93cfd3e6fced9c5d8838017/addons/dragging/functions/fnc_startDragLocal.sqf#L110-L113
sighs
Just use CBA events
It's the same shit.
To test if it's a remote exec exclusive issue
We do the same thing with remoteExecCall. It works.
Okay cool, but they're having an issue. So test something else to see if it's some issue with remoteExecCall or something else.
game with no mods 
If remoteExec doesn't work then you have bigger problems anyway.
more likely the code isn't getting that far because there was a silent error earlier.
I tested the code and remoteeexec is executed only sometimes. I even repeat the code call 3 times and it is not always executed (but sometimes it is executed with a delay when it should have returned the mass back. That is, instead of inserting 20 it inserts 0.01 which should have been issued a long time ago). There is clearly a problem with owner.
but sometimes it is executed with a delay when it should have returned the mass back
uh, it's always executed with a delay. It doesn't return anything useful.
no executed ...
_mass = getMass _box;
[_box,0.01] remoteExec ["setMass",0];
[_box,0.01] remoteExec ["setMass",0];
[_box,0.01] remoteExec ["setMass",0];
server pickup box
All work...
Why are you changing the locality of the box?
Ok but i simulate setmass by console. work..
I did this both before and after changing the locality. First I did it after changing the locality and now before.
Paste the simplest, complete and most plausibly correct version of your code that doesn't work.
Because all I'm seeing is partials and random garbage tacked on.
client drop box and mass not return in 20.
All my code is scattered across different files to create functions, so I can't combine everything into one.
My game crashed when I entered the editor.... Excellent, I spent 23 hours in arma without closing it.
Still cannot phigure out how to limit zues dang poop
You can try doing a waitUntil knowsAbout==0 (not actual syntax)
https://community.bistudio.com/wiki/setPhysicsCollisionFlag
You can completely disable physx of these boxes, they'll collide with nothing.
I need this right now. 
only a few more weeks
For 2.18 publish?
And when you hide the bushes, is it possible to somehow remove the sound of rustling leaves besides killing the bush itself?
I think many who make their bases on an open field would really like a separate command that completely disables the existence of map objects, especially sounds (rain on roofs, rustling bushes). The game engine in dynamic terraforming can now work, but can't it handle this?
Why are you using the PFH for that at all?
hello I would like some help with a script I'm making. it's to teleport vehicles in a mission. I want them to teleport on an oil stain named "p1". I want vehicles of the the ypes Car, Tank, WheeledAPC, TrackedAPC to use the teleporter only.
what is the trigger for teleporting them?
an area trigger
so they drive near the point (which will be marked with a cone or helipad)
private _veh = vehicle (_this select 1);
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
}]; ```
here's my code so far
OnActivation?
yes
I just need the check system
for the kind of vehicle (APC, Tank, TrackedAPC, WheeledAPC,Car)
driver vehicle player addAction [<t color='#FF0000'>"Teleport Vehicle</t>", {
private _veh = vehicle (_this select 1);
if ((typeOf _veh) in ["APC", "Tank", "TrackedAPC", "WheeledAPC","Car"]) then {
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
};
}];
something like this?
yea
1 sec
let me try but I'll put it so the check happens before the whole thing
I had a mistake there
@polar belfry now I think it's good
also now thinking of it - IF should be outside of addAction call, because now you would always have the option but it would work only if vehicle is of the right type
it doesn't teleport
maybe there's an issue with the check
could try a long iskindof
because with other solutions he would have single digit framerate or frames per second
is this correct
condition
private_veh = vehicle player;
this && (_veh isKindOf "APC" || _veh isKindOf "Tank" || _veh isKindOf "TrackedAPC" || _veh isKindOf "WheeledAPC" || _veh isKindOf "Car")
On activation
private _veh = vehicle (_this select 1);
driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
}];
this is present, anyplayer on condition
the problem with TypeOf was that it returned the actual class
and those are base classes
oh
And after testing there also should be a deactivation code for removing the action.
I assume you make some sort of "Get into the garage" action
yes
Keep in mind this is the CBA PFEH, where you can set it to sleep between intervals. So it's not running every frame.
Yes, scroll down trigger settings.
which one of the two? countdown or timeout
Depends on your needs. Read tooltips.
guess and check😆 (sry)
I want it so if someone gets through the teleported the other person cannot instantly run the command too and arma the other one
I'll do some testing
I think those trigger timeouts won't help you because you should try to put a some sort of coordinated cooldown on the action itself
I have a tricky idea but not shure it's a clean one
I found settrigerinterval
condition
his && (vehicle player isKindOf "APC" || vehicle player isKindOf "Tank" || vehicle player isKindOf "TrackedAPC" || vehicle player isKindOf "WheeledAPC" || vehicle player isKindOf "Car")
On Activation
thisTrigger setTriggerInterval 10;
driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
private _veh = vehicle (_this select 1);
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
}];
On Deactivation
driver vehicle player removeAction 0;```
again, this is not a trigger problem
what if 2 players are already in the zone and all trigger cooldowns applied
to both of them
both of them get their actions and can perform them at once
Also the ID of added action can be greater than 0.
that can be solved with get/setVariable
there might be a case that 2 vehicles shouldn't be allowed to teleport into the same spot at all
so my deactivation code doesn't work
I found out it becomes whatever the player has +1
so I wrote this
driver vehicle player removeAction _actions+1;```
but it doesn't work still
Save action ID in the trigger.
Activation:
uiNamespace setVariable["actionIdIndex", driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
params ["_target", "_caller", "_actionId", "_arguments"];
_veh = vehicle _caller;
_teleportPoint = p2;
_veh setPos getPos _teleportPoint;
}]];
Deactiovation:
driver vehicle player removeAction (uiNamespace getVariable "actionIdIndex")
thisTrigger setVariable ["actionIdIndex", _actionId];
I think it's something that should be relative to a player or even player's UI
becasue otherwise it might bug out in MP
trigger on deactivation might clean up other's player action
If you do everything right, everything will work.
ok from what I read triggers are local so it should work as well
so in removeaction I put _actionid after this?
you put thisTrigger getVariable ["actionIdIndex"]
driver vehicle player removeAction (thisTrigger getVariable ["actionIdIndex"])?
Looks right
the command is still there
And new activation code?
thisTrigger setTriggerInterval 10;
driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
private _veh = vehicle (_this select 1);
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
}]; ```
Look at this example
driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
params ["_target", "_caller", "_actionId", "_arguments"];
private _veh = vehicle _caller;
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
}];```
I may need help changing params
You just need to put _actionId = driver vehicle player addAction...
And then setVariable
The rest of the code worked fine on my test
thisTrigger setTriggerInterval 10;
_actionId = driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
params ["_target", "_caller", "_actionId", "_arguments"];
private _veh = vehicle _caller;
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
}];```
?
dude no
you firstly assign and then use the var
thisTrigger setTriggerInterval 10;
_actionId = driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
params ["_target", "_caller", "_actionId", "_arguments"];
private _veh = vehicle _caller;
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
}];
thisTrigger setVariable ["actionIdIndex", _actionId];
I see
now I get it
found something that made it work
_actionId = driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
params ["_target", "_caller", "_actionId", "_arguments"];
private _veh = vehicle _caller;
private _teleportPoint = p1;
_veh setPos getPos _teleportPoint;
driver vehicle player removeAction _actionID
}];```
it removes the action
Don't use setPos/getPos
Use setPosWorld/getPosWorld
that's so it can also take height in account
?
will this work lets say with the vanilla carrier
if I want to bring apcs up?
Yes. But there's more
Read the biki pages on setPos and getPos
is there a way to make it work with vehicles that are cargo of othervehicles
eg an apc in a bigger boat or zubr
eg this
cause with the current one they stay in
just as a thought experiment
normal teleport works
If the cargo vehicle supports ViV, I have a script for this
it does
I used this script in a operation to let players load vehicles into a LCU
don't forget to change the class of the cargo vehicle, I was using a LCU from CUP
I want to unload them
just need to find how to tell the vehicle to unload on the oil stain (reference point)
Well, I have a WIP script for that in the end of that same script, it's under comments
thanks
from my last test, it's working
trg1 is the point they will go?
yes
it's the same point that you can load stuff
actually, this IS an EH, so put this code on the cargo vehicle
when you unload using the action, the cargo children will be teleported to the a safe area in the trg1
ok
_cargo = _this select 1;
private _teleportPoint = p1;
_cargo setPos (getPos _teleportPoint);
];```
I used the event handler
now the question is how do I add it to the trigger so it happens only in the area of the script (teleportation to p1 not just unloading)
you can check If your vehicle is inArea your trigger.
_x addEventHandler['CargoUnloaded',{if (_this#0 inArea T1) then {_cargo = _this select 1; private _teleportPoint = p1; _cargo setPos (getPos _teleportPoint);}}]
T1 is the trigger
this addEventHandler ["CargoUnloaded", {
params ["_parentVehicle", "_cargoVehicle"];
if (_parentVehicle inArea T1) then {
_cargoVehicle setPosATL getPosATL p1;
};
}];
any way to make sideRadio messages louder
theyre too quiet no matter what db i set them to
lol it's in my code already, under comments
this addEventHandler ["CargoUnloaded", {
_lcu = _this select 1;
if (!(_lcu inArea trg2)) exitWith {hint "You must be in the right area to unload"};
// Check for vehicles on the unload target area
_veh = (vehicles select {
_x inArea trg1
});
if ({
_x isKindOf "landVehicle"
} count _veh > 0) exitWith {
hint "There is a vehicle in the area"
};
_cargo = _this select 1;
_pos = [trg1, 0, 10, 1] call BIS_fnc_findSafePos;
_cargo setPos _pos;
}];```
thisTrigger setTriggerInterval 5;
_actionId = driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
params ["_target", "_caller", "_actionId", "_arguments"];
private _veh = vehicle _caller;
private _loadingcheck = isVehicleCargo _veh;
private _teleportPoint = p1;
if ( _veh isKindOf "Landvehicle" && isnull _loadingcheck) then{
private _dist =(_teleportPoint select 2) + 5;
_teleportPoint = getPos this vectorAdd [0,0,-_dist];
_veh setPosATL getPosATL _teleportPoint;}
else{
this addEventHandler ["CargoUnloaded", {
params ["_parentVehicle", "_cargoVehicle"];
if (_parentVehicle inArea T1) then {
_cargoVehicle setPosATL getPosATL p1;
};
}];
};
driver vehicle player removeAction _actionID
}];```
I'm trying to put it in a trigger and when I tried it the apcs disappeared
I tried yours and they weren't near the ship
probably on the shore
why not just use setVehicleCargo?
if the lcu supports ViV you should use setVehicleCargo instead of those setPos thing
would set vehicle cargo work if the vehicle calling the command was the apc in the lcu through the add action
make sure you have the vehicles inside the trg1, and the lcu inside trg2, also, check the cargo parent class and it should work
attach the addAction in some object with a good radius, there is a way to create the addaction when you are inside a trigger and delete it when you are outside of it (by putting addAction code in the trigger itself)
at least, my script gets any vehicles inside the trg1 and put in the LCU that must be in the trg2
I see
in my operation, i've attached the addAction in a terrain object, like a Crane
oh for my the addaction is given to the apc/ vehicle driver
I see, what happens when you try?
you said that the apc just dissappers, but, it "loads" in the lcu?
I tried only the unloading part with the safe unload
also found out I had a different variable name for my trigger so probably they got thrown to 0 0 0
yes
check those variables
it should work normally as you intend
What's wrong with these triggers? 5 pieces of arty label arty1 - arty5 refuse to fire on their respective markers even though all the conditions are met
are they in range
yeah, that was my first thaught. They are smack dab in the middle of the medium range distance bracket
Well, one thing is that trigger activation code is an Unscheduled context, so you can't use sleep like that. You'd need to use spawn to create a Scheduled thread where suspension is allowed.
And does
getMarkerPos"marker_1" work?
Without space 🚀
I do get this error though
seams so
just a question can I force set vehicle cargo to unload at a specific point (eg an oil spill)
https://community.bistudio.com/wiki/setVehicleCargo
Well, there's a waypoint for that IIRC, although I doubt it ever got much testing.
oh which one and how may I utilize it
the thing it's so players in viv can get their vehicle out without the viv driver pressing unload all vehicles
I don't know. It's undocumented.
oh ok
thisTrigger setTriggerInterval 5;
_actionId = driver vehicle player addAction ["<t color='#FF0000'>Teleport Vehicle</t>", {
params ["_target", "_caller", "_actionId", "_arguments"];
private _veh = vehicle _caller;
private _loadingcheck = isVehicleCargo _veh;
private _teleportPoint = getposasl p1;
if ( _veh isKindOf "Landvehicle" && isnull _loadingcheck) then{
private _dist =(_teleportPoint select 2) + 0.5;
_teleportPoint = _teleportPoint vectorAdd [0,0,_dist];
_veh setPosasl _teleportPoint;};
if ( _veh isKindOf "Landvehicle" && !isnull _loadingcheck) then{
private _dist =(_teleportPoint select 2) + 0.5;
_teleportPoint = _teleportPoint vectorAdd [0,0,_dist];
private _success = objNull setVehicleCargo _veh;
_veh setPosasl _teleportPoint;
};
driver vehicle player removeAction _actionID
}];
excuse the placement of lines
I tried this script and it works on smaller vehicles but on tanks it teleports the thing to p1 (oil stain on deck) but then sends it back in the lcu
it is meant to teleport vehicles that are in a loading bay in the back of an lhd on the lhd specifically on a reference point named p1
nice stuff (Lou) in the pinned Messages i like it thxs you
it's even better than a sleep actually
You probably have an invisible character there
Use NPP or ADT to detect and remove those
And as NikkoJT said you also need spawn in the other code
Hey there, I've been doing mission-making and zeusing for a while now, but I've never really learned to script. Does anyone have a recommendation on where I can learn
There's a link to introduction to scripting page in the pins
Create a laser target object on it
"LaserTargetW" for west and "LaserTargetE" for east
nice, thank you
As long as you need the sleep duration to be reliably exact.
is there a way to set an Obj position in reference to its current position
for example set an Obj 2 meters higher then it was before?
_position = getPosASL obj;
_position set [2, (_position select 2) + 2];
obj setPosASL _position;
@lone glade "and while {true} do loops are bad, just plain bad"
what if you just need something to run permanently
how would you write that
(i have while true sleep everywhere in my code, performance is good)
PFH, or just design something that doesn't need to be ran permanently
Is there an event handler for AI awareness level? (Combat, safe, etc). I'm trying to start a counter and execute code base on if an AI squad has detected the player.
I can't use the in editor trigger for blurfor detected because I can't find a way to have a condition timer (e.g. AI squad alive && it's been 10 seconds)
it exists without CBA ? all i find is links to the CBA doc
mokay
guess i'm not convinced
"it's bad" doesn't do much if you don't tell me why it's bad
Because it's an unending loop that hogs performance.
so if i have good performance do i need to care ?
well, yeah avoid getting bad habits
You could just have a stacked frame EH, and check the time delta with diag_time
Thats basically the CBA EH
so you're going to check the time every frame
is it better than sleep performance wise ?
i mean isn't it exactly what sleep already does ?
Sleep in scheduled environment becomes unreliable after a while
For most things it would not really matter
you mean it becomes much longer when lots of scripts are running in parallel right ?
Variables of your function / script can change between executions
d addEventHandler [
"CuratorObjectRegistered",
{
_classes = _this select 1;
_costs = [];
{
_cost = if (_x isKindOf "WBK_Combine_CP_SB") then
{
[true,0.5];
};
_costs = _costs + [_cost];
} forEach _classes; // Go through all classes and assign cost for each of them
_costs
}
]; ```
I have the gamemaster module set to none default addons and want to add one thing for the zues to spawn but it seems I cannot figure out how to get it to work
You basically lose control over what code gets executed when, yes
yes I've been looking at this
It has an example.
I know, it's what I used but it doesn't seem to work, I tried putting the code above in a trigger, initServer.sqf, initPlayerLocal.sqf, but the man does not appear in the spawnable list
never had a case where that becomes an issue
and yeah variables changing is the definition of what a variable is
- What is
d? - The
ifin the example also haselseblock. Where is it in your code?
d is the modual, I also tried myCurator
Imagine a script that tracks a unit
You mentioned you'd turned off all addons in the Zeus' settings. That'll be the problem. This EH is meant to go through all the available assets and hide them if they're not your chosen class. However, if your chosen class belongs to an addon that's turned off for this Zeus, then it won't be available to begin with and this EH can't unhide it.
You should turn on addons, and then use this EH to hide the things you don't need (this is what the missing else part from the example does)
OH okay
While alive unit etc etc
Now in scheduled, the code might halt at any point
If the unit dies after the alive check but in the middle of the following code
You might run into issues
Again, most scripts wouldnt run into issues with this but it is something to keep in mind for longer running scripts