#arma3_scripting
1 messages · Page 674 of 1
oh.
class CfgFunctions
{
class bsTag {
class buyShop {
file = "functions";
class vehicleIsBuyable {};
};
};
};
looks for functions\fn_vehicleIsBuyable.sqf
no
Aah
I'm pretty sure you can also do that if you only "add one function at the time". I saw sth like that in a description.ext anyway, and the function worked just fine. But yeah, I think what Leo suggested is definitely easier & clearer
And the code can just be in that file without wrapping it ye ?
yes but it should be in the function class itself
not the category
weird, it says: script functions not found 
description.ext
class CfgFunctions {
class bsTag {
class buyShop {
file = "functions";
class vehicleIsBuyable {};
};
};
};
you have "functions" folder in the mission folder?
what you put two cfgFunctions?!
No that's sarcasm lol, keep trying.
A while back ago i was searching a script to make the scope more "Realistic" on RHS scopes but now i wanna put it back to normal and i have no idea how?
and its getting annoying. Some scopes doesnt work at all anymore. It more like zoom out, most SU230 scopes i think was is called are fucked
@little raptor one more thing, _price is not reachable so i need t opass a variable to that object right? like this:
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction['Unlock', {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
if([player] call HALs_money_fnc_getFunds >= _price) then {
[player, -_price] call HALs_money_fnc_addFunds;
_target setVehicleLock "UNLOCKED";
_target removeAction 0;
{ [west, 'HQ'] sideChat format['%1 just purchased a car for €%2', name player, _price]; } remoteExec['call'];
}
}];
Well, just tested it and seems to be working 
or not 
{ [west, 'HQ'] sideChat format['%1 just purchased a car for € %2', name player, _price]; } remoteExec['call']; everything works expect the fact that it outputs: BlackShadow just purchased a car for €any 🤔
so i need to pass it on again?
pass it on?
so { [west, 'HQ'] sideChat format['%1 just purchased a car for €%2', name player, _price]; } remoteExec['call']; this can reach it? or need to make it global?
_price to price
urgh, no
not global
[[west, "HQ"], format ["%1 paid %2€", name player, _price]] remoteExec ["sideChat"];
what you are saying here is "create the string locally, and send it to be sideChatted there"
[leftArgumentIfAny, rightArgumentIfAny] remoteExec ["command"]
it's only that really 🙂
It looks so difficult x)
how so? 😄
if you want to hint something where player_1 is local, do```sqf
["Hello"] remoteExec ["hint", player_1];
[thatGuy, 1] remoteExec ["setDamage", thatGuy];
```(ok here it does not make sense since it is a global command, but you get the idea)
thatGuy twice ?
the second thatGuy means "exec this on the machine where thatGuy is local"
aah oke
it can be the server if a unit is playable but not played, or on the player's machine
ty
it gifs error plz help
File C:\Users\dylan\Documents\Arma 3 - Othet Profiles\falcon\mpmissions\warlort%20v8.takistan\description.ext, line0: '.Class': 'C' encounterd instead op '='
Did you followed some tutorials?
Hm peeps what'd be the right way to add an ace self interaction to ever player inside a trigger area?
I've been looking at this ace wiki page which explains how to add an action using code, but I'm not sure what'd be the right condition https://ace3mod.com/wiki/framework/interactionMenu-framework.html
why trigger area?
also is it a "dynamic" trigger?
as in can people enter later on?
yes
I want to make a sort of thing where when the player is at base they get a self interaction to set up their TFAR SR/LR frequencies
and then the base is just contained in a trigger
but if you have a better idea I'm open to suggestions 👀
🤔
why not some local triggers
that run for each client
when they get in they get the action
when they get out it's removed
i can move in effectCamera now
cameraEffect
or what it was
Well, you better to read the tutorial again... this time, carefully
you're going way above my level now
Class has to be class; must be lowercase
i had to override and re-write the entire Arma 3 movement system
_trigger = createTrigger ["EmptyDetector", _pos, true];
_trigger setTriggerActivation ["ANYPLAYER", "PRESENT", true];
_trigger setTriggerStatements ["this", "thisList call some_fnc_addAceAction", "thisList call some_fnc_removeAceAction"]
Oh wait I could props also just throw the ace interaction code into the triggers activation/deactivation fiels, no?
when the player is at base they get a self interaction
yeah but it's not that readable
also note that triggers activate only ONCE
- It's
CfgWLRequisitionPresetsnotCfgWLRequisitionPreset requirments [];illegal.requirments[] = {};correctrequirments [H];the[]is here not to declare things in an array.{H}.requirments [H]=;requirments [A]={A};
"West" >> "CUP_B_US_Army" >> "Infantry"incorrect,"'West' >> 'CUP_B_US_Army' >> 'Infantry'"
if player A gets in, trigger won't activate for player B
tanks
is there an eventhandler i can use to hook into the player tabbing in/out of arma
Alt+Tab you meant?
isGamePaused
If so, isGameFocused is the getter command. No EH, tho
also note that triggers activate only ONCE
you can set them to repeatable, no? or do you mean that they activate once when the first person comes in and when another person comes in they arent activated again for that person?
yeah

which is why I suggested local triggers
I wish stuff was just easy 
they can be
just use a loop! 😄
Eh I'll throw it on the to-do list and pick it up again at some point I guess, not feeling like spending my evening on it now
while {true} do {
waitUntil {
sleep 1;
player inArea _trigger;
};
call some_fnc_addAction;
waitUntil {
sleep 1;
!(player inArea _trigger);
};
call some_fnc_removeAction;
};
_trigger can just be an area, not necessarily a trigger
(^ goes in initPlayerLocal.sqf)
it's a local variable
Ye I know
you can just use some trigger you defined in the mission
_trigger = my_mission_trigger
ah 👍
(and put it outside the loop)
Ye ye
Read what I wrote again, please
yes I dit but its stil not wurking
CAREFULLY this time. No workaround, no ignore something. Read what I wrote, follow what I wrote, carefully
requirments[] = {};
isn't this a #arma3_config question?
and i cant use that command when the game is not focused because scripts dont run?
if they have pause on lose focus
Yes you can use. Scripts will run even if you don't focus on it
nice
@little raptor remember my code with buyingVehicle, my mate bought a vehicle and it unlocked but he cant get out x)
You know why by any chance?
this
he has to pay for the ride too 😛
or maybe for gas 
x)
Thats what i got right
I meant look at the locality 
Is there a way to emulate the same black bar effect of BIS_fnc_cinemaBorder without using it?
I want the players to still be able to run around when the effect plays and not stop them in their tracks.
_target removeAction 0;
player
yes
use rscTitles
but its one the car right
I mean use _actionID instead of 0 and use _caller instead of player
also I have no idea what you just said 
cutRsc ["RscCinemaBorder", "PLAIN"]; Is how BIS_fnc_cinemaBorder does it
Sorry x), I mean the action is on the car right.
it is
but that's not the issue
first of all do what I said here:
#arma3_scripting message
_caller removeAction _actionId; changed it do this now.
second of all, setVehicleLock requires the arg to be local

change player -> _caller
not _target -> caller
and this?
#arma3_scripting message
@heady quiver locaaal, so remoteExec!!
but _target is localvar right x)
of course, if you don't change the code it won't change the effect 😄
i know i was just looking
_var is a local variable (meaning, private to the script/scope)
But the object might be remote (as in, "on another" PC)
NOOO

