#arma3_scripting
1 messages Β· Page 654 of 1
And how will i have to set this up in Notepad?
How will the script check, if PC1 or PC2 has already been hacked and not to add the addaction back into the PC?
Notepad? 
Im using Notepad++, yes.
notepad++ is not notepad
lel
anyway, I think your code should work as it is (not to say it's good)
just replace those two lines
wherever you use addAction, use this (to store the actionID):
_actionID = something addAction ["blabla", {...}];
something setVariable ["some_action_ID", _actionID];
and wherever you remove the action, use this (to get the actionID):
something removeAction (something getVariable ["some_action_ID", -1]);
of course, something is whatever you're adding/removing the action to/from.
@still forum speaking of intercept, I'm assuming that each plugin can only lock the game if the total execution time is less than 3ms right?
In other words:
plugin1 locks -> 1 ms code
plugin2 locks -> 2 ms code
plugin3 -> is ignored during this frame because we reached the 3 ms limit, so it happens in the next frame
is that correct?
also, each code is "unscheduled" right? (if one plugin locks and executes a 1000ms code, the game freezes for 1 second?)
yes
I'm referring to this:
https://community.bistudio.com/wiki/callExtension
The extension execution timeout, after which 301: EXECUTION_WARNING_TAKES_TOO_LONG warning is issued, is hardcoded on clients and is 1000.0 milliseconds (1 second). On the server the default limit is also 1 second, however it is possible to set custom limit with callExtReportLimit param (see Server Options).
also intercept is not fair share like SQF.
in your example above.
next frame again starts with plugin1, then plugin2, and plugin3 might again not get its share
It says there's an invalid number in expression. using your older script works, but sqf will not trigger
its a log message, it isn't stopping execution
ah that's bad 
that's not the full code
you must adapt it to your code
trying to get an ai controlled plane to fly level during an intro segment but flyInHeightASL doesn't appear to be working
anyone know why that might be? setup this code in the planes init:
this flyInHeightASL [260, 260, 260]
anything else i'm missing?
tried it with the waypoints too
bit of an odd behavior going on. I am keeping track of objects in an array that we save orientation bits, and registered variables for.
this is saving okay, have verified. when things re-load and restore, I am finding duplicate objects piling up.
the orientation bits are consistent, but the first instance has no variables.
I think possibly there is an instance landing in the array first.
then the variables are restored, and THAT instance lands in the same array.
does A3 treat objects+variables as unique (?)
I want to know whether it is possible to give a player a custom load out and give them the ability to spawn in with it every time, instead of having to manually load it from an arsenal. Any ideas how I can achieve this easily?
You can make a sqf with a custom loadout and load the sqf from player init
https://www.google.com/search?q=arma+3+respawn+fixed+loadout π€·ββοΈ
Several reddit and forums posts which explain how to do it
Donβt worry my buddy found a way. Just ticking something like: respawn with same load out
Is there a template for that .sqf? Im kind of new on making this things
I've got two PCs that should be hacked and a task that will should say something like "You hacked %1 computers!" when the two are hacked, though I want the task title to count by itself using a format, but i dont know how to fit the format and %1 inside the task, nor do i know how to share the information about how many PCs have been hacked?
Sure. If you want the player to get a random loadout youll have to use selectrandom, else you just load the sqf as normal. Ill put some in Pastebin for u
thx
You can actually go into virtual arsenal and export the loadout, thus will save you A lot of time.
btw
Thanks m8
ACE uses setUnitLoadout and getUnitLoadout
so it will just be an array which you get and set
Ok, thanks guys
Do you know how to make a task that shows how many PCs a player have hacked? I'm trying to use format and createsimpletask, but it doesn't seem to work.
after the second PC has been hacked, check if the first one was indeed hacked, and use setTaskState to complete the task
I'm using the task framwork, and can't seem to get ant scripts to work. The task won't show up on screen, even the ones copied diretcly from BI wiki
@clever radish Show us your code.
[independent, ["task2"], ["Good luck finding this cookie", "Find Cookie", "cookiemarker2"], objNull, 1, 3, true] call BIS_fnc_taskCreate;
syntax is wrong
Perhaps...
if no parent task exist, 2nd argument should be string. Dunno if array works as well in that case.
Nevermind.
The code you posted works fine.
@clever radish
Did you try it out? If so, my mission must be broke
nope, indenpendent
Then I don't know.
alright. thanks
Can you open a empty mission
place an independent unit
and try it there?
Also make sure that "task2" is unique
If you've already used it, then it will not create another task.
It's an empty mission. Whenever i make larger mission scripts or so, i make them in VR. Ill try restart my pc
@torpid swift Why not use the restricted area module?
I figured it out. Thanks for your help
Zone Restriction
What was it?
Modules β Zone Restriction
I don't know, I create a VR and named everything as simple as possible; script.sqf, p1, trigger1. Works now
ah ok
re: my Q: ^^, I figured it out. the modules/framework were actually creating TWO instances of a vehicle in the same specs.
why isn't it possible to put count [trg1, trg2, trg3] > 2 in condition of a trigger if i want it to trigger whenever two of all three is activated?
because count counts an array, not "is the array item activated"
hopefully, there are other ways to do so
Wouldnt (Trg1 && trg2) OR (Trg1 &&trg3) work?
&& takes boolean, not object
(you also forgot 2&3)
{ triggerActivated _x } count [trg1, trg2, trg3] > 1
if triggerActivated is the proper command π¬
and it is, cool
Will that work too, if I got three triggers with that code, one being == 1, another == 2, .... so on? - I've got three triggers that will tell the player how many trg's have been activated.
so. fsms are preeeeetty cool for missionFlow
what is the point of assigning a scriptName when it can't be used as a handle?
so you can debug it better I would guess
Is there a technical or performance difference between defining inline functions in a set of files and #includeing those files into something like initServer.sqf verses using function-as-files? I prefer the former because I can develop more quickly using the editor to update functions and I find it easier to organize like functions in a single file, but I want to make sure I'm not introducing any kind of performance penalties.
There will always be a performance impact when splitting files, including, putting everything in one file, using CfgFunction, using PREP, etc.
However I do believe that the impact is minimal in any way, compared to the impact it will have to you as a developer to stay sane.
what wiki page do i go to to read about #define, #blah etc etc
ty
Better use > 0, > 1 etc
Better not use triggers too but hey
How to create speed limit to vehicle in multiplayer mission?
Depends what kind of speed limit you mean
Limiting a vehicle speed in general is not possible without modding, and even then it requires per vehicle modification
Limiting the speed for AI driven vehicles is possible
You could try addForce (as a function of velocity) to pull the vehicle backwards as it moves, but I don't know the consequences, or if it works at all
limitSpeed for AI, setVelocity with a normalised multiplied vector mayhaps (will also slow down a freefall π)
setVelocity is not a good option
It's "jumpy"
Henlo
Would it be viable to use unitcapture for 6-7 helicopters at the same time in MP?
Or heavy desync/lag?
it's not ideal, but it should be ok (using unitPLAY, right?)
No lag
the code is scheduled
but I guess you should already know the other problems that come with it
unit play is generally not recommended for MP
it could be better if you do it on the server
as long as your server FPS is high
How would I translate it into a script?
I've got three PCs which a player can hack, and a Task with a title says how many PCs have been hacked.
hackedLaptop = 0;
hackedLaptop = hackedLaptop +1;
hackedLaptop = hackedLaptop +1;
hackedLaptop = hackedLaptop +1;
waitUntil { hackedLaptop > 0 };
task set "1 done";
waitUntil { hackedLaptop > 1 };
task set "2 done";
waitUntil { hackedLaptop > 2 };
task set "3 done";
```something like that (pseudocode)
The PCs has an addaction with a counter script that makes a hint whenever the laptop is hacked. Do i put the "hackedlaptop = hackedlaptop +1" in there?
you can yes, as long as you public the variable and remove the action afterwards
note that addAction is local π
Ok, this function has global effect right?
yes
π
Where to read about this?
the addaction is on an object (the PC) and is set to be removed when the script is ended.
The variables is public, but I can't seem to make it communicate with the script that tells how many PCs are hacked
Does anybody here know how to use setForceGeneratorRTD or addForceGeneratorRTD
https://community.bistudio.com/wiki/setForceGeneratorRTD
https://community.bistudio.com/wiki/addForceGeneratorRTD
I think these'll allow me to make a full autopilot for advanced flight model, but I can't get them to work
if you get it to work, please tell us how in #community_wiki so we can fill it π
for anyone curious about the in-game information about the command, this is what it says
addForceGeneratorRTD [
bool enabled,
int type,
vec3 strength,
vec3 position,
vec3 radius,
vec3 orientation,
object AttachTo
]
I used setActualCollectiveRTD before for my PID controller of AFM, and worked like a charm. Not sure what exactly is the goal for you but does this work?
yeah I have that for my collective based altitude autopilot
but I want to use force generators to push the tail around to create heading/speed autopilots
Ah hmm, I see
but yeah if I add one and have enabled set to true, then read it out with forceGeneratorRTD, the first boolean will be set to false (which I guess means it disabled itself)
I'm not actually sure anyone can really answer this question without digging in to the rotorlib implementation of A3, but hopefully I'm wrong and someone knows how this works
holy fuck just after I wrote that I figured it out
to enable it, you can use
index setForceGeneratorRTD [bool enabled];
I'd still really like to know what things like int type actually mean, like what the types are etc
Quick question. I have variables that are defined in initPlayerLocal and some code that use those variables in initPlayerServer. Most of the time, everything runs correctly. However, there are times that seems to be the client loads initPlayerServer before initPlayerLocal since there are rare occasions that the code can not detect the variable at launch. Anyone knows what is really happening under the scene and which potential solution should I take ?
there is no guarantee that initPlayerServer runs after initPlayerLocal
https://community.bistudio.com/wiki/Initialization_Order
it's hard to give you a "potential" solution without looking at the code
I seee, gimme a sec I'll try to post the sqf.
waitUntil not isNil "yourVarName" ?
If you use getVariable you can assume a default value. No idea if that's useful in your specific case tho.
sleep 5;
for [{ private _i = 0 }, { _i < 6 }, { _i = _i + 1 }] do
{
sleep 5;
west reportRemoteTarget [t1, 100];
t1 confirmSensorTarget [west, true];
sleep 1;
g1 fireAtTarget [t1, "weapon_vls_01"];
g2 fireAtTarget [t1, "weapon_vls_01"];
sleep 2;
};
I added sleeps, not sure why my scenario stuttering
ship 1 https://i.imgur.com/TC7OG1m.jpg
ship 2 https://i.imgur.com/TC7OG1m.jpg
vidya https://www.youtube.com/watch?v=FTG_Tqds06E
Can any one help me with a small script to call other scripts.
I would like to drop a officer at my base with an addaction option called βRearmβ. This is to call a script that rearms the player depending on there slot they chose from the lobby.
Each playerable unit will have a set named variable such as A11SL, A12SL, A13SL for the squad leaders. A11M, A12M, A13M etc for the medics.
I would like the rearm script to call a script that does something like:
If player is A11SL or A12SL or A13SL then run \loadouts\SL.sqf
If player is A11M or A12M or A13M the run \loadouts\medic.sqf
I know how to do the addaction, I just donβt know how to right the script that checks their slot and runs the associated sqf.
is it something like?
if ((player) isEqualTo 'A11SL' (player) isEqualTo 'A12SL' (player) isEqualTo 'A13SL') then{
"loadouts\SquadLeader.sqf"];
if ((player) isEqualTo 'A11M' (player) isEqualTo 'A12M' (player) isEqualTo 'A13M') then{
"loadouts\Medic.sqf"];
please use ```sqf (see pinned messages)
It sounds like you're missing the operator or and the command execVM, amongst a number of smaller tweaks. But yes, easier to read with proper formatting as Lou said
i dont have the code, i have not written anything yet as i dont know how to do it
how do you know that script is the problem?
also, don't use C-style for loops
they're slower
use the SQF for loop:
for "_i" from 0 to 6 do {
sleep 5;
west reportRemoteTarget [t1, 100];
t1 confirmSensorTarget [west, true];
sleep 1;
g1 fireAtTarget [t1, "weapon_vls_01"];
g2 fireAtTarget [t1, "weapon_vls_01"];
sleep 2;
}
Rough, someone may need to touch this up:
if (player in ["unit1","unit2",...]) then {
[player] execVM "loadout1.sqf" };
something addAction ["Rearm", {
params ["_target", "_caller"];
if (_caller in [A11SL, A12SL, A13SL]) exitWith {
[_caller] execVM "\loadouts\SL.sqf";
};
if (_caller in [A11M, A12M , A13M ]) exitWith {
[_caller] execVM "\loadouts\medic.sqf";
};
}]
^that's it
and you would put that on the init of the officer at the armoury?
or in a seperate script that the officer calls from the addaction
We should have a pinned message that says "don't put things in the init field"
you can use initPlayerLocal.sqf
something is the officer
whatever you set the variable name to
Is there any way to tell an AI in driver position of a vehicle do hit 'reverse'? No mater what I do, the AI refuses to go backwards. Would like to make an unstick routine for tanks stuck on poles, structures and alike. I already got something with setVelocity and setDir. Just asking if there is any other option.
BIS_fnc_isLoading?
@languid oyster have you tried vcom or LAMBS AI?
Use setDriveOnPath
@desert cargo tried both, and like them, except for the fact that AI is able to ghost through walls. Which I dislike very much.
@little raptor setDriveOnPath? Will have a look
Thank you
Is it absolutely necessary to detect the exact moment the screen ends? Especially as it can be different for different players, it may be best to just have a blanket 10-second wait
Hi, I am not sure if this is the right channel to ask, if not please let me know what channel I should be asking this in.
I am a experienced developer, currently trying to make an extension dll for ArmA 3. I would like to use Newtonsoft and I have seen repo's where they use this package.
Tho I can not seem to get it to work. The game crashes with a generic .NET exception code in the .rpt log. Is there a specific version of Newtonsoft I need or anything?
Thanks in advance. π
quick question. Would i use something like the if statements in the initplayerlocal.sqf to set the loadouts on load in of the player?
i find that most times i set the player loadout in the editor, it ignores it when the mission starts and i get the default stuff.
That shouldn't happen
If you are right clicking a playable unit, selecting edit loadout, and clicking OK to save the loadout when finished, you should get that loadout if you play as the unit you edited.
If you're not getting the expected loadout, you may be running another script or mod that does loadouts
Editor defined loadouts are, in my experience, 100% reliable when not overwritten by something else.
i have done it a few times on various missions and it did always default it. I will try it on this mission i have, to see if it does it. I did remove the radio from everyone and that seemed to work. As TFAR was being a pain and doing this whole reissuing radio thing and not setting channels. Some post said to remove the radio from player spawn and make them pick one up from an arsenal. That seemed to work. Having me set their radio again may break it.
@little raptor ```sqf
NIC_fn_Drive = {
params [["_vehicle", objNull]];
if (isNull _vehicle) exitWith {};
_relpos = _vehicle getRelPos [30, 180];
_arrowG = createVehicle ["Sign_Arrow_Green_F", _relpos, [], 0, "CAN_COLLIDE"];
_arrowG setPos _relpos;
_vehicle setDriveOnPath [_relpos, getPos player];
};
cursorObject call NIC_fn_Drive;
I've put a Slammer with an AI driver in the editor. Pointed to it, and local executed the code above. Of course that thing does not move or event turn on the motor. Where is my fault?
doStop
The unit won't follow the path unless it is not taking orders
which only happens when the unit is stopped
@little raptor I'm confused. The unit is stopped when I apply the code?
Doesn't matter
You must use doStop
@little raptor ```sqf
NIC_fn_Drive = {
params [["_vehicle", objNull]];
if (isNull _vehicle) exitWith {};
doStop _vehicle;
_relpos = _vehicle getRelPos [40, 180];
_arrowG = createVehicle ["Sign_Arrow_Green_F", _relpos, [], 0, "CAN_COLLIDE"];
_arrowG setPos _relpos;
_vehicle setDriveOnPath [[0,0,0], _relpos, getPos player];
};
cursorObject call NIC_fn_Drive;`
This doesn't work either
For anyone wondering as well, I was being stupid. Long story short, you have to use something like the package Fody to make sure it all compiles to one .dll.
Not really exprienced with scripting but I am getting an error with the following script, that I found online where it states that line 78 has an "Unidentified Variable in expression: _lootarray" I would appreciate some assistance xD ```_getLootTable = {
_lootType = _this select 0;
// Loot Categories
// Get correct array to spawn items from
_lootArray = [];
switch (_lootType) do {
case 1: {
_lootArray = scclootCivil;
};
case 2: {
_lootArray = scclootIndustrial;
};
case 3: {
_lootArray = scclootMilitary;
};
case 4: {
_lootArray = scclootMedical;
};
case 5: {
_lootArray = scclootSupermarket;
};
default {
_lootArray = scclootDefault;
};
};
_lootArray;
};```
if any sccloot* variable does not exist, _lootArray will be undefined yes
why do you use [0,0,0]?
*splash, out*
@little raptor Just wanted to select an additional waypoint. Test code, if you want.
I am sorry I don't follow
the code is setting _lootArray equal to some other variables named like sccloot...
if they are not defined, _lootArray will also become undefined
LOOT select _lootType```
Wouldn't that be easier than all the switch stuff?
I have no idea, bad with scripting as it is, and this is not my script so Idk xD
How can I detect a vehicle becoming disabled? I want some code to run as soon as a vehicle has been hit to an extent where the AI just leave.
try MPHit or Hit event handlers
Then check canMove
Thank you that is what I needed π
@little raptor i have placed the script and i seem to get this error
'..."_target, "_caller"];
if (_caller in [ #A11SL]) exitwith {
error undefined variable in expression: a11sl
thats if i am in another class
if i am in SL then it works, but it is though it is still trying to run through the script even though that slot is not taken or calling it
What's the value of A11SL @fathom rapids ?
its the variable name of the slot (player) Squad Leader has the variable name of A11SL
this is my code
'''sqf
how do you do this lol
'''sqf
see pinned messages
/* your code */
armaofficer addAction ["Rearm", {
params ["_target", "_caller"];
if (_caller in [A11SL]) exitWith {
[_caller] execVM "loadouts\SquadLeader.sqf";
};
if (_caller in [A11TL]) exitWith {
[_caller] execVM "loadouts\TeamLeader.sqf";
};
if (_caller in [A11AT]) exitWith {
[_caller] execVM "loadouts\RiflemanAT.sqf";
};
if (_caller in [A11ARB, M11ARC]) exitWith {
[_caller] execVM "loadouts\AutoRifleman.sqf";
};
if (_caller in [A11R]) exitWith {
[_caller] execVM "loadouts\BasicRifleman.sqf";
};
if (_caller in [A11MB, A11MC]) exitWith {
[_caller] execVM "loadouts\medic.sqf";
};
}]
so even if i am in the squad leader role i get the error about the next one which is A11TL
so it is not seeing me and exiting
/* your code */
armaofficer addAction ["Rearm", {
params ["", "_caller"];
diag_log _caller;
diag_log A11SL;
if (_caller in [A11SL]) exitWith {
[_caller] execVM "loadouts\SquadLeader.sqf";
};
if (_caller in [A11TL]) exitWith {
[_caller] execVM "loadouts\TeamLeader.sqf";
};
if (_caller in [A11AT]) exitWith {
[_caller] execVM "loadouts\RiflemanAT.sqf";
};
if (_caller in [A11ARB, M11ARC]) exitWith {
[_caller] execVM "loadouts\AutoRifleman.sqf";
};
if (_caller in [A11R]) exitWith {
[_caller] execVM "loadouts\BasicRifleman.sqf";
};
if (_caller in [A11MB, A11MC]) exitWith {
[_caller] execVM "loadouts\medic.sqf";
};
}]```
Try this and check the output in the .rpt file
you most likely have the unit not spawned
Yeah, probably
yeah so if i jump in as the medic i want to be able to walk up to my armaofficer, select rearm and take a fresh kit
and then the same if i take the Team Leader slot
all slot (playable units) have variable names given as per the above code
correct
SO what it does
It goes from top to bottom executing the conditions
but A11SL is objNull for example because the unit does not exist.
we want to have no arsenal crate to prevent players from choosing anything and modifying the loadouts. If you return to base then you go to the armoury and select rearm
so how do i make it skip?
read the variable and execute accordingly
// Guys if I do this:
class CfgFunctions
{
#include "vScripts\vServer\vServerFnc.hpp"
#include "vScripts\vClient\vClientFnc.hpp"
};
// in description.ext
// And then:
class VAL
{
class allServer
{
class vServerFncInit {file = "vScripts\vServer\vServerFnc.sqf";postInit = 1;};
}
};
// In vServerFnc.hpp
// Then I no longer need to do:
if !(isServer) exitWith {};
call compile preprocessFileLineNumbers "vScripts\vServer\vServerFnc.sqf";
//in initServer.sqf
//RIGHT? ```
I'd do:
initPlayerLocal.sqf
player setVariable ["Equipment","RiflemanAT"];
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""];
if (_type == "") exitWith {hint "No gear for you!"};
_caller execVM format ["loadouts\%1.sqf",_type];
}]```
ok so where do i define the variable name of the player?
You don't need to define it anymore
You just set a variable in the player's namespace via event script
i am so sorry you have completely lost me there
π yelp guys!
the script i posted above was in my initplayerlocal.sqf
@wind hedge What's not working?
- Create a file inside your mission folder called 'initPlayerLocal.sqf' (This file is executed when a player takes control of a unit)
- Inside that file place
player setVariable ["Equipment","RiflemanAT"];
- Change the script (see above)
// Guys if I do this:
class CfgFunctions
{
#include "vScripts\vServer\vServerFnc.hpp"
#include "vScripts\vClient\vClientFnc.hpp"
};
// in description.ext
// And then:
class VAL
{
class allServer
{
class vServerFncInit {file = "vScripts\vServer\vServerFnc.sqf";postInit = 1;};
}
};
// In vServerFnc.hpp
// Then I no longer need to do:
if !(isServer) exitWith {};
call compile preprocessFileLineNumbers "vScripts\vServer\vServerFnc.sqf";
//in initServer.sqf
//RIGHT? ```
it is not that it is not working... I am asking if a call compile is redundant after doing the previous...
Yes, that's the whole point of CfgFunctions
besides some other advantages of course
Thank you!
@cosmic lichen what i dont understand is how does that code identify the different players when you have defind "riflemanAT" in the first line
Yeah right. My bad.
also i have 4 squads
with the same player setups
so if any of the squadleaders go up they all get the same kit loaded from the Squadleader.sqf
New approach:
Init field in the editor:
if (local this) then {this setVariable ["Equipment","RiflemanAT"]};```
In the attribute of the units, there is a field called "init"
So in the init field of the Squad Leaders i should put that code with the text of RiflemanAT changed to SquadLeader
and then the same principle for medics etc
Yes
ok but the previous code with the _type bit in how does it refer to the correct sqf for the slot?
do i repeat the if section for the different sqf's?
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""]; //Lets say the value it returns is "RiflemanAT"
if (_type == "") exitWith {hint "No gear for you!"};
_caller execVM format ["loadouts\%1.sqf",_type]; //Here we replace %1 with the value above which returns "loadout\RiflemanAT.sqf", which is the path to the file ;)
}]
so i keep repeating
if (_type == "") exitWith {hint "No gear for you!"};
_caller execVM format ["loadouts%1.sqf",_type];
after?
no
The path will be auto generated if the variables in the init are set correctly.
---mission.map
-----mission.sqm
-----description.ext
-----initPlayerLocal.sqf
where does postInit = 1 fit there?
That was not for you.
I know but still wanna know π
It doesn't
Thanks, it is loaded right after initPlayerServer
@cosmic lichen you sir are a star
Uhm I am quite lost on what to do with regards to the Undefined Expression
Like I understand that it is not defined but what do I do to fix that
Same script
That did not seem to fix the problem, now I get more errors with regards to the scclootcivil and so on
All saying that they are undefined
Well, are they defined?
Wdym by that ? (Sorry know little to nothing about scripting)
Yes, is that sqf file executed before the one you posted above?
Not in the same sqf file no
There is no mention of it
Though I do have an execute command in a init file
Just like what the github script instructions say
_getLootTable = {
private _lootType = _this select 0;
// Loot Categories
// Get correct array to spawn items from
private _lootArray = [];
switch (_lootType) do {
case 1: {
_lootArray = 1;
};
case 2: {
_lootArray = 2;
};
case 3: {
_lootArray = 3;
};
case 4: {
_lootArray = 4;
};
case 5: {
_lootArray = 5;
};
default {
_lootArray = 6;
};
};
_lootArray;
systemChat str _lootArray;
};
call _getLootTable;
Execute that in the debug console
If it prints a number from 1 to 6 then the basic script works and you need to figure out why the variables are not defined.
Nothing happens when I execute it so I am going to assume it is not working at all
Shame the script looked so promising
I appreciate the help
Thanks
try now
It works, I tested it. So the issue is that those other variables are not defined.
tbh, if you are new to scripting, rewriting a framework is quite complex.
I mean I am not rewriting it
You should probably get familiar with sqf first before you try something like that.
The script is supposed to be configurable
And I just followed instructions on the read file
And added custom building and items to the script and that's it
It seems I did something wrong then xD
Yes, I posted the code above expected you know the basics of sqf, but you don't. That's why it couldn't work.
If you only wanna add buildings, why don't you contact the developer on github?
Because they already put the instructions on how to do that
Okay, let's start fresh
Did you try the script without modifications? Does it work?
okay, so what do you wanna add?
I tried adding some items and a custom building just for testing
Included their class names
In the appropriate files
Which file did you modify? and how?
For the items there is file called lootTables.sqf
Because that script you posted ealier, doesn't look like any configuration file from that framework
And in it I added the cup_u_c among other things ```// Loot Tables
// By default this list contains items from ARMA 3 only.
// However, items not found are ignored - making it safe to add items from mods here.
// Format is classname, spawn chance.
// Default loot that will spawn in any building not defined in the config file:
scclootDefault = [
["U_Competitor",5]
];
// Civilian loot
scclootCivil = [
["CUP_U_C_Functionary_jacket_03",30], ```
The script that I posted earlier is part of a file called lootSpawn.sqf
scclootCivil = [
["hgun_P07_F",100],
["CUP_U_C_Functionary_jacket_03",30]
];```
Like this right?
Yup
does that work?
Wdym? (I know I am a pain in the ass for not knowing basic sqf or scripting, sorry xD)
The categories were already pre-made, you have civil military industrial medical and I just added more items to those categories
You just need to add them here and you are good then.
No need to modify https://github.com/samscodeco/SCCLoot/blob/7b8f2be3885cbb0ec5b5baf01c012bd0e4599a9d/SCCLoot/System/lootSpawn.sqf#L42 then.
Yup but that's what I did
For example ```// Industrial loot
scclootIndustrial = [
["Binocular",30],
["Crowbar",50],
["ACE_TacticalLadder_Pack",30],
["ACE_wirecutter",50],
["V_Safety_yellow_F".50],
["Shovel_Russian",50]
];
// Military loot
scclootMilitary = [
["CUP_srifle_M14",20],
["CUP_20Rnd_762x51_DMR",50],
["rhs_tr8_periscope",10],
["CUP_arifle_Galil_556_black",20],
["CUP_35Rnd_556x45_Galil_Mag",30],
["B_FieldPack_cbr",50],```
Yep, that should work out of the box according to the documentation.
["V_Safety_yellow_F".50],
This line is wrong
How do you guys spot these??? xD
Years of staring at script files at 3 am, not finding the issue.
Lmao
Have you turned off script errors?
I don't believe so .... ? xD

The game would've told you about that error otherwise
I am getting errors yes
Whenever I try to test the mission
I get the same error which states that the expression is not defined
It states the _lootArray, some of the sccloot expressions like scclootcivil and so on
Are not defined
then look in the rpt log
Post the whole script
if you haven't turned that off as well 
There must be a typo in it
No idea what that is xD
It's too long
type this in run:
AppData\Local\Arma 3
while {true} do
{
if (coy_a distance coy_b < 10) then
{
(group coy_a) setgroupID ["Coy"];
}
else
{
(group coy_a) setgroupID ["0"];
};
};
I have this in a unit's init and the stuff inside the while do loop runs just fine from the console but not inside the loop for some reason. Anyone able to help?
Okay
for the love of god
use sleep in while loops that are time dependent
I thought sleep didn't work in init's though?

so because it doesn't work your solution was to remove it?
do you even know how the while loop works?
it keeps running
that's it
with no sleep, you're telling it to freeze my game plz
So is there a better way to loop something in an init then?
The rpt file has a lot of "Error Position" or "Error Undefined variable in expression" multiple times
And all of the errors are found in the same file "lootSpawn.sqf"
Delete everything in the rpt
rerun the mission (or whatever you do)
then look at the new errors
and maybe post them here so someone can tell you what you're doing wrong
There is so many errors that I don't think it's worth looking at tbh
I will search for another script
Though I appreciate the help @little raptor @cosmic lichen
And apologies for being a pain in the ass 
There are multiple errors in the RPT refering to missing ] markers in the code. You should probably investigate those lines along with all the other errors in the RPT.
I would if I were experienced in scripting but unfortunately I am not
And tbh I have been burned out on this thing for the past few days trying to see what the issue is (Yes through research and what not xD) , and I feel for me just to search for these [] is just gonna waste a lot of time
I understand, that is reasonable, but it's not a waste of time. You learn coding and, any stuff that matter, by doing and learning from mistakes. From what I've read it seems like most of the problems just come from missing characters which leads to the whole script kinda dying.
["LOP_U_CH>
19:42:53 Error Missing ]```
For example, I'd search for that line and look for a missing ] character. Probably just use the search functionality inside what ever software I'm using to edit the file.
Right so I checked that but it all seems fine unless I am that stupid that I either did not see something or did something wrong ["B_FieldPack_cbr",40] ["LOP_U_CHR_Villager_02",60], ["LOP_U_CHR_Functionary_01",50], ["LOP_U_PMC_tacky",80],
stupid then xD
Oh god
["B_FieldPack_cbr",40] !!!!!!!!!!!!!!!!!!!! missing ,
["LOP_U_CHR_Villager_02",60],
Syntax problems are a very common problem if you're not experienced. It should be one of the first things to look for when something doesn't work. Every time you make a mistake you're less likely to do it the next time. The debug log is quite helpful in these cases, most of the time at least.
Normally the game would give you a big error on your screen when starting the scenario.
-nologs
This post was made by the systemChat gang
Again thanks @cosmic lichen and thanks @small forge Probs should actually start learning scripting after today xD
The first steps are made by implementing code in your scenarios, may it be yours or not. If you put some consistent effort into it you'll learn with time. Just keep the community wiki close for any documentation on SQF
@native narwhal Does it work now?
If you wanna learn scripting check this page https://community.bistudio.com/wiki/User_talk:R3vo (Yes I know it's my talk page)
@cosmic lichen just tried packing my pbo and deploying it on the server. When i try it now it says no gear for you. So something is different when acting on a server
how do i change this to work on the server?
if (local this) then {this setVariable ["Equipment","AutoRifleman"]};
Init field huh?
yeah of each playable unit
https://community.bistudio.com/wiki/player
Accurate facts about this are hard to come by, but chances are your code does run on the server, perhaps on the server and the connecting client. It's a mess.
Put player setVariable ["Equipment", "AutoRifleman"]; into initPlayerLocal.sqf and avoid all those problems.
Init fields are a sensitive topic in multiplayer scripting.
i cant do that as i have different roles
My guess is that the init field is not working properly for some reason. The variable is probably not being set. Reasons could be that the (local this) condition doesn't get fulfilled or the init field is not even being ran. Not quite sure about what it could be specifically
i dont want to define them in initplayerlocal
works fine when i run the mission in multiplayer on my machine
We m ight need to public the variable
i have 8 slots, all different roles. When the player takes the medic slot and he goes to the armoury and asks for a rearm, the medic kit will be given
And?
it will be something to do with that init as the initplayerlocal is running and telling there is no gear as it cannot see my role
@fathom rapids just use getVariable and be done with it
Could be it. Try turning it into if (local this) then {this setVariable ["Equipment","AutoRifleman",true]};
if (_caller in [missionNamespace getVariable ["A11SL", objNull]])
How does having eight slots prevent you from using a switch-statement?
switch (roleDescription player) do {
case "My Medic Slot": {player setVariable ["Equipment", "Medic"];};
case "This is the Autorifleman": {player setVariable ["Equipment", "Autorifleman"];};
};
On the wiki: Multiplayer: The variable space of the object is local to each client and by default changes are not broadcast. Since Arma 2: If the public parameter for supported types is true, the value will be synchronized also for a JIP player.
R3vo is probably right, it needs to be broadcasted.
Where were all those ppl 60min ago π
lol
ok now i think i get ansin11's response. The part in the " " will be what i have in my role description under the unit attributes?
if it is i have to do this like 35 times as my role descriptions are all different for the different squads
Another way is to check for the unit type if all the medics are the same unit
Hello (-:
A friend of mine is creating a few maps and we have the problem, that our player always loot the enemies. So my idea is to randomly drop grenates which explode on looting. My question is, if this is possible with scripting?
8 slots, 35 slots, what next...
if ("Medic" in roleDescription player) then {
player setVariable ["Equipment", "Medic"];
};
"medic" in toLower ...
yes
for example one squad has "Alpha 1-1 - Bravo - Combat Medic" & "Alpha 1-1 - Charlie - Combat Medic"
so having "medic" would pick this up?
@void panther I think this should do the trick
_g = createVehicle ["grenadeHand", _pos];
_g setDamage 1;
"medic" probably not, because in does case-sensitive comparison, but "Medic" should work π
I don't remember if it was "grenadehand" or "handgrenade"
ok i will try that
I think the former was for ammo
latter for mag
@void panther While it is certainly possible, I would advise to not go that way.
Killing player randomly, sounds like fun...not

Yeah, we will see how people will find that. I personally would find it very funny
which is why I said this:
Thank you for helping π
would this work?
/* your code */
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""];
if ("Medic" in roleDescription player) then {
player setVariable ["Equipment", "Medic"];
_caller execVM format ["loadouts\%1.sqf",_type];
}]
Probably not, I believe you use getVariable too early.
then how would i add the next option of AutoRifleman, SquadLeader
this is blowing my brains, I know what i want to achieve but just cant get my head round this code.
You should probably put that if statement in something like initPlayerLocal.sqf
thats where it is
then maybe put it before the addAction
player setVariable proooobably doesn't survive respawning though, might want to move it to onPlayerRespawn.sqf. Let me write something up.
onPlayerRespawn.sqf:
private _equipment = "";
if ("Medic" in roleDescription player) then {
_equipment = "Medic";
};
if ("Autorifleman" in roleDescription player) then {
_equipment = "Autorifleman";
};
//Add more if-statements just like those for all your roles.
player setVariable ["Equipment", _equipment];
and after that last line i would add
_caller execVM format ["loadouts%1.sqf",_type];
Certainly not π
so how do i call the sqf
When do you want to call it?
when it has found out what the role is, call the appropriate loadout sqf
i have autorifleman.sqf, basicrifleman.sqf, commander.sqf, marksman.sqf, medic.sqf, riflemanAT.sqf, sniper.sqf, squadleader.sqf and teamleader.sqf
player execVM format ["loadouts\%1.sqf", equipment]; at the end of initPlayerLocal.sqf should work for the first time when spawning
And what about the "Rearm" action?
just change the equipment = here to lowercase
that is placed on the armaofficer on the map
we go up to him, scroll and select rearm he then checks our role, and gives up the correct loadout
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""];
_caller execVM format ["loadouts\%1.sqf",_type];
}]```
should work just fine as long as you remove the if statement you asked about earlier
You know what guys
yeah nothing is setting the variable thats why we have the init field with that code
This is all pointless
please tell me why
AddAction has local effect and is only locally created
True. Could just use private variables
So just add the action via initPlayLocal.sqf and assign the script directly
without defining a dynamic path to the file.
files(s)
i have done this before where the player would go to the crate and scroll and select the loadout
forget about it. I am too tired.
it worked fine but i dont want a medic to take AT weaponary, only to have what they were given
but when we RTB to rearm, i want them to go and rearm and get their old kit back
i have exported their loadouts into sqf files, so they are ready to go, i just need a way to call them from the rearm guy
Why should it not work @cosmic lichen? I was going to comment how that would be a big brain move and then you come and say "nevermind"?
As I said I am really tired π
As in too tired to explain that big brain idea to the less experienced? π
If you're not worried about respawning with appropriate gear since you have the arming officer. Then just use this: ```
//// initPlayerLocal.sqf
private _equipment = "";
if ("Medic" in roleDescription player) then {
_equipment = "medic";
};
if ("Autorifleman" in roleDescription player) then {
_equipment = "autorifleman";
};
//Add more if-statements just like those for all your roles.
armaofficer addAction ["Rearm", {
params ["", "_caller"];
_caller execVM format ["loadouts%1.sqf", _equipment];
}]```
Should work fine unless there are syntax errors or something I missed
#arma3_scripting message
If you have that
code in onPlayerRespawn.sqf, the "Equipment" variable is defined every time the player (re-) spawns.
#arma3_scripting message
Then you just use that
in initPlayerLocal.sqf and the "Rearm" action works.
ok i will try
That won't work π
Just be aware that roleDescription will not work in single player
Just like... slots...
The wiki says it works on SP. Is the wiki wrong?
Does setting other players volume with setPlayerVoNVolume persist after said player dies and respawns?
I am updating it
https://community.bistudio.com/wiki/setPlayerVoNVolume
My guess would be no since it uses the object as a parameter but I am not sure. Never used the command.
If you know SQF basics, you could try it out by using the getPlayerVoNVolume command to return the value before and after death.
Think it should. But dunno
try it out and tell us so it can be added to the wiki
error undefined variable in expression: _equipment
script loadouts\any.sqf not found
yeah my bad _equipment doesn't transfer to the scope of the addAction
can that be fixed?
Yep, set my own volume to 0.5 via debug console and when I killed myself and respawned, it reset back to 1.
hello guys π
any way how to get rid of it? script in pbo working like it should with restriction but error msg still shows up (i am not running -showscripterror) https://gyazo.com/093f2d36cb36bf0aa940df3843b54c2c
//// initPlayerLocal.sqf
private _equipment = "";
if ("Medic" in roleDescription player) then {
_equipment = "medic";
};
if ("Autorifleman" in roleDescription player) then {
_equipment = "autorifleman";
};
//Add more if-statements just like those for all your roles.
armaofficer addAction ["Rearm", {
params ["", "_caller", "", "_type"];
_caller execVM format ["loadouts\%1.sqf", _type];
}, _equipment]; ``` Try this. Someone shout out if the syntax to passing args to addAction's script is wrong. Haven't done it in a while
that seemed to work, gonan upload it now to see if that resolved it
What error does it give you?
https://community.bistudio.com/wiki/param
Since Arma 3 v1.53.132691, onscreen errors are displayed for when the input is of the wrong type or size.
Maybe that?
I need help with a trigger condition. I have set a condition of Ishacking && !(p1 in thisList) && Trg3 for three triggers (Trg1, Trg2, Trg3 is the difference). Whenever p1 is hacking hacking.sqf contains; IsHacking = true Trg1 = true. Whenever p1 leaves area a hint and IsHacking = false is set to be activated.
Now the problem occurs whenever p1 goes into the second and third trigger area and activates the hacking script, it instantly fires the hint, even though the player is still in the trigger area.
@cosmic lichen Fixed it, it was a bunch of small mistakes I missed out and some lines stuck to each other. Getting the hang of it, and might even start learning scripting. Thanks a lot for the support xD
What are the conditions in the other triggers?
The condition in all triggers are the same, except "Trg".
Ishacking && !(p1 in thisList) && TrgX
Would the solution be something like editing the "IsHacking" to the same like "Trg", having three diefferent "IsHacking?
The first thing I notice is that the H is lowercase on the trigger but uppercase in the .sqf file
Typo, its the same in game. Sorry
:/ changed it from before and still didnt help
I checked Debug and it all sums up with the "IsHacking" part. It turns out fals whenever p1 leaves trigger area on all triggers.
And should it be that way?
How are you using BIS_fnc_addVirtualItemCargo?
@clever radish You set Trg1 = true in the file? You do that with the other triggers too? What are the in game, Eden set, conditions for the triggers? Not the script ones
Let me start from the begenning - It's much easier. (pls wait while i find all codes, cant copy in one chat. )
TRIGGER1;
CON Ishacking && !(p1 in thisList) && Trg1
ACT hint "Signal lost. Download interrupted."; Ishacking = false; PC1ScriptRunning = false;
TRIGGER2;
CON Ishacking && !(p1 in thisList) && Trg2
ACT hint "Signal lost. Download interrupted."; Ishacking = false; PC2ScriptRunning = false;
PC1;
Hardware1 addaction ["Download Content of device", "HackCounter\PC1.sqf"];
PC2;
Hardware2 addaction ["Download Content of device", "HackCounter\PC2.sqf"];
PC1.SQF;
PC1ScriptRunning = true; _HackCount = 0; ishacking = true; Trg1 = true;
ishacking = false;
PC2.SQF;
PC2ScriptRunning = true; _HackCount = 0; ishacking = true; Trg2 = true;
ishacking = false;
Of course, bug does not occur whenever p1 completes the hack and ishacking = false in SQF. Capital letters doesn't seem to affect the script.
β¦forgetting all the code behind, anything related; what is the behaviour you want?
from an outsider's pov
I want the hacking to be stopped whenever p1 leaves Trigger area "PC2ScriptRunning = false"
What's the purpose of the TrgX variables? Are they always true?
_markers = allMapMarkers select {toUpper _x find "SHAI" >= 0};
_side = east;
_myunitarray = ["C_Scientist_F"];
_spawnedGroups = [];
{
_grp = [getmarkerpos _x, _side, [selectRandom _myunitarray],[],[],[],[],[],180] call BIS_Fnc_spawnGroup;
_spawnedGroups pushBack _grp;//in case you want to access all spawned groups
{_x disableAI "PATH"} forEach units _grp;
} forEach _markers;
_spawnedGroups```
Hey guys is there anyway I can change this script to only select markers with "SHAI" in them at random? At the moment it spawns the unit on every marker with "SHAI" in the name, id like it to only spawn 15 enemies at a time on randomly chosen markers.
Aplogies for the lack of markup, i dont know how to do it π¦
```sqf
your code
```
see the pinned message π
Maybe BIS_fnc_holdActionAdd?
Awesome, thanks @winter rose
Yes they are always true. If i remove TrgX the Triggers will activate hint, but will continue Hacking script after showing the hint.
@gloomy aspen https://community.bistudio.com/wiki/selectRandom
Pair this with a for loop and remove the selected one from the _markers list if you don't want multiple units to spawn on the same one
@clever radish Are the Eden conditions the same? I mean are they all set to player present or etc?
All Triggers are set to Player Not Present. All triggers have !(p1 in thislist) in condition, tho
Isn't that the same as Player not present? 
Bug occurs whenever:
I complete hacking of PC1 and continue to PC2, where the hint from the TRIGGER2 will show and the script will continue after one second. (It will not if i activate the TRIGGER1 for PC1)
Meaning that the hint from TRIGGER2 will show, even though player is inside TRIGGER2 area.
Well, the trigger is supposed to activate when the player is not in the trigger area, soooo
yes; try allMapMarkers and in, e.g ```sqf
private _shaiMarkers = allMapMarkers select { "SHAI" in _x };
private _randomShaiMarker = selectRandom _shaiMarkers;
I know, and that is the point.
In fact, T2 should be activating when the player is in the T1 area (if the areas are distinct): T1 sets Ishacking to true, the player is not in the T2 area, Trg2 is always true, thus: Everything is true and T2 activates.
@small forge thanks mate, have looked into that a little but will read more
@winter rose trying your solution now, apologies if im missing an obivious part, but how would i define how many units to be spawned in that instance? 15 of them to be exact
my solution only says "take a random SHAI marker"; regarding 15 units see https://community.bistudio.com/wiki/BIS_fnc_spawnGroup documentation π
Thanks, found the solution. I made the script disable TrgX if player completed the hacking.
private _shaiMarkers = allMapMarkers select { "SHAI" in _x };
private _randomShaiMarker = selectRandom _shaiMarkers;
_side = east;
_myunitarray = ["C_Scientist_F"];
_spawnedGroups = [];
{
_grp = [getmarkerpos _x, _side, [selectRandom _myunitarray],[],[],[],[],[],10] call BIS_Fnc_spawnGroup;
_spawnedGroups pushBack _grp;//in case you want to access all spawned groups
{_x disableAI "PATH"} forEach units _grp;
} forEach _shaiMarkers;
_spawnedGroups
Up to here so far, seems to be spawning the correct number of enemies, but on the same positions each time? Am i using your solution incorrectly?
nope π
you did a forEach _shaiMarkers; why do you want to spawn on each?
you want to spawn on only one, the random one (if I understood it correctly)
Damn π
15 random marker positions to spawn enemies out of an unlimited number of markers containing the term SHAI in the variable name
Thats the plan!
Surely not as simple as removing forEach ?
I tried it just incase thats what you meant, but got a missing semi-colon error on that line and now im even more bewildered!
for i from 1 to 15 do {
spawn on a randomly selected SHAI marker
}
So i could use some help. i suck at math especially algebra.
I am trying to create a script to file roads with dirt. Its not working well.
It only does one dirt per road segment but there is plenty of space needing to be filled.
can someone take a look at my code and point out what im doing wrong.
https://pastebin.com/CDb8ZQVQ
private _shaiMarkers = allMapMarkers select { "SHAI" in _x };
_side = east;
_myunitarray = ["C_Scientist_F"];
_spawnedGroups = [];
{
_grp = [getmarkerpos _x, _side, [selectRandom _myunitarray],[],[],[],[],[],10] call BIS_Fnc_spawnGroup;
_spawnedGroups pushBack _grp;//in case you want to access all spawned groups
{_x disableAI "PATH"} forEach units _grp;
for i from 1 to 15 do {
private _randomShaiMarker = selectRandom _shaiMarkers;
};
};
_spawnedGroups```
I think Ive really ruined the script now @winter rose .. Im not sure I understand where everything is meant to go, am I just lacking some basic sqf knowledge? Seems like I put all the right bits in the right places, but seemingly not. Theres no errors being thrown up by 3den, but also no effect at all now π¦
https://i.imgur.com/y3R3LIX.jpg
https://i.imgur.com/z3gQiCL.png
I want that this particular tower can be destroyed by single satchel
object 31478 setDamage 0.9;```
this return error
object 31478 is not a reference to the object. I don't know how you obtained that, but it's probably just the String representation of the reference.
do3DENAction "ToggleMapIDs";
this addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
while {!isNil _projectile} do {
_marker = createMarker ["markername", _projectile];
_marker setMarkerType "hd_dot";
sleep 1;
};
}];
Im trying to make a simple script that updates the pos of an arty shell on the map as it flies, no need to remove markers this is just for debug testing, any pointers to make it work right?
Working on it now but above code gives errors
Try using the Edit Terrain Module to setDamage, that should work well.
isNil checks if there is a variable with the given variable name. The documentation will tell you that in order for that to work, isNil expects a String argument. _projectile is not a String, and the variable _projectile also always exists in that code you posted.
Try isNull.
@willow hound https://www.youtube.com/watch?v=xoaoikQiNyM
seems impossible
Double click on the module, there are some checkboxes for additional map object types.
is there a way to check when a unit is ready to be moved into a vehicle on mission start? It seems that right at the start of the mission it is not possible to do so but I honestly don't know anything that might cause it. From initPlayerLocal.sqf:
waitUntil {!isNil "MIS_fnc_missionFlow_state" && !isNil "MIS_fnc_missionFlow_plane"};
if (_didJIP) then {
//--- Bring to respawn screen
forceRespawn _player;
if (MIS_fnc_missionFlow_state == "pause") then {
//--- Respawn during pause
sleep 1;
[_player] call MIS_fnc_respawnPlayer;
};
} else {
//--- Paradrop
_player addBackpackGlobal "B_Parachute";
"RscWaitingForPlayers_layer" cutRsc ["RscWaitingForPlayers", "PLAIN"];
["start move in: %1", time] call BIS_fnc_logFormatServer;
while {!(player in MIS_fnc_missionFlow_plane)} do {
player moveInCargo MIS_fnc_missionFlow_plane;
sleep 1;
};
["end move in: %1", time] call BIS_fnc_logFormatServer;
};
``` without the sleep only the hosting player is moved into the plane at mission start. the other client is moved in on the next try. RPT:
1:04:18 "Terra(76561198050689859)/BIS_fnc_log: start move in: 0"
1:04:18 "Terra/BIS_fnc_log: [BIS_fnc_preload] ----- Scripts initialized at 875.977 ms -----"
1:04:18 "TerrasMinion(76561198050689859)/BIS_fnc_log: start move in: 0"
1:04:21 "PLANE STARTING"
1:04:21 "Terra(76561198050689859)/BIS_fnc_log: end move in: 1.003"
1:04:22 "TerrasMinion(76561198050689859)/BIS_fnc_log: end move in: 2.021"
Same with _player?
yep
okay i removed the sleep just out of curiosity. the actual time difference for TerrasMinion is 0.277 s.
That's a lot of attempts
1:13:29 "Terra(76561198050689859)/BIS_fnc_log: start move in: 0"
1:13:29 "Terra(76561198050689859)/BIS_fnc_log: end move in: 0"
1:13:29 "Terra/BIS_fnc_log: [BIS_fnc_preload] ----- Scripts initialized at 817.871 ms -----"
1:13:29 "TerrasMinion(76561198050689859)/BIS_fnc_log: start move in: 0"
1:13:32 "PLANE STARTING"
1:13:39 "TerrasMinion(76561198050689859)/BIS_fnc_log: end move in: 0.277"
no errors in both rpts 
another interesting part is that on postInit the hosting player is moved into the plane during the briefing
actually no nevermind i changed that. the initPlayerLocal moves the player into the plane
but during the briefing, the player is displayed at the position of the plane
How do you edit particle effects for ground-hits, explosions, smoke, etc? i.e Blastcore changes some effects drastically and I want to do something similar
Blastcore (and similar) is using 90% configs and 10% scripts to setup the custom particles.
The wiki has a lot of documentation about it:
thanks alot
Also, are there maybe any way to use a realtime-GUIs that are made for particles or do you have to just experiment using scripts and stuff?
Which format for GUIs are consistent across all screen resolutions/aspect ratios? I'm using this and the result is offset for each resolution:
_bat ctrlSetPosition[0.33*safezoneW+safezoneX,0.38*safezoneH+safezoneY,0.02*safezoneW,0.08*safezoneH];```
It's looking like pixelGrid commands will be what I need to replace safeZone
Disregard, it's only messed up for people who edit their FovLeft and/or FovTop values in their Arma3.cfg π
GUI_GRID format (used by the game GUIs)
It's based on safezone format, but it also resizes according to aspect ratio/interface size
It doesn't exist by default and you'll have to create it (using define)
Safezones give you ability for making controls relative to the screen like 0.8*safezoneH means 80% of screen height. while H and W are straightforward, X and Y need some mind bending and the picture here explains it https://community.bistudio.com/wiki/safeZoneW that safezoneX is negative, so if need additional calculation between width of your control and width of the screen and that safeZoneX offset. I might write some examples though
@violet gull Added examples to safeZoneXXXXX pages
does anyone know how to implement the QS Mag Repack into a script form. We are running invade and annex framework on one of our servers and it is implemented, without the clients downloading the mod. I wish to now have it on our training server, but dont know how to extract it and get it working. I would like a simple action that the player performs [LCTRL] + R to execute a mag repack function.
we really dont want to add more mods
i have googled around and not finding any simple mag repack scripts i can use
Have you tried to unpack the pbo? The script is in there.
i have but it refers to a lot of other stuff too
i have just found one script that may work, will try it tonight
can you tell me how i can execute the command from a [LCTRL] + R key stroke?
the code wants me to put
this addAction ["Repack",{null = [_this] execVM "repack.sqf";}];
on each player
i would prefer to have a keybind
easier then to duplicate the mission files for other maps
something in the initplayerlocal or init sqf's
would this work?
//fnc in initPlayerLocal.sqf
dokeyPress_fnc = {
switch (_this) do {
//key
case 39: {
nul = [] execVM "earplugs.sqf";
};
};
};
just have to work out how to change that to LCTRL + R
@fathom rapids Check this script
#include "\a3\ui_f\hpp\definedikcodes.inc"
params ["_ctrl","_button","_BtnShift","_BtnCtrl","_BtnAlt"];
private _buttonDisabled = false; // true: block the original comand, false: Execute the normal command of that button
private _blockInput = { _ButtonDisabled = true; };
if (_button isEqualTo DIK_W) then // DIK_W = 17 = 0x11 = "W"
{
// For now, button W is just registered, but won't block the original command for now (player can move forward).
// If SHIFT is pressed, block "W" (walk forward) and show the systemchat message
if (_BtnShift) then
{
systemChat "Shift+W pressed";
call _blockInput; // call to disable the original command
};
};
_buttonDisabled
See more at https://community.bistudio.com/wiki/DIK_KeyCodes
would i have to put that top line in the description.ext?
and the rest in initlocalpplayer.sqf?
thats the issue i have with that wiki, most of the time it doesnt tell you where to put stuff lol
There's no single correct way to organize your code, but the BIKI could use more examples, yeah
You need to use displayAddEventHandler https://community.bistudio.com/wiki/displayAddEventHandler
when using event handlers (as they run in unscheduled environment by default), is it good practice to spawn into a scheduled environment unless you need to run a time-critical script or should you just leave it as it is in unscheduled
@slate cypress I'm not an expert on this, but I think it depends on the case
Scheduled execution tends to be a bit risky because of the way it works in Arma, but you do get rid of the potential FPS drops with it
risky how?
@slate cypress From KK's blog:
The scheduled environment does not guarantee the order or priority of execution of queued scripts. The engine will simply do it when it is feasible and possible. If you have too many non scheduled calls and they also take time to complete, your scheduled scripts can be delayed significantly, we are talking minutes! For the same reason non critical scripts should be run in scheduled environment so that a) they do not get on the way of urgent executions, b) give engine more flexibility for rescheduling when needed.
Having said that, scheduled environment, despite its name, is pretty unpredictable. If you spawn 100 scripts, it is not guaranteed they will execute in the same order they where spawned. Also you cannot predict when they finish. You can however check IF they finished with scriptDone command. And if you have many unoptimised scripts running, especially of a 3rd party addons, and you have no control over what is going on, it is very likely there might be some issues.
And like in any case of threaded execution (whether actual threads or simulated ones), you can run into issues of parallel programming that can get really complex and hard to debug, such as data races and deadlocks
unscheduled will freeze the game until its done.
Depends on what you're doing.
if you need the EH code to run right now, then leave it unscheduled, if you don't care about delays, scheduled is better/safer
Thanks
Just out of curiosity, a lot of composition mods on the workshop use the BIS_fnc_attachtoRelative
With say 30 or so items connected to say, 10 different vehicles is there a noticeable performance hit? The objects generally have had simulation disabled but I wonder what the performance cost is of the game 'moving' them relative to a vehicle
Apologies if theres a better channel for this question
No such thing in sqf. Everything is single threaded and there's no "data race"
due to suspension, there can be race conditions
_v1 = MyGlobalVar;
_v2 = MyGlobalVar;
_v1 != _v2
it's not technically a data race
like in multi threaded programming
same end result tho
^ this
it is absolutely is a race condition, where did you dig term data race? Dedmen did not say data race @little raptor
you quoted Dedmen, itβs confusing
So data race and race condition are different things? TIL
I always thought they referred to the same phenomenon
(I never encountered "data race")
@tender fossil
https://en.wikipedia.org/wiki/Race_condition#Data_race
data race seems to be a kind of race condition, in which two threads access the same data
@winter rose Ah, of course. I feel dumb now π
I didn't know it had a specific name :p
Hello, sorry for stupid question, but don't understand how to do this thing π¦
I have trigger, when player leave trigger (onDeactivation) code must move player back
(to the trigger center direction - on 50 meters)
There needed vectors ( i think ), but don't understand how to calculate a new position by vector.
Could you help me with that, please?
there are no stupid questions, only stupid users! π
Wanna make a restricted area?
If so, there is a module which does that.
I would say ```sqf
private _pos = getPosATL _unit;
private _vectorFromTo = getPosATL _trigger vectorDiff _pos;
private _vectorFromToNorm = vectorNormalized _vectorFromTo;
private _vector50 = _vectorFromToNorm vectorMultiply 50;
_pos = _pos vectorAdd _vector50;
_pos set [2, 0];
_unit setPosATL _pos;
@cosmic lichen something like that, but inverted (when player leave zone - he's getting moved back and see message on the screen)
_aboveAndBehindPlayer = player modelToWorld [0,-1,3];
@winter rose ?
he might turn his back to the trigger π¬
sneaky...
or move diagonally, etc
yeah I have some experience with such sneaky stuff π
@winter rose thank you a lot!
please re-check it, it might move you 50m in front
I wrote that "on the corner of a table", please re-check π
you could also use getPos/getDir alternative syntaxes, etc
i will, anyway - thank you!
you could also just turn the player around, looking at the trigger π
Going to create some nice confusion
ye, probably
But still, i think - better move him little bit back to be sure - player is back to trigger
Yeah, he could also walk backwards
player setDir (player getDir trigger);
player setPosATL (player modelToWorld [0,50,0]);
``` π
@winter rose that awesome, 2 variants - works fine π
But, i think - better will be use - last one, with less code π
Thank you a lot!!!
setPosATL != AGL
Does anyone know how to code roleplay shops like cars truck,bike clothing hole lot need help with
I'm trying to make a simple EH that gives you another magazine when you reload. Here's what I've got:
player addEventHandler ["Reloaded", {
params ["_unit", "_weapon", "_muzzle", "_newMagazine", "_oldMagazine"];
if (_weapon in ["launch_rpg7_F","gm_p2a1_launcher_blk"]) then {_unit addMagazine (_newMagazine select 0);} else {
_unit addMagazine (_oldMagazine select 0);};
}];
you'll notice there's special cases for launchers. That's the problem: if the weapon you reload is a launcher....you don't get a new magazine. Even with those special cases in place. I don't quite understand or know how to resolve this.
Do you have enough room for that?
Did you check?
yes
I know the EH is being added correctly because it works for non-launcher weapons
Did you check _newMagazine? It's not empty right?
I guess I'll check but it'd be a hell of a thing if it was empty
can confirm it is not empty
_oldMagazine is empty but that's why the special case is what it is
maybe when you add the new magazine, it gets loaded
add two new magazines
see if it fixes the issue
You can also verify that by checking if the new magazine was already loaded:
secondaryWeaponMagazine _unit == _newMagazine
Even if it gets loaded straight into the tube, I should still come out of it with the same number of magazines....I think? One launched, one added, right?
Not necessarily
maybe the game removes it
I don't know
Just check
I'm not sure
Nope, firing a rocket still reduces my total amount of rockets by 1
silly question: are you sure that the true part of if is executed?!
because if you have enough room, adding two mags should've given you at least 1 mag
so either you don't have enough room
or the code was not being executed
well, I'm definitely holding a launch_RPG7_F and that matches the if criteria, so it would be weird if it wasn't
and I'm 100% sure I have enough room
add a systemChat or hint to make sure
yes, I'm going to
If it still doesn't work, add the magazine specifically to the backpack
That command has always been a bit weird and iffy for me
in is case sensitive btw
yes, which is why I suspected that it was the problem
yes, that was it
then convert all cases to lower and then compare
if (toLowerANSI _weapon in ["launch_rpg7_f","gm_p2a1_launcher_blk"])
getting the case right in the first place also solved it
objective_1 = true;
if ((!alive target_1) || (!alive target_2) || (!alive target_3) || (!alive target_4)) then
{
objective_1 = false;
hint "Bridge destroyed";
};
use killed event handler
(if possible)
or a trigger?
is there any difference between calling a function like this: "myTag_fnc_myFunction" versus calling it "vMyFunctionFnc"?
it is just a standard but no difference engine wise right?
mytag_fnc_myfunction is created by using cfgFunctions in description.ext, but they all work the same
in terms of calling the functions at least
you could manually define it as well and it would be fine unless its already defined inside cfgFunctions and it'll just throw an error that the function is already defined
ye
One name is shorter
:3
Hello π
I am trying to figure out how to drop an item if a player loots an enemy. I was able to drop the item, but I have no idea on how to get the container/inventory of the enemy.
My idea is to work with eventListeners, but I cannot find the correct property. Any hints/ideas?
Basically I am trying to do the following:
_enemy.container addEventHandler ["ContainerOpened", {
params ["_unit", "_container"];
hint "opened";
}];
drop the item in a new container at the position of the body
create a weaponHolderSimulated as the container
I don't understand what you are saying
create a new container
is that simple enough?
Sure, but how do I assign it to the enemy?!
why should it be "assigned" to the enemy?
it's just there
you can use setVariable if that's a necessity
Okay
you could also try looking for weaponHolder/weaponHolderSimulated objects in the vicinity of the body (using nearObjects or nearestObjects)
Hmmm... nearOBjects or nearestObjects does not return anything π¦
or at least no weaponholder
well then try this:
Add a take event handler to the player
pick an item from a dead body
see what it returns
player addEventHandler ["Take", {
params ["_unit", "_container", "_item"];
systemChat typeOf _container
}];
or you know just use that
why do you need container opened in the first place?
you can use take EH for that too
How do I see the systemChat?
nevermind
Yeah, I got it π
this is how i had to do it in order to get the weapon holders show up:
_enemy addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
_unit spawn {
sleep 1;
_container = nearestObjects [_this, ["WeaponHolderSimulated", "WeaponHolder"], 1];
{
systemChat typeof _x;
_x addEventHandler["ContainerOpened", {
_claymore = "APERSMine_Range_Ammo" createVehicle position player;
_claymore setDamage 1.0;
systemChat "opened container";
}];
} forEach _container;
};
}];
I should probably remove the eventhandler afterwards
I want the functionality of BIS_fnc_replaceWithSimpleObject but the documentation recommends not to use it in MP scenarios. Is there a workaround?
Create simple objects from the start?
Get object class, remove object, create new simple object?
it gets removed automatically by the game (and even if it doesn't it won't matter)
if its a player and they respawn the EH would stay attached no?
I want to replace objects with simple objects on the go; not at initialisation. The aim is to turn a vehicle into a simple object once it has been disabled.
In that case grab class name, location and direction of the object, remove the object itself and create a new simple object with the data you stored
Which afaik is exactly what that BIS function is doing as well
how would i set a script so i could respawn unit's that are targets on a IFV range from laptop?
hey can someone link me dedmen's script profiler? I can't find it from searching (probably not searching for the right thing)
nvm found it
can I target a editor folder. say I place a bunch of objects in a folder in the editor, is that stored as a variable somewhere?
dipped a toe into scripting and i've fallen at the first hurdle. I've put down a trigger called "trigger1", and I'm getting a mission module to fire off mission1.sqf with the line: trigger1 setTriggerActivation [WEST, NOT PRESENT, true];
And I get the error "undefined variable in expression... line 1"
Am I just not understanding the syntax on the wiki?
Iβll try this thanks.
Any idea why the BIS function doesnβt work in MP then?
I haven't looked in the function, so don't know exactly. I guess it will work but will cause some issues server side
Yep it works but causes server side issues as expected
Are players able to edit their own profile namespace and change data within it?
Is it safe to store data, for example how many points someone has, in their profile namespace or should I store it to the server profile namespace?
@slate cypress Profilenamspace is not safe. It can be freely edited. So server profile it is
Thanks
Hey guys, you can laugh, but any idea on how to make an item display custom intel?
How do you control a marker's alpha parameter through scripting events? For that matter, how do you access parameters like that at all with a script in the first place?

