#arma3_scripting
1 messages ยท Page 731 of 1
from what I can see you just meant to put a string there
just wrap it in ""
I figured that too as I remembered about the whole string thing from yesterday's conversation with Lou.
But when I try running it, I get another error:
Error 1 elements provided, 2 expected
- default value is missing
Oh so I just need to make it like:
forEach (allUnits select {(side _x == east || side _x == west) && !(_x getVariable ["UFA_fnc_skillSet",false])});
yeah
Or would it be true in this case? 
ยฏ_(ใ)_/ยฏ

depends what you want to happen
looking at the code, false is what you want as the default value
That when it runs, it applies a variable (which by default is false) and any unit with that variable as false gets their skills set and then their variable changed to true. If its true, it skips that units. It then checks every 10 seconds to see if any units have that variable set as false, then repeat.
Atleast that is what I think I'm trying to do
You can delete the block that was once the first forEach-loop ๐
The entire thing?
Tho I guess that does make sense.
[] spawn
{
while {true} do
{
{
_x setSkill ["aimingAccuracy", 0.12];
_x setSkill ["aimingShake", 0.1];
_x setSkill ["aimingSpeed", 0.1];
_x setSkill ["commanding", 1.0];
_x setSkill ["courage", 1.0];
_x setSkill ["reloadSpeed", 1.0];
_x setSkill ["spotDistance", 1.0];
_x setSkill ["spotTime", 1.0];
_x setSkill ["general", 0.0];
_x setVariable ["UFA_fnc_skillSet",true];
} forEach (allUnits select {(side _x == east || side _x == west) && !(_x getVariable ["UFA_fnc_skillSet",false])});
sleep 10;
}
};
considering the east || west thing
Kinda late to this party, but does it have to be 3 letters, or is that just for conformity?
I know, but I've done with two :x
It doesn't do anything anymore. Besides, combining the two forEach-loops into one was the goal of this entire operation ๐
Or at least, I got something to work with SR_fnc_nameHere, dunno if I accidentally blew up Malaysia or anything.
Just like that, yes.
"Why did you become police officers?"
So I like how I started with this:
[] spawn
{
while {true} do
{
sleep 10;
{
_x setSkill ["aimingAccuracy", 0.13];
_x setSkill ["aimingShake", 0.1];
_x setSkill ["aimingSpeed", 0.1];
_x setSkill ["commanding", 1.0];
_x setSkill ["courage", 1.0];
_x setSkill ["reloadSpeed", 1.0];
_x setSkill ["spotDistance", 1.0];
_x setSkill ["spotTime", 1.0];
_x setSkill ["general", 0.0];
}
forEach allUnits;
}
};
And got to that.
Regarding the side _x == east || side _x == west, what would be the correct way to add the INDEP side to this?
at that point just do !(side _x == civ)
Like so?
forEach (allUnits select {!(side _x == civ)) && !(_x getVariable ["UFA_fnc_skillSet",false])});
Or am I brain dead?
Not brain dead, cause even reading this I know its wrong.
side _x isNotEqualTo civilian
you have a mismatched ) after civ (which would indeed be civilian not civ)
forEach (allUnits select {(side _x isNotEqualto civilian) && !(_x getVariable ["UFA_fnc_skillSet",false])});
Like so?
Or is 'isNotEqualto' just English for an actual code piece?
Fair enough
hey does anyone know a script that plays a static weapons animation?
i want to make a mortar fire for a screenshot
If you're just making screenshots, POLPOX's Artwork Supporter mod has a lot of useful tools, including a function to make weapons fire continuously, and the ability to convert something to a Simple Object which you can manually play with the animations on
I would recommend it over custom-making a script because of all the other useful things it can do as well
im using POLPOX stuff, the PLP_fnc_fireWeapon thing didnt work for statics so i thought i needed some other script for static / vehicles
plus i get some weird error when i try loading ammo with the Simple Object Placer
This is not the place for a full tutorial on that. I'll just say that you don't need to load ammo, just rightclick -> transform -> convert to simple object, rightclick -> transform -> simple object editor, turn on "zazleh" in the selections tab, and browse the animations tab for recoil animations etc.
ah thanks
Need some help on a simple parameter-pass to an sqf. My pseudocode is below:
_TrackList = [/*trimmed*/"];
};elseif param == 1{//OST + Menu
_TrackList = [/*trimmed*/];
};elseif param == 2{//ATD
_TrackList = [/*trimmed*/];
};
_TrackDelay = p2;
[_TrackList, _TrackDelay] call BIS_fnc_music;```
How can I set this up such that the required call is something that looks like `null=[p1,p2] execVM "ScriptName.sqf";`?
Quite simple:
params ["_trackListIndex", "_trackDelay"];
//Rest of the script ...
Additionally, since SQF has no else-if I recommend using a switch-statement instead.
_genpos1 = marker1;
_genpos2 = marker2;
General setPosATL selectRandom [_genpos1, _genpos2];```
is this code concise or is it bloated, I'm to start scripting by myself and was wondering if I need to define _genpos1 and 2 to variables,, or if I can use the variable names on the markers init in the array
I don't know why you're broadcasting General
if I can use the variable names on the markers init in the array
if you mean this, it's possible ofc:
General setPosATL selectRandom [marker1, marker2];
i thought since the general was a physical thing in the mission, it would need to have it broadcasted. thank you though
you're broadcasting the variable not the object
Well you need positions ofc
if its guy setposATL [m1, m2]; how does that not work?
https://community.bistudio.com/wiki/setPosATL takes position(array) as the right argument, you're passing it an object instead
gen setPosATL selectRandom [getPosATL marker1, getPosATL marker2];
so this would work?
yes, but what you're doing is not the best
by getting the position of the selected object instead of first getting every position and then selecting
how would i write that..?
getPosATL selectRandom [marker1, ...]
this way you only call getPosATL once, instead of getting it for every object, and then selecting it
genpos = getPosATL selectRandom [marker1, marker2];
gen setposATL genpos;```
so that would work>
yes, but you should use tags for the global variables
ok
see more here: https://community.bistudio.com/wiki/OFPEC_tags
are there any further resources on how I know what variables should be local/private or global?
https://community.bistudio.com/wiki/Variables https://community.bistudio.com/wiki/Code_Best_Practices#Variable_format i think those are the closest
thank you
So I put a switch into my code, but it still doesn't seem to work (I used the example call that is commented)
//null = [0,5] execVM "\b47_wz_music\scripts\SoundtrackPlayer.sqf";
params ["_trackListIndex", "_trackDelay"];
switch (_trackListIndex) do{
case 0: {_TrackList = ["/*trimmed*/"];};
case 1: {_TrackList = ["/*trimmed*/"];};
case 2: {_TrackList = ["/*trimmed*/"];};
//All, OST, ATD
//default All
};
[_TrackList, _trackDelay] call BIS_fnc_music;```
Here is the error I get: https://drive.google.com/file/d/1ToxqRAk98gEU3CwxJBY0RijZN7zIcWV5/view?usp=sharing
put a _TrackList = []; on top of switch, it is undefined outside switch.
Yes, this is the way of SQF (response to deleted comment ;))
you don't even need to use switch here, you can just make an array, and use https://community.bistudio.com/wiki/select
yeah this code is unnecessarily complicated. Regardless to say.
but yeah I never comment on these, using different stuff, building experience is good.
if (alive player) then {
0 = ["DynamicBlur", 400, [10]] spawn
{
params ["_name", "_priority", "_effect", "_handle"];
while {
_handle = ppEffectCreate [_name, _priority];
_handle < 0
} do {
_priority = _priority + 1;
};
_handle ppEffectEnable true;
_handle ppEffectAdjust _effect;
_handle ppEffectCommit 1;
waitUntil {ppEffectCommitted _handle};
systemChat "My head hurts, it should pass soon...";
uiSleep 60;
_handle ppEffectEnable false;
ppEffectDestroy _handle;
systemChat "I'm feeling better already.";
};
};
if (playerside isEqualto civilian) then {
player switchmove "AinjPpneMstpSnonWnonDnon";
player setDamage 0.9;
};
How do I turn _handle into a global variable?
When running in another script, I want to remove the blur effect.
first, 0 = is not needed
second, BETA_ppEffectHandle = _handle is enough to make it a global variable
and here you go!
Thank you so much for your reply.
is this right?
if (alive player) then {
player switchmove "AinjPpneMstpSnonWnonDnon";
player setDamage 0.9;
BETA_ppEffectHandle = _handle
0 = ["DynamicBlur", 400, [10]] spawn
{
params ["_name", "_priority", "_effect", "_handle"];
while {
_handle = ppEffectCreate [_name, _priority];
_handle < 0
} do {
_priority = _priority + 1;
};
_handle ppEffectEnable true;
_handle ppEffectAdjust _effect;
_handle ppEffectCommit 1;
waitUntil {ppEffectCommitted _handle};
uiSleep 60;
_handle ppEffectEnable false;
ppEffectDestroy _handle;
};
};
no
you still have 0 = before your spawn
you should set BETA_ppEffectHandle e.g after the ppEffectCommit
and don't forget to close the line with ;
if (alive player) then {
player switchmove "AinjPpneMstpSnonWnonDnon";
player setDamage 0.9;
["DynamicBlur", 400, [10]] spawn
{
params ["_name", "_priority", "_effect", "_handle"];
while {
_handle = ppEffectCreate [_name, _priority];
_handle < 0
} do {
_priority = _priority + 1;
};
_handle ppEffectEnable true;
_handle ppEffectAdjust _effect;
_handle ppEffectCommit 1;
waitUntil {ppEffectCommitted _handle};
BETA_ppEffectHandle = _handle;
uiSleep 60;
_handle ppEffectEnable false;
ppEffectDestroy _handle;
};
};
I edit it like this:
thank you. Now how do I remove the blur from another script file?
or switchmove stop
the same as here, using BETA_ppEffectHandle instead of _handle
BETA_ppEffectHandle ppEffectEnable false;
ppEffectDestroy BETA_ppEffectHandle;
Is this right? Sorry for my stupid script skills.
it is
It's just "standard" it doesn't actually matter
If you wanted to you could also just use a emoji
But they only work in get/setVariable strings
Thank you..๐
regex: ^[A-Z][A-Z0-9]{2,4}$
don't give them ideas
(originally posted by @graceful kelp)
Thx
Hey gyus,
What is the switchmove code for prone position?
see https://community.bistudio.com/wiki/Arma_3:_Moves
but you can also use theUnit playAction "Lying"; I think
Prefer playAction to playMove or switchMove
And even if you need to switch, you can easily do "switchAction" by reading the correct move from the config
Would someone be able to give me a hand with fixing a script? It's meant to half the weapon reload time of a tank cannon, however, when another gun on the vehicle fires, it resets the cannon, so if the commander is firing their weapon, the cannon is continuously set to reload while they're firing. I was thinking of trying to set it so that it just checks if the cannon has been fired instead of all of them, but I'm not sure how to sort it
this addEventHandler ["Fired",{
_this#0 setWeaponReloadingTime [gunner (_this#0),currentMuzzle gunner (_this#0),0.5];
}];๏ปฟ
you may need to keep track of the cannon's muzzle
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired
this addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}];
https://community.bistudio.com/wiki/setWeaponReloadingTime
unit addEventHandler ["Fired", {
_this # 0 setWeaponReloadingTime [_this # 0, _this # 2, 1/3];
}];
Well, my issue with the event handler info is that I don't quite understand how they're meant to be interpreted and then utilised. I'm just kinda getting into SQF, so it's a bit confusing for me. Could it just be a matter of checking for the specific weapon? If so, how would you write it out in the EH?
Is there a way to dis-/re-enable tactical pings for specific players?
I would like to disable a player ability to make a tactical ping himself and to see those of his teammates.
PS: I am talking about the HUD. I know about the ability to disable the tactical ping visibility on the map via the disableMapIndicators-command.
is there a way to create a scripted camera without blocking player input?
like to have the player still be able to move their character while the scripted camera is "running"
Hello, I have a simple question regarding HashMaps. I'm trying to create one and see how they work but nothing happens. I also noticed that the command "createHashMapFromArray" is not highlighted as a command, nor it seems to exist in the auto complete. Am I doing a mistake syntax wise? there is no error though.
private _WeapsArray= createHashMapFromArray [["arifle_TRG21_F",800] , ["arifle_Mk20C_plain_F", 900], ["arifle_MXC_F",1000], ["SMG_03_black", 1100],["arifle_AKM_F",1200]];
test1= _WeapsArray getOrDefault ["arifle_TRG21_F","Does not Exist"];
systemChat format ["Test%",test1];
If swing at a player while trying to place an object, that player will take damage.
How can I avoid taking damage?
Highlighted where?
You can just test it in debug console
I did try the console, Unless I'm doing something wrong I'm at a loss. What I mean by highlighted is that notice how in the example "createHashMapFromArray " is plain Gray? Same goes in Visual Studio code.
That's probably because the syntax highlighting Plugins are out of date, doesn't mean anything about ingame
Well did it work in console or not?
I think your code looks alright
I wrote three lines in the debug console:
_WeapsArray getOrDefault ["arifle_TRG21_F","Does not Exist"];--> No result
_WeapsArray get "arifle_TRG21_F"; --> No result
createHashMapFromArray [[1000,"Test1"],[200,"test2"]]; ---> Result: [[1000,"Test1"],[200,"test2"]]
1, don't name it array as it is not one
2, what is your Arma version?
Launcher version: 1.5.148470
Game version: 2.06.148470
private _hashmap = createHashMapFromArray [
["arifle_TRG21_F", 800],
["arifle_Mk20C_plain_F", 900],
["arifle_MXC_F", 1000],
["SMG_03_black", 1100],
["arifle_AKM_F", 1200]
];
private _result = _hashmap getOrDefault ["arifle_TRG21_F", "not found"];
systemChat format ["Result = %1", _result];
_result;
```I don't see any issue here
Neither do I but there is no print in the systemchat, I tried the debuglog and checked the RPT . I see nothing, does it work on your machine?
it works on my machine.
Does Singleplayer show systemChat?
yes afaik, and at least Eden does (confirmed)
Weird, I tried my debug console, but nothing comes through, Even when launched without mods the result is the same.
What does productVersion return?
I'm not asking for the document. I'm asking the duck
Yes, why not?! 
You might have a lot of codes in the scheduler that execute forever
vanilla debug console's button code is spawned
Yikes
Scheduler! ๐ป
More like... bugifier
Spooky Scary Scheduler
Send shivers down your spine
All your threads are now waiting
And can't wait of dying
It's used for running the code outside the UI context
otherwise stuff like createDialog or display would crash the game
But I only have this script running, Could There be something else running at the same time"?
try in vanilla, ZERO MODS AT ALL, in a VR Eden Editor session, without even starting the mission
Also if the command didn't exist in the game you'd get a missing ; error, not just no ouput
I actually did that, I just wrote the code in the console in an empty mission in VR
then check your game files cache, for something is very wrong if this doesn't work.
Steam file verification process:
Right Click on game -> Local Files -> Verify Integrity of game files
Mod repair process:
Open Launcher -> Right Click on mod -> Repair
No it does not, it only outputs if I write
createHashMapFromArray [ [100,"test1"], [200,"test2"]];
otherwise there's no input
??
console is unscheduled.
Right, So I did both. Nothing has changed, honestly an error or a crash would be welcome just to see something different.

the button's code itself is spawned
Hmm... I'm having a little trouble. How would I force the crew of a vehicle to stay inside the vehicle?
It's a modded AAT tank. Locked doesn't work.
I think it's the gunner and commander seeing the vehicle without a driver and that it was damaged, so it's disabled and they should abandon it? but idk...
if you want proof just try:
for "_i" from 0 to 10000 do {
[] spawn {
while {true} do {
for "_i" from 0 to 1000000 do {
true
}
}
};
}
good luck ๐คฃ
I have code that works, but they still sometimes get out. It's-
The senario save is still loading one sec xD
allowCrewInImmobile?
For the vehicle or the unit inside
vehicle
one sec, I have to spawn a civi again and give em a gernade xD
oh ok
Welp, that's new
I understand that you guys are busy people, but is there a chance I can screenshare with someone to check if I'm doing something wrong or the hashmap just doesn't like me?
Arma crashed. So fun
try my debug console too:
https://steamcommunity.com/sharedfiles/filedetails/?id=2369477168
I refuse your ninja, as I saw your message and wanted to provide the documentation link!
I meant you ninja'd me ๐
oh
I was gonna post the link too
that'd be a no
this addEventHandler ["GETOUT",{_this select 2 moveindriver (_this select 0);_this select 2 moveincargo (_this select 0);_this select 2 moveInCommander (_this select 0)}]
this seems to work though... Just curious if anyone had any better ideas
It works on you debug Console, Sadly. my init.sqf still does not work
I guess you might have a script in your mission with an infinite loop or something
as I pointed out before
what's wrong with your vehicle?
is it half destroyed or something? 
Well it's modded, so- I don't actually know xD
You may be right, The problem is I have nothing else running. the init has nothing else except the creation of the hashmap and a systemchat
did you verify the game like Lou said?
yes
you could just check its damage (getDammage)
what about DLCs?
or CDLCs?
I have not purchased any DLC's
is this the first time you're working with init.sqf file or you've done that before?
No its not my first time. A small update, the vanilla console sort of works and prints the corrects output but there's not output from the file when the mission is launched
โฆwere you using systemChat from init.sqf ๐
slap a waitUntil { time > 0 }; before it
or sleep 0.00000000000000000000000000000000000000001;
that won't work tho 
let me have my daily laugh
I know just saying so people don't actually do it ๐
I do not know what emotion to feel, should I feel anger that the script needed a sleep to print the systemchat? ,relief that its finally over, or shame that This is what I dragged two people into
all 3 ๐
Can't wait to stop scripting in Arma , its not my expertise as you can see
The command deleteVehicle for locally created objects causes an error Ref to nonnetwork object, what are the solutions to the problem?
naught
Ignore the error?
you can
1/ ignore the error
2/ not do the action
I mean, you could check if it's the server
Then if it is, continue. Otherwise, skip
You can do isServer right? Or am I remembering another API
isServer is a thing, but that won't help here
oh
Oh, wait, is it not just me who finds SQF annoying? :P
no such person has ever been reported, everyone loves SQF
shotgun pump noise in the distance
(I assume this is satire... Yay not being able to detect jokes sometimes!)
Also, I am not good with 3D movement when it comes to position and rotation. How might I have something that auto places stuff?
Basically, I have scifi doors and I think the attached image looks really cool!
oh wait I can't attach images...
It's okay, except for the scheduler
Not terrible for what was probably someone's first attempt at language design
Oh wait- If I tell the debug console to place something- will it do it... (In editor, not while testing the senario)
I am experiencing the ADHD laziness. I don't wanna place 2 tent lamps above each door. So instead I wanna spend double the time and double the frustration (atleast) trying to make something that does it for me! :D xD
yes
there's absolutely no better way to create a single threaded scheduler.
How? B/c "createvehicle" isn't working :P
it should
just know that object varnames don't work
you can refer to player, which is a command
I'm playing playing, I'm in the editor. With Senario, Edit, View and such on the top of the screen
aaand what is your createVehicle?
Land_TentLamp_01_suspended_red_F
no like, its code
Land_TentLamp_01_suspended_red_F createVehicle [0,0,0]
"Land_TentLamp_01_suspended_red_F" createVehicle (getposATL player);
@astral bone โ
otherwise, you create it at terrain's bottom-left ([0,0,0])
I mean- it's not making it in the entity list
unless it doesn't do that when createvehicle
If I play senario, it will spawn it when i run the command
oh
well it still isn't putting it in the entity list :P
no, it only creates an object
to create an Eden editable entity, you need something else
ok now how to I remove em... xD
you don't ๐ start and stop the mission, they will get removed
to create an Eden entity, use create3DENEntity
oh yea that makes more sense
And uh- How would I make it so it translates and rotates?
Basically, I know I can translate it to be offset by 1,0,0 but then if I want it to be offset and it's rotated, it wouldnt translate properly
Idk if that makes any sense xD
Can I set dir around an object?
yes, use getPos's alternative syntax
@little raptor , no!! ๐
it's a legit getPos usage!! ๐
I went like
for a sec ๐คฃ
wait is variable names with an underscore inheritly private? I assume no now...
oh huh
they are local yes
@sharp grotto You seen this ?
private _rot = (position this) getPos [1,(getDir this)];
_rot set [2,0];
private _lamp = createVehicle ["Land_TentLamp_01_suspended_red_F",_rot];
[_lamp, (3.5+((getPosATL this) select 2)), _rot,"ATL"] call BIS_fnc_setHeight;
_lamp setDir (getDir this);
probably horribly inefficient but
It sorta works... xD Only issue is- How to I do getPos?
rrread the doc! ๐ ๐
https://community.bistudio.com/wiki/getPos
No, I mean the first line. I am giving it the position and offset. But I must be doing the direction wrong
the thing is: what do you want to do (in human words)
Rotate around a center point.
wait
Lets say I have an object facing south. Then I want an object to be infront of it by 1 meter. So it'd be 1 meter to the south of the main object.
However if I rotate the main object so it's facing southeast, I want the sub object to still be 1 meter infront of it.
so you want to find "a position 1m in front of an object, whatever its direction is"
this is what you do here with getPos
Well, when i try it...
oh I can't show you b/c I cant post images... Can I post links?
Well, it's not where I want it to be
wait
no
might want to add 90 degrees oh yeeee
that's because it might be offset
createVehicle can take a "CAN_COLLIDE" argument to avoid "other objects check"
[_lamp, (3.5+((getPosATL this) select 2)), _rot,"ATL"] call BIS_fnc_setHeight; this actually gets around that :P
Yay! It's kinda far off the door, but I can change the distance
the "bruteforce" best way to be sure is to use setPos setPosATL after that
I think BIS_fnc_setHeight does setPosATL?
private _positionInFront = this getPos [1, getDir this];
_positionInFront set [2, 3.5];
private _lamp = createVehicle ["Land_TentLamp_01_suspended_red_F", _positionInFront];
_lamp setPosATL _positionInFront;
_lamp setDir getDir this;
_posATL may have been another name
It does need to include the this z, as it might be in the air. Err... Does yours do that?
ah true, missed that
private _posATL = this getPos [1, getDir this];
_posATL set [2, getPosATL this select 2 + 3.5];
private _lamp = createVehicle ["Land_TentLamp_01_suspended_red_F", _posATL];
_lamp setPosATL _posATL;
_lamp setDir getDir this;
```here you go
I want lights above my scifi doors to show if it's locked or not (Locked as in static)
I guess Lou's code will do then (although I wouldn't do it like that, but it should work)
after the error is fixed
_posATL set [2, getPosATL this#2 + 3.5];
I double fixed ๐
I think lou and I spotted it at the same time xD
Also, direction isn't fixed ;P
heading*
.
Is there a way to have multiple functions in a single file?
So I can have a value that is persistent...
oh wait
value that is persistent?
Like set up stuff. constant values
like immutable?
And also-
Alarms = [
[false,false,"ven_alarm",(getMissionLayerEntities "AlarmEmitters_Alarm0" select 0)],
[false,false,"luk_alarm",(getMissionLayerEntities "AlarmEmitters_Alarm1" select 0)]
];
// isOn, isRunning, alarmname, AlarmObjects
ALARM_LoopSound2 = {
params["_CurAlarm","_pos"];
while { _CurAlarm select 0 } do {
_source = _pos say3D [(_CurAlarm select 2),250];
waitUntil {(isNull _source || not (_CurAlarm select 0))};
if((_CurAlarm select 0)==false && not isNull _source)then{
deleteVehicle _source;
};
};
};
ALARM_LoopSound = {
params["_alarmnumber"];
_CurAlarm = Alarms select _alarmnumber;
_CurAlarm set [1,true];
{
[_CurAlarm, _x] spawn ALARM_LoopSound2;
} forEach (_CurAlarm select 3);
_CurAlarm set [1,(false)];
};
ALARM_Toggle = {
params["_alarmnumber"];
_CurAlarm = Alarms select _alarmnumber;
_CurAlarm set [0,not (_CurAlarm select 0)];
if(_CurAlarm select 0)then{
_alarmnumber call ALARM_LoopSound;
};
};
cfgFunctions seems to be only for ALARM_Toggle , not to initilize and allow the functions inside to be visible
when you don't even know what you wanna ask for...
oh
sqf does not have constants
use #define
or dont since you wont be able to refer to the value after compiling
in Description.ext you can define constants
you can maybe do constants in SQF with using compleFinal on a function that only returns the constant value
i just learned
Did you know that what @umbral oyster described here is most likely ( if done repeatedly ) the cause of Exile servers with high player numbers getting masskicks where the server just is like; oh no, to much in jip, to much ref to nonnetwork object and starts kicking half the server?
i feel like you have 2 questions but talk about them simultaneously
I am used to lua, python, c#... If I want a function/method, I can put several into a single file. I can then have a value defined outside those functions, but inside the file, so I can share the value's data between the functions.
With sqf, is that possible even?
Is possible.
use a global variable?
A global variable (variable vs _variable) is accessible to all scripts on the current machine
no, did not (are you sure of it?)
That would be the right way to define a function in cfgFunctions, but you can just save a function as a global variable in any file, and you can do that however many times you like
And wait, when I do the function inside cfgFunctions, how would I use them?
Pretty sure now that @umbral oyster pointed out that he found that behaviour. I know for a fact that it's happening because i've been discussing that problem with @sharp grotto. He is having that issue with his server. Some clients can create within Exile, cuz of the loot system and more, more then 6-10K local objects. Eventually the server jip gets 18mb and higher, server starts to get fps issues and randomly kicks like 30/40 players. Server with 65 player slots.
making them visible
When you define a function in cfgFunctions, all you're doing is defining it. CfgFunctions is a good place to do it because it's one of the first things that's done when the mission is loaded (so the function is available as soon as possible) and because it happens on all machines.
You then call the function with call, spawn, or remoteExec.
So for this, I'd define an array in description.ext that can hold bool,bool,string,objects?
@winter rose Not quite sure who Rabito already had contacted here, but from what he told me Dedmen and KillzoneKid are 2 people here that he reached out to. Most given answer to fix it was: go fix ur scripts in this discord while it's a command issue from what i can understand here now.
description.ext is not sqf
i know- i am confused... :(
Yes
Second, I'm just trying to figure out how your code is supposed to work
Do you know lua?
oh
i forget why exactly the 2nd bool is there... I think it's so it knows it's currently playing the sound?
@astral cypress You also might be interested in this. Masskick issue.
What's the overall objective of this script? Like, what's it trying to accomplish in the mission? A looping alarm sound?
Yes. Multiple. and from multiple locations
I have any numbers of objects that I add this action too
this addAction ["Toggle Alarm", {<ALARM NUMBER> call ALARM_Toggle},[],1,true,true,"","_this distance _target < 10"];
So the enemy carrier can have an alarm, enemy HQ on the ground can have an alarm, and so can the friendly carrier and friendly HQ.
They are all independent of each other. Enemy HQ alarm isn't sounding when another of the other 3 should be.
And then it can play from multiple locations.
So multiple speakers?
Then I have a layer called AlarmEmitters_Alarm<ALARM NUMBER> for each alarm.
Any object inside will act as a speaker and broadcast the audio
see #arma3_feedback_tracker
but from what I see it's about having plenty of local objects, not about trying to delete them
Yet the server log is getting 100K lines after "cannot find ref to network objects bla bla"
https://gyazo.com/0261782a731cdea9aa3fdc93c2cf031b Friendly Carrier
https://gyazo.com/89f26c15827c34aa059afadb61404585 Enemy Carrier
Gonna read #arma3_feedback_tracker, didnt saw rabito was busy there.
Then I could expand it somewhat easily if I wanted another carrier and HQ. Or say an air raid siren for a city
I shall look into this more later... for now...
How do I change a tent light's power? :P
There are probably some optimisations that could be made and/or missing ;, but this should get you off the ground. https://drive.google.com/file/d/1Vq1g9_grLFmofvr_GBadbwv4hVfk-1Ft/view?usp=sharing
I've moved on b/c adhd wee
how do I set a tent lamp's lightpower
Well that was a waste of 15 minutes then
I'm not sure if it's practically possible to change the properties of an object light source like that. If you want custom lights you'll need to create some #lightpoints.
[_this,_value] execVM 'a3\Props_F_Enoch\Military\Camps\scripts\setTentLamp.sqf' seems to work? <:D
That's probably just about the only object in the game it works on, that looks very custom-coded for a specific purpose
thats ok xD
aww yesh
Can add sqf this spawn { [_this,0,0] call DOORACCESS_PlaceAccessLight; }
to an object and it will add lights. _this being a door, first 0 being the door type, and second 0 is if it's locked or not. (1 means it's unlocked)
this is why I moved on
@hallow mortar B/c I was getting side tracked on a task that had already taken me about 3 hours ๐
why not just [this,0,0] call DOORACCESS_PlaceAccessLight?
...and where did you find this? That's not a BIS_fnc and there aren't any search results for it
DOORACCESS_PlaceAccessLight is a custom fuction
modified from this
So, ye, I spent- about 3-4 hours on making a dumb function I'll never use again :)
Be careful of locality. If you just run that in an object init field you'll create one light object for every connected client
if (isServer) then {
[this,0,0] call DOORACCESS_PlaceAccessLight;
};```
And I just change call with spawn?
Why?
Oh
It's calling it too soon
I have to wait until the object is present and stuff. I think..
if it's in an init field it won't run until the object is present
what is the exact error you are getting?
Where is the function defined?
init.sqf now
https://community.bistudio.com/wiki/Initialization_Order
If you want to use the function that early, define it in cfgFunctions
It's really not that difficult. A description.ext with defined functions is included in the file I linked earlier. If you look at it, you should be able to spot how it works.
Ah ok, and I see I can make a 'constant' value too. (Not really constant, but not meant to be changed either)
What would I call to do the alarmToggle?
fn_alarmToggle.sqf contains a comment describing how to use it. All the files also contain comments explaining how they work (with the assistance of looking up commands on the wiki)
oh
wait, no, I don't wanna use it that early
I wanna wait until the object is spawned in. B/c I don't think it's registering the fact the object isn't at 0,0,0
or something... idk
I got it so the cfgFunction works for the status light, I still needa use spawn but eh
Use what how early?
For Editor-placed objects, the object will exist in its Editor-placed position at the time the init field is run. (Some special aspects may not be fully initialised but the position will be correct). For this script, you do not have to "wait until the object is spawned in".
Idk what to tell you, if I dont have spawn it gives no errors, and it doesn't call it
You said the script was modified from Lou's example. Modified in what way?
params["_door","_doortype","_unlocked"];
if (isServer) then {
private _item = doorlocked select _unlocked;
private _values = doortypes select _doortype;
private _val1 = _values select 0;
private _val2 = _values select 1;
private _posATL = _door getPos [(_val1 select 0), (getDir _door)+(_val1 select 2)];
_posATL set [2, (((getPosATL _door) select 2) + (_val1 select 1))];
private _lamp = createVehicle [_item, _posATL];
_lamp setPosATL _posATL;
_lamp setDir ((getDir _door) * (_val1 select 3));
[_lamp,2] execVM 'a3\Props_F_Enoch\Military\Camps\scripts\setTentLamp.sqf';
private _posATL2 = _door getPos [(_val2 select 0), (getDir _door)+(_val2 select 2)];
_posATL2 set [2, (((getPosATL _door) select 2) + (_val2 select 1))];
private _lamp2 = createVehicle [_item, _posATL2];
_lamp2 setPosATL _posATL2;
_lamp2 setDir ((getDir _door) * (_val2 select 3));
[_lamp2,2] execVM 'a3\Props_F_Enoch\Military\Camps\scripts\setTentLamp.sqf';
}
So I am making my first mission, to put it simply the map is a small island off the coast of the main land, you spawn at camp on the small island, brief and gear up, travel by boat to man land, kill bad guys, leave.
The distance between both island is unfortunately very large and I don't want to have players waste 15 minutes literally just sitting in a boat. What I have been trying to do is have it so the players walk up to the boat next to camp, scroll onto the action "head inland", and then have it (for all players simultaneously) fade to black, fade out, and then have all players on a boat moving towards the main island. A nice smooth transition that still keeps them immersed.
Now I don't know much about scripting but from literally spending 5 hours today searching across YouTube and old forums, I have a script that makes the players teleport, but its super sudden, and they don't spawn in the boat they just get instantly thrown on top. It does it so fast the fade to black happens when you're already on the boat.
so yeah this is a cry for help
Okay, so...that's almost unreadable. Actually, mostly unreadable.
But it looks like it's relying on the doorlocked and doortype variables, which I assume are being defined in init.sqf. So I guess you do need spawn, then. And you only need if (isServer) either here or in the init field, not both (won't break it but is redundant).
There is probably a better, cleaner, way of writing that function, though.
post code
I know. And also, I actually put isServer in the main function and not in each object init
since it's slightly less code
_tele =_this select 0;
_caller = _this select 1;
[1, "BLACK", 5, 1] spawn BIS_fnc_fadeEffect;
_caller setPos (getPos (mine));
and that fade looks super janky as well
looks like you woke up after being knocked out
uh- Is Leopard20 here?
You should look at moveInCargo rather than setPos. And you'll also need a sleep to time it with the fade effect.
so replace _callet setPos (getPos (mine)) to like _caller moveIncargo (mine); or something similar?
It's slightly more efficient (not by a lot, but it could matter another time with a larger script) to do the server check in the init field before calling the function. That way, clients never call the function at all, rather than calling it then skipping most of it.
What I used, although I am also extremely new to this, is-
this addAction ["To Venator", {player setPosATL getPosATL LAAT_Venator_Teleport},[],6,true,true,"","_this distance _target < 20"];
``` then an object with variable name of 'LAAT_Venator_Teleport'
i am conflicted. I wanna have less code to copy and paste but then you have a point- xD
Yes. But if you want it to move all players, you'll need something like (like):
{ _x moveInCargo mine } forEach playableUnits```
don't use setPos and getPos... 
there he is!
They aren't going to use setPos and getPos (or any kind of setPos/getPos type command) because those aren't the right commands for what they want to do.
I see I see
why not? wasn't the question how to teleport the caller somewhere?
They want to teleport the caller into a boat, and I don't mean clipping into it
omg it worked
you're a legend!
its funny how simple the syntax actually is
I just over complicate it and over think it
It's simple until you want to do something that should be simple, but BI didn't think of it in 2013 and now it takes 3 separate functions
ahahaha
I do want to learn it more to do mission creations for friends and stuff
its a lot of fun when everything works together after hours of composition
Do note that this script could fail if the number of players exceeds the number of seats available in the boat. Taking that into account would be more complex.
The max players for the mission is 4 players
and the boat has I think 6 seats so we're safe
I'm trying to add sleep into the fade effect
so its a lot of cinematic
there's no need
just call it
(if it doesn't spawn another loop itself...)
call it?
There was a need because the fade effect isn't synced with the teleport - the teleport was happening before the fade was fully blacked out
If you want to use sleep you can't do it directly from the action code, because of things to do with the scheduler (it's complicated). So your action code needs to do something like:
[] spawn {
[1, "BLACK", 5, 1] spawn BIS_fnc_fadeEffect;
sleep 1; // however many seconds needed to line up, trial and error
{
_x moveInCargo mine;
} forEach playableUnits;
};```
you can
action code is scheduled
Are you sure about that? Because I'm pretty sure trying to do sleeps in action code has bit me before
In that case you don't need the [] spawn { and the last };. Everything else will work fine, just tune the sleep value to whatever you need to sync it up.
also I'm not sure how BIS_fnc_fadeEffect worked. iirc it just faded to black and stayed like that
if that's the case there's no need for sleep either (instead it should be called), like I said
There is a need for the sleep because it hasn't finished fading to black by the time the teleport happens. Since the purpose is to obscure the teleport........
it will be
again depends how that thing works
I haven't used that function before so 
Execution: spawn
๐ค
yes but you can call it from scheduled, and depending how it's written you might not have to do any additional suspending
it means scheduled
doesn't have to be spawned
how do you manipulate the fade effect such as taking away blur, fading into black then out?
I see the commands on the wiki but I'm not sure how to implement them, theres only one example
you just put in whatever you need in the order specified
[fadeInOrOut, blackOrWhite, duration, blur, music, ending, success] spawn BIS_fnc_fadeEffect
and make sure the types match
oh so its in that order?
and if you want to skip something you have to put in the default value
I set a AI unit unconscious withsqf _ai setUnconscious true;after some time a set it conscious withsqf _ai setUnconscious false; but he never get up again.
The unit is still alive, but stay lying down on the ground.
@low sierra
_ai playmove "UnconsciousOutProne"
I had a similar issue while trying to make a basic revive script; beyond just making sure it's called everywhere, sometimes you have to force the animation to free them up
Thanks! I will use:sqf [_ai,"UnconsciousOutProne"] remoteExecCall ["playMove",-2];
I will make a dead AI turn into a zombie after die.
So his death is fake.
Good luck ๐
๐
remoteExec zero
think of player-hosted servers, dangit
hello guys, whassup ๐
I have a problem with my script, i spawned a heli in the script like this :
_GG1 =[];
_heliback2 =[];
_heliback3 =[];
_GG1 = creategroup WEST;
_heliback2 = [getMarkerPos "paddi", 140,"B_Heli_Transport_01_F", _GG1] call BIS_fnc_spawnVehicle;
but the heli spawns in the air, how do I make it so it spawns on the ground? i am really noob at scripting,
i tried flyInHeight 0 but then it does not want to go to the location i just stays there
why not just use createVehicle?
because crew I suppose
yes, thats why i didnt use createVehicle ๐
well just do this then:
_GG1 = creategroup WEST;
_heli = createVehicle ["B_Heli_Transport_01_F", getMarkerPos "paddi"];
units createVehicleCrew _heli joinSilent _GG1
ok, i will try that, thank you
thank you, it worked, i just need to understand how it works ๐
It creates an empty group for later use. Then it creates a vehicle. Then it creates a crew for the vehicle (createVehicleCrew automatically detects the vehicle and creates its default configured crew) then adds the new crew to the group.
why not private _GG1 = group _heli;? yeah that โ instead, as createVehicleCrew returns the group
also if you want _GG1 to be the original crew side you can just do:
_heli = createVehicle ["B_Heli_Transport_01_F", getMarkerPos "paddi"];
_GG1 = createVehicleCrew _heli;
cause I wanted to keep the "original code"
you copy*cat* leopard ๐
I just create a vehicle and create crew for it... 
local variable
will be deleted after the scope ends, but be sure to use private
ok, thank you ๐
does someone has a script to decrease the viewdistance by fps laying around?
is there a good way to check if, e.g. the player has pressed the "throw grenade" button that respects the player rebinding those keys?
like e.g. in the above case having it still work if the player has rebound the button to "H" instead of "G"
yes. user action event handlers
what do you mean
like if fps is this then set view distance this and so on?
any way to extract a jpg version of the vanilla maps?
I am trying to build a admin tool that shows locations of units / vehicles in a web-browser
however to get the coordinates right I need a jpg / bmp file with the same dimensions as the original map
I have found some jpg files googling but they do not have the correct dimensions hence skewing all of the coordinates (making shit unusable)
if a vehicle is destroyed, is the wreck the same object?
It will have the same variable-name
(which is why I conclude YES)
Buildings however is different
does anyone know how to make AI stay in an area?
for example I have some enemies guarding an outpost but when they are in combat they just run out into the open which looks really dumb
I've already tried setting it to guard, but I don't want to have to resort to complete removing their movement
I just want them to stay in an area
in which file does setObjectViewDistance goes?
whatever file you like
that's unfortunate because in desciption.ext it aint working
That's why I was asking, I sadly couldnt find the wiki page stating the different file types
I was on that one, but wasn't there one with just a table where it stated the different file names and usages?
https://community.bistudio.com/wiki/2D_Editor:_External#Files
Slightly old info it seems but should work
sadly not the one I meant :/
Wha...
It was just a basic table, left side the file name and right side a pin-point explenation
If you have a big question about this one, you can contribute in #community_wiki with how it is confusing and what is needed
about what now?
I mean you've struggled with this
We can consider this is a very, very simple thing, so might not really documented in a straightforward way
It might be cool for beginners to state where such commands could go into
like for real woodie newbies
veiculo = _ambulancia addAction ["medic", {call action_colocar;}];
How can I add color to code like this?
Like what?
I want the message that appears when I roll the wheel to be colored instead of white.
veiculo = _ambulancia addAction ["<t color='#FF0000'>MEDIC</t>", {call action_colocar;}];Is this right?
Seems fine
Thanks
action_levar = {
_fe = nearestObjects [player, ["C_man_1"], 5];
_obj = nearestObject [player, "Land_Stretcher_01_F"];
_ferido = _fe select 0;
_ferido attachTo [_obj, [0, 0.20, 0.25] ];
};
action_soltar = {
_obj = nearestObject [player, "Land_Stretcher_01_F"];
_ambulancia = nearestObject [player, "Car"];
_obj = nearestObject [player, "Land_Stretcher_01_F"];
detach _obj;
ativo = false;
pegar = _obj addAction ["<t color='#9B111E'>lifting a stretcher</t>", {call action_carregar;}];
levar = player addAction ["<t color='#9B111E'>Lay the patient down</t>", {call action_levar;}];
_ambulancia removeAction veiculo;
player removeAction soltar;
};
How can I get the action to show for the cursor man?
To put it simply, it's not just displayed, it's displayed when you hover over a man.
levar = player addAction ["<t color='#9B111E'>medic</t>", {call action_levar;}];
isPlayer cursorTarget this command?
Sorry for the lack of English explanation.
I want to modify it so that the action only appears when looking at a person.
You will see the phrase "Lay the patient down" even if you are not looking at the person at the moment.
do you mean "for every man"?
cursorObject isKindOf "CAManBase"
thank you. How do I add that code?
see https://community.bistudio.com/wiki/addAction addAction's documentation; it's the condition parameter ๐
Yes i was thinking like: 3000*(diag_fps/100) where 3000 is the maximum view distance.... (Kind of cuz when the player has more than 100fps it will go higher but arma over 100fps in a mission ๐ )
If someone has a better way of calculatin a value to set as view distance based by performance of the player ...
you set some target framerate, and change the view distance at some fixed rate depending on the deviation of the current framerate from the target
Yeah bu not every pc can for example reach 50fps... So the math will result in a lower and lower view distance since it cant reach 50
so you set limits
do like _dist max 500 or something ๐
How can I reduce gun sway ?
setUnitRecoilCoefficient
take a knee or lie down, deploy (default C), use a bipod, don't be exhausted
there might also be setCustomAimCoef
that's for recoil, not sway? or does it impact it as well
yeah true 
So there is no way to remove it from a mission or server ?
not without a mod, and even that requires lots of modifications
ok thanks ๐
R3vo made a mod at one point
I think if you disable fatigue and set load coeff to a very low (or was it high?
) value you can reduce sway a lot
thanks all for your help ill investigate now !
hey, is there a fisheye effect in arma 3?
no
you can change FOV but that's about it
thank you, and is there a way to display the black vignette screen effect via script?
yes
private _emptyDisplay = findDisplay 46 createDisplay "RscDisplayEmpty";
no xD i mean this effect
call BIS_fnc_fatigueEffect;
well, you just did
make it stay permament
see BIS_fnc_fatigueEffect's content in the Functions Viewer, that should put you on track
Hey
Need some help
How does one go about adding music to the Zeus module?
I know how to use CfgMusic but no clue why it's not showing up in Zeus
Is there a way to force/fix the range of a mortar meaning that you can e.g. only use the "close" setting and can't switch?
afaik no
Basically I have seen this (https://youtu.be/0TvGSqpuRP8) and am now wondering if there's any way to make "smoke rockets" in Arma. I thought about adding a Mortar with Smoke shells only to a Ceasar but since you can't see the setting I would need to lock it to make the impact are predictable.
You can use regular rockets and a Fired event handler to replace them with smoke shells after firing
(Or just attach smoke shells to the rockets if you don't care about collateral damage)
That was my first thought too but the smoke shell doesn't seem to work. (Spawned one on the ground and triggered which worked but when I tried to attach it to the rocket it doesn't work anymore.)
this addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
_smoke = "Smoke_82mm_AMOS_White" createVehicle (position (_this select 0));
triggerAmmo _smoke;
_smoke attachTo [(_this select 6),[0,0,0]];
}];
First of all, why are you doing params and then ignoring all the params and using this select instead
I just copied it from the wiki.
The real question is why it is no getting attached to the projectile...
Well, you're triggering it before you attach it, so it might not exist any more
Created shells are still impact-triggered, so you can just leave it alone and it will go off when the rocket hits
Nope, that's not it. I just remove the tiggering and it still doesn't attach...
How do you know it doesn't attach?
Because it's smoking behind me while the rocket is flying forwards.
PS: I am also creating it at the position of the projectile now but that doesn't help either.
It sounds like it's colliding with something at its initial position and counting that as an impact. Find somewhere else to spawn it, where you can guarantee it will spawn in clear air with no obstacles (e.g. a position high in the sky in a corner of the map)
Jup, done that already ([0,0,100]) but that doesn't work either.
Can you try using Smoke_120mm_AMOS_White instead? I had some kind of problem with trying to use 82mm smoke before and I ended up just using the bigger shells instead.
Give me a minute, I have to figure out how to keep the plane from exploding now...
Because you probably created cfgMusic inside description.ext, instead of making it a mod.
Incorrectamundo :P
But we got it fixed regardless
did u use displayName instead of name ? :P
For some reason that works now but the smoke is all over the place (it seems that thing has multiple submunitions which are as far as about 500 meters apart at times)...
We didn't have CfgMusicClasses or musicClass entries set
Seems to work with the other ones as well now. No idea why. Arma never ceases to amaze me... ๐คฃ
Anyways thanks for your help.
anyone know how to make Ai stick to one area and guard it? for example holding an outpost when under attack instead of just running out into the open
is there a way to restrict their movement in a small area without entirely removing it?
by script, when not in area, move back yes
do I attach that to a trigger? or sync the unit to the trigger?
you are in #arma3_scripting , so in a script
hmm so when i use switchCamera while in 3p view it seems to "lock" me into the wrong external camera view distance
even if i switchCamera player again after
is that normal/expected or am i just using it wrong
do you use the syntax that sets the camera mode?
hmi have also tried player switchCamera "external";
which seems to have the same issue although i could have fucked it up
I don't know what you're talking about 
it works fine for me
well i should mention that i have really nonstandard external camera settings
on a custom unit that isn't a normal infantryman
yes please
you should definitely mention that
it seems like hitting switchCamera player actually just assumes default infantryman camera settings regardless of the unit type
so it is, in this case, too close (since i defined the camera position to be much farther back)
hmm if i do switchCamera _unit (where _unit is just the player unit) it works, but via very slowly interpolating the camera backwards
i guess that's actually good enough though
i defined the camera position to be much farther back
through mod?
yeah
via extCameraPosition in the config
(also by moving the camera bone in RTM but i'm not sure which one is more important)
hmm setVelocityModelSpace doesn't need to be remoteexec'd right
https://community.bistudio.com/wiki/setVelocityModelSpace if you look to the right of version, you can see it says "local argument"
How can I prevent the player from being damaged by objects?
Arbitrarily using a script to place an object and then if the player touches the object, the player is damaged and dies.
try not placing the object on top of a player?
how to use #define to set variable name and then use it as string ?
#define VARIABLE_NAME "TAG_var"
player getVariable [VARIABLE_NAME, 0];
does what you have not do what you wanted?
no
what is it exactly that you want to achieve?
@lost dock use #creators_recruiting indeed
see the wiki
you should use # and ##
Is there any way to fire off a smoke launcher, like a tank's, from a set position? Ive tried using camp_guidedProjectile, but the closest I could get was creating some 82mm smoke rounds which can work, but arent quite as impactful.
Im trying to set up a thing where a player has a smokescreen on a triggered action.
Quick question: On the Community wiki it says that if the "Fired"-Event handler is added in multiplayer on a remote object it only fires when the vehicle is within range of the camera. What happens if I add the event handler on the server itself, does it always fire or never because the server technically has no camera?
What do you mean?
so it seems like unit init code is run before the unit is actually assigned to the "correct" client for e.g. player units
what's the best way to initialize a player unit on the client (from a mod rather than a mission)?
local?
local?
does that always happen for player units at the beginning too?
it fires on change of ownership
right
hmm so in this case i'd do something like remoteexec addeventhandler to get that eh on every client in init
or is there a way to know which client a unit belongs to at init and i could remoteexec only that one client?
[intelUAV] call BIS_fnc_initIntelObject;
if (isServer) then {
intelUAV setVariable ["RscAttributeDiaryRecord_texture", "Images\UAV.jpg", true];
[intelUAV, "RscAttributeDiaryRecord", ["UAV Log", "4:00 โ Fuel low, return to base recommended, 5:00 โ Fuel critical, emergency landing initiated near 065-101, 5:10 โ Touchdown near 042-084 shutting down."]] call BIS_fnc_setServerVariable;
intelUAV setVariable ["recipients", west, true];
intelUAV setVariable ["RcsAttributeOwners", [west], true];
};
Hi, what do I need to add so the object WON'T be deleted when a player will pick up the intel?
Question
Is it possible to add simple objects to mission laters after mission start?
For example, we're looking to hyperoptimize our mission
So current plan is to delete unused layers of missions once players move on
However
With our current system, objects replaced with bis_fnc_replacewithsimpleobject aren't included in the layer and thus aren't deleted
Any way to add a returned simpleobject into a mission layer, or do we have to rig up a system to do it with arrays?
Yes, you'll have to grab the objects position and it's 3d model path then you can delete your original object and create a new one with createsimpleobject.
We're using BIS_fnc_replacewithsimple object :P
Hyper optimize, lol, thats impossible with arma.
We're trying XD
Relative hyperoptimization
Also
What is the locality of append? https://community.bistudio.com/wiki/append
arrays are not replicated between machines, so none
Purely within the scope of the script.
So, let's say I have an array of objects which I want to be known on all machines
i wouldn't word it this way at all
I want to be able to add new objects to that global array
And yet it only does something with a _private or global var
Assuming I'm using things like publicVariable, what would be the best way to do that?
depends. who mutates?
Goal is, I want to have a script I can place in object inits of objects in a large composition to make them simple objects
But have the array retrievable later on so I can delete
Why does it need to be public to all clients ?
I mean it techncioally doesn't, kind of only needs to be on the server I guess ๐
Hmm
Although
If I onnly have it execute on server
What's the locality of BIS_fnc_replaceWithSimpleObject?
Then write it to mission namespace
Good idea
๐คฆ Depends on the scope of the script your working within.
Sorry ๐ In a rush, I meant will it be replicated on clients if I execute it on server?
If you use on a a global var, its global on x machine, if you use it on a private var, its within the scope of that script, if you use it on a public var its known to the whole server / clients
Ofcourse not
Commands only do stuff within the scope of said script you're using
you don't really know what you're talking about, do you mr snail?
Maybe i'm describing it wrong.
the function says "replaceWithSimpleObject" so you can just look at https://community.bistudio.com/wiki/createSimpleObject which says "global effect"
English isnt my main language
It's okay ๐ I mean locality as in multiplayer locality, not as in execution environment
Also, is there a way to quickly check what 3den layer an object is in (if any) from object init?
Then im anwsering your questions indeed wrong.
i guess you can run https://community.bistudio.com/wiki/all3DENEntities (index 6 gives you the layers), combined with https://community.bistudio.com/wiki/get3DENLayerEntities and perhaps a findIf that checks if the wanted object is in it(that would be the layer index)
i'm not familiar with the 3den commands, but that seems to be a nice starting point
Hi-
I'm a little unfamiliar with event handler scripting. I want to have multiple event handlers (doesn't matter if it's serverside or global) be able to trigger a script, but I don't want multiple executions. So "OR", in other words. What's an elegant way of doing this, besides several deletions of event handlers upon first execution?
what event handler are you talking about?
MPKilled
and what exactly do you want to do?
I am makign this sound more complicated than it is ๐
OK. Players start a mission at an enemy base, where they can take the vehicles (cars) to the next objective. However, chances are reasonable they will lose the vehicle. Instead of a regular vehicle respawn, I want civilian cars to drive by, that are easily hijacked, once either of their first base vehicles have blown up.
The civilian vehicle drive by part is straightforward (literally).
And I have done things like this with triggers in the past. But I want to improve mission performance/reduce bugs, so I thought trying eventhandlers would be better.
Triggers delete themselves once executed, so that cleans up loose ends. But how do you wrap up multiple conditions of event handlers simply?
what multiple conditions?
Either of their vehicles being destroyed.
you just add the EH to the vehicle. once blown up, you order the civilians do drive their cars to the objective
Yes, but then you have multiple event handlers for each vehicle
so that creates multiple executions of the same code.
no, why multiple?
just one (per vehicle)
I have 2 vehicles, and I add an eventhandler to both of them, and I activate both handlers, I will ahve 2 executions of the code, yes?
so you mean you want the civilian to only do that once?
I don't know how long the players will take for the mission, so my civilian car spawn will create new cars and drivers every few minutes or so.
why?
Long story short: I want ONE script activated by Multiple eventhandlers arranged in OR.
just create the vehicles when the original ones are destroyed
I understand that magically respawning the cars in the same spot is programatically the simplest solution. But just like the many ambient civilian scripts, I think it adds immersion to a mission if civilian cars and drivers are added in a pseudorandom fashion. I can make the pseudorandom car script. But I want this one script, executed once. How do I tie together multiple event handlers to start the script only once in an OR ?
no need for "OR"
just use a global variable
car addMPEventHandler ["MPKilled", {
if (!isServer || {missionNamespace getVariable ["alreadyActivated", false]}) exitWith {};
params ["_car", "_killer", "_instigator", "_useEffects"];
alreadyActivated = true;
//call your script here
}];
Ah, of course, a global variable. Thank you.
how about you keep track of the number of vehicles available to the player, and if it goes too low you create more?
so the starting vehicles count, as well as any active civilian vehicles that are driving around. when any of them is disabled, you count that one out
@pliant stream OK. So I create function that periodically checks how many members an array has, or were you thinking of something in particular?
you can still use events, though you have to decide what it means for a vehicle to be disabled
is it only when the vehicle is killed? does destroying a wheel count?
Hmmmmm. Interesting idea, but I can think of many situations where players will abandon vehicles, where I would have to program extra conditions. I don't mind if the (rather large) mission (that will take 90 mins tops) will get a lot of leftover cars.
But interesting idea! I just repeated myself ๐
okay, alternatively you could just keep track of active civilian vehicles driving around
I don't mind if
well you don't. what about the poor players' PCs?!
when one is disabled you create a new one
Ha. 6 players max. About 50 AI units total (spread over several km2). No cluster bombs or craziness. On an AWS Dedicated server. It'll be fine, I think.
But good point.
Yeah, I'm lucky that my mission takes place on the coast of Altis. Players make their way down from Fotia to Kavala. It's mostly a single road. So I just spawn and despawn units from end or the other. So I am afraid I will be lazy (๐ฅธ ).
Is there any solution out there for IR flashlights/illuminators?
Yeah
Either just make a IR flashlight as a mod.
Or spawn a reflector and attach it to gun
was recommended to post this over from the editor and mission making threads - Hi all, would anyone have a solution for this - while creating a mission on a custom map with Ravage, everything works well (loot, gear, AI, etc.), but this crazy annoying bug happens - in towns/villages, this caravan model "Land_Caravan_01_green_F" keeps spawning in random and absolutely buggy locations. This seems to be an attempt to generate "lootable" buildings, but fails. My question is, how would I approach to ensure this model gets deleted around a reasonable distance from the player? This is SP, btw.
I'm not sure if I'm missing something here but I thought that by default arma only supported a visible light flashlight or IR laser - is this something that has changed since I last looked?
2.08 gets non-IR lasers
Yeah you'd probably have to script that.
Spawn a #lightReflector or.. #reflectorLight or smth don't remember.
Then attachTo with followbonerotation to head, and setLightIR to make it a IR light
Oh I'd just have the IR illuminator as a separate attachment
in the flashlight slot
so you can choose to have with/without
Ah I thought you meant attached to the NVG item :D
aha lol
Which I'm pretty sure doesn't support having lights on it
Tho headlamp would be neat
nah more like this https://i.imgur.com/9dFuEkz.jpg
ACE mod is working on IR flashlights, I think RHS and CUP too
cool
aha found the details. This is so cool. One last follow up - is there a setViewDistance equivalent command for PiP view distance?
Afaik no
ok, no problemo. Thanks!
Hi again. It turns out I have forgotten how to script waypoints (in newly created units). I want to create a civilian car and make it drive to a waypoint.This is my code:
newcivgroup = creategroup civilian;
newcar = "C_Hatchback_01_F" createVehicle (getposATL civstart1);
createVehicleCrew newcar;
newcar setDir (getDir civstart1);
newcivgroup addWaypoint [(getposATL civend1), 5, 0, "endpoint1"];
newcivgroup setWaypointBehaviour "CARELESS";
newcivgroup setWaypointSpeed "FULL";
newcivgroup setWaypointType "Move";
newcivgroup setCurrentWaypoint [newcivgroup, 0];```
civstart1: an invisible nonsimulated car object
endpoint1: an invisible nonsimulated car object
The result is a fully crewed new hatchback, that does not move. Note: I *can* script new waypoints for cars already placed in the Editor. It's just ones created by script. What step am I missing?
you're giving the order to an empty group
also why on earth do you use so many global variables?
ha! you're right
I'm using global variables for troubleshooting. Thanks
Of course end result will not use global variables
well
newcivgroup = creategroup civilian;
createVehicleCrew already creates a group and returns it to you
newcivgroup setCurrentWaypoint [newcivgroup, 0];
addWaypoint already returns the waypoint
yes, you're right; I was doing things double. Had been messing around for 30 mins and just decided to cover every base I could think of.
does forEach support doing stuff like appending to or deleting from the array inside the loop?
no
appending = infinite loop
deleting = skipping next element
ok so it's just an iteration over an index into the array
not some fancy iterator construct that copies the state or whatever
It iterates by index
is there a "batch delete" function anywhere, in that case?
deleteRange
well for non-adjacent indices
or -
like if i know i want to delete indices [0, 4, 5, 8]
and i only want to perform the "move" once instead of 4 times
if the array is not large just use -
it's fast (enough)
ofc if you have duplicate elements then it will delete all instances
does A-B calculate the set difference between the arrays, preserving order in A?
yes
just note that it won't work with nested arrays
is this just because it cares about reference-equality and nested arrays tend not to be actually the same reference
or is there an additional layer of special-case logic on arrays
ยฏ_(ใ)_/ยฏ
I'm not a dev.... 
It does value equality but not recursive
oh i see, so one level of nesting will work but two won't?
It only removes element X from array.
Not element X from array in array
oh i get it
sorry i was thinking about the case where X was itself an array
so e.g. [[1],2] - [[1]] would work, right
no
actually it seems like it works in Arma 3 (according to wiki)
_result = [0, [0], [[0]]] - [[0]]; // [0, [[0]]] - Since Arma 3
_result = [0, [0], [[0]]] - [[[0]]]; // [0,[0]] - Since Arma 3
pretty sure it didn't use to work tho (you had to set the elements to a non-array value to delete them)
Yes, cuz value equality
doesn't work in A2, no
Don't know what A2 did differently there 
Maybe related to the isEqualTo stuff
it just doesn't have any array equality
in, find, set difference, none of it works in A2
makes sense
so you can send anonymous functions over as remoteExec params right? how does the scoping for those work
like if i do [{ SomeVariable; }, SomeVariable ] remoteExec ["foo"]; that would call foo with the remote value of somevariable, then the local value of somevariable, right
if you mean "code", yes
and that just gets executed in the global namespace/scope?
foo with the remote value
wat?
it has to be a variable containing a code, or command
and it must exist on the target machine
well in that case (i assume) { SomeVariable; } gets executed on the remote machine, returning the value of it there, but SomeVariable gets executed on the local machine and that local value is then passed to the remote machine
so foo gets two arguments when it's called on the remote machine, that can be different
does that seem right?
yes, but what you wrote won't execute
unless foo is a function that executes the code
yes assume in this example that i have defined a function in the global namespace called foo, somehow
yes
are preinit functions called in the order they're listed in CfgFunctions? or is the order undefined/random

can initPlayerLocal.sqf be provided in a mod
and if not, is there a good alternative for it
If it's a non player postInit (server) player will be null, otherwise it shoooooould be set
Can also check !isServer
That's probably smarter 
Got an issue, trying to make a hold action for a PvP mission, but it doesn't seem to work on a dedicated server, but shows in editor & local hosted
The action doesn't show up at all
initServer.sqf sqf [] execVM "DNRWin2.sqf";
DNRWin2.sqf ```sqf
_flag = flagObj;
_afterCommand = {};
_fncOwnFlag = {
params ["_winSide"];
_flagPath = "%1.paa";
_fileFlag = switch _winSide do {
// case west: {"flag_nato_co"};
case east: {"\rhsafrf\addons\rhs_main\data\flag_dnr_co"};
case independent: {"\po_main\data\ui\flags\flag_ukr_co"};
default {"\po_main\data\ui\flags\flag_ukr_co"}
};
format [_flagPath,_fileFlag];
};
_actionParams = ["_flag", "_caller", "_actionId", "_arguments"];
_flag setflagAnimationPhase 1;
_flag setFlagTexture (independent call _fncOwnFlag);
_flag setVariable ["TER_flagSide",independent];
_icon = "\a3\ui_f\data\igui\cfg\holdactions\holdaction_takeoff2_ca.paa";
_duration = 10;```
_addID = [_flag, "Set up DNR flag", _icon, _icon,
"_target getVariable [""TER_flagSide"",independent] != side _this && _target distance _this < 4",
"_target getVariable [""TER_flagSide"",independent] != side _this && _target distance _this < 4",
{},
{
params ["_flag", "_caller", "_actionId", "_arguments","_progress","_maxProgress"];
_arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
_relProgress = _progress/_maxProgress;
if (_relProgress < 0.5) then {
_flag setFlagAnimationPhase (1-(2*_relProgress));
} else {
if (_relProgress == 0.5) then {_flag setFlagTexture (side _caller call _fncOwnFlag)};
_flag setFlagAnimationPhase ((2*_relProgress)-1);
};
},
{
params ["_flag", "_caller", "_actionId", "_arguments"];
_arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
_flag setVariable ["TER_flagSide",side _caller];
[] call _afterCommand;
sleep 5;
["DNRWin2", true] remoteExecCall ["BIS_fnc_endMission", 0];
},
{
params ["_flag", "_caller", "_actionId", "_arguments"];
_arguments params ["_actionParams","_fncOwnFlag","_afterCommand"];
_flag setFlagAnimationPhase 1;
_side = _flag getVariable ["TER_flagSide",independent];
_flag setFlagTexture (_side call _fncOwnFlag);
},
[_actionParams,_fncOwnFlag,_afterCommand], _duration, 1.5, true, false] call BIS_fnc_holdActionAdd;
_addID```
Followed some help on the BI forums and asked about this in the past here, but didn't get around to trying on a dedicated server until now
Adding hold actions on server doesn't make sense, actions are client side, and I'm not aware of holdActionAdd doing remoteExec
So I should run it in the init.sqf instead?
Aka, not in initServer, but initPlayerLocal
Alright, will try that
hmm should i worry about stuff like isDedicated vs isServer here
ahh dang..
isServer is bad, because if you self host, you are the server but also a player.
isDedicated would filter server and HC
wait are headless clients isDedicated?
oh i see
well that's nice actually
hm i guess maybe if (!isDedicated && !isNull player) to be safe
actually ill just try only the isdedicated check for now, that looks like the right thing 
I currently have vehicle player in thisList, for detecting players in a trigger, and later also executing a script on them, is there an equivalent of player for player+ai?
I tried object, anything, & anybody but that didn't do anything, and didn't find anything else on biki
Through I might've looked poorly
what's the point? a trigger already does that
I later excecute a script on them:sqf [] spawn { hint "You have exited the operations area. You are about to die."; sleep 5; player setdamage 1; };
So I want to replace the player with something that affects AI too
I mean what's the point of writing a custom condition?
I later excecute a script on them:
usethisListlike you did before
It didn't work until I did it that way, why thats the case I don't remember, to long ago
Where would I put that? thisList setDamage 1;?
thisList is an array
you have to iterate over its elements
see forEach
Alright, will do
{_vehicle setdamage 1} forEach vehicle thisList;
{_player setdamage 1} forEach vehicle thisList;
{player setdamage 1} forEach units thisList;
Tried these, and some other combinations, all give same error that thisList is undefined
I don't understand why, since as far as I see it's defined in the trigger activation
you use them in the spawn
they're not defined there
also you're using them wrong
this
ah, so I should re-define it all with vehicle player in thisList inside the spawn too?
depends what you mean by "redefining"
The error I kept getting before was that "thisList is not define", so I assume I have to define it again by grabbing all of the units that enter my trigger
The code was so short & worked perfectly with only players.. how come it gets so much more confusing when I try to make it detected AI too?(
because you're making it complicated unnecessarily
Well, I don't know how not to do it))
I assumed there was a single word I could replace player with and it would work just like before
I have just a little over 0 knowledge of mission scripting, so I have no idea whats being done wrong here or how I go about fixing it
So please excuse my possibly awful questions)
for starters get rid of this condition
it makes no sense to show hints for AI either
neither for other players
so this should only show the hint to the player that exited
Currently it does that
it doesn't
Only I saw the hint when I tested it on a dedicated server, but I'll take your word for it
I replaced condition with just this
well it's because of that condition
Alright, got it
is there a way to "block" on a remoteexec? like if i wanted to do
[_x, owner player] remoteExec ["setOwner"];
selectPlayer _x;
but i wanted to make sure it worked and didn't go in the wrong order
as for the rest of this:
set the trigger to server only, and put this in for the code:
[thisList] spawn {
params ["_list"];
_players = _list select {isPlayer _x};
["You have exited the operations area. You are about to die."] remoteExec ["hint", _players];
sleep 5;
{_x setDamage 1} forEach _list;
};
also set the activation stuff to ANY PRESENT
Set to anypresent & server only already
I don't see the point of that code, but you can just use a callback
well i want to switch the player to a remote unit
also that code is wrong
since selectPlayer only works on local units
setOwner is serverExec
Alright, want to try and understand what this does then:
Firstly, params ["_list"] defines the part of thisList? Or is that a new variable?
you're executing for all
how does one use a callback
_players = _list select {isPlayer _x};
this selects the specific player in the trigger rather than giving the hint to the entire server I assume
or by "callback" do we just mean "have the remoteexec'd target send you a remoteexec back"
I'm passing it thisList into the spawned code
{_x setDamage 1} forEach _list; & this damages everything in the thisList because of the params above?
yes, that
Alright, gotcha
& the rest I understood
I doubt it but ok ๐
Well, understood enough to be able to copy-paste it where needed I hope)))
Alright, worked perfectly, thanks alot!
& if I want to make it side specific, I just change the activation to e.g. OPFOR and nothing else?
yeah
there's a problem with triggers tho. if you put one object in there the trigger will activate, and it won't reactivate as long as it's activated by that one object
so other objects can roam freely...
altho not for long in this case
that object will die in 5 seconds...
Yeah, I noticed that since the vehicle I was in died in 5 seconds, and I did 5 seconds later
I guess I can either reduce the timer or extend the trigger zone so nobody can slip through it in those 5 seconds
you could use loops instead
I think my caveman plan of just making the zone bigger will suffice for now))
I also have a trigger before that one which warns them to turn around, so there should be enough time to rethink before dying in a huge ball of flame
If it does cause problems however, how would I go about making it loop?
I guess making the loop after the trigger activation until after all objects inside are dead?
Would smth like this work?sqf [thisList] spawn { params ["_list"]; _players = _list select {isPlayer _x}; ["You have exited the operations area. You are about to die."] remoteExec ["hint", _players]; sleep 5; {if (alive _x) then {while {alive _x} do {{_x setDamage 1} forEach _list;}; }; }; };
Nvm, that broke it(
I guess I'll just lower the cooldown to make sure nothing can slip through
I meant use a loop instead of the trigger entirely
ah, well that is probably way out of my knowledge then))
Throwing 4 tanks to charge through the trigger at full speed resulted in none surviving, so it's good enough for now)
That works, thanks for the help!
But now the code executing & finishing execution is only visible to the player doing it, but nobody else (flag being lowered & replaced)
Can that be fixed somehow, should I use smth other than initPlayerLocal, or am I out of luck?
This is for codeProgress, codeCompleted, & codeInterrupted
hm does anyone know if there's a good way to make ACE stamina/medical not apply to a specific unit
i think the only way you can do it is a hacky solution, you basically want to poll cba_common_waitAndExecArray and remove the array element that handles fatigue, which is ran recursively every second, https://github.com/acemod/ACE3/blob/master/addons/advanced_fatigue/XEH_postInit.sqf#L66 https://github.com/acemod/ACE3/blob/master/addons/advanced_fatigue/functions/fnc_mainLoop.sqf#L81
is there any way to hide city names in the map?
Does this look okay for defining functions in description.ext? Do I need the extra sub-class? or is this fine?
class CfgFunctions {
class TRI {
class lootSpawn {
file = "functions\lootSpawn.sqf";
};
class vehicleSpawn {
file = "functions\vehicleSpawn.sqf";
};
class gameFlow {
file = "functions\gameFlow.sqf";
};
};
};
also is the way I formatted this frowned upon in any way or does it look good?
If is recognized properly, should be shown in Functions Viewer
Hey guys!
I want a civilian counter so if x amount of civilians are killed, something happens.
Now I have a code from BI forum that works and I just need to refine the EH of the civilians..
This is what we came up with
if isServer then {
{_x addMPEventHandler ["MPKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
if (isplayer _killer) then {
call fnc_countCivDeaths
};
}];
}foreach allunits- allplayers;
};
Problem - foreach allunits- allplayers
Includes Opfor, I know
I need to define it so it'll be ONLY civilians, and I'm concerned that Arma treats animals as well as civilians. How can I make sure it count ONLY civilians and not rabbits / snakes..?
Thanks a lot!
You should try forEach (units civilian) :)