why do you keep using remoteExec ["call"] ?!
Apply what I told you earlier ;-)
[_target, _actionId] call ['removeAction', _target];
also Lou told you some comments ago
sigh.
why _actionid?
woops
removeAction *
[_target] remoteExec['setVehicleLock', _target];
[_target, _actionId] remoteExec['removeAction', _target];
did I say anything about removeAction?!
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
_target setVehicleLock "UNLOCKED";
_target removeAction _actionId;
[_target] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
Yes, but it needs to be unlocked for all players.
it has GLOBAL effect
it will be
first of all
_target setVehicleLock "UNLOCKED";
second of all
[_target] remoteExec ['setVehicleLock', _target];
I mean correct those
read https://community.bistudio.com/wiki/Multiplayer_Scripting @heady quiver, it may help 😉
is there anyway i can return or calculate the inventory level on armor?
like the level 1
awesome didn't know about this. still a bit confused about getting titleRSC and cutRsc to work together, titleRSC just seems to stay there and cut can't effect it, cut's effects are instant and over before i can do anything but I think i get what i need to muck around with from the wiki. Found a steam thread though that's got what I needed so don't worry, I'll figure out cutRsc in time.
https://steamcommunity.com/app/107410/discussions/17/1729837292638666076/
what level?!
you know when you hover over it in your inventory and it gives you the Armour level
Armor level: I, II, III, IV
hovering over clothing items ingame that offer protection give you "armor levels" in the hover text. that's what they're probably referring to
oh that
ok
@hearty loom ```sqf
getText (configFile >> "CfgWeapons" >> vest _unit >> "descriptionShort")
it's a text
not number
in case you're still on that
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
that's it
remember: leftArg, rightArg
and remove the duplicate
_target setVehicleLock "UNLOCKED";
it will ruin everything
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
_target removeAction _actionId;
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
I guess it'll work
give it a go
Here is an example of an SQF command that we want to write a remoteExec for:
_target setVehicleLock "UNLOCKED"
``` ^1 ^2 ^3
1: `leftArg` (what's on the left of the command)
2: `command`
3: `rightArg` (what's on the right of the command)
`remoteExec` template:
```sqf
[leftArg, rightArg] remoteExec ["command", ...];
``` Just copy paste the `leftArg`, `rightArg` and `command` into the template. You can add the `remoteExec` target and the rest of the parameters (such as JIP, see the wiki) in the `...` area.
so it becomes:
```sqf
[_target, "UNLOCKED"] remoteExec ["setVehicleLock", _target]; //setVehicleLock must be executed where _target is local, so we put _target in the ... area
Another Example: unary command (no leftArg)
hint "hello"
``` ^2 ^3
(no `leftArg`, so skip)
```sqf
["hello"] remoteExec ["hint", 0]; //show the hint to every client
Another Example: a binary command with multiple arguments in the rightArg array
_unit addAction ["hello", {code}]
``` ^1 ^2 ^3
```sqf
[_unit, ["hello", {code}] ] remoteExec ["addAction", 0]; //add the action to _unit for every client
A tricky one: unary command with array rightArg:
createSimpleObject ["Land_Wrench_F", _pos, true];
``````sqf
[["Land_Wrench_F", _pos, true]] remoteExec ["createSimpleObject", _player]; //creating a simple object locally on another machine (_player's)
**Functions: ** This is how you remoteExec a function:
[_arg1, _arg2, _arg3] call My_fnc_function
``````sqf
[_arg1, _arg2, _arg3] remoteExec ["My_fnc_function", ...];
the function only needs to be defined on the target machine(s)
Nular commands or functions with no parameters:
remoteExec ["My_fnc_function", ...]
Yea it works.
Only thing is that the buy option stays for everyone else.
remoteExec removeAction
note that actionID may not be the same for everyone
you'll have to store it
Any way to make an 'on salute' event handler?
that's an animation
use animStateChanged EH
Gotcha, thanks!
Another question- is it possible to add event handlers to certain uniforms, vests etc.?
Via config, that is
And is there any way to create 3D text within the world, using whatever principle setPlateNumber uses?
user textures?
Well yes, but I mean to specifically create 3D text from a string input
In the same way that you could with setPlateNumber
Like, a jank solution would be to find an object I could modify with setPlateNumber, attach it, and just remove all its textures, but that's a rather inelegant solution
I mean, there is a 4×4 "user texture" object
but nothing where you can set "use this text plox kthxbai"
Someone could make [as a mod] an object that's nothing but a holder for a setPlateNumber display, but there's not one in the base game
Made before. It didn't satisfied me
@tidal ferry what kind of usecase do you have?
Just looking to try and add nametags to some uniforms
Would save a lot of data to have a function that could do that instead of a bunch of individual name tag textures
Id say if you are going through the trouble of adding name tags that are quite hard to see anyway, do it with textured tag object and the textures.
if you want it to look anyway nice
I've attempted to modify a Getin event handler that I had to a WeaponAssembled event handler, but it's not working. Anyone willing to take a look at it and tell me what I'm doing wrong?
["I_HMG_02_high_F", "WeaponAssembled", {
params ["_unit", ""];
if !(_unit getVariable ["WeaponSP", false]) then {
playSound "Denied";
["<t color='#FFBB00' size = '.5'>You're not a Weapon Specialist.</t>",-1,0.8,5,0.5,0,789] spawn BIS_fnc_dynamicText;
};
}] call CBA_fnc_addClassEventHandler;
you're supposed to add the event handler to the unit, not the weapon
so, add to CAManBase class instead
Hoping one of you folks can give me a hand. I'm creating dynamic patrol groups but, as you can see from the code, each one is given a private variable name that is the same as the previous group.
It works fine but I don't think it's best practice and I'd also imagine the previous group variable would no longer exist.
So, does anyone have a suggestion on how I can give each group a unique private variable as they are spawned in?
//Spawn patrol groups
_smlGroups = [];
for "_i" from 1 to 5 do
{
private _patrolPos_01 = [_trigPos, 0, 100, 0, 0, -1, 0, [], [[0,0,0],[0,0,0]]] call BIS_fnc_findSafePos;
private _patrolGroup_01 = createGroup [TPHSide, true];
for "_i" from 1 to floor (random [4,4,6]) do {
_patrolUnit_01 = _patrolGroup_01 createUnit [selectRandom TPHUnits, _patrolPos_01, [], 0, "NONE"];
};
[_patrolGroup_01, _patrolPos_01, 150] call bis_fnc_taskPatrol;
_patrolGroup_01 enableDynamicSimulation true;
_smlGroups pushback _patrolGroup_01;
sleep 0.15;
};
why would you want to do that
the ideal way would be to use an array, like you're doing it right now(neat if you need to do something with those groups later)
@copper raven Ok now it registers that I don't have the correct Variable, plays the sound and gives error notice. But it still builds the static. I'm not sure what to add to stop the build process.
My primary concern is that, as each new group is created using the same variable name, the previous one loses it's identity.
@copper raven Thank you, I'll look into that.
I'm running this on a server, together with LAMBS_danger, and each time a firefight kicks off the rpt is spammed with Ref to nonnetwork object and I'm wondering if it's looking for a group name that no longer exists. I could be waaaaay off, and probably am, but if there is a way that I can rule it out by assigning unique variable names it'd help.
that message is w/e seen it a lot of times for a long time now, nothing to do with that
It only pops up when I'm running LAMBS though, so it got me thinking.
maybe something's broken
in the mod
some people verify cache and it fixes it
wouldn't worry about that log message though
Righto, cheers for the assistance.
anyone have a script for teleport on mission start? My mission is teleporting me way the heck out in the middle of no where under water so i need a script that runs on mission start to teleport players to where they are supposed to start.
oh shit thats perfect! of course if only i had googled set position of object instead of teleporting scripts lmao thanx mate!
I would like to write something that would run a script every time a player added a UAV terminal to their loadout. But i'm not sure what function I should be looking at. Any suggestions?
Containerclosed event handler, then check assigneditems is a solid start.
Anyone have any tips on how to time-effectively make a small model scale of a compound/HQ/village with setObjectScale?
There is already a script/mod that does that on the workshop
@still forum Mind sharing the name of that mod?
Don't remember
Seb's Briefing Table
https://steamcommunity.com/sharedfiles/filedetails/?id=2422853226
@buoyant hare
@sharp grotto cheers big ears!
So is there a script to force a type of glasses onto a character and still have the glasses slot freed up?
like a way to force it onto the character model itself like adding a flag to a vehicle?
when I'm looking through functions say on CBA/ZEN/ACE github etc, when you are reading the file description and they do the name, arguments, usage, and stuff, and they list Public, does that usually refer to public as in, open to everyone to look at on github, or do they mean a function that is known by every client?
could you send an example?
you can just attach it
this particular one I'm looking on ZEN's github...
/*
* Author: Kex
* Makes the given VLS unit fire on the given position.
*
* Arguments:
* 0: VLS Unit <OBJECT>
* 1: Position <ARRAY|OBJECT|STRING>
* - in AGL format, or a Map Grid when STRING
* 2: Spread <NUMBER>
* 3: Magazine <STRING>
* 4: Number of Rounds <NUMBER>
*
* Return Value:
* None
*
* Example:
* [_unit, _position, 0, _magazine, 1] call zen_common_fnc_fireVLS
*
* Public: No
*/
@little raptor attach it meaning?
attachTo
ehh, idk for sure. my guess would be it is Public: yes if it is a function intended for public use vs a function only intended for use within other systems of the mod
I didnt know you could do that with characters and gear items i will give it a shot
oh I see what you are getting at, didn't think about just internal mod use
they have a model
you just create it and attach it
can that be done through config files for a custom character? thats ultimately my goal
Not working
might i also add there isnt a placeable model for the glasses item im wanting to use
without remaking the model no
ok that answers my question then
then why do you ask for a "script"?!
#arma3_model
hello, does anyone know if you can set the playback speed for a pre-recorded unitCapture script?
e.g. if I wanted it to go faster than was recorded
not possible
unless you make your own function
a shame! I thought there'd be some remnant of that feature in A3 since I've seen a similar thing be available in VBS so I assumed it was reused haha
Hey guys. How can I prevent editing in my profile fovTop and fovLeft
Probably related to this: https://feedback.bistudio.com/T157579
since I can't send args to a onEachFrame handler, and I can't use a missionnamespace variable as its has the potential of being overwritten by another instance of the script, should I just use a really small sleep on a while loop? how small for a frame?
i'm trying to avoid CBA to keep no mods. But I know they have a perFrameHandler function that allows for args.
depends what you want to do
I normally design my each frame loops like this:
var_scheduler = [];
onEachFrame {
{
_x#0 call _x#1;
var_scheduler set [_forEachIndex, 0];
} forEach var_scheduler;
var_scheduler = var_scheduler - [0];
};
var_scheduler pushBack [nil, {hint "hello"}];
```(I use a bit more complicated version, but that's the gist of it)
it's essentially the same as what I wrote above
hmmm interesting
also don't use onEachFrame 
I'm looking at doing some VLS missile tracking a target since the target would move (have to move a static laserTargetW). I could probably sacrifice some accuracy for a lower refresh time and performance and just do a loop every .2 sec or something
be wary of the scheduled environment 
oh did you mean don't use the onEachFrame command or the event handler then?
oh I get that. I was referring to your dont use onEachFrame after you just posted a work around for onEachFrame lol
oh. of course I meant the command.
Q: how robust is BIS_fnc_sortBy when the thing being sorted is 0- or 1- elements?
Q: how robust is BIS_fnc_sortBy when the thing being sorted is 0- or 1- elements? i.e. do I need to include any special wrapper logic around that? like a count-oriented switch ... do, let's say?
Of course, responding accordingly to arrays of different sizes, would not want to _array#0 a 0-element array due to DBZ errors.
wdym 0 elements?
if you mean the original array, then it's empty
what's there to sort?
@little raptor well, that's my question. if I approached it "ignorant" of the size, 0- or 1- element arrays do not need to be sorted, but can I feed that through the sortBy algo anyway? is it robust enough to handle that? or am I right to wrap that in a switch or other construct?
yes
I'm just looking for ways to potentially clean up my code without this pattern cropping up
something that's empty won't get sorted
or said, could consider count _x > 1 gets sorted?
in terms of gauging sortBy robustness I mean
I have no idea what kind of "robustness" you're going for
but here's the sortBy function
#include "..\paramsCheck.inc"
#define arr1 [_inputArray,_inputParams,_algorithmFnc,_sortDirection,_filterFnc]
#define arr2 [[],[],{},"",{}]
paramsCheck(arr1,isEqualTypeParams,arr2)
_inputParams params ["_input0", "_input1", "_input2", "_input3", "_input4", "_input5", "_input6", "_input7", "_input8", "_input9"];
// filter is specified
if !(_filterFnc isEqualTo {}) then
{
_inputArray = _inputArray select _filterFnc;
};
// alternative sorting algorithm is specified
if !(_algorithmFnc isEqualTo {}) exitWith
{
_cnt = 0;
_inputArray = _inputArray apply
{
_cnt = _cnt + 1;
[_x call _algorithmFnc, _cnt, _x]
};
_inputArray sort (_sortDirection == "ASCEND");
_inputArray apply {_x select 2}
};
_inputArray =+ _inputArray;
_inputArray sort (_sortDirection == "ASCEND");
_inputArray
okay, so practically speaking,
private _ranges = _units apply { (getPos _x) distance2D _markerPos; };
private _sorted = [_ranges, [], { _x; }] call BIS_fnc_sortBy;
_sorted params [
[Q(_range), -1, [0]]
];
_range;
There may be no units, one unit, or how ever many units.
yes
if you've already used apply why do you sortby?
just sort
and if you care about "performance" never use getPos
in this instance, sure, good point. for those times when may be dealing with arrays of a different shape.
I can just use the unit itself? i.e. _x distance2D _markerPos (?)
yes
but I mean getPos is the slowest position command
oh I see, is there a better one? that plays well with markerPos?
in this case it's 2D
so it won't matter
getPosWorld/getPosASL/getPosATL are the fastest
but they are different in 3D
yes oc
if I wanted basically "on the ground" reference?
guessing that's getPosATL
on the ground or from the ground?
"terrain" as the docs suggest
I mean 0 height from the ground?
or the actual unit height (e.g when in building)
but as you said, 2D, so likely a wash, but for performance gains
in your example just use the unit itself (for distance2D)
but getPosWorld is the fastest
by a small margin
okay dokay, thanks. appreciate it.
Is there a way to add decimal numbers to round numbers? Like I want to turn 75 into 75.0000
toFixed
thanks, the explenation got me confused
Curious to what you want to use 4 decimal accuracy for.
either way, all numbers in sqf are floats
that's just useful for string representation
(also floats have only up to 7 significant digits afaik)
Ah so probably useful for UI for say a countdown as returning a countdown directly would give all the decimals of time.
Instead of doing the math directly with a round or something then showing that.
Does the init.sqf get executed for every person on a server?
yes, and the server
it does on mission start
Thanks
biki -> Event Scripts
So what would happen if I executed an entitykilled eventhandler in the init.sqf?
it would fire for every computer
it would execute it for the server and every player 😄
Right just making sure, thanks a lot!
hi, im new to this (very), and im trying to make a mission that has two objectives-
1 - Kill a target
2 - Extract the three Hostages
the second objective needs to be triggered by the first one being completed, and once the second one is completed, the mission is complete.
Fail condition is if all three hostages are killed.
ive got the entities sorted out but now i need to work on the actual guts of the mission - the objs and pass/fail conditions. TIA
why is CBA's wait and execute preferred over using waituntil?
because it runs in an unscheduled environment
Target's death: give the target unit a variable name, create a trigger with !alive your_target_name as the activation condition.
Hostage extraction: well....this is more complicated and depends on how you want the extraction to work.
Hostages dead: trigger with (!alive your_hostage1_name) && (!alive your_hostage2_name) && ...
For sequential objectives you can sync Tasks modules to the triggers (though my personal preference would not be a hard requirement to do them in order, just give them the objectives and the freedom to choose the order), and use triggerActivated target_dead_trigger as part of the hostage extraction's conditions
... pain... i just overwrote my scenario attempting to load it from a blank map...
good thing most of it is scripts but man is that annoying
thats why i always make backups lol
i also just lost most of my profile data because of a power outage
arsenal loadouts, settings, addon settings etc are gone
paaaaainnn
and my last backup is from january OOF
well at least i still have most of the settings and loadouts
love to get patronising little "you're such an idiot" emojis stuck to my message because I didn't manage to divine the one true approved way of solving the problem
i've come to collect them now
how would i remoteExec this?
MAN4 setGroupID ["Blue Boy"];
MAN4 sideChat "Test Text Hello!";
or more so make it so when a trigger goes off with server only ticket that it this side chat text appears for all players
//Normally
A command B
//RemoteExec
[A, B] remoteExec ["command", whereTO]
try that and i'll check it
[MAN4 ["Blue Boy"]] remoteExec [setGroupID, 0];
[MAN4 "Test Text Hello!"] remoteExec [sideChat, 0];
can't test right this second because i need players so i'm making as many versions as possible of things to test atm, but is this looking right?
ah no getting a "missing ]" error. hang on let me try fix this
[MAN4 missing , on both lines
ah right, thought because you didn't need comers in the original you could get away with spaces. now i think about it probably not lol
yeah there we go, thanks Connor
Maybe you fixed it already but it should be ["setGroupID",0] (etc.) - the quotes are important
Yes, always for the command name in a remoteExec
excellent thank you. that's what might have been causing me other problems too
missionNamespace setVariable ["PART10", true, true]
[setVariable ["PART10", true, true]] remoteExec ["missionNamespace", 0]
due to how the command is structured I have no idea, but how would i do it with this, can't get it not to spit errors right now
remember, you can remote execute to objects and stuff too. like if you put a vehicle in spot for your 0, you can send the function to the owner (typically driver) of that vehicle's client
oh nice
good to know that helps a lot thanks
so on your missionname space thing
that second "true" makes it public
so you dont have to remote exec it at all
just be careful. its the same as using publicVariable and if you over use it, you can clog the network
ah, right. gotcha.
setting up a large test mission to see what things work so i wanted to see if a remote version would work. makes sense though thanks.
if you don't need to send it to every client, then don't. keep it on the server
[
this,
"Turn on table",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"_this distance _target < 3",
"_caller distance _target < 3",
{},
{},
{ missionNamespace setVariable ["PART3", true, true] },
{},
[],
3,
0,
true,
false
] call bis_fnc_holdActionAdd;
main thing i've been trying to do is this, which i think will work now hopefully lol because I've been having hell with hold actions due to trying to remote execute the whole thing lol.
yes, that would be an instance where you would make it public. I had to do that recently as well
just remember, if that code is only firing on the server, you still need to send the whole handler to the clients as well
example of what I had to do recently
oh damn this is some good stuff thanks for sharing that
"_this distance _target < 3 && !PART1",
"_caller distance _target < 3 && !PART1",
if you where going to have this for the requirement stuff for a MP game, would having PART1=FALSE in init.sqf be the right move? Or would having it in initServer.sqf?
well what is part1? object? bool? number?
bool
you could forget having to define part1 earlier and instead use `!(isNil "PART1") which will return true once PART1 becomes anything but non existent. or you could define before. its up to you.
oh no nice i didn't think checking it was nill was a thing, only true and false. that works great.
does "Put" fire when a unit drops an item as well? cause isn't the ground considered a "container"?
should fire yes
performance question. is there significant overhead with stacking if thens vs one long liner if statements?
i know that sqf doesn't short circuit unless using lazy evaluation but how does stacking if thens do?
more commands = slower
no reason to stack if then, when you can use lazy evaluation
faster, cleaner
From the perspective of your question, yes. But the ground isn't considered a container. In fact, when you "put something on the ground" you're actually creating an invisible holder object and putting the items into its inventory; "the ground" isn't an inventory space that exists. These invisible containers are how nearby items are grouped (and why they sometimes aren't). You can even see them in Zeus if you add all objects after one has been created.
Or to phrase it better, the ground isn't considered a container; there are invisible containers that are considered the ground.
[
this,
"Turn on table",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"_this distance _target < 3",
"_caller distance _target < 3",
{},
{},
{ missionNamespace setVariable ["PART1", true, true] },
{},
[],
3,
0,
true,
false
] call bis_fnc_holdActionAdd;
So i've got this which works.
But when someone does the action, the option is still there for all the other players (not that it really matters since it's just setting a bool to true)
I wanted to remove this issue with !(isNil "PART1") but i'm getting a error for missing "]", modified code below with the !(isNil "PART1")
any ideas?
[
this,
"Turn on table",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"_this distance _target < 3 && !(isNil "PART1")",
"_caller distance _target < 3 && !(isNil "PART1")",
{},
{},
{ missionNamespace setVariable ["PART1", true, true] },
{},
[],
3,
0,
true,
false
] call bis_fnc_holdActionAdd;
Quotes inside strings
use single quote or escape with 2x " e.g " ""hi"" "
The parser thinks the quote before "PART1" is the quote at the end of the string, so you have to do that ^
nothing to do with spaces
Only for the ones that are inside another set of quotes
"isNil "var"" bad
"isNil ""var""" good
whoop, must have done a bad copy paste, removing the IsNill ones did work
excellent, thanks as always gents
I prefer to use ' instead of "" FYI
You still need quotes, you just need to show the parser that they're quotes within the string and not the quotes delineating the string
Basically: You can't use " inside "
you can, you just need to escape it properly
instead of backslash you use the quote type that was in the beginning of the string twice
In sqf, anything wrapped in " is a string (text value). For reasons unknown, the addAction command needs you to pass code as a string for some of its parameters, so if your code itself contains a string, you have to escape the quotes
"One says: "This is a illegal string!""```This is considered as three parts:
`"One says: "`, `This is a illegal string!`, `""`. Obviously the middle part is illegal while others technically aren't, so this is a illegal code
uh how would you get to work on a server? I've tried remote executive it but yeah neither of these pops up for other people.
Both work for me, but yeah.
MAN1 setGroupID ["Blue Boy"];
MAN1 sideChat "Hello ladies!";
[MAN5, ["purple Boy Man5"]] remoteExec ["setGroupID", 0];
[MAN5, "Test Text Hello! for man5"] remoteExec ["sideChat", 0];
In theory the remoteExec'd version looks fine to me (barring the potential to duplicate it if all clients broadcast the remoteExec, but one thing at a time)
Are you sure this code is actually being executed?
it's just in a trigger with a activation of any player present
with the MAN1 unit standing beside it and so on
would having "server only" ticked on the trigger probably breaking this?
https://community.bistudio.com/wiki/setGroupIdGlobal Why not use ?
yeah…?
at least, that's what the doc says 😊
anybody had success creating actions with ace and applying colors to them? been trying
_action = ["kisk_example_class", "<t color='#ff0000'>fancy red option</t>", "", kisk_example_action, _condition] call ace_interact_menu_fnc_createAction;
Welp, looks like it doesn't accept structured text or I'm doing this wrong
requires string
(and what you put is a string, not structured text)
also I've never seen the ACE interact menu with custom colors
welp, sad, but it does make sense.
I think it is possible due to the medical options
they do change colors based on the wound type/severity
then look at the medical code, see how they do it
ace medical only colours the icon as far as I can see. which can be done by setting the icon parameter to something like ["path/to/icon.paa", "#FF0000"]
Oh, well, thats actually nice
was taking a while to index the whole code to search for this
Yup! works perfectly! thank you a lot
Think this is probably a better place to post than before
https://steamcommunity.com/sharedfiles/filedetails/?id=1129927793 trying to get this to work for when i do mini ops with friends so it doesnt need TS, but for some reason it wont work. I don't get an error message or anything. I made sure to transfer the AFAR folder into my mission folder, make 2 notepad files and put the right code in each before saving them as init.sqf and Description.ext but it does nothing. Any ideas as to what I'm doing wrong? Ive tested in multiplayer and singleplayer.
if it doesn't show anything you didn't put the init.sqf and description.ext properly
I copied and pasted the code from the workshop page exactly, I'll double check now
not the code
where did you put init.sqf and description.ext?
inside the mission folder from in my documents
C:\Users\James\Documents\Arma 3\mpmissions\Tropic%20Osram.psyfx_pht
Same place the mission.sqm is
Is that the wrong place?
no
paste this in it:
systemChat "working!";
see it you see a message when the mission starts
also you shouldn't just restart the mission when you edit those files
you should close the mission, go back to eden and start again
Should I put it into the init.sqf? The system chat thing
I've been restarting my whole game to try and fix it
doesnt seem to have changed anything i dont think
yes
it wasn't supposed to change anything
then either you didn't put the init.sqf correctly or its contents are incorrect
https://media.discordapp.net/attachments/793812603427094531/832288631283515412/unknown.png?width=800&height=640 Thats the conents of my init.sqf
init.sqf might run too early to see systemChat expressions, not sure though.
yeah good point
@tough abyss
what about this:
[] spawn {sleep 1; systemChat "working!";};
(altho your file seems ok to me)
Do you have file extensions turned on in Windows Explorer?
I mention this because init.sqf is described as a "text document" in the type column, whereas for me a correct init.sqf is described as "SQF file". So I wonder if you actually have a file named "init.sqf.txt"
it says "EXT" and "SQM", so I'm guessing yeah
Windows always displays extensions for files not associated with any program. In the screenshot, init.sqf is associated with Notepad but the other two are not associated
(View tab -> file name extensions checkbox)
@little raptor @hallow mortar Thanks both, turning on the file extensions and I saw the init was actually named init.sqf.txt
Getting rid of the .txt seems to have fixed it thanks both
Guys, the "U_I_OfficerUniform" cannot be re textured by using setObjectTextureGlobal?
I've tried this in the unit's unit but does not work: SQF this setObjectTextureGlobal [0,"textures\uniforms\AAF_Officer\AAF_Officer_Green.paa"]; this setObjectTextureGlobal [1,"textures\uniforms\AAF_Officer\AAF_Officer_Green.paa"]; this setObjectTextureGlobal [2,"textures\uniforms\AAF_Officer\AAF_Officer_Green.paa"];
Might try
(uniform player) setObjectTextureGlobal....
uniform returns a string
Uff true. I didn't say anything
it's uniformContainer
and afaik it should work the same as setObjectTexture on the unit
uniformContainer did not work eighter 😦
and afaik it should work the same as setObjectTexture on the unit
I didn't expect it to
Nothing works on U_I_OfficerUniform, just tried SQF this setObjectTextureGlobal [0, "\A3\Characters_F\Common\Data\basicbody_black_co.paa"];
and that one works on every other uniform I've tried on
So... why is U_I_OfficerUniform protected?
maybe it doesn't have any hidden selection textures 🤷
So if all other uniforms have Hidden Selections and U_I_OfficerUniform doesn't, does that means that it was an oversight by the devs and needs fixing?
🤷
you can report it in #arma3_feedback_tracker and ask reyhard
I have just spent two hours doing a texture I cannot apply, so I will try all the channels to get this fixed 🙂
hello can you script a unite to arrive at a specific time for example to sync an attack between multipl groups in arma 2 co
did you try syncing their waypoints or something?
nvm
well you can add the waypoints to both groups once they have both completed a waypoint
Allright Lou wants a Ticket on it, but I am unable to log to the feedback tracker for some reason... worked fine a week ago... I you ever have the time please do a ticket on this issue
@dim terrace is that a bug? ☝️ or is it intended?
I just did a quick check and it seems the U_I_OfficerUniform uniform does indeed have hiddenSelectionTextures, but it cannot be changed with setObjectTextureGlobal
if it's a bug please let me know to open a ticket.
Hmm. But I tried forceAddUniform with a different unit (B_soldier_F) and it didn't work on it either
I'm pretty sure it works on B_soldier_f
i know how to script way point its like i want them to meet there at the same time like coordinating an attack
nope. at least not with that uniform
well you can add the waypoints to both groups once they have both completed a waypoint
perhaps someone else could try it?
here's the script I use in case someone wants to try ☝️ :
[] spawn {
u = createGroup west createUnit ["b_soldier_f", getPosATL player, [], 0, "NONE"];
_u = uniform u;
for "_i" from 1 to 10 do {
sleep 3;
u setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"]; //works
sleep 3;
u forceAddUniform "U_I_OfficerUniform";
u setObjectTexture [0, "#(argb,8,8,3)color(0,0,0,1)"]; //doesn't work
sleep 3;
u forceAddUniform _u; //readd default uniform
}
}
Bug! Please open a ticket!
there is no need for ticket for that one
Thanks!
just curious, is there a work-around for placing multiple custom vehicles that have attach scripts on them? as in, do i have to change variable names every single time i want multiple custom-comp vehicles?
i assume i could technically group it all into one model, but i'm not quite sure how to do that, since i'm still sorta new to the whole custom-composition thing, and i think i'd need to physically model the vehicle with all the parts on it to do that.
[this] execVM “your script here”;
Place that in the objects init
i'll try that out, thanks
will this work with attach scripts?
Attach scripts?
the main issue im having is when the variable names switch and then i have to individually go into the car's init
and start switching variable names around
to match the new ones
placing one normally is fine, but if i place a second one, it'll break unless i switch the variable names.
Could you send me the script?
yeah
Is that the AAF Officer uniform?
Use any other uniform as a base, call that uniform model and there you go, magic
Is there any way to suspend script inside a forEach loop?
spawn the loop
Worked, thanks!
What is Solomon Maru's face? I need a unit to look like him without the 'Solomon Maru' tag popping up.
Nevermind, think I got it
What is an exception, exactly?
Something that wasn't expected! 🙃
Gotcha
Is SQF Object Oriented?
what makes you think that?
hey guys I have a question that i can not find the answer for on google. I have a script that takes some time to get through do to it having a progress bar. It can be called many times within a couple seconds but i need it to queue the script to be ready to be called again once the script is done. do you guys have any suggestions?
I can share the script with you if you so desire
How does SQF view 6am? on the 'date' wiki page it uses 3 >= 19 for 7pm, but idk how to change that to 6am if you know what i mean
You're comparing what with what?
If I get your question properly, this is it for you
https://community.bistudio.com/wiki/BIS_fnc_isDateTimeNewer
= 6
Thank you
there is no way to perform a reference comparison of arrays, is there?
that would work with value or reference @warm hedge
private _array1 = [];
private _array2 = +_array1;
private _array2ref = _array1;
// how to get _array2ref isRefTo _array1
How to make friendly fire messages (push notification before he got killed) and not make it spam the chat?
{ if (side _x isEqualTo WEST) then
{
_x addEventHandler
[
"HandleDamage",
{
_returnDamage = (_this select 2);
if ((side (_this select 0)) isEqualTo (side (_this select 3))) then
{
_returnDamage = 0;
_string = str text format ["%2 has friendly fired %1.", (name (_this select 0)), (name (_this select 3))];
[_string] remoteExec ["systemChat", 0, false];
};
_returnDamage;
}
];
};
} forEach allUnits;
{ if (side _x isEqualTo WEST) then
{
_x addEventHandler
[
"HandleDamage",
{
_returnDamage = (_this select 2);
if ((side (_this select 0)) isEqualTo (side (_this select 3))) then
{
_returnDamage = 0;
if ((diag_tickTime - LastFriendlyFireNotif) >= 10) then
{
_string = str text format ["%2 has friendly fired %1.", (name (_this select 0)), (name (_this select 3))];
[_string] remoteExec ["systemChat", 0, false];
LastFriendlyFireNotif = diag_tickTime;
};
};
_returnDamage;
}
];
};
} forEach allUnits;
Add to initplayerlocal.sqf
LastFriendlyFireNotif = diag_ticktime;
Maybe like that , untested tho ^^
units west instead of allUnits 😉
hello, not sure if this is the right place to ask but is there a way to "connect" states so that lets say a building is destroyed a vehicle destroys itself as well?
Or lets say a generator is destroyed the things connected to it by script "turns off" or gets destroyed as well?
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed
The two examples you give sound like good use cases for the Killed EH to me.
so I'll need something along those lines, and then some other line of code to "kill" the other things? sorry for stupid quesiton but I've never done any scripting in arma XD
For the first example (building gets destroyed --> vehicle gets destroyed) you could use the Killed EH like so:
MyBuilding addEventHandler ["Killed", {
MyVehicle setDamage 1;
}];
hmm, alright and MyBuilding would be changed to whatever the variable name I set it to. Could it also be used to kill multiple vehicles at the same time?
Of course it could, yes. You can place any valid code you like within the curly brackets {}.
alright, just wanted to check. Thank you very much!
wrt. reference equality of arrays, i realise that it is possible by observing mutation of the array. insert an element via one reference, observe the mutation via the other, then roll back the mutation. a bit dirty for sure though
referenceEquals =
{
local _0 = _this select 0;
local _1 = _this select 1;
local _s = count _0;
if (_s != count _1) exitWith { false };
_0 set [_s, 0];
local _r = count _1 != _s;
_0 resize _s;
_r
};
you would want to use isNil to ensure it is unscheduled then 😄
yes, either that or name unscheduled execution as part of the contract
It's works! very much thanks.
But should I put this script in the init.sqf section? or any other suggestions? @sharp grotto
in what world do you even need something like that? 😄
determining reference equality can be very useful
there are many ways, calling pushBack on same arrays will print -1 etc
but with an error 
oh yeah
Hey, how can i _target removeAction _actionId; remoteExec this again for all players 🤔
Thats within addAction btw
as I said, save the action id when you add it to each client
then remote exec a function that gets the action id on their system and removes the action

_id = _target addAction [...];
_target setVariable ["my_action_id", _id];
do it in reverse order in a separate function (remoteExec this):
params ["_target"];
private _id = _target getVariable ["my_action_id", -1];
_target removeAction _id;
_target setVariable ["my_action_id", -1];
action id might not be the same on every client, so you need to save it like said above
Iam lazy and just do this
RemoveActionByName = {
params ["_object", "_name"];
{if (_object actionParams _x select 0 == _name) exitWith {_object removeAction _x}} forEach actionIDs _object;
};
[_playerObject, '[Stand up]'] call RemoveActionByName;
works great 😛
_target setVariable ["my_action_id", _actionId];
{
_id = _target getVariable ['my_action_id', ''];
_target removeAction _id;
} remoteExec['call'];
@little raptor something like this?

it does nothing
look at the new example
when you're adding the action to clients, save the action id to the namespace of the object you're adding the action to
then when you want to remove it, get the id from the object and remove the action
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
_target setVariable ["my_action_id", _actionId];
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
_target removeAction _id;
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
This the entire function, it works but when i (me) unlock it, my buddy still has the option to unlock it.
I already said what to do
make this into a function:
#arma3_scripting message
then remoteExec it
and save the action id in the above function
deleteAction = {
params ["_target"];
_id = _target getVariable ["my_action_id", -1];
_target removeAction _id;
_target setVariable ["my_action_id", -1];
}
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
_target setVariable ["my_action_id", _actionId];
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
_target removeAction _id;
[_target] call deleteAction;
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
BUT
Remote exec it
make it a CfgFunctions function
ok 😦
and you're not saving the id
so it does nothing
and you're still keeping removeAction
remove it
class bsTag {
class buyShop {
file = "functions";
class vehicleIsBuyable {};
};
class removeActions {
file = "functions";
class removeActionFromVehicle {};
};
};
inside: fn_removeActionFromVehicle.sqf
params ["_target"];
_id = _target getVariable ["my_action_id", -1];
_target removeAction _id;
_target setVariable ["my_action_id", -1];
action:
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
_target setVariable ["my_action_id", _actionId];
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
_target removeAction _id;
[_target] call bsTag_fnc_removeActionFromVehicle;
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
you didn't do any of these:
#arma3_scripting message
you have to save it when you add it
hi
@little raptor so what didnt i do? You pointing to that setVariable part but i dont understand 
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
_target setVariable ["my_action_id", _actionId]; <---------------------- RIGHT HERE NO?
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
_target removeAction _id;
[_target] call bsTag_fnc_removeActionFromVehicle;
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
Because i am setting it ?
addAction returns the action id
save the result into a variable, and use setvariable
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
{[_target] call bsTag_fnc_removeActionFromVehicle;} remoteExec['call'];
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
_car setVariable ["my_action_id", _car];
addAction returns the action id
_id = _target addAction ...
ooooooooooh
params['_car', '_price'];
_description = format['Unlock for €%1', _price];
_car setVariable ["price", _price, true];
_id = _car addAction[_description, {
params ["_target", "_caller", "_actionId", "_arguments"];
_price = _target getVariable ['price', ''];
if([_caller] call HALs_money_fnc_getFunds >= _price) then {
[_caller, -_price] call HALs_money_fnc_addFunds;
{[_target] call bsTag_fnc_removeActionFromVehicle;} remoteExec['call'];
[_target, "UNLOCKED"] remoteExec ['setVehicleLock', _target];
[[west, "HQ"], format ["%1 just purchased a car for €%2", name _caller, _price]] remoteExec ["sideChat"];
}
}];
_car setVariable ["my_action_id", _id];
you really need to stop remoteExecing call 
now in the part where you call removeaction, remoteexec some removeaction function(the one you were given)
(and even if you wanted to that's invalid)
ah wait you changed the code to something invalid again

removeActionFromVehicle, what does that even do? or is that the function leopard gave u?
params ["_target"];
_id = _target getVariable ["my_action_id", -1];
_target removeAction _id;
_target setVariable ["my_action_id", -1];
Thats the function
why
to remove the action for everyone
why remoteexec call? just remoteexec the function instead, no need to do such wrapping
you were taught a million times 
_target is undefined like i told you
local variables don't carry over like that, the target machines won't magically know what _target is inside the code, either pass it properly, or remoteexec the function, and not do that wrapper stuff
[_target] remoteExec ['bsTag_fnc_removeActionFromVehicle'];
now _target
but _target isnt local right
i mean it is.
but

_target will be resolved first. Eg. remoteExec will send the object stored in _target instead of the _target variable
does anybody know how exactly setMissileTarget works?
What is not working?
I'm trying to get a Mk41 VLS to fire at some random position
but I just can't find a way to have the missiles actually do anything other than fly up
not even fireAtTarget with laserTarget player works
Is that a modded missile?
https://community.bistudio.com/wiki/setMissileTargetPos doesnt a random POS require a targetpos and not a target 😄 ?
how do you use it?
but that also doesn't work
use what? fireAtTarget or setMissileTarget?
whatEverFunctionYouWannCallIt = {
[] spawn {
_sendPos = if (isNull cursorObject) then {AGLtoASL screenToWorld [0.5,0.5]} else {aimPos cursorObject};
_spawnPos = player modelToWorldWorld [0,-500,200];
sleep 5;
_missile = createVehicle ["M_Jian_AT", ASLtoAGL _spawnPos, [], 0,"CAN_COLLIDE"];
_missile setMissileTargetPos ASLtoAGL _sendPos;
_missile setVectorDir (_spawnPos vectorFromTo _sendPos);
}
};
This is what i use... i aim at something and call that function maybe with radio and it fires a rocket.
whatever it is you do
fireAtTarget requires a vehicle to fire the missile
setMissleTarget works on the missile object
launcher fire "weapon_VLS_01";
launcher getVariable ["missile", objNull] setMissileTargetPos position target;
This doesn't work (setMissileTargetPos just returns false)
and missile is?
launcher fireAtTarget [target, "weapon_VLS_01"]
This returns true and the missile just goes up
missile is the projectile, which I get from a "fire" event handler on launcher
then setMissileTarget there
does that make a difference?
yes. missile may not even exist when you do this:
#arma3_scripting message
ah
yes it does
mainly because I ran the code, waited for a second, then ran the code again
the missile was definitely already flying at that point
just do what I said
yea, still doesn't work though
does the missile face the target?
nope, still goes straight up
it needs to be in its targeting cone to lock
those missiles never spawn looking at the target though
hmmm...
I'll try pointing the missile straight at the target I guess, maybe that helps 🤷
nope, pointing the missile right at the target object (setVectorDir to vectorFromTo) and then calling setMissileTarget also just fails
@loud python just hopped on discord so i haven't read through everything yet but i see you are talking about VLS?
and targetting? cause I just was working through something with that this week
VLS Indeed!
may be relavent, but I use fireAtTarget and remoteReportTarget
remoteReportTarget?
and if you want it follow things, you create a "laserTargetW" or "laserTargetE" and attach it to an object
I tried launcher fireAtTarget ["...", laserTarget player] and it didn't work
hopefully you are in a singleplayer environment when doing that?
yea
for now just playing around
later on I'll switch to laserTargetW if that works
try using remoteReportTarget
oh...
yea
just did that
remoteReportTarget works flawlessly, even when the target is a game logic object 😄
Thanks a lot for that tip ❤️
yuppers
if you set the time too low, it will stop being broadcast and the missile will lose lock and crash to ground
so I get the artillery ETA and add a little bit extra
and use that as the time for the remote broadcast
nah, I mostly want this for very precisely scripted situations
like firing a missile at a target that won't move near the AO
for the cool effect
so I can just figure out a number that works 😄
if 30 is too low, I'll take 60 xD
and if you don't want to go through the hassle of making units and stuff for just a scripted sequence that the player won't see the launch, just use BIS_fnc_EXP_camp_guidedProjectile
hmmmmm...
that sounds super useful as well 😄
I'll have a look at this function, thanks for that as well
thats how you like shoot helicopters out the sky for scripted sequences easily, or top down attacks on tanks and stuff
where the player doesn't need to see the launch
cause it will spawn the missile out of thin air
I'll see if I can get setMissileTarget to work as well
but yea...
call { private _missile = "ammo_Missile_Cruise_01" createVehicle position this; missile setVectorDir [0, 0, 1] }
one would expect that code to spawn a missile that points up, but one would be mistaken
ah never mind, I'm dumb
vectors have magnitude though, not just direction
wait what coordinates does setVectorDir use?
setVectorDir
xyz
what space I mean
world
it is up
the question is what is the direction of your model
createSimpleObject ["ammo_Missile_Cruise_01", eyePos player];
ugh... it seems the problem was I needed to setVectorDirAndUp for it to work
if your missile is horizontal yes
oooooh wait I'm even dumber than I thought nvm
my missile was in the _missile variable but I was calling setVectorDir on missile
also, that won't create the cool particles I think. its just a naked missile
doesn't matter if the missile spawns half a map away 😉
buuuuut... setMissileTarget still won't work, even after reportRemoteTarget 😭
the reportRemoteTarget is if a launcher actually exists as it needs a data network
yea, it seems setMissileTarget is just black magic and doesn't work
try using the example on the wiki page or a different missile
since it mentions that not all missiles work
ah, yes, "Missile_AGM_01_F" seems to actually work
guess it's just that it doesn't work with cruise missiles then
dumbest thing I could think of is spawn a VLS, have it shoot a missile and instantly delete it again xD
then I'll just make it invisible I guess xD
is there a way to rotate which teams are available in the lobby at start? cause I guess the mission init hasn't started then yet which means you couldn't use any commands like changing the unit to playable.
Nope
I don't think there even is such a command (maybe the mission.sqm loading functionality could do it? haven't tried)
Hi all - I'm scratching my head trying to get an event handler to fire from a mine when it's triggered by a player walking over it at the moment i'm trying to add;
_unit addEventHandler ["Deleted",{(_this) execVM "\RW_zeus\functions\CleanObject.sqf";}];
as the EH "Killed" doesn't fire
The addEventHandler is being added to an ACE IED which has the same functionality as the base game AP mines
it gets cleaned automatically
why are you trying to clean it?
I have a module that "buries" the IED using setPos and then adds an oil stain on the top with createVehicle
The oil stain is then stored as a variable in the IEDs namespace and picked up by the script to clean itself up
ok
I.E
_unit setVariable ["RW_oil_1", _oil_1];
// Get object references to indicators.
private _oil_1 = _unit getVariable "RW_oil_1";
// Delete oil stains.
if !(isNil "_oil_1") then { deleteVehicle _oil_1; };```
- you might want to turn that code into a function for improved performance
- did you try
firedevent handler?
well I just tried it myself
the object doesn't accept any event handlers it seems
where do i find the stuff again on the wiki from a config sensor like rectangular=1 or angle=-150
i cant find it in sensors or im blind
That's strange - it's accepting "Killed"
as the EH "Killed" doesn't fire
The same cleanup script fires when a curator/zeus hits "end"
_unit addEventHandler ["Killed",{(_this select 0) execVM "\RW_zeus\functions\CleanObject.sqf";}];``` has been working for me
that's a unit
not a mine
(ammo)
_unit is the object that I drop my zeus module onto
if this "works for you" then what's the problem?
That works when a Zeus presses "End" on the object, it does not work if a player triggers it by stepping on it
I tried Fired and that doesn't do it either 😦
I'll try adding a Hit EH to the object I spawn ontop of the buried mine and see if I can remove it that way
bold idea: killed EH on the player, uses the killer information to determine if it was a mine and if so delete any nearby oil stains
it works then because you're adding the EH to the module and you're deleting the module
when the mine explodes/is deleted it has nothing to do with the module
and as I said no event handler works on Ammo objects
I'm not following, the module is deleted as soon as it drops onto the object - the mine then exists with some bits on top of it that are stored in the namespace and then removed when the Zeus selects the object (mine) and presses "End" to destroy it using the "Killed" EH
It's being dropped on IEDLandBig_F
Can I change the buoyancy of a static trawler to make it sink?
buoyancy probably not, but you could try changing its mass and seeing if that overcomes the buoyancy
also, I'm not 100% sure, but I think the trawler will sink if it's "destroyed", so trawler_name setDamage 1 might work
nope, tried that already
trawler can't be "destroyed" xD
how would I change its mass?
setMass
I'll try 😄
also, how did I turn a vehicle invisible?
I see the option in the editor, but I think it could be scripted as well
hideObjectGlobal
be advised that this can make the object intangible as well as invisible
are setVariables transferred from corpses to units when they are respawned?
The respawn system is supposed to do that, yes.
if (date select 3 >= 6) then{
nul = [this] spawn {
while {true} do { (_this select 0) say3D ["Reveille", 500, 1, false, 0]; sleep 30; };
};
};```
Trying to make something play at 6am, doesn't work for some reason
of course; it starts the loop only if it is after 6am. Not waiting until it is 6am.
so waitUntil would work better
nul = you don't need that btw
use isNil
correctly
Or read this page
"What's the easiest way to check if nothing has been selected in a list box?"
https://community.bistudio.com/wiki/enableRopeAttach
Anyone can confirm this has global effect?
who is good with initial setup for the description.ext
What in your opinion would be the best way to get the position of a bullet (in Fired EH) at the first impact? What I have right now works well enough but I was wondering if there was a better way to do it that utilized the impact somehow instead of looping. Apparently the bullet momentarily teleports to [0,0,0] before being deleted from what I heard. Hence _projectile select 0
// inside FIRED-EH
waitUntil {
// updating the pos
if (getPos _projectile select 0 != 0) then {
_impact_pos = getPosASL _projectile;
};
_min_ratio = (speed _projectile)/_previous_speed;
_previous_speed = speed _projectile;
// If the bullet velocity decreases more than to 0.99 during an iteration (from the looks of it), it impacted something -> the loop is over
getPos _projectile select 0 == 0 || (_min_ratio < 0.99);
};```
I tried to get EpeContactStart-EH working here but with no luck. It didn't seem to execute at all. biki says` It can be assigned to a remote vehicle but will only fire on the PC where the actual addEventHandler command was executed. `.I'm not that familiar with EHs yet, but I thought this wouldn't be an issue as I thought I needed it to "fire on the bullet". What I tried:
```sqf
// inside FIRED-EH
_projectile addEventHandler ["EpeContactStart", {
params ["_object1", "_object2", "_selection1", "_selection2", "_force"];
_impact_pos = getPosASL _object1;
}];
The bullet teleports
It doesn't teleport. It gets deleted and becomes a reference to objNull instead.
fsm condition priority, lower number is higher priority right?
also, can you terminate a FSM externally with terminate?
isnt there a terminateFSM command?
not on scripting commands or functions page
_resultArrived = missionNamespace getVariable format ["WFBE_JOIN_RESULT_ARRIVED_%1", getPlayerUID player];
waitUntil {
_resultArrived;
};
Can I do this a.k.a. is _resultArrived passed as reference?
not entirely sure what you are trying to achieve there, but what ever it is, you're doing it wrong.
No
yeah i was confused too... that doesn't do anything he probably wants
You get it once, then expect it to change - never going to happen
Only arrays, structured text and hashmaps can be passed by ref
i imagine you're after waitUntil {!isNil format ["WFBE_JOIN_RESULT_ARRIVED_%1", getPlayerUID player]} perhaps?
It would if it the variable was passed as reference, but as it doesn't, it doesn't work indeed 🙂
Ah true, I can do it that way as well 🙂
It's funny, I can create relatively complex scripts but I keep making stupid mistakes like this 😄 😄
(To clarify: the variable is being initialized and assigned a value in another thread in parallel)
There's no "pararell thread" in sqf
If you're the one assigning it why do you wait for it?
Just make an "event handler"
Scheduled (as in "wait for something") loops are bad. Unless you have to, don't use them
Yes - the value is being publicVariable'd by server once it has gathered the required data from other clients
No
so to do that without a loop you'd use remoteexec
@robust hollow Not in Arma 2 😛
oh dear 🤢
BIS_fnc_MP 🤷
Arma 3 0.5 😛
How did you do it in older armas then? 
There was a system for that, dont remember the name
@little raptor Yes, I use publicVariable EHs otherwise but in this case it's simpler to just use waitUntil (because I'm being lazy and don't want to refactor the whole code) 😄
_skillPlayer = profileNamespace getVariable "WFBE_CL_VAR_SKILLPLAYER";
if (isNil _skillPlayer) then { // <<--- FAIL
_skillPlayer = 100;
};
The above code fails with "Undefined variable in expression: _skillPlayer"
isNil "_skillPlayer"
Saving that in profile? Nice 😄
does a2 not have the alt syntax where you define a default value?
Nope
you sure? the wiki has notes specifically for getVariable in a2
I think the alt syntax applies to Arma 3 only, no?
It was only defaults for specific namespaces
if I do this function add method,
class CfgFunctions
{
class myTag
{
class myCategory
{
file = "myPath";
class myFunction {};
};
};
};
can I still do a preInit by placing it in class myFunction {preInit = 1};
yea
currently testing and it seems to have a strange locality. when executing it locally on a remote player it only updates on the server but if you execute it from server it works for everyone. so @winter rose what should we do about the BIKI article? SE? which is kind of weird. Or FT?
You pinged a green boi 😮 joke
@distant oyster I tested it this morning with someone sitting in a heli with slingload assistant open
I did cursorObject enableRopeAttach false and it was no longer on his assistant, then true gave back same functionality
Granted, the crate was local to me
so i've got this code I got from a steam forum.
When i'm hosting a server and it's just me it runs fine. and in singleplayer too it also runs fine.
But how would i run this so everyone can see it when other people join the server? I tried executing it globally with the run code module but nothing happened for anyone.
Any ideas?
i've just gone ahead and set the arguments to local and effect to global as far as i can tell from my testing
put it into a function and remoteExec it
from initPlayerLocal.sqf if you want it to run every time someone joins
was going to run during the mission at a half way point.
and uh, put it in a function? Not quite sure and I'm sure you don't mean just put [ all the code] remoteExce
Could i stick all the cod in a sqf file and remoteExce it? would that do it?
How confident are we the object needs to be local? 🤔
that could work yeah, something like:
[[], "path\to\script.sqf"] remoteExec ["execVM", 0];
``` even though it is not the best way in case remote exec of execVM is not allowed
i tested it on a hosted server with another client running. when executing it on the hosting client (server which is the owner of the vehicle) it had an effect on all clients, when i executed it on the connected client it only had an effect on the hosting client / server / owner
I'm just hosting stuff on my own PC at the moment for friends so it should be good, I guess?
yeah
sick i'll try and text it in the next few days when i can get people on
you can also launch multiple arma 3 instances via command line / batch file
and test with yourself as host and client
oh? wow I didn't know that I'll look into that it'll help a lot thanks!
https://community.bistudio.com/wiki/Multiplayer_Scripting there's also this article with more info, especially the last section is about what i just talked about. I personally do it on hosted MP from eden since it is faster but you have to know a bit what to look out for
Thanks a bunch i'll have a good read of it
Okay I have a really dumb question:
What happens if I execute setPos / setDir on objects with createVehicleLocal?
Does this cause any issues, because setPos / setDir have global effect, but the object exists only locally or does it just work fine and Arma is smart enough to not broadcast the changes to other clients? 🤔
it'll work fine (as long as you execute it where the object is local)
Yeah obviously. I wouldn't have a reference to the object if I would execute on another machine 😄
Thanks a lot ❤️
tbh I didn't expect anything else but just wanted to make sure because it's Arma... 😄
I want user "Saved_Loadout" in profile folder, not in mission, so each time when player connected to server mission, he already receives his loadout automatically.
How to rewrite this code?
[missionNamespace, "arsenalClosed", {
profileNamespace setVariable ["Saved_Loadout",getUnitLoadout player];
hint "Selected gear saved!"
}] call BIS_fnc_addScriptedEventHandler;
player addEventHandler ["Respawn",{
0 = [_this select 0] spawn {
params [["_player",objNull,[objNull]]];
waitUntil {sleep .2; alive _player};
_player setUnitLoadout (profileNamespace getVariable ["Saved_Loadout",[]]);
};
}];
will local variables be shared between codeStart/codeProgress/codeCompleted in holdaddaction if say the local variable was created in the codeStart scope? or do I have to use a set/get variable as a work around.
{
//codeStart
params ["_target", "_caller", "_actionId", "_arguments"];
private _nearUnits = allUnits select {_x distance _target >= 100};
if !(_target getVariable "launcher_team" isEqualTo resistance) then {
[server, [missionnamespace getVariable "server_channel", format ["%1 is now neutral and is being captured!", _launcher getVariable "launcher_name"]]] remoteExec ["customChat", allplayers];
};
_target setVariable ["launcher_team", resistance];
},
{
//codeProgress
params ["_target", "_caller", "_actionID", "_arguments"];
private _handle = [
{
playSound "readOutClick";
}, 1
] call hyp_fnc_addperframehandler;
},
{
//codeCompleted
params ["_target", "_caller", "_actionID", "_arguments"];
_handle call hyp_fnc_removeperframehandler;
}
looking specifically at _handle
Use saveProfileNamespace after setVariable (but make sure to use a different variable name than "Saved_Loadout" as somebody else might already be using that).
@willow hound simple as that?
[missionNamespace, "arsenalClosed", {
profileNamespace setVariable ["Saved_Loadout123",getUnitLoadout player];
saveProfileNamespace;
hint "Selected gear saved!"
}] call BIS_fnc_addScriptedEventHandler;
player addEventHandler ["Respawn",{
0 = [_this select 0] spawn {
params [["_player",objNull,[objNull]]];
waitUntil {sleep .2; alive _player};
_player setUnitLoadout (profileNamespace getVariable ["Saved_Loadout123",[]]);
};
}];
Yes.
AFAIK no
you can use the argument I believe
it's passed as reference (if array)
Been working on a freeze/unfreeze AI script for use in training environments. It's basically an add action to disable/enable simulation on all opfor. The addaction itself is added locally to the intructors but I've been having trouble setting up the remoteExec.
params ["_target", "_caller", "_actionId", "_arguments"];
missionNamespace setVariable ["ai_freeze", true];
((allUnits select {side group _x == east}) + (vehicles select {side group _x == east}) - (allPlayers)) apply {_x enableSimulationGlobal false;};
},
nil, // arguments
0, // priority
true, // showWindow
false, // hideOnUse
"", // shortcut
"!(missionNamespace getVariable ['ai_freeze',true])" // condition
];```
I attempted to save the array to a variable to pass to the remoteExec but no dice
_eastAI = ((allUnits select {side group _x == east}) + (vehicles select {side group _x == east}) - (allPlayers));
{[_x, false] remoteExec ["enableSimulationGlobal", 2]} forEach units group _eastAI;
While it is far more efficient to make a function that runs on the server to collect all the OPFOR units and disable their simulation, I can't see a reason why...
{
[_x, false] remoteExec ["enableSimulationGlobal", 2];
} forEach (units east);
```... shouldn't work.
What certainly won't work for multiple instructors is the addAction condition with ai_freeze, but that's a different topic.
well I wanted to avoid having to load CBA up but its unscheduled framehandlers are too good. I wanted the mp mode to be available to the public without mods. Guess I'll have to be super careful and see if I can make it so only the server needs it.
you can make them yourself if you don't want CBA
i tried, but stuff gets pretty messy. they worked but the organization is garbage that I'm doing lol
But what good does a PF EH do on the server?
its just timings and everything is remotely executed from the server. I'm just trying to avoid waitUntils and sleeps
what I have currently. trying to have a loop on 120 seconds, with a waitUntil for the firing sequence to start. before it was a while loop with 120 sec sleep and a waituntil at the beginning. still trying to figure it out.
params [["_launcher", objNull, [objNull]]];
private _handle = [
{
[
{
_this getVariable "launcher_captured";
},
{
private _team = _this getVariable "launcher_team";
private ["_target"];
switch _team do {
case west : {
_target = missionNamespace getVariable "westTarget";
[_target, "alarm_blufor"] remoteExec ["say3d", allPlayers];
[_this, _target] call hyp_fnc_launcherFire;
};
case east : {
_target = missionNamespace getVariable "eastTarget";
[_target, "alarm_opfor"] remoteExec ["say3d", allPlayers];
[_this, _target] call hyp_fnc_launcherFire;
};
};
},
_this
] call cba_fnc_waituntilandexecute;
},
120, _launcher
] call cba_fnc_addperframehandler;
i think I'm messing up arguments somewhere
Was there something wrong with the while-loop?
just trying to keep things out of scheduled environment for accuracy and lag.
how does a bit of delay matter when you're doing it every 120s?
Yes, I can't follow the rationale behind that either 
you're right, it doesn't. but, I'm trying to learn a different way in the process which gives me more stuff in my brain bank to work with in the future. I'm trying to learn the CBA and ACE coding rules as well.
many of these things never get finished. I just like learning a new thing and figuring it out lol
Well this right here certainly is an overcomplicated and erroneous approach if you ask me
your not wrong. and part of the process is banging your head against the wall until you go... man, this really ain't worth it in the long run haha
which I'm about at
This adds the same code to waitUntilAndExecute every 120 seconds by the way, so whenever launcher_captured finally returns true, all the accumulated instances of that code run.
yeah, I see that now. I'll probably just go back to my original.
params [["_launcher", objNull, [objNull]]];
while {true} do {
waitUntil {
_launcher getVariable ["launcher_captured", false];
};
private _team = _launcher getVariable "launcher_team";
private ["_target"];
switch _team do {
case west : {
_target = missionnamespace getVariable "westTarget";
[_launcher, "alarm_blufor"] remoteExec ["say3D", allplayers];
[_launcher, _target] call hyp_fnc_launcherfire;
};
case east : {
_target = missionnamespace getVariable "eastTarget";
[_launcher, "alarm_opfor"] remoteExec ["say3D", allplayers];
[_launcher, _target] call hyp_fnc_launcherfire;
};
};
uiSleep 120;
};
You can pull [_launcher, _target] call hyp_fnc_launcherfire; (and in theory also remoteExec) out of the switch and uiSleep is probably not what you actually want here, but other than that this looks pretty good.
why uiSleep? 
something like that needs sleep
(it's not UI related)
already fixed
so all of a sudden my custom chat channels just stopped working...
my customchannelID is 2.
radioChannelInfo 2 states it exists, and that my character is added, yet I cannot access the channel. direct commands to the channel do not show up either. I didn't change anything when it was working...
is the channel disabled?
i switched my editor to SP and it worked, then switched it back to MP and its now working... weird. I didn't change anything and no it wasn't disabled
sounds like i may have a editor mod conflict somewhere
hmm and few seconds later it stopped working again... interesting
so this is my creation function
if isServer then {
private _channelname = "SERVER MSG";
private _channelID = radioChannelCreate [[0.85, 0.4, 0, 1], _channelname, "GAME", [server]];
if (_channelID == 0) exitwith {
systemChat format ["Custom channel '%1' creation failed!", _channelname]
};
[_channelID] remoteExec ["hyp_fnc_radioChannelAdd", [0, -2] select isDedicated, _channelname];
missionnamespace setVariable ["server_channel", _channelID, true];
};
and this is the player add function
params ["_channel"];
_channel radioChannelAdd [player];
it appears that it is creating the same channel on both indexes of 0 and 1, but it shouldn't ever return 0 because that means it failed.
as radiochannelinfo 0 and radiochannelinfo 1 return the same thing
0 and 1?
custom channels are in the range 6-15
you should add 5 to _channelID to get the actual channel
yes, but when created they are the lower range. i believe only for things like enablechannel do you have to add 5
we don't even get that far anyways because even with the create channel, it doesn't let me access it with channel switch keys, even though my character shows its added to that channel
afaik the only way that can happen is if the channel is disabled
but I haven't given any enableChannel commands lol
all channels 0-15 are [true, true]
what if you set the channel manually? (using script)
does it work then?
The given channel may be disabled (see enableChannel), this is why this command returns boolean, true on success or false on failure.
either it's not added or not enabled 🤷
radiochannelinfo returns [[0.85098,0.4,0,1],"SERVER MSG","GAME",[server,p1],false,true] which is my channel, and p1 my character is added


