#arma3_scripting
1 messages · Page 61 of 1
weapon holder no, but uniform/vest containers
for all uniform/vest/backpack it returns the unit wearing that thing (And potentially, would need to test, would return the weaponHolder/AmmoBox/Vehicle they are stored inside)E
Hello,
Returning to a problem of mine: I currently have a intro, scenario and outro phase. There are two videos, one video plays at the beginning of the intro phase, while a other ones starts in the outro phase.
While I am able to start the Intro video with initintro.sqf, I wasn't able to find anything for the outro. I could start the outro with a trigger instead, but a slight delay tends to happen. Any idea if something like initintro.sqf exists for the outro?
you can start it wherever you end the mission
True, but this would also mean it won't be skippable, which I would like to have for players.
For those looking for object oriented programming, I'm looking for feedback on this new feature https://feedback.bistudio.com/T170647#2421993
Responses please in #arma3_feedback_tracker 
Any idea if something like initintro.sqf exists for the outro?
this script file triggers for all 3, initIntro, outroWin, outroLo(o)se
https://community.bistudio.com/wiki/Event_Scripts#initIntro.sqf
It didn't trigger for me. It only worked for the intro and not for the outro, but it could be that I did something wrong.
hm, it should AFAIK
as there are no parameters provided allowing to distinguish, you could trick by naming the player unit differently, or some other trick
if (vehicleVarName player == "OutroWin") exitWith { execVM "initOutroWin.sqf"; };
or
just place execVM "initOutroWin.sqf" in a unit's init field
Going with the last idea, thank you so much! I always forget that the units inits field works like that
(Should make some notes sometimes)
don't forget that copy-paste may sometimes trigger all the scripts at once 😆 (memory of the OFP era…)
"ah yes, I did put the script in that one unit too…"
no worries, but thanks for the heads up
so from everything ive read in different forums seem to make it sound like trying to control AI heli fly height is pointless, just use unitcapture and fly the thing yourself, anyone think different?
no idea what you mean here, sooo
is there something to make AI heli pilots actually fly the height you want them to when using flyinheight or flyinheightASL, they never go below 50m no matter what you set
or is there another way of doing it
Hmm. If they're already hovering then they can go right to the ground with flyInHeight.
I don't know what test case you're using.
basically i just want a heli to fly low (below 50m) through a valley, it seems if you put a value in for flyinheight and flyinheightASL less than 50m it doesnt work
ive seen alot of forums about how both those commands dont work if you want the heli to fly below 50m, which seems crazy but watever
alot of people just use unitcapture and prerecord the flight path, which i have done before, i just suck at flying heli's lol
Honestly I'd say the AI low-level heli flying is pretty good compared most other AI code, but 50m would be pushing it.
yes i guess im asking for too much maybe, cuz another thing id love to do is have a heli do a rooftop insertion (which i figured out how to do) but make the decent to the roof more gradual as the heli gets closer
I want to emphasize that I'm not sure about this but I think that it's quite deprecated option as we have much better functionality for this now (like the engine based remote execution framework etc. etc.)
Or, let the server only to use setVariable with the public param set at least. It's not the best idea to let clients to set them because then you can't categorically filter them out with Battleye filters
It's not automatically wrong to public setVariable from clients but you should stick to an ownership concept.
Do not risk situations where client and server try to publish the same variable at the same time.
^ in an example that comes to mind, any control list that has to be broadcasted from server to client, like when a mod sets lists that can be modified by server and only read by clients
Isn't it kind of deprecated option if we think about security? Or am I wrong here
I.e. that stuff coming from clients should always be sanitized and verified and setVariable as a command makes it a bit complicated
Unless one wants to write complex BE filters with regexp... Or do I have a mistake in my logic here somewhere?
I think in an ideal world that's true but there's no actual block on public setVariable or publicVariable anywhere?
I have a Problem i want to set an Array when a specific condition is set. But this dont work is there a syntax error or something?
{
case "con_1": {_new = ["1","2"]};
default {};
};```
At least, as far as I know, CfgRemoteExec only applies to remoteExec.
Yeah, that's what I meant kind of
I.e. should always use it when just possible
kinda hard to avoid using global or object-setVariables in SQF :P
That's true, but couldn't you do it via remote execution framework? That way you could filter off the low hanging fruits (exploits) quite easily as they would have to be customized to the mission
(Speaking of the script based ones)
Nah, the trouble is that even if you never publish a variable in the mission, any client can still do it.
I'm not sure if I understand. What if you just filtered all variable broadcasts (with the direct commands) with BE filters? Wouldn't it work then?
Oh yeah, I guess BE can do it.
fair point then, if you want to build your mission secure from the start.
I see, thanks for the insight in any case!
is it possible to tweak the damage BIS_fnc_moduleLightning does?, possibly to nullify the damage and just use it as an effect
step 1 copy function
step 2 comment out line
If you used strictly remote execution framework only (configured properly), every script based cheat/hack would have to be customized to the mission so the generic ones would get caught/kicked off the server with Battleye filters
So it's like disabling the low hanging fruits (and the vast majority of) cheats with relatively simple and easy-to-implement tricks
See AgentRev's comment on this page https://community.bistudio.com/wiki/remoteExec , maybe it helps to understand it. But yeah, when it comes to your comment, I would say so
ty I kept thinking the damage was part of the function itself and missed the setDamage in the examples 
Any way to rotate text created with setObjectTexture and the new text texture?
Yes, but which init? init.sqf? initPlayerLocal.sqf? initServer.sqf? The init field of some object in the Editor?
init.sqf lol i said init not initplayerlocal
Alright. Does the countdown work? Do you get to see the output of the last line (hint "Teleported!") after the countdown ends?
yes everything works i just dont get tped
just init?
btw, if that code is intended to run once, it would be better to run it in initServer if this is a multiplayer mission and have the server manage the tp of the players
By the way, you can save some lines by doing a for loop instead of a while if its just a single time counter
for "_i" from 1 to 60 do
{
hint format ["Choose Loadout: Timer %1", (60 - _i)];
sleep 1;
};
The only obvious mistake in the script is publicVariable "_countdown" (local variables can not be broadcast).
It is possible that side player does not return what you expect it to return, so try to confirm that the setPos-statements are actually reached; for example like so:
switch (_side) do {
case west: {
systemChat "case west";
player setPosATL getMarkerPos "blufordome";
};
case east: {
systemChat "case east";
player setPosATL getMarkerPos "opfordome";
};
default {
systemChat "default";
};
};
you can use ui on texture instead
Hi, is it possible to prevent drone to fire ? Because the drones are firing on random target everytime so which AI feature i need to disable ?
hey guys. does anybody know what the 3rd parameter of the ilsposition is? ilsPosition[] = {9240,10144,141};
found this on "sara"
click "Show list"
this mixed up my script which finds airstrip position with the right direction
yeah thank you but i already know that but i don't know which one will prevent to fire on a random target. I will try to disable the AutoTarget feature but i can't test because like i said it's a random target and the drone shoot when he want. There is no feature against "Fire" and i think it's something like "AutoTarget" or maybe "Target" or maybe both or maybe an other feature so it's why i'm asking 😄
Edit : I forgot that we can change to "Don't shoot" on a drone waypoint so i think now it will work.
it is propably just n error, since a some config data seems to be off
I've never seen any drone target automatically 
Ask in #arma3_terrain ?
yeah you are propably right. wasn't sure where to ask this, since the problem is the output of my script ^^
Bit lost...
Help you in 30
I'm not great at ArmA. I'm a plug and chug kind of guy, and if I need to change a name sure. But it's a bit Greek to me.
I'll write something. Let me get home.
if !(isServer) exitWith { false };
// create task
private _description = "my task description here";
private _title = "my task title here";
[
west, //side
"dropoff", //task reference name
[_description, _title], //self explainatory
[0,0,0], //destination position - probably the location of your dropoff point
"CREATED", //starting task state
-1, //priority - largest priority first
true, //show notification
"rearm", //icon
false //always show
] call BIS_fnc_taskCreate;
// task completion
[] spawn {
private _trucks = [
truck_ammo_0,
truck_ammo_1
];
while {sleep 1; true} do {
//task failure - any truck is not alive
if (_trucks findIf {!(alive _x)} != -1) exitWith {
["dropoff", "FAILED"] call BIS_fnc_taskSetState;
};
//task success
if (_trucks findIf {alive _x && !(_x inArea "myAreaMarker")} == -1) exitWith {
["dropoff", "SUCCEEDED"] call BIS_fnc_taskSetState;
};
};
};
true
Morning, is there a function that abbreviates first and anything but the last name of a name in Arma 3? Bis_fnc_something? I get the name on the side of a plane via sqf private _name = format ["%1 %2", [_unit, "displayNameShort"] call BIS_fnc_rankParams, name _unit]; currently, but the name can be too long to be displayed.
You mean name _unit part?
Good question actually. I don't think there is a good native method to show only either first or last name
Anyone else having this problem? http://forums.a3wasteland.com/index.php?topic=2208.new#new #arma3_scripting #server_windows
yes, I meant that. I quickly came up with this now, but I don't know how it works with non ascii strings: ```sqf
ttt_fnc_abbreviateName = {
params [["_name", ""]];
private _newName = _name;
private _nameArray = _name splitString " ";
if (count _nameArray > 0) then {
// systemChat str _nameArray;
private _lastName = _nameArray select -1;
_nameArray deleteAt (count _nameArray - 1);
_newName = "";
{
private _firstLetter = _x select [0, 1];
_newName = format ["%1 %2", _newName, _firstLetter];
} forEach _nameArray;
if (count _newName > 0) then {
_newName = format ["%1 %2", _newName select [1], _lastName];
} else {
_newName = _lastName;
};
};
_newName;
};
oh, this works too: sqf private _lastName = _nameArray deleteAt (count _nameArray - 1);
forceUnicode command may help
I wasn't even aware it exists, hmm
just for wasteland?
Hi there, getting an "Error isnull: Type Bool, expected Object."
_squadMember1Target = objNull;
_target = cursorTarget;
if (isNull _squadMember1Target) then {
_squadMember1Target = _target;
hint "Target assigned to Squad Member 1";
};
Are you sure this part is causing the error?
I'll post you the full script
Please do
// Initialize variables
_squad = units group player;
_squadMember1 = _squad select 0;
_squadMember2 = _squad select 1;
_squadMember3 = _squad select 2;
_squadMember1Target = objNull;
_squadMember2Target = objNull;
_squadMember3Target = objNull;
// Define the _assignTargets function
assignTargets = {
params ["_squad", "_squadMember1", "_squadMember2", "_squadMember3", "_squadMember1Target", "_squadMember2Target", "_squadMember3Target"];
// Get the target under the mouse cursor
_target = cursorTarget;
// Check if the target is an alive enemy unit
if (alive _target) then {
// Assign the target to the first squad member
if (isNull _squadMember1Target) then {
_squadMember1Target = _target;
hint "Target assigned to Squad Member 1";
};
// Assign the target to the second squad member
if (_squadMember1Target != _target) then {
_squadMember2Target = _target;
hint "Target assigned to Squad Member 2";
};
// Assign the target to the third squad member
if (_squadMember1Target != _target && _squadMember2Target != _target) then {
_squadMember3Target = _target;
hint "Target assigned to Squad Member 3";
};
};
};
waitUntil {!isNull(findDisplay 46)};
// Add the event handler for the T key to assign targets
(findDisplay 46) displayAddEventHandler ["keyDown", "if (_this select 1 == 20) then {call assignTargets};"];
Of course it goes on but the rest is out commented
No idea since the intention is yet unknown
Probably by initialize inside of the fnc not outside
So in general I want to create a syncshot script as in Ghost Recon Wildlands/Breakpoint.
With the eventhandler I want to be able to press the T key and assign up to 3 targets.
Everytime I press the key again it should check if a squadmember already has a target assigned and assign it to the next member.
params reads the parameters you give to a function.
it doesn't magically find local variables you have defined somewhere else.
You have the display in your function, and you have the display as parameter inside the eventhandler.
you can use setVariable/getVariable on the display, to store your variables on there
What would be the proper script (in the object init) to add an action that kills the player?
depends
MP? SP? should everyone see this action? only that unit?
Everyone should see it, also MP
(and please don't crosspost)
thx, np 👍
private _actionTitle = "Kill that dude";
if (this == player) then { _actionTitle = "Kill self"; };
this addAction [_actionTitle, {
params ["_target", "", "_actionId"];
_target setDamage 1;
},
nil,
1.5,
true,
true,
"",
toString { alive (_this select 0) },
5
];
another thing, I already have another action on the object so if i wanted to combine the other action and this action would I just paste everything after line 2?
no idea… what exactly do you want, merge these two actions in one?
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
what is your other action?
i like that tostring thing u did lou
@lunar goblet also from your question it sounds like just sqf this addAction ["Kill Player", {player setDamage 1}]; is what u want?
oh my god im an idiot
a lifesaver we lacked since OFP
thank you, just formatted my stuff wrong which is why my previous action to kill the player wasn't working
I really need to get used to syntaxing and formatting stuff properly...
I'll check that out, thanks!
morgan freeman narrator voice "he never checked it out"
I swear my settings are broken or something, when i put the mission file on the server it has the action, but when i host it on my laptop it doesn't work 😂
im pretty useless outside of dedicated server environ... no ideea what the issue could be
i would be using the "initplayerlocal.sqf" init script and a respawn event handler for the action
well it works on the server, which is all i need.
// initplayerlocal.sqf
player addAction ["Kill Player",{player setDamage 1}];
player addEventHandler ["Respawn",{player addAction ["Kill Player",{player setDamage 1}];}];```
It seems to be giving me an error, I've never done the // initplayerlocal.sqf thing so i don't know what this means nor how to fix it.
right?
So neat
yea dont bother. there is learning there required in order to use that code. go with what you know and are familiar wwith
will do 👍
init fields do not take // comments
Expansion:
// initPlayerLocal.sqf```
This line is a comment, which means it's for you to read, not the computer. It causes an error when placed in an Editor code fields because of enginelimitations, but also it's there to tell you to put the code in the initPlayerLocal.sqf file (look that one up) and not in an Editor code field at all.
It really is. I especially like it for setting trigger statements.
it was when condition was added to addAction (in Arma 2, so first syntax) that I seriously wondered why they went for String again
now it occurs to me that it was maybe for consistency, but I was confused then
Those action callbacks are also executed in a new thread, which is pretty surprising. I pass
isnil
{
// args to pass to addAction: [callback code, args]
// calls the script with [args, [object target, object caller, int ID, args]]
[_this select 3 select 1, _this] call (_this select 3 select 0);
nil
};
And the actual callback and arguments in an array in the addAction arguments.
Would there be any real difference between these 2?
myFunction =
{
params ["_result"];
//Some Code here using result;
result;
sleep 10;
[result] call tag_fnc_myFunction;
};
[someParameter] spawn tag_fnc_myFunction;
instead of
[] spawn
{
private _result = someValue;
while {true} do
{
//Some code here using result
_result = //newValue from code;
sleep 10;
};
};
No specific code, just wondering if something has advantage over the other
they have many differences 
the first one is worse
because its stack keeps growing and it keeps slowing down
How can I find what number a certain key is? I.e displayCtrl 2414
like where do I find what button on the keyboard that is
displayCtrl has nothing to do with key
^
Oh lmao
for keys you are looking for the hex code or DIK code
There is an admin menu script but I can't for the life of me find where it tells it what key to use
do you have the script at hand?
look for a keydown event handler
Yeah the two, it is very hard to see what's common part
When you push DOWN, it is keyDown. Up, vice versa
onKeyUp
Use on: Display, Control
Fired on: Releasing any keyboard key. Fired after the onKeyDown event.
Returns: Returns the display or control, the keyboard code and the state of Shift, Ctrl and Alt.
params ["_displayOrControl", "_key", "_shift", "_ctrl", "_alt"];
The code doesn't condition the key used, so it would fire when pressing any key.
Is this your code or you got it from somewhere?
Was it working already?
Is this a public tool of some sort with documentation? If so you should probably read how to use it properly
_key it is
Hi, is there a way to make a unit follow the player while keeping a certain distance (300m)?
yes sir - but what if the player comes back to it, should it keep its distance?
yes, exactly. it should always keep its minimum distance to the player.
I would go with
private _angle = _followed getDir _follower;
private _expectedPosition = _followed getPos [300, _angle];
_follower move _expectedPosition;
thanks very much for this!
I am trying to spawn a small sniper group which follows the player at a certain distance. This is the code I have so far:
SniperUnitList = [
"rhsusf_socom_marsoc_sniper",
"rhsusf_socom_marsoc_spotter"
];
snipertotal = (count SniperUnitList);
rndsniper = 1;
grpsniper = createGroup west;
for "rndsniper" from 1 to snipertotal do {
picksniper = SniperUnitList select rndsniper -1;
sleep 0.2;
spawnpossniper = [player, 5, 50, 3, 0, 0, 0] call BIS_fnc_findSafePos;
_myUnit = grpsniper createUnit [picksniper, spawnpossniper,["myMarker1","myMarker2"], 200, "NONE"];
sleep 1;
};
_sniperunits = units grpsniper;
//Set Anim Coefficent
{
_x setAnimSpeedCoef 1.15;
}forEach [_sniperunits];
//Order team to follow
{
_x doFollow player;
}forEach [_sniperunits];
My problem is, that the group is not following the player. Any idea what I am doing wrong?
please avoid walls of code (and unnecessary empty lines too!)
doFollow is about units in the same group
Oh i see.
Is there a command I could use to make the team follow a unit which is not in their group?
this requires scripting, so what I posted
ah, i see. you are using move for this. testing it out now. thanks a lot again.
decided to ask chatGPT some questions, is this a good idea? would the logic running each frame affect performance at all?
addMissionEventHandler ["EachFrame", {
private _time = diag_tickTime;
if (_time - time_last_save > 300) then {
saveFactionData();
time_last_save = _time;
};
}];
imo it still gives good guidance, sometimes even code you didnt think about
good for helping create a plan for myself
doesnt even know the syntax
Absolute garbage as usual. It's a terrible idea doing anything in EachFrame that isn't required. saveFactionData() isn't SQF. time_last_save isn't defined.
i use that bot for powershell and regex shit thats about it lol
yeah kinda figured but just wanted to see if gpts code got any better
I usually use it for sql honestly
its pretty good at that
Hopefully better than the human SQL I've seen
i mean 95% of arma 3 steam workshops are same way lol, we just done have the old school arma2 genius coders anymore
kids writing shit like track each bullet with public variable type of shit
Is there a place to report code related bugs?
SniperUnitList = [
"rhsusf_socom_marsoc_sniper",
"rhsusf_socom_marsoc_spotter"
];
snipertotal = (count SniperUnitList);
rndsniper = 1;
grpsniper = createGroup west;
spawnpossniper = [player, 0, 1, 0, 0, 0, 0] call BIS_fnc_findSafePos;
for "rndsniper" from 1 to snipertotal do {
picksniper = SniperUnitList select rndsniper -1;
sleep 0.2;
_myUnit = grpsniper createUnit [picksniper, spawnpossniper,[], 200, "NONE"];
sleep 1;
};
//Set Vars for group
{
_x setAnimSpeedCoef 1.15;
_x disableAI "RADIOPROTOCOL";
_x enableFatigue false;
_x setSkill 1;
}forEach (units grpsniper);
sniperloop = {
_followed = player;
_follower1 = units grpsniper select 0;
private _angle = _followed getDir _follower1;
private _expectedPosition = _followed getPos [20, _angle];
_follower1 move _expectedPosition;
_followed = player;
_follower2 = units grpsniper select 1;
private _angle = _followed getDir _follower2;
private _expectedPosition = _followed getPos [20, _angle];
_follower2 move _expectedPosition;
};
while {alive (units grpsniper select 0) || alive (units grpsniper select 1)} do {
call sniperloop;
sleep 5;
};
hint "Lost contact with Delta 2";
Can someone tell me why those two units do not spawn next to each other and how to fix this? Somehow they spawn at completely different positions around the player.
try putting "CAN_COLLIDE" instead of "NONE" in the createUnit arguements
Still spawning at different locations
Not sure why
Oh I guess because: placement: Number - placement radius
Never mind, got it sorted. Thank you
can you avoid posting walls of code thank you
use https://sqfbin.com/
isnt createVehicle at [0,0,0] then setPosASL faster?
Question about Dedicated Servers, I'm trying to use a Show/Hide module with Hold Action. In code complete i have science = true and on trigger condition i have science
This works in single player but I don't know how to make it global so it works on a dedicated server
Tried reading through the Wiki, but I didnt really understand the examples. (im not doing it through an external SQF either, i'm doing it through the object's attributes)
What are you trying to hide?
Well, I can't help you with the show/hide module because it's not documented for scripting.
But there's hideObject and hideObjectGlobal.
I just need to make that "Code complete" from the object's attribute menu to run globally
You just want to set science=true globally?
yes
science = true; publicVariable "science";
I'll test in Dedi give me a minute
that worked, thank you!
I was coming to ask a question but in the process of writing it down, I realized the issue. For future reference, if you use BIS_fnc_moduleLightning on a target that was created below ground, the lightning strike would result in a water splash effect
Fixed it by shifting my target to at least be above 1m above terrain level
Hi, All. Have following problem. I create mission using ticket system. Also I want AI slots in lobby dissapears after tickets for this slot ended. Now when tickets ended I can just exit to lobby, sat on the same slot and play game as if I have at least 1 ticket. Does anybody know how to solve this problem?
disable respawn?
Don't think thats possible
Maybe there is some workaround, ticket system is just meaningless when everyone can "cheat" leaving to lobby and entering the same slot?
Where do I put this
I do apologize Hypoxic it's been many moons since I've played arma 3 and made missions I'm trying to get back into the groove
I really appreciate your help man
will try
Put it in a file and name it with .sqf then execute it in init.sqf with either
call compilescript ["myfile.sqf"]
Or
execVM "myfile.sqf"
Is it possible to have AI become unfriendly to their own side, but keep their group as friendly?
I'm using this:
independent setFriend [independent, 0];
But can't find a way to keep them from shooting their own group.
no
if you want one group to go rogue / join the enemy, it is possible
also theoretically I can set respawnOnStart=1 and set faster respawn on first enter to mission, will try also
@tough abyss , perfect thank you for the information
Is this code good? 3den is giving me an error that it is expecting a bool.
addAction ["Make a Wish",{[_this#1] joinSilent createGroup east},[],6,true,true,"","_this isEqualTo vehicle _this and side _this isEqualTo west",5,{player setDamage 1}]
Hi I am using the following code to spawn a unit in a safe position:
grpsniper = createGroup west;
spawnpossniper = [player, 205, 250, 0, 0, 0, 0] call BIS_fnc_findSafePos;
_myUnit = grpsniper createUnit ["B_ghillie_lsh_F", spawnpossniper,[], 1, "CAN_COLLIDE"];
This spawn the unit in a 360 radius around the player. I am now trying to find a way to spawn the unit only behind and out of sight of the player. Is this possible?
{player setDamage 1} in this context is wrong
so would i remove the brackets?
Never mind, I found a way.
but what if i want to outright kill the player?
Actually, when do you want to do so?
when they use the action via scroll wheel interact
Then replace {[_this#1] joinSilent createGroup east} into that
Actually correction, i want them to be killed after they are swapped over to OPFOR (east)
so they respawn at the OPFOR spawn point
{[_this#1] joinSilent createGroup east; (_this#1) setDamage 1}```
Like that
Alr thanks, it seems to work now
I think the slot can't spawn if there aren't any tickets left
for tickets the respawnTemplate appears to work pretty well
tv setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
uav lockCameraTo [tgt, [0]];
cam = "camera" camCreate [0,0,0];
cam cameraEffect ["External", "Back", "uavrtt"];
cam attachTo [uav, [0,0,0], "PiP0_pos"];
cam camSetFov 0.1;
"uavrtt" setPiPEffect [0];
addMissionEventHandler ["Draw3D",
{
_dir =
(uav selectionPosition "laserstart")
vectorFromTo
(uav selectionPosition "commanderview");
cam setVectorDirAndUp
[
_dir,
_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
];
}];
so currently we've gotten the UAV to stream live feed to a screen but it currently just shows the "driver" view instead of the gunner view (which does point at the correct target. Any suggestions?
credit Killzonekid for scripts via his blog.
@prisma glen cant respawn if respawnOnStart=1
if respawnOnStart=0,-1 then slot can spawn but can't respawn
Check config for more bones to attach your camera to
Vehicles have RenderTargets config class in them which lists cameras it has
Use Splendid Config viewer, find your vehicle class, RenderTargets in it and see what it has there
PiP0_pos seems to be driver view camera position in most vehicles
Bones are unique per vehicle, so best solution would be to dynamically pull them from the vehicle
If your vehicle is always the same, you can just hardcode it like you have now
uavCameraDriverPos="pip_pilot_pos";
uavCameraDriverDir="pip_pilot_dir";
uavCameraGunnerPos="PiP0_pos";
uavCameraGunnerDir="PiP0_dir";
it seems PiP0_pos is for the gunner, so it should work but it doesnt
class RenderTargets {
class commander_display {
renderTarget = "rendertarget0";
class CameraView1 {
pointPosition = "commanderview";
pointDirection = "commanderview_dir";
renderVisionMode = 0;
renderQuality = 2;
fov = 0.305731;
turret[] = {0,0};
};
BBoxes[] = {"PIP_COM_TL","PIP_COM_TR","PIP_COM_BL","PIP_COM_BR"};
};
class driver_display {
renderTarget = "rendertarget1";
class CameraView1 {
pointPosition = "PIP0_pos";
pointDirection = "PIP0_dir";
renderVisionMode = 0;
renderQuality = 2;
fov = 0.8;
turret[] = {-1};
};
BBoxes[] = {"PIP_DRV_TL","PIP_DRV_TR","PIP_DRV_BL","PIP_DRV_BR"};
};
};
```Some other vehicle
PIP0_pos is driver here
I guess checking for uavCameraDriverPos and uavCameraGunnerPos is easier though
cam attachTo [uav, [0,0,0], getText(configFile >> "CfgVehicles" >> typeOf uav >> "uavCameraGunnerPos")];
```guess this should work
STRING in HASHMAP makes me wish we could do same check for entity variables
Something like OBJECT isNil STRING, so:
isNil{_entity getVariable "key"}
```can be shortened to
```sqf
_entity isNil "key"
Though it could use a better name, something like hasVariable
_entity hasVariable "key"
yep, otherwise in allVariables which is not pretty
also in would be case-sensitive (I think setVariable/getVariable isn't)
isNil {} is very fast already, but still makes me wish to be able to do the check in a single command
You're right, entity variables are case insensitive while hashmap keys are
I know Dedmen would prefer isNil over hasVariable because it is using an existing command, but still, hasVariable would make sense to me
but isNil covers a case where ["TAG_varName", nil] too
Hmm, does setVariable ["key", nil] triggers a delete instead of setting a nil? 🤔
there was a mismatch iirc where setVariable ["var", nil] would delete locally but setVariable ["var", nil, true] would not delete but set to nil, at least remote ones
it's really "off the top of my head" so confirmation needed
🤔
are there any other ways to disable AI features and improve FPS than _x disableAI "all"; ?
thx tried with enableSimulation but no notable FPS inc
ooh it works if I disable the vehicle sim (enableSimulation)
if i want to make a registered sqf function (using intercept) return an array of arrays of positions, do i need to construct that array in some special way or can it just cast from std::vector<std::vector<vector2>>?
is there any use calling disableAI "all"; if you do enableSimulation false ?
I'm calling enableSimulation on static gun
no
using simple and super simple objects would be the best solution
Interesting question whether it still runs AI stuff if you disable simulation on the crew's vehicle.
at least the lag is gone
You could check whether targets changes, although that might be separate from FSMs etc.
I have checked and it doesn't. at least not the driver
the gunner also becomes invulnerable
I would assume the same for other seats
Gunner also becomes invulnerable if you disable simulation of the gunner but not the static.
I forget whether they also shoot back :P
yeah doesn't at all
gunner doesnt die first (when I shoot him) but when i shoot the static the gunner dies....
How did we make the code box again?
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
params [
"_is3D", "_group", "_waypointId",
"_mouseButton", "_posX", "_posY",
"_shift", "_control", "_alt"
]; if (_shift == true && _control == true && (_group getVariable ["mined", false])) then
{
group1 setVariable ["mined", "true"]; createMine ["ATMine", (leader _group) getRelPos [0, 90], [], 0.1]; createMine ["ATMine", (leader _group) getRelPos [3, 90], [], 0.1]; createMine ["ATMine", (leader _group) getRelPos [6, 90], [], 0.1]; createMine ["ATMine", (leader _group) getRelPos [10, 90], [], 0.1]; createMine ["ATMine", (leader _group) getRelPos [3, 270], [], 0.1]; createMine ["ATMine", (leader _group) getRelPos [6, 270], [], 0.1]; createMine ["ATMine", (leader _group) getRelPos [10, 270], [], 0.1];{ west revealMine _x; } forEach (allMines select { _x inArea [(leader _group), 50, 50, 360, false, 20] });
};}];``` Thank you kind lad
Im trying to have multiople groups able to lay mines once by switching a variable when they do lay mines, but i dont seem to get the variable set for group before this runs. Any ideas what i could try?
i dont seem to get the variable set for group before this runs
What do you mean by this?
im trying to have "hasmined" as false, and the Eh can only trigger if the group has "hasmined" false. The code triggering sets "hasmined" true, preventing further use
for group
- what on earth is that kind of formatting?

- there's no "hasmined"
- if you mean "mined", you're setting it to a string. it should be bool
so you want them to lay mines when you do ctrl+shift+click on the group icon?
The condition is backwards, group1 should be _group and the set should be a bool.
_this setVariable ["mined", false];
addMissionEventHandler ["GroupIconClick", {
params [
"_is3D", "_group", "_waypointId",
"_mouseButton", "_posX", "_posY",
"_shift", "_control", "_alt"
];
if (_shift && _control && !(_group getVariable ["mined", false])) then
{
_group setVariable ["mined", true];
{ west revealMine createMine ["ATMine", (leader _group) getRelPos _x, [], 0.1]; } forEach [
[0, 90],
[3, 90],
[6, 90],
[10, 90],
[3, 270],
[6, 270],
[10, 270]
];
};}];
And yeah, the allMines stuff was disgusting :P
also there's no need to write == true or == false
Im sorry im still in my baby steps on what comes to coding😄
Thanks, it worked like a charm!
how do i add this library https://github.com/AngusJohnson/Clipper2 to my c++ intecept project? (i have no clue how cmake works)
add what's under src to add_library part of your project
add what's under include to target_include_directories
also that question has no place here 
ask in dedicated intercept channel in Dedmen's server
where do i find that server?
thank you
hey so I want to make my player's spawn feel a bit more alive. currently messed around with a shooting range, other soldiers walking around, etc.
I want to make a bunch of people (AI) do the kata / karate animation and have it loop, is there anyone willing to help me? as I am completely clueless in this matter
respawnTemplates[] =
no menuposition?
No I meant your first part is wrong
ah alr
ty
@warm hedge by chance, would you know how to get rid of the overlapping?
I don't know how you make the respawn
Look at the list in the centre left panel. It's overlapping because you've got the position defined twice for some reason
i see that and i did update it
i fixed the Respawn Base positions to their respective areas (one at the malden heliport section, one next to the large hangar)
however the overlapping does continue
as seen
IIRC this is due to being admin.
christ
wait
?
I posted that as you posted the image 
lolol
That isn't normal behaviour.
I meant, if it was only one respawn (the main one)
post the full description.ext
right, however, both respawn points (diferrent variable; respawn_west_base/respawn_west_heliport)
bet
respawnTemplates[] = {"MenuPosition"};
respawnOnStart = 0;
lol
thats your entire description.ext
that is the entire description.ext

as i was following youtube videos
and theyre usually pretty lackluster
id be delighted to put in absolutely everything i need
lemme send you what I use (as a template, and try it with that)
sure
im only using the scripts for respawn points
i just need to have my friends be able to use them etc etc
so i could copy it over and nothing would happen, hopefully?
copy or download. whatever is best.
I would personally download and replace.
and it would still work with the respawn selection?
Read, what it says next to & under //respawn parameters.
i do not have an onPlayedKilled.sqf so
would you like one?
im good, we're just playing with regular USMC
all i really need atm is just a non-fucked pick-respawn map thingy
and IIRC there may be an internal one that gets fired
okay
just that if you have one in the mission file, that one gets used instead.
You'll need both
onRespawn is referenced, and contains the bit that saves your gear before respawning you.
onKilled ensures that you retain your gear, before firing onRespawn
did you delete your one?
yep
i just inserted this into yours as your script didnt pop up the respawn area
yeah
respawnTemplates[] = {"MenuPosition"};
respawnOnStart = 0;
i inserted this into your script
No
- not a script.
- it includes those
this is telling you there is a duplicate
okay
for respawn on start
okay your script does not bring up to pick where to respawn
or whatever its called
all in all, same point
i just respawn at either respawn point
@frank mango
The script doesnt do that
as I said.
the description.ext i sent was a template
you need to change the respawn type
(as the wiki link, that is text to it, explains the different types
okay
@frank mango yeah this is way too much i have to look through for 2 locations on a map
especially with me whose almost illiterate with this
change
respawnTemplatesWest[] = {"Base"};
to
respawnTemplatesWest[] = {"MenuPosition"};
change.
not copy.
okay pur, it works buttttt theres still the overlapping
i did not modify anything else besides base to menuposition
right. what else is in your mission
how are the respawns placed?
how
oh
what did you use
im tired as shit im just tryna get this done, my apologies
okay i am using respawn position, and placed down in the map regularly
why are the respawn variable name respawn_west_base ?
that was following some youtube video, i'll fix it
not sure if that is the issue. just a thought
i dont think it is
ill check
nope, not an issue
it could easily be an admin glitch
ill ask my friend to hop on
changed the respawn modules to markers and it worked fine
I'm guessing using the modules AND description.ext caused it to double the respawns
makes sense
It was the variable name
you named the respawn module, respawn_west
as the module already does respawn, you naming it, that. gave it 2 respawns
Yes. also you changed some things in the description.ext that shouldnt be changed.
which were?
Does anybody know why my unarmed, ungrouped NPCs congregate in groups after running for a bit
Are they running out of stamina?
disabledAI
This was set to off (0), which is why AI were automatically assigned to your player roles.
aiKills
This was set to off (0), which Enables AI units score to appear in score table.
Bump
Having an issue with code scope and I'm failing on finding a way to fix that. There a way to work this out? Please ping if you answer as this will probably be lost in other questions / Much appreciated
// Simplified names to make it easy to read
switch STATEMENT do {
case "CASE": {
INNERSCOPE_VAR = VALUE;
};
};
PLAYER setPosATL INNERSCOPE_VAR //aka OUTERSCOPE use INNERSCOPE_VAR
This is due to AI trying to find the fastest path possible to the location they are going to and if they are close together, the fastest path will be similar for at least a few of them
This can be fixed by grouping them together. When grouped together they usually space out in their designated formation but will all have a common end point if you do that 
INNERSCOPE_VAR = switch STATEMENT do {
case "CASE": {
VALUE;
};
};
PLAYER setPosATL INNERSCOPE_VAR;
private "INNERSCOPE_VAR";
switch STATEMENT do {
case "CASE": {
INNERSCOPE_VAR = VALUE;
};
};
PLAYER setPosATL INNERSCOPE_VAR //aka OUTERSCOPE use INNERSCOPE_VAR
```or this
If you need to return several values you can do something like this:
switch(true) do {
case(condition): {
[getPos obj1, getDir obj1]
};
default {
[getPos obj2, getDir obj2]
};
} params ["_pos", "_dir"];
player setPos _pos;
player setDir _dir;
Lots of options, structure your code depending on what you need
When squeezing performance is not important, you can make it even prettier\readable with hashmaps
private _result = switch(true) do {
case (condition): {
createHashMapFromArray [
["pos", getPos obj]
,["dir", getDir obj]
]
};
case (other_condition): {
createHashMapFromArray [
["pos", getPos obj] // Only returning pos here
]
};
default {
createHashMap; // Empty hashmap
};
};
player setPos (_result get "pos");
player setDir (_result get "dir");
More advanced method of doing it, If there is no key in hashmap (other condition or default), then get will return nil and setPos/setDir commands will do nothing. Be careful with nils though.
player setPos (_result getOrDefault ["pos", someDefaultPosition]);
player setDir (_result getOrDefault ["dir", someDefaultDirection]);
```another way of having it, with `getOrDefault`
Good morning.
I read from wiki that attachTo event is terrible for performance in MP.
If I want create multiple objects where is multiple attached objects.
Can I do this via config?
I would have bomb where is attached wires which is needed to cut.
But if I do this via attachTo commans. I attach every wire to my object, let's say 7, and i delete wire when it get cut.
This works on SP fine and when I'm testing alone in MP. But if I understand correctly, my way will cause lot of traffic in MP , if I have 10 different Bombs (like canister where is 7 wires attached oneach) , I'm right?
What did you read exactly?
Comments from attachTo event in wiki forum, I can research. Dedmen answered there that attach To event it's not good for mp
Not sure about this so I'm asking here. Which is correct way to do.
you'll find that the OCD over-optimizers dont actually produce much if any playable content
Need specific examples
Didn't see anything related to it being bad for MP
Build what you need to build for a fun experience, and then assess whether performance is hindering that experience
Q: I want to add some trees to my mission, but the specific trees in question don't show up in the mission editor. I know I have to create a class for it, but is there a way to do it without creating a mod? Can I also reference the class in the mission file?
createSimpleObject with tree's model
You can get model paths with getModelInfo command
I have the models already figured out, so I'll try createSimpleObject. Thanks. 🙂 Speaking of, is there an invisible object that is optimal to anchor this command to?
That or I can have it delete itself after.
Logic objects are a good fit
Keep locality in MP in mind though (create and delete only on server)
Ah okay. It's supposed to fire at the start of the mission. So I should use a server logic object?
Tried it myself:
createSimpleObject ["a3\plants_f\tree\t_pinuss2s_f.p3d", player modelToWorldWorld [0,5,7]]
```Works, but the tree can't be broken down with a tank unlike normal tree
Depending on how you do your mission. Just place a logic object in editor, have the object call your script on Init but make sure it only executes the script on server.
Also tree trunks aren't exactly in the center of the model so you'll need to account for that
Ah okay. It's specifically this log and these stumps:
"a3\vegetation_f_exp\treeparts\d_treestump_natural_small_f.p3d"
"a3\vegetation_f_exp\treeparts\d_treestump_natural_large_f.p3d"```
happens to me often after using ropes
it is a physx thing, applying vehicle setdamage (damage vehicle) fixes
any sort of physx wake
although the "awake" command is too weak
Hello, I am trying to build an eventhandler which get the player out out incapacitated state after 3 secs. This is my script but it does not seem to work. I am not very familiar with EHs but can you tell me what I am doing wrong?
player addEventHandler ["HandleDamage", {
params ["_unit"];
if (lifestate _unit == "INCAPACITATED" ) then {
sleep 3;
_unit setUnconscious false;
};
}];
do you have script errors on? i dont think sleep works there because the EH is unscheduled
no script errors
let me try to remove sleep
It still does not work
I am trying to trigger the EH with:
player setUnconscious true;
player setDamage 0.2;
But nothing happpens
not sure if setDamage triggers the EH
put some debug hint in the EH to see when/if it triggers
Ok, I will try to trigger the EH with an explosive. But any idea how to avoid that the player dies and only goes into incapacitated state?
setUnconscious should do it
dont know if arma ever sets the INCAPACITATED or do you have to use the command
player addEventHandler ["HandleDamage", {
params ["_unit"];
hint "EH live";
_unit allowDamage false;
_unit setUnconscious true;
if (lifestate _unit == "INCAPACITATED" ) then {
sleep 5;
_unit setUnconscious false;
};
}];
This works but as you mentioned sleep does not work with EH. Any idea how to implement a delay?
Use spawn
player addEventHandler ["HandleDamage", {
params ["_unit"];
hint "EH live";
_unit allowDamage false;
_unit setUnconscious true;
if (lifestate _unit == "INCAPACITATED" ) then {
spawn {
params ["_unit"];
sleep 5;
_unit setUnconscious false;
_unit allowDamage true;
};
};
}];
Haven't used spawn before but this gives me a syntax error.
Ah got it sorted Forgot to use _unit
Thanks very much both
{
{_x playMove "AmovPercMstpSnonWnonDnon_exerciseKata"} forEach [kar,kar_1,kar_2,kar_3,kar_4,kar_5,kar_6,kar_7,kar_8,kar_9,kar_10,kar_11,kar_12];
};```
managed to get the karate thing to work, however I still need a bit of help in terms of having the animation loop
Apparently the kata animation is not really good for looping, but you can force them to loop using AnimDone EventHandler
alright, thank you i'll test it out
How can I make an AI mate report "injured" via the radio?
player sideRadio "SentHealthCriticalDefault"```
Hmm, somehow I don't hear anything
Probably your character doesn't have voice
I'd appreciate a bit of guidance here as I'm completely new to scripting
params ["_unit", "_anim"];
}];```
I'm assuming I have to change the _unit to _kar and the _anim to _exerciseKata, right? or have I misunderstood something
No
this addEventHandler ["AnimDone",{
params ["_unit", "_anim"];
_unit switchMove _anim;
}]```
but it receives radio messages from the AI
“But”?
Got it working. Thanks Polpox.
I'm trying to make an "smart" teleport script where an object will get teleported in the same model position from the from object to the to object, both objects are of the same type, but are elsewhere and have a different direction.
setPos part works great, but can't get the direction working.
I've tried doing it with getRelPos and some stuff with vectorDir, but I just can't get the correct end result.
Anyone has any clue on how to get the direction working correctly?
I once wrote a script that teleported player into random exact same house when they went inside.
You have that script available somewhere :P?
You need to run your object vector dir and up with vectorWorldToModelVisual and then convert it back with vectorModelToWorldVisual
Couldn't find it anymore, but its pretty simple, worldToModel and modelToWorld back for all related vectors
Sadly couldn't make it cool enough, you had to catch a moment when player didn't see any windows so teleport isn't noticable, also there is an issue of preloading after teleport, then there is house orientation and shadows
Was brainstorming ideas for a horror mission, didn't go anywhere
Uhm... tried something but still not really working...
{
private _modelPos = _from worldToModel (ASLToAGL getPosASL _x);
private _dir = _to vectorModelToWorldVisual (_from vectorWorldToModelVisual (vectorDir _x));
_x setPosASL (AGLToASL (_to modelToWorld _modelPos));
_x setVectorDir _dir;
} forEach _objects;
Is this what you meant?
Looks okay, what didn't work about it?
(There is modelToWorldVisualWorld btw, which is ASL)
Are all your objects upright?
If no, then you'll need to do that for both vector dir and up
I'm doing it on the salt lake in Altis so I guess so 😛
ok... changing the setPos part to what you said with modelToWorldVisualWorld somehow fixed it?
actually that script from above works as well... idk what happened maybe I forgot to save the function after editing...
I am trying to find a way to give units four times more hit points before they die. This is the script I am using but it is not working. Any idea how to fix this?
{
_x addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_dam"];
//(_this select 2)/20;
_damage = _damage / 20;
hint format ["%1", _damage]
}];
} forEach units group player;
hint "EH started";
{
_x setPosWorld (_to modelToWorldVisualWorld (_from worldToModelVisual ASLtoAGL getPosWorldVisual _x));
_x setVectorDirAndUp [
_to vectorModelToWorldVisual (_from vectorWorldToModelVisual vectorDirVisual _x)
,_to vectorModelToWorldVisual (_from vectorWorldToModelVisual vectorUpVisual _x)
];
} forEach _objects;
_damage is final damage, not added damage
private _old_damage = if(_hitIndex < 0) then {damage _unit} else {_unit getHitIndex _hitIndex};
private _added_damage = _damage - _old_damage;
private _final_damage = _old_damage + _added_damage / 4;
_final_damage;
Works great and seamless 👍
Thank you, I tried this but it does not seem to give the units more hitpoints, does it? I guess I am doing something wrong.
{
_x addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_dam"];
private _old_damage = if(_hitIndex < 0) then {damage _unit} else {_unit getHitIndex _hitIndex};
private _added_damage = _damage - _old_damage;
private _final_damage = _old_damage + _added_damage / 4;
_final_damage;
hint format ["%1", _final_damage]
}];
} forEach units group player;
hint "EH started";
Your event handler doesn't return anything, _final_damage; must be final statement.
It returns result of hint command, nothing.
Your original script didn't work because of that as well btw.
It didn't return anything
EH is called for each selection (body part) btw so your hints will override one another
Sorry, I am confused. What I am trying to achieve is that the units can take more hits before they die. I am not very familiar with EHs. The hint is not really relevant. Just put it in there to see if the EH fires.
Last statement of the function is its returned value
Your last statement is hint which returns nothing, so game ignores EH result.
Have _final_damage; as final statement of the EH
{
_x addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_dam"];
private _old_damage = if(_hitIndex < 0) then {damage _unit} else {_unit getHitIndex _hitIndex};
private _added_damage = _damage - _old_damage;
private _final_damage = _old_damage + _added_damage / 4;
hint format ["%1", _final_damage];
_final_damage;
}];
} forEach units group player;
hint "EH started";``` Like this.
Oh, I see
I didn't realise that the order with hint makes such a big differnce
Thanks very much guys
if i have a spot in an array that can either contain either an array in a predetermined format or nothing, then what would be the most reasonable thing to put in there for "nothing"?
like should i use an empty array, an empty string, a number, objNull or something else entirely?
Depends on what you do with that spot
You can have nil there which will mute all commands that operate with that spot.
if i use nil i'm gonna eventually introduce a bug where everything gets muted and i don't know where it came from
Up to you to design your code around it
If you iterate through that spot, have empty array there
If you compare against it, you can have 0 there, 0 isNotEqualTo [your,array,here] will work fine
i plan on accessing it directly and then checking if something is already there
If you'll use in or find, empty array is a good idea then
thats probably the way to go for me
count(_array select _my_spot) == 0 is pretty fast too
thanks
Quick question how do you arm claymore ?
What do you mean?
I found it thank you i was applying dmg to Claymore_F but armed clay more is ClaymoreDirectionalMine_Remote_Ammo
I've seen stuff like somevar#0 in other people's scripts. What does the # do? It's basically impossible to search for on the wiki
it's a short form of select https://community.bistudio.com/wiki/select
ah! thank you
can this be optimized? ```sqf
private _units = [];
_esides = [west,east]; // Random
{
_units = _units + (units _x);
} foreach _esides;
My take:
private _units = allUnits select {side _x == West OR side _x == East}
well "normally" the _esides would be dynamic so I dont know the sides..
units <side>
flatten [units east, units west]
Huh, that's a new one on me.
same
but if the sides are fixed the fastest way is units east + units west
sorry i forgot to mention the _esides would be random
then flatten (_sides apply {units _x})
that really faster? 
also using append instead of + makes this faster
try 
ok thx I will run some tests to make sure 🙂
Execution Time: 0.0251 ms
Execution Time: 0.0233 ms
Execution Time: 0.0257 ms
wtf?
ironically insert is faster 
Execution Time: 0.0249 ms
I guess it's a bug in append
with how many units per side are you testing?
yeah + is little bit faster than append (in my tests)
3 sides, ~40 units per side
it shouldn't be tho
like how insert is faster
I am using a mission framework that has a bunch of functions that are rarely used. They're defined via CfgFunctions{} in description.ext. AIUI, the only "dead weight" in this case is some memory and some loading/parsing time. Once the mission is running, it only eats a small amount of memory. Is that assertion correct?
what does AIUI mean?
As I understand it
Functions take up a small amount of memory when preloaded, but have no other performance impact if they're not actually running.
They do contribute a bit to file size which affects how long it takes to download the mission file from the server.
They do technically slow down all global variable lookups.
Yeah, I figure that some pollution of the global scope happens, but I figured that lookups there aren't any worse than O(n)
Is there a way to check if the mission is currently active? Like the PC is alive and being controlled by the player? And it is not just open in the editor?
I usually do !is3DEN (not in 3den) and allDisplays isNotEqualTo [findDisplay 0] (not in main menu)
for being controlled by player you can add a alive player or !isNull player
you can also check !isNull findDisplay 46 (mission is running)
Thank you
Another question. A script I am tinkering with is using _sideN = getNumber (configFile >> "CfgVehicles" >> typeOf _pvic >> "side"); and then compares that to 3 and 4 to see if a vehcile's base class(?) is Civilian. I presume this is because this ignores the occupants of the vehicle, and instead looks at what side it would be, had it spawned with default occupants. The comparison with 3 and 4 has two problems: it's not all that readable (compared to west etc) and I have no clue what side 4 is supposed to be. Are there better ways of doing this?
(_pvic being the vehicle the player is in by way of objectParent player)
The basic goal is to figure out if the player stole a vehicle from a side that is aggressive to them
#define SIDES_ENUM [east, west, independent, civilian, sideUnknown, sideEnemy, sideFriendly, sideLogic, sideEmpty, sideAmbientLife]
4 is unknown
it's not all that readable
you can define them as macros instead
for that you can check the side of the crew
well, it never had a crew
side group (crew _veh param [0, objNull])
if it has no crew you have to use the config method then
Imagine setting down an empty CSAT vic, and the player steals it. How do I distinguish that from the player stealing a civ vehicle?
I see, thanks. the #define will help with the numbering bit
where does that enum (and thus its order) come from? Just so I can put in a comment for future-me
BIS_fnc_sideID
thanks again!
#define SIDES_ENUM [east, west, independent, civilian, sideUnknown, sideEnemy, sideFriendly, sideLogic, sideEmpty, sideAmbientLife]
_sideN = getNumber(configOf _pvic >> "side");
if ([SIDES_ENUM#_sideN, side group player] call BIS_fnc_sideIsEnemy) then {
systemChat "Stealing enemy vic!"
}
wow, that just eliminates like two dozen lines of code 🙂
I owe you a beer (or other beverage of choice)
Hello. Maybe there are ideas how to create inertia for the player? I would like to make it so that the weight of the equipment would affect the movement and speed of the player's turn.
weaponDirection
for speed you can use setAnimSpeedCoef but for turn there's no command
another way would be enforcing a maximum turn speed and acceleration using setVelocityTransformation every frame (but it's kinda slow to do)
how do i print out a numbers full value without it being rounded?
toFixed
thanks
undefined, i.e NaN
if you do acos of a number for which abs(x) > 1 you'll get that
it's the same thing
how do i check if a number is NaN?
finite
thanks
idk what pythogoreum is... 
asin is arc sine
i.e. it gives the angle corresponding to a sine
well that's all I could do in paint 
and I wanted to explain it in 3D
note that if magnitude wasn't 1 you would have to do asin (_vec#2 / vectorMagnitude _vec)
but azimuth is still _vec#0 atan2 _vec#1 (if you want 0 to be north and angle is CW, like in Arma's getDir)
Hello, I thought that a local variable within a child scope is already defined if the local variable is defined in its parent scope. However, I am getting several errors about undefined variables and I am not sure what the issue is. Here is my code: https://sqfbin.com/oquximemufucaqikiqad
What am I doing wrong?
your code is not executed
you put it all into curly brackets
that just makes it be a code type value
Not sure if I understand. Deleting the first and last curly bracket does not sole the issue with the undefined variables.
what precisely are the errors?
All the local variables after
for "_taskruns" from 1 to _taskcount do {
are undefined
Although I defined them at the beginning of the script
there's again curly brackets inside your for loop
And?
you are doing
for (blah blah blah) {
{
//your code is here
}
};```
that stuff is not being executed
get rid of the double curly braces
I deleted all these brackets now as suggest: https://sqfbin.com/enosejapuhuroxegimam
But the local variables remaining undefined
I don't know how I can use the within the curly brackets.
you are creating them in a deeper scope than you are using them
Sorry, I don't know what that means
_spawnpos for example only gets created in the inner for loop
therefore it will only be valid in the inner for loop and scopes inside that
you are trying to access it from outside of the inner for loop
you need to initialize that variable before you enter the inner loop
for example add a _spawnpos = []; in line 42
that wont actually solve their issue it'll just get rid of the error
they want something along the lines of if (_rnd in [1,6,11,16]) then {continue};
i didn't look to deep into their code
Hmm, appreciate your help but I am a bit lost now.
You mean to change this in line 48?
no, read the local variables scope section of the wiki page i sent to you
On it
i want to disable the onboard laser marker on a vehicle.
Any idea on how to do it?
remove the weapon?
removeWeaponTurret 
or that
afaik it dont work on vehicles
prob i did something wrong then
possible wiki is wrong too 🙃
ohh im doing this on a drone, maybe is that
that's still a vehicle
it has nothing to do with drones
you should find where the weapon is
is it a main vehicle weapon? or a turret weapon?
drone laser pointer is a turret weapon, obviously
i used drone = allunits select 0 
i was using the crew instaed of the vehicle
is there a rate limit for scripted ehs
didn't know they were rated
5 out of 7?
if you mean "a max amount", no (but maybe int.MAX)
*24 bit int if so
a maximum amount per second or whatever
not adding just the eh being fired -- eh fired on people talking
no, EHs just trigger when they need to
Anybody know why my ungrouped indep units with default everything are hostile to each other
If you create units in a group of an enemy side (rather than joining them to the group later) then they'll be hostile to each other.
IIRC they'll even shoot each other if they're in the same group.
so im trying to get my ai to stop walking i've given them these commands and they stil want to walk is their anyway i can use the phsyics system to not let them walk ( if there isn't much i might just attach them to a can)
disableAI "MOVE"?
disableAI "PATH" is normally sufficient.
still be able to shoot/aim
was thinking lambs was getting in the way but should be disabled via their documentation
link for reference
What, you need not to let them shoot as well?
See if you can replicate the behaviour without Lambs. If not then report it as a bug or something.
good point
unit = group player createUnit [typeOf player, getPos player, [], 0, ""];
player remoteControl unit;
deleteVehicle unit;
```Apparently there is no way to remove remote control state from the player and its stuck forever 🤔
If anyone had experience with remoteControl and bullshit around it, please let me know
selectPlayer, switchCamera, remoteControl on a new unit, on itself, nothing helps
makes some sort of weird Arma sense given that the suggested removal syntax is objNull remoteControl unit
Yeah, the command is both weird and bugged
Couldn't find a way to fix remote control if controlled unit is deleted or fully dies (removed from group), you're stuck forever
selectPlayer to another unit and back doesn't fix it either
What's interesting it keeps AI unit stuck too
Made a ticket: https://feedback.bistudio.com/T171207
Using UAV terminal to connect to UAV fixes stuck control btw
So a hack fix would be:
- Spawn some UAV
- Give player UAV Terminal, connect it to UAV through script
player action ["SwitchToUAVDriver", player];- Delete UAV and Terminal

Now imagine a new scripter trying to figure this all out
https://feedback.bistudio.com/T82060 - can be set as resolved btw
https://feedback.bistudio.com/T128006 - poor dude making such a thorough ticket and nobody giving a damn about it
is “player action …” still required or can we just use “action …”
action is binary, needs both operands
And that action needs real connected UAV, doesn't work otherwise
check alt syntax?
🤔
👀
Yeah, action ["SwitchToUAVDriver", player] is enough
player action ["SwitchToUAVDriver"] works too
no argument needed
WTF is boundingCenter exactly?
Thought it might have something to do with offset between getPosASL and getPosWorld, maybe related to land contact position but nope
getPosASL and boundingCenter * -1 are at different Z
boundingCenter for Mohawk is [-0,-1.26353,3.54672], thus my assumption I need to add it to getPosASL
isn't it just the bbox's volume centre?
Lines around the heli are drawn with boundingBoxReal return
add unitAimPositionVisual to the list?
I am flabbergasted and willing to know more about it
Close to [0,0,0]/getPosWorld but not quite
I remember something about aiming point being an issue back in OA, with BAF Jackal specifically, it had its aiming point positioned super weird, front, left and bit above the vehicle
And it turned out that engine looks for hardcoded memory point name
Found it, aim point used to be hardcoded to zamerny memory point
Mohawk doesn't have it though, I guess it got changed in A3
I guess its calculated procedurally now?
depends on what you actually mean by that
Quad bike has the selection, but its different from unitAimPosition
probably construct in special way.
I think you can cast vector<vector2> to a game value and it will work, but vector from vector probably not
there is model center (0,0,0 when p3d is created), then there is center of mass, center of bounding sphere, center of bounding box
Oxygen 2's [0,0,0] coordinate?
yes
What a useless command 🤔
unless autocenter thingy where it gets moved according to... either bounding box or bounding sphere
Very misleading in its name, makes you think its related to boundingBox somehow
Should we update the Wiki to point this out?
We should
Found the only meaningful usage of it through google: https://foxhound.international/sqf-snippets/export-arma-3-to-terrain-builder
A script to export from Arma 3 missions or the Eden editor into the Terrain Builder object format.
Found a single official use in SSM module back in A2(OA?):
modules_e\ca\modules_e\SSM\data\scripts\init.sqf
// developer documentation https://wiki.bistudio.com/index.php/SimpleSupportModule
//-----------------------------
// Simple Support Module - SSM
// By LaKing, BI Studios 2010.
//-----------------------------
...
_newHeight = ((boundingCenter _x) select 2) + (((boundingBox _x) select 1) select 2) + ((getPosASL _x) select 2);
Won't be surprised if this command was introduced just for this module 🤔
WFSideText flashbacks
@still forum Can you please confirm what unitAimPositionVisual does now? Back in OA aim position was set from selection with a hardcoded name zamerny, but looking at quad bike it has this selection but unitAimPosition differs from it.
Was it changed to be auto generated somehow instead of hardcoded selection name?
seems to be geometry center
yeah geometry center (bounding box) by default, and zamerny IF it exists
Thanks, checked Quad again and unitAimPosition is equal to zamerny.
Command is needed if there is no selection though (like for Mohawk)
tiny difference in precision due to floats
Anyone has an idea how I can keep the ability to use map* when using switchCamera?
I just want switchCamera change the camera to a different view and that's it... no other stuff
Hello, is there a way to select the last element of an array without knowing how many elements are stored within the array?
_array select (count _array - 1);
And since last update you can do:
_array select -1
Negative indexes are selected from the end of array
[1,2,3,4,5] select -1 => 5
[1,2,3,4,5] select -2 => 4
Brilliant, thanks a lot for your help!
for things like this, what do I need to do to adjust object values in a script or trigger?
I want to have an interaction with one of these where players cannibalize one to replace another. But for that I need to be able to adjust these values. How may I do that?
Land_PortableServer_01_sand_F
That's an animation or animationSource.
I beleve to animate that object you need to use animateSource
https://community.bistudio.com/wiki/animateSource
Is it?
I mean I could have a look
Where would I find the object related stuff I would need to imput? Since im guessing you dont just do animatesource on an object and nothing else
Like the example given is
barGate animateSource ["Door_1_sound_source", 1]; // Open
You can check what that slider is doing by looking in config Attributes
Look in its animationSources in its config to see all possible animations
Alright
Here is a simple code you can add in init of that object to animate it opening and closing:
this addaction ["Open", {
params ["_target", "_caller", "_actionId", "_arguments"];
_target animateSource ["Server_Move_Source",1];
_target animateSource ["Lights_Off_Source",1];
}];
this addaction ["Close", {
params ["_target", "_caller", "_actionId", "_arguments"];
_target animateSource ["Server_Move_Source",0];
_target animateSource ["Lights_Off_Source",0];
}];
I found my ways but thank you
How can I compare two arrays? The following code gives me an error:
if (_selectedarray == _lastselectedarray) exitWith {
hint "Exit - same array";
};
https://community.bistudio.com/wiki/isEqualTo
if (_selectedarray isEqualTo _lastselectedarray) exitWith {
hint "Exit - same array";
};
could someone help i wanan try making so a opfor sqaud inside a trigger don't fire at bluefor only if blurfor attacks them then they turn hostile
how many BLUFOR?
anyway you can do it in 2 ways:
- make the blufor guys captives. that way opfor won't target them
- join the OPFOR guys to another side that is friendly to BLUFOR, then make them join the OPFOR side when BLUFOR attacks them
You could also have the group set to Careless, and change that when they're attacked, e.g. with a Hit or FiredNear EH
careless groups do attack tho 
Under what circumstances?
idk I seem to recall they do 
https://community.bistudio.com/wiki/AI_Behaviour
According to this, careless units will not typically attack, although vehicle gunners will (I remember seeing this actually, so that's still true). It also says they will attack if they have injured legs!?!?!?!?
So you could combine it with the Forced Hold Fire combat mode, to be safe.
Hello. I'm playing OPEX mission from workshop. Creator have made some script to it, that player can't hear (or see text) himself giving order to AI. Orders work, but I would like to also hear my guy speaking them. I found this code from function viewer (named DisabelingameRadio). Can you guys se from this am I able to overwrite code from debug menu? Or is there any other way to get voice outloud? Thanks for your help
Code is:
if (!isMultiplayer) exitWith {};
[
"Gemini_disableInGameRadio",
"onEachFrame",
{
private ["_allHumans", "_playerSquad_ALL", "_playerSquad_HUMANS"];
_allHumans = (allPlayers - entities "HeadlessClient_F");
_playerSquad_ALL = units group player;
_playerSquad_HUMANS = [];
{if (_x in _allHumans) then {_playerSquad_HUMANS = _playerSquad_HUMANS + [_x]}} forEach _playerSquad_ALL;
if (count _playerSquad_ALL == count _playerSquad_HUMANS)
then {enableRadio false}
else {enableRadio true}
}
] call BIS_fnc_addStackedEventHandler;
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
plz refer to the above.
as for your problem, you need to create a new mod to override anothers' function
I'm sorry, not sure did I understand. So I can't write some code to debug menu, but have to create new mod. (In editor?)
you have to create a new mod entirely to override another mod's function
Oh, ok. Thank you for your reply
IIRC opex had a setup screen where you could change the speaker's language and hide chat texts
Oh, I missed that setting🤦♂️ 😂 Thank you for letting me know
In this case you should also be able to remove that undesired feature by running ["Gemini_disableInGameRadio", "onEachFrame"] call BIS_fnc_removeStackedEventHandler from the debug console.
#arma3_editor message
what should i put as _targetPos? can it be something likegetpos invisible_helipad?
i used to place logs as a target position for cruise missiles xD
Yes, that would work (though getPosATL would be better in this case).
i need to send remoteexec from HC to Client, only thing i have is the remote Object that belongs to the client. Any idea how HC can get the client ID of the object ?
You can use the object itself (see the targets parameter on https://community.bistudio.com/wiki/remoteExec).
tried that already
let me try one more time with debug
players blufor
2
then making those guys captive might be easier
nvm its working, damn mission cache wasn't updated
you can try something like this in trigger activation code:
[{
player setCaptive true;
private _eh = player addEventHandler ["FiredMan", {
_this#6 addEventHandler ["HitPart", {
private _hitObj = _this#1;
if (side _hitObj == east) then {
[{player setCaptive false; player removeEventHandler ["FiredMan", player getVariable ["CaptiveFiredEvent", -1]]; player setVariable ["CaptiveFiredEvent", -1]}] remoteExec ["call", 0];
};
}];
}];
player setVariable ["CaptiveFiredEvent", _eh];
}] remoteExec ["call", 0];
it's a bit lazy but meh
and you can put this in trigger deactivation to make them targetable again:
[{player setCaptive false; player removeEventHandler ["FiredMan", player getVariable ["CaptiveFiredEvent", -1]]; player setVariable ["CaptiveFiredEvent", -1]}] remoteExec ["call", 0];
also make the trigger server only
😠
what about changing their combat mode to not fire unless fired upon?
meh. it'll still work 
not in the mood to write something else
it won't be terrible don't worry
so i post either one in every opfor uinit?
wat?
I told you where to put each code
first one is for trigger act, second trigger deact
not sync opfor to trigger?
if any further steps were needed I would've told you
you just need to copy paste the codes
ok so how does the code work for opfor in the trigger ai they won't shot any blufor players and not act aware only if players shoot them?
all opfor units will ignore the players while they're in the trigger and do not shoot any opfor unit
well while at least one of them is in the trigger
np
There's no way to do that other than emulating map behvaiour manually
how do i attach something to a map object? (e.g. attach a flag to a building)
A bunch of random things are tied into the current camera unit :P
it is not recommended to use attachTo because the simulation rate is low
"just" place the flag pole on the building where you want
when it join the lobby, if the mission its already running
afaik there is no way to execute code as soon the player join the server, and the mission its on the lobby
if there is any, ill need it to a modlist check
(i dont use verify Signatures)
missionEH OnUserClientStateChanged?
if i send the mission to the breafing phase, it should work
proper support for respawn templates pls
Maybe some developments that will help 3rd party spectator, or hopefully even redundancy of 3rd party spectator :P
i get it, but when the building is destroyed it just floats in the air
also, please ping me in the replies. thank you
I'm actually not aware of what that is?
Emulates the camera like the remote client sees it
scopes etc
When he ADS , camera shows it too etc
"VIEW": exactly what spectated unit sees (gun optics, binoculars, TI and NV, etc.) (1.30+ only)
Ah I see
That would be pretty sweet
I'd also love a command that returns the current camera object
Currently there's no general way to find out if some scripted system has switched to a camera
I know we're approaching the date but it isn't christmas yet.
What is everybody working on this evening
everybody?
Yes everybody
SilentSpike cameraOn?
Anybody know why you can't create a unit in a friendly group as in sideFriendly
I mean when something does cameraEffect ["Internal","back"] on a camera object
because it's not a unit side
There's no (practical) way to check for that
or should I say it has no center
Yup :)
So if I want to use that side can I just create the unit with a group in one of the 3 unit sides then set the unit's group to a friendly group after it's created
It is working in this manner
yes you can but weird stuff start happening if you dont let the engine handle side friendly and side enemy
So... no? :D
In this case it's not spectator though. It's revive system that uses ragdoll and everything about it works okay, just that I lose the map when incapped (Yes I know, not 'realistic', but that's not a reason for it not to work). I just set cameaView on the old body after respawn...
It works, I just meant under his circumstances
I just realized with the ACRE configuration for zeus you could technically go into the camera of a shell while in ACRE and scream
so you'd be flying down range screaming through ACRE
"I AM YOUR DOOM WEEEEEEEEEEEEEE"
cfgammo doesn't like setvariable
nope
you could make something with particle effects though.
But that requires config changes
you could have a building destroyed event handler to delete the flag on building destruction, or make the building indestructible
So it won't support addon X
how can i make the building indestructible?
but the building is a map object so it doesn't have a var name
and god BI made nearestTerrainObjects 😉
https://community.bistudio.com/wiki/nearestTerrainObjects
@digital wasp ^ (sorry, keep forgetting the ping)
it's ok
I'm trying to find where a bullet lands (every bullet, really) without it utterly murdering server performance in a large firefight