WEST and NOT PRESENT need to be strings (text) so they need quotes, e.g. "WEST"
https://community.bistudio.com/wiki/setMarkerAlpha and see the Markers command group link at the bottom
let me know if you still need help with part 2 of your question
I'm getting an error for this code. I don't work with locations often so I'm not sure what I'm doing wrong here:
_lockDoors = {
_nbDoors = getNumber (configfile >> "CfgVehicles" >> typeOf this >> "numberOfDoors");
for "_i" from 0 to _nbDoors - 1 do {
_var = format ["bis_disabled_Door_%1", _i];
this setVariable [_var,selectRandom [0,1],true];
};
};
_worldCenter = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
{
{
_x call _lockDoors;
} forEach (nearestTerrainObjects [locationPosition _x, ["house","building","tourism"], size _x]);
} forEach (nearestLocations [_worldCenter, ["NameVillage", "NameCity", "NameCityCapital"], worldSize]);
What's the exact error?
Type array expected number before nearestTerrainObjects
size returns an array, [x,y]. nearestTerrainObjects expects a single number for its radius parameter.
so I should do size _x select 0 /2?
That seems likely, though you might also want to introduce something to determine whether the x or y dimension is larger
it works, thanks
Is there any witchcraft I need to know about to get the z axis of a GUI object to be consistent across all resolutions/aspect ratios/interface sizes/FOV?
I think my GUI buttons are off because my z = 0.22 of the object they are positioned on top of. No safeZone or whatever stuff used in the z axis of the model/object.
class LRRadio {
idc=90909;
type=82;
movingEnable=0;
model="\A3\ui_f\objects\radio.p3d";
scale=(0.235*0.675*(SafeZoneW Min SafeZoneH));
direction[]={0,10,1};
up[]={0,1,0};
inBack=0;
x=0.4*safezoneW+safezoneX;
y=0.58*safezoneH+safezoneY;
z=0.22; // dis b da bad boi?
xBack=0.4*safezoneW+safezoneX;
yBack=0.58*safezoneH+safezoneY;
zBack=0.22;
enableZoom=0;
zoomDuration=1;};
SOLVED: This seems to have fixed it for the z axis:
z=0.19+pixelH*pixelGridNoUIScale;
GUI related questions go in #arma3_gui
When the player is in a vehicle, and drives near an ammo bearing vehicle, like the ammo truck, there appears a 'rearm' icon. Upon pressing, the player vehicle is rearmed.
I would like to have a look at this rearm routine. Is this possible, or is it hardcoded?
hardcoded
@winter rose thought so. Thank you.
This didnt work at all, nothing happened when i pressed those keys
@fathom rapids Paste your code here
You need to initialize the event handler during the start of the mission
can you tell me how to do that and where it goes?
i can read the scripting code that arma uses, i just cannot write it
sorry
Is there a way to force intercept to ignore this? (i.e execute my code no matter what!)
initPlayerLocal.sqf:
fnc_onKeyDown_burbMagRepack = call compile preprocessFileLineNumbers "path/to/your/script.sqf";
fnc_burbMagRepack = call compile preprocessFileLineNumbers
"path/to/magRepackScript.sqf";
[] spawn {
waituntil {!isnull (finddisplay 46)};
burbMagRepack_keyDownEHId = findDisplay 46 displayAddEventHandler ["KeyDown", {call fncBurbMagRepack}];
};
Your script (see above: "path/to/your/script.sqf")
params ["_ctrl","_button","_BtnShift","_BtnCtrl","_BtnAlt"];
private _buttonDisabled = true; // true: block the original comand, false: Execute the normal command of that button
if (_button isEqualTo 39) then
{
// For now, button R is just registered
// If CTRL is pressed, repack mags
if (_BtnCtrl) then
{
call fnc_burbMagRepack;
};
};
_buttonDisabled
"path/to/magRepackScript.sqf":
// Whatever the mag repack script is, paste it here
@fathom rapids
Fix'd
Why re-invent the wheel. Just make MagRepack Mod and Earplug mod optional. Then ppl can use or not.
Please, can someone explain, why this works,
_turrets = [_unit] call BIS_fnc_getTurrets;
{
_magazines = getArray (_x >> "magazines");
_turretPath = (_turretPaths select _foreachindex);
diag_log format ["_magazines: %1, _turretPath: %2", _magazines, _turretPath];
} forEach _turrets;
while this throws an error?
{
_magazines = getArray (_x >> "magazines");
_turretPath = (_turretPaths select _foreachindex);
diag_log format ["_magazines: %1, _turretPath: %2", _magazines, _turretPath];
} forEach [_unit] call BIS_fnc_getTurrets;
} forEach [_unit] call BIS_fnc_getTurrets;
} forEach ([_unit] call BIS_fnc_getTurrets);
See https://community.bistudio.com/wiki/Order_of_Precedence @languid oyster
//Plant
objective_2 = true;
target_5 addEventHandler ["killed", {
killed = _this select 0;
killer = _this select 1;
systemchat format ["%1", killer];
objective_2 = false;
hint "Plant is destroyed";
}];
target_5 is undentified rpt says
Put target_5 to the Object Variable Name instead?
ooouf
Not sure where you run this thing though
run your code via your own eachFrame handler and command
What if I want it to be "scheduled"? Is that possible?
also why do you use so many global vars?
killer = _this select 1;```
params
_ before a variable name is convention for a private/local variable?
local
local and private are different things
objective_3 = true;
target_6 addEventHandler ["killed", {
killed = _this select 0;
killer = _this select 1;
systemchat format ["%1", killer];
objective_3 = false;
hint "Radar destroyed";
}];```
This will work too? i need only objective_3 = false;
```sqf
objective_3 = true;
target_6 addEventHandler ["killed", {
objective_3 = false;
hint "Radar destroyed";
}];```
sorry im not into programming at almost all
all code in init.sqf
is there a good way to do that?
All I can think of is measuring the execution time with std::chrono::high_resolution_clock::now() after every function call 
figure something out π
yes
but don't use loops to check when objective_3 becomes false
whatever you want to do, do it with that event handler.
example
objective_3 = true;
target_6 addEventHandler ["killed", {
objective_3 = false;
hint "Radar destroyed";
["some_task", "SUCCEEDED"] call BIS_fnc_taskSetState; //complete this task
}];
_playerVehicles = [];
{
_x addEventHandler [
"Hit",
{
params ["_unit", "_source", "_damage", "_instigator"];
[_unit] spawn
{
_unit = _this select 0;
if (!(_unit in playerVehicles)) then
{
Why is _playerVehicles not accessible from inside the EH?
This is a followup to my previous Q about variable scopes
If I use _ without private
Because the EH has its own scope @slate cypress
ah so is the only workaround to remove the _ from _playerVehicles?
or are there other ways
also why isn't the EH scope a child scope of the script itself?
because it is a code that will be executed by the engine at some point by itself)
if you want external data, either calculate it from within the EH or use global variables yes
(also, you have playerVehicles both with and without underscore)
oh yeah that's because I changed it from a global variables to a local variable to describe the question better but forgot to change playerVehicles to _playerVehicles π
ok thank you π
so what would be the difference between using sqf private playerVehicles = []; and ```sqf
playerVehicles = [];
both will be accessible from the EH
private would mean that playerVehicles cannot be accessed from outside that scope/script but it can't be accessed from outside even without private?
private playerVehicles = [];
````private` is of no use here
see https://community.bistudio.com/wiki/Variables#Local_Variables_Scope the schema there to see where private is useful
so if I'm correct, playerVehicles = []; won't be accessible from outside the script unless I use publicVariable?
global != public
global means it can be accessed from anywhere in the script and public means it can be accessed from anywhere in the script and other scripts in the mission?
no, a public variable is accessible by the server and other clients
and a global just on the local machine?
Correct
I think you want to use set if you want to insert a value at the front.
Index 0
append and pushBack will both add it at the end
set will replace the value though
yes sir; is3DENPreview
_modelInfo = getModelInfo _unit;
_modelPath = _modelInfo select 1;
_simpleObject = createSimpleObject [_modelPath, getPosWorld _unit];
How can I modify this so that the simple object is in the same orientation as _unit?
see vectorDir, vectorUp etc? π
I tried vectorDir and getDir but I couldn't get either to work.
_modelInfo = getModelInfo _unit;
_modelPath = _modelInfo select 1;
_orientation = vectorDir _unit;
deleteVehicle _unit;
_simpleObject = createSimpleObject [_modelPath, getPosWorld _unit];
_simpleObject setVectorDir _orientation;
setVectorUpaftervDirtoo
@slate cypress setVectorDirAndUp
_modelInfo = getModelInfo _unit;
_modelPath = _modelInfo select 1;
_vectorUp = vectorUp _unit;
_vectorDir = vectorDir _unit;
deleteVehicle _unit;
_simpleObject = createSimpleObject [_modelPath, getPosWorld _unit];
_simpleObject setVectorDirAndUp [_vectorDir, _vectorUp];
It still doesn't work unfortunately.
of course, you delete the unit before getting its pos
I fixed that but it somehow worked even though I got the position after deletion. The rotation is still not as intended.
how is it? 180Β° opposed? other?
because simple objects are sometimes wrongly oriented
Yes 180 degrees
also have you heard of our lord and saviour BIS_fnc_replaceWithSimpleObject?
Also the wheels are in the ground
Simple objects use the model center as "land contact"
Yes but it recommends not to use it in MP scenarios.
(they actually don't have land contact)
sure, but it is doing what you are doing (but better)
wait so if it does the job then why does the biki advise against it in MP?
performance I suppose
I tried it and it worked... however it didn't register as a simple object to any of the machines
I have no more info about it
Is there another method with better performance?
params
[
["_template",objNull,[objNull]],
["_forceSuperSimple",false,[true]]
];
if (isNull _template || {count crew _template > 0}) exitWith {["[x] Template object (%1) must not be NULL and must not contain any crew!",_template] call bis_fnc_error;};
if (isSimpleObject _template) exitWith {["[x] Function was executed on simple object!"] call bis_fnc_error;};
private _class = typeOf _template;
if (_class == "") exitWith {["[x] Cannot retrieve classname!"] call bis_fnc_error;};
//scan simulated object
private _data = [_template] call BIS_fnc_simpleObjectData;
//get world position, dir and vector up
//private _pos = getPosASL _template; _pos set [2, (_pos select 2) - (_data select 3)];
private _pos = getPosWorld _template;
private _dir = getDir _template;
private _vectorUp = vectorUp _template;
//delete simulated object
deleteVehicle _template;
//create simple object
private _object = [_data,_pos,_dir,false,_forceSuperSimple] call BIS_fnc_createSimpleObject;
//set position (to negate built-in auto-adjusting)
_object setPosWorld _pos;
//set vector up
_object setVectorUp _vectorUp;
_object
comes from that function
how can I delete this simple object after?
deleteVehicle doesn't seem to work with simple objects
it does
sleep waitForDisabledVehicle - waitForBody - 1;
deleteVehicle _unit;
"The vehicle has been deleted!" remoteExec ["hint", 0];
"The vehicle has been deleted" gets outputted
vehicle remains
what is _unit? π
a simple object created with replaceWithSimpleObject
how do you get it?
"A vehicle has been disabled!" remoteExec ["hint", 0];
sleep waitForBody + 1;
_unit call BIS_fnc_replaceWithSimpleObject;
"The vehicle has been turned into a simple object!" remoteExec ["hint", 0];
sleep waitForDisabledVehicle - waitForBody - 1;
deleteVehicle _unit;
"The vehicle has been deleted!" remoteExec ["hint", 0];
yep, the original _unit has been deleted
private _simpleObject = [_unit] call BIS_fnc_replaceWithSimpleObject;
ah ok thanks
publicVars are synced with a delay
they probably only exist way after init
JIP is different
So I'm trying to use this
_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];
for "_i" from 0 to (count _arsenalData - 1) step 2 do {
_name = _arsenalData select _i;
_arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
_nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;```
which I found on the forums to import loadouts from virtual arsenal into the respawn menu.
As it said there, it is in both initPlayerLocal.sqf and OnPlayerKilled.sqf
However, rather than allowing me to choose, it just gives me a random kit I have saved.
Yes
are you sure this is correct
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
because it will get and set from different locations
I am having troubles with scopes.
What do I have to do, to have an outer variable be found in e.g. an event handler?
No matter what I do, it is not defined within the event handler's scope
is that even possible?
I think it's fine
Altho the code is written very badly
Problem is; if one person stores it in the mission namespace, and a second person overwrites it, the first person will get the loadout from the second person.
And, if you save stuff in mission namespace, it won't be available in the profile namespace... so will never be available
any known issues with BIS_fnc_EGSpectator currently causing the respawn UI not to load with default arguments?
/#login PRONIGHT
it's not public
missionNamespace is global, profileNamespace is local
So it will mess up stuff when used wrong
missionNamespace is global for the client
it's not "shared"
aka not public
it requires the public flag to become public
Returns the global namespace attached to mission.
So it's global for the mission, aka everyone can access it
missionNamespace setVariable ["something", 1];
```is the same as
```sqf
something = 1
which still doesn't solve the issue of using 2 different namespaces π€·ββοΈ
Depends which namespace the game reads from
it can be valid
I don't know
I haven't looked at how the game reads the inventory stuff
Yeah that makes sense
which is being released...
... on Tuesday
Not living in the same timeline
finger cross π
Well that's only the official ETA. We'll see.
ahah, what are the chances of me making this command myself and BE whitelisting my addon, before 2.0.2 is released?
who is fastest, BE or BI
You know how to use Intercept?
yeah
Then go for it π€£
hahaha
BI as they should release on Tuesday
Radical, delete the saved in in the script and test it.
Can it be good for performance to activate dynamicSimulation for groundweapon holder ?
not really
If I have a script for a mission and iterate over all units. Is that particular code executed on the server or on each client?
depends on where you execute that script
init.sqf?! π
[] execVM "inventory_ieds.sqf";
init.sqf runs on server and clients.
initPlayerLocal only on players
initServer only on server, ...
I think the wiki page for them is called "Event Scripts"
Okay, I will take a look. Not sure if that is the behaviour I want/need π
I suspect the best approach for you will be to run the script in initServer.sqf, and in the script use remoteExec to target the machine where each unit is local
Yes, I think that would work.
but why. initPlayerLocal runs script locally too. And itsn't so wasteful as a remoteExec
it might not be only players
and it sounds like inventory commands so you only want it to happen once per unit
can someone give me the bohemia page on vehicle parts? I wanna damage an engine when players are inside
yeah, that is my concern, that it is executed too many times or for the wrong players π
arma 3 scripting Commands sethitpointdamage <- highlight, right click, search with google. π
You might wanna consider CBA XEH (that is if you're using CBA)
if it's a one time thing
I tried initPlayerLocal.sqf, but whatever I put in there it is only executed on the host. π¦
Read what others wrote again:
use remoteExec
and you didn't say if it's a one time thing or a loop
But isn't initPlayerLocal supposed to work as well?
yeah
Just want to understand, because documentation states it should work
I'm not sure what you meant by only executed on the host.
the person hosting the mission sees all the stuff what is scripted in initPlayerLocal.sqf. Other players connecting, won't
and what "stuff" is that?

