#arma3_scripting
1 messages ยท Page 668 of 1
I'm running a displayeventhandler in a script for keyUp and Keydown. Which change a variable. (and print it in a hint for testing)
However when I check the variable in a loop it hasnt changed.
How do I get the value from the eventhandler back into my script?
it's a local variable btw
making it a global variable ain't a smart thing to do right?
That's the easy way out
actually...now I think of it.
Wouldnt matter for multiplayer. It isn't published over the network with PublicVariable command.
If eventhandler is start you can call thรฉ fonction and set argument in the call
[_local] call tag_fnc_name;
Or spawn...
Good day again. Just to make sure - there are no bitwise operations available in SQF? Specifically interested in "if (a & b == a)"
you want to put 2 conditions in the same if?
if (a && a == b) then {}
``` is valid
But bitwise is afaik not available with commands
Thanks a lot!
And another one: I see we have multiple options of organizing and accessing the code for execution, from your experience, which is faster/less memory consuming/both in case of planned single use (on, say, init) or multiple uses per game session (hotkeys for example)?
- store as "MyScript.sqf" and call compileFinal preprocessFileLineNumbers (turn it into function before use)
- define a function like ASM_fnc_doStuff
- execVM "MyScript.sqf"
(the latter must be "slowest" of all, as I suppose)
calling once: execVM, compile (very bad for performance and security)
multiple times: compile(Final) once, CfgFunctions does it automatically with some more benefits
CfgFunctions is the easiest to manage and good practice unless you need something specific
That's what I thought too ๐ Thank you guys
Anyone know if there's a way to retrieve the layerID of a layer after it's been created?
talking about while In 3DEN*
or better yet to check which layerID a given entity belongs to
I suppose I could just use get3DENLayerEntities and loop until I find the correct layer...
Can I do a task that is triggered when I talk to an npc?
yes
How could I do it, is there a tutorial?
I've been looking for about 20min and I can't find anything
@raw haven If there isn't a exact tutorial for what you are looking for then look for tutorials about the subparts of what you are trying to do:
- how to "interactions" to "npcs"
- how to create and complete tasks with script
- addAction is a good command to look into
- Task Framework is a good place to start (https://community.bistudio.com/wiki/Arma_3:_Task_Framework)
ok Thanks
Because that way if they get shot at in the water it won't do anything.
And respawning it isn't ideal because then I need to add back a couple of event handlers, ace cargo contents and it's inventory. Plus also copy over any other damage sustained.
Hello again, I'm trying to create a vehicle disabled check using canMove and canFire that will trigger a script. I need this check to apply only to vehicles disabled by the player, but I'm not sure what the best way to do it.
I was initially thinking of putting it in a "HitPart" or "HandleDamage" EH, but that might not be best performance wise. Neither would a dedicated script with waitUntil attached to every vehicle.
Any suggestions as to the best place to place such a check?
EHs are good, don't be scared of them ๐
how would I use setVelocityTransformation to move an object along a linear path from object a to object b??
Something like this?
t1 = time;
t2 = time + 10;
onEachFrame
{
player setVelocityTransformation
[
AGLtoASL (getpos player),
AGLtoASL (getpos target),
[0,0,0],
[0,0,0],
[0,1,0],
[0,1,0],
[0,0,1],
[0,0,1],
linearConversion [t1, t2, time, 0, 1]
];
};
I'm currently trying to get a chopper to make a nice descend.
waitUntil {(_aircraft distance _destination) < 1000};
[0.5] call _kiDescend;```
```sqf
private _kiDescend =
{
params["_z1"];
_v1 = -6;
_refreshTime = 0.1;
_z2 = getpos _aircraft select 2;
_v2 = velocity _aircraft select 2;
_Vel = [];
_velZ = 0;
_z = getpos _aircraft select 2;
while{_z >= _z1} do
{
_z = getpos _aircraft select 2;
_velZ = [_v1,_v2,(_z-_z1)/(_z2-_z1)] call BIS_fnc_lerp;
_vel = (velocity _aircraft);
_vel set [2,_velZ];
_aircraft setVelocity _vel;
sleep _refreshTime;
};
};``` However, somehow the chopper does not really go down to the ground in a nice 45-60 deegres angle. Instead it sometimes occur that the helo does a 50 deegres angle in the air for slowing down and then the script fires and uses this angled position as base which results in the helo going upwards instead of down.
Is there anything I should adjust to counter-act this?
position of player should be saved outside as an _initPos then passed into the command otherwise you give new position each time which would result in some quite ridiculous acceleration.
getPos shouldn't be used at all
there is also just a command named getPosASL , instead of AGLtoASL (getPos...) which you can use
May I ask if your purpose is to simply change the altitude of the chopper?
Just want to make sure you are aware that these commands exist:
https://community.bistudio.com/wiki/flyInHeight
https://community.bistudio.com/wiki/flyInHeightASL
not only. My purpose is that the helo makes a descend into a landing zone instead of just flying at full speed and then makes a altitude change by going step in the air (to slow down) and then go down
here is a image representing my goal https://i.imgur.com/hwqyoe1.png
more or less
https://community.bistudio.com/wiki/forceSpeed
https://community.bistudio.com/wiki/limitSpeed
You mean these as well?
already tried them, they are not usable in my case. My code above somewhat works, it just has sometimes the issue that the helo banks to the sky (probasbly for slowing down) and then the script fires. It then uses that weird angle as basis which results in the chopper going upwards then down
that doesn't work
this is my current code:
t1 = time;
t2 = time + 10;
player setDir (player getDir target);
["rabbit_attack", "onEachFrame", {
if (player distance target > 1.6) then {
player setVelocityTransformation
[
getPosASL player,
AGLtoASL (target modelToWorld (target selectionPosition "neck")),
[0,0,0], // fromVelocity
[0,0,0], // toVelocity
[0,1,0], // fromVectorDir
[0,1,0], // toVectorDIr
[0,0,1], // fromVectorUp
[0,0,1], // toVectorUp
linearConversion [t1, t2, time, 0, 1]
];
} else {
["rabbit_attack", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};
}] call BIS_fnc_addStackedEventHandler;
I need to change the
_nextVectorDir,
_currentVectorUp,
_nextVectorUp,
params so the object (in this instance player) faces the target
how is it supposed to move to target if velocity is 0?
it already moves to the target
then what is the problem?
velocity is for mp purposes, command doesnt use it for positioning
it is for sync over network
the problem is getting the vectordir/vectordirup to face the target
what vectors do I use for vector1 and vector2 in the syntax?
does vectorUp even work for player though? (Unless in vehicle)
I mean it does but upon landing it goes back to normal standing
but I assumed that was for testing
because the code doesn't make sense (moving the player up to some bunny?!)
use vectorDir player for vector1 , and the calculation Leopard gave for vector2
(I stopped questioning such stuff in this channel) 
I think I was just looking for
vectorDir player,
vectorDir target,
vectorUp player,
vectorUp target,
well kind of
you want player to look at the direction bunny looks?
nah, I just want the rabbit (player) to face the player during the movement
wait is rabbit the player?
the rabbit (player) ends up looking the direction of the object at the end of the conversion
yes

I am putting together a whimsical easter mission

its the vectorup bit that I need to adjust right?
as I said, just use vectorFromTo
for next vector direction
I did but like I said, the player ended up facing the same direction as the target at the end of the transformation
I still am trying to understand this line (player will face player?)
I think I just need player setVectorDir (vector1 vectorFromTo vector2 before the setVelocityTransformation starts
player face target
setVelocityTransformation
yes you shouldnt do anything dynamically there. (ie. get all your values outside onEachFrame from start and pass them into command)
(Unless you know what you are doing)
I agree, I think something closer to this is what I'm aiming for:
t1 = time;
t2 = time + 10;
player setDir (player getDir target);
player setVectorDir ((vectorUp player) vectorFromTo (vectorUp target));
["rabbit_attack", "onEachFrame", {
if (player distance target > 1.6) then {
player setVelocityTransformation
[
getPosASL player,
AGLtoASL (target modelToWorld (target selectionPosition "neck")),
[0,0,0],
[0,0,0],
[0,1,0],
[0,1,0],
[0,0,1],
[0,0,1],
linearConversion [t1, t2, time, 0, 1]
];
} else {
["rabbit_attack", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};
}] call BIS_fnc_addStackedEventHandler;
though I don't think I should be using vectorUp for the two vectorFromTo objects
Well in here, you do not even modify the final vectorDir in setVelocityTransformation value so...
you're still on this? 
I'm just trying to workout the vectorFromTo command. Do I use _vectorDir = (getpos player) vectorFromTo (getpos target); and then reference _vectorDir for vectorDirTo and vectorDirFrom inside setVelocityTransformation?
yes, I don't have a full understanding of the vector commands yet
t1 = time;
t2 = time + 10;
_p1 = getPosASL player;
_p2 = target modelToWorldWorld (target selectionPosition "neck");
vec2 = _p1 vectorFromTo _p2;
player setVectorDir vec2;
["rabbit_attack", "onEachFrame", {
if (player distance target > 1.6) then {
_p1 = getPosASL player;
_p2 = target modelToWorldWorld (target selectionPosition "neck");
player setVelocityTransformation
[
_p1 ,
_p2 ,
[0,0,0],
[0,0,0],
vec2 ,
vec2 ,
[0,0,1],
[0,0,1],
linearConversion [t1, t2, time, 0, 1]
];
} else {
["rabbit_attack", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};
}] call BIS_fnc_addStackedEventHandler;
the vectorups probably need conversion too
the thing is, I don't want the vectordir to change mid transformation, which it does when you do vectorFromTo inside the transformation block itself
but your code might be the closest possible result to what I was looking for
then just use the new code
I tested it, the result was what I mentioned
I updated it just now
strange, I tried my own version of that and it was broken =/
it is broken
oh, it was probably because I didn't do
_p1,
_p2,
no
player setVelocityTransformation
[
getPosASL player,
AGLtoASL (target modelToWorld (target selectionPosition "neck")),
[0,0,0],
[0,0,0],
[0,1,0],
[0,1,0],
[0,0,1],
[0,0,1],
linearConversion [t1, t2, time, 0, 1]
];
your vectors are [0,1,0]
sorry, I meant I had
getPosASL player,
AGLtoASL (target modelToWorld (target selectionPosition "neck")),
in place of the
_p1,
_p2,
in the transformation block
I had
t1 = time;
t2 = time + 10;
_p1 = getPosASL player;
_p2 = target modelToWorldWorld (target selectionPosition "neck");
vec2 = _p1 vectorFromTo _p2;
player setVectorDir vec2;
``` outside the transformation block
and had
```sqf
vec2 ,
vec2 ,
inside the transformation block
it changes nothing
I already told you what's wrong
they weren't that the last time I tested
I didn't paste my last test before using your updated code, It looked like this:
t1 = time;
t2 = time + 10;
//_vectorDir = (vectorUp player) vectorFromTo (vectorUp target);
_vectorDir = (getpos player) vectorFromTo (getpos target);
player setVectorDir _vectorDir;
["rabbit_attack", "onEachFrame", {
if (player distance target > 1.7) then {
player setVelocityTransformation
[
getPosASL player,
AGLtoASL (target modelToWorld (target selectionPosition "neck")),
[0,0,0],
[0,0,0],
_vectorDir, //vectorDirFrom
_vectorDir, //vectorDirTo
//[0,1,0], //vectorDirFrom
//[0,1,0], //vectorDirTo
[0,0,1], //vectorUpFrom
[0,0,1], //vectorUpTo
linearConversion [t1, t2, time, 0, 1]
];
} else {
["rabbit_attack", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};
}] call BIS_fnc_addStackedEventHandler;
is what I was trying to explain
_vectorDir is local
That would explain why it broke haha
I don't think the:
_p1 = getPosASL player;
_p2 = target modelToWorldWorld (target selectionPosition "neck");
vec2 = _p1 vectorFromTo _p2;
player setVectorDir vec2;
``` before the onEachframe is necessary
nevermind
my monty python spoof mission is near completion
I even modified the rabbits to have red eyes and bloody faces
Probably a really dumb question but I'm still fairly new to SQF files, and was wondering if there was anything necessarily wrong with this script? It works fine but I don't know a lot of the convention for sqf files as much as other programming languages.
/*
* Briefing Script
* Just edits some markers on the map
*/
openMap [true, false];
// [variable name, marker type, marker text]
_markers = [
["task_meetup", "hd_join", "Meetup"],
["task_rescue", "hd_unknown", "Rescue"],
["task_extract", "hd_pickup", "Extract"]
];
for [{_i=0},{_i<(count _markers)},{_i=_i+1}] do { // Can you have spaces? I tried spacing stuff out but it caused a "missing ;" error
_markerName = (_markers select _i) select 0; // This + the array at the top can probably be done better
_markerType = (_markers select _i) select 1;
_markerText = (_markers select _i) select 2;
// Move Camera
mapAnimAdd [1, 0.1, markerPos _markerName];
mapAnimCommit;
sleep(1);
// Edit Marker
_markerName setMarkerType _markerType;
_markerName setMarkerColor "colorwest";
_markerName setMarkerText _markerText;
// Make marker blink
[_markerName, 0.5, 3] call BIS_fnc_blinkMarker;
sleep(3);
};
apart from using for [{_i=0},{_i<(count _markers)},{_i=_i+1}] do there's not much wrong with it
you might also want to take a look at params
also no need for parenthesis when using sleep
you can just do sleep x?
yes
read the rules of precedence:
https://community.bistudio.com/wiki/Order_of_Precedence
alright, and what was wrong with using a for loop?
that's the slow variant of for
you should use for "_i" from 0 to count _markers - 1
sqf is not like other languages
I mostly meant like "the standards" of sqf, so like for python, 4 spaces is "standard" for indents. While in others, 2 is "standard"
there are no such standards in sqf
Indents are simply considered good programming practice (for reading). so you can use whatever you prefer
I personally prefer 4 spaces
I was just using indents as an example
take a look at the list at the top of this page. (expand it)
https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
it contains almost everything you'd need
is there an easy method of getting values for setVectorDirAndUp ? Like e.g. have a person on the ground rotated in a specific way and then having a sort of getVectorDirAndUp command.
if i have a script running locally on a vehicle and that driver leaves the game, do I need to restart that script when the locality changes or will it automatically transfer over?
you can't have a script running on a vehicle
it runs on the client or the server.
if the vehicle changes its locality you have to make your script detect that and adjust
yeah thats what i meant. the driver's computer is in ownership of the vehicle
never worked with anything more advanced than placing and syncing stuff so how would i set up delayed spawns for groups of units?
what I like to do it disable simulation, hide them, then reenable them when I want. gives the effect of "spawning" but I placed everything in the editor before hand. can even be fun to create states with FSMs
so then via a trigger re-enable them?
you can if you want
you are gonna want this.
{
private _group = _x;
{
_x enableSimulationGlobal true;
_x hideObjectGlobal false;
} forEach units _group;
} forEach globalGroupVariablePoolHere;
How can you get a list all the units in a group? I tried using (units group squadName) join player; but this gave an error saying that it was a group and not a list of objects.
I was looking on the wiki and it said that units returns an array of objects so I don't know what I did wrong.
just units groupnamehere
returns array of units... [unit1,unit2,unit3]
so in total
(units squad_1) join player;
ropeCreate doesnt work, despite setting enableRopeAttach to true
im getting null-object as return
im getting an error on this undefined variable _gunner
[_gun] spawn{
waitUntil {time > 10};
_group = createGroup [west, true];
_gunner = ("B_RangeMaster_F" createUnit [position gun, _group]);
sleep 2;
_gunner moveInGunner _this#0;
};```
_gunner is literally defined just before
your syntax of createUnit doesn't return anything
i see
if you want a return you HAVE to use group createUnit [type, position, markers, placement, special]
How can you check if all the units in a specific group is in a vehicle? I tried using (units groupName) in heli in the condition [of a waypoint] but it gave a general error.
units groupName findIf { !(_x in heli1) } == -1
units groupName findIf { alive _x && !(_x in heli1) } == -1
even better as it filters out dead units that are in the group but haven't been removed yet
so it reads... if a unit is alive, and not in heli1, you will get a value that is the index of that unit in the array (so basically >= 0)
so if there are units alive, and none of them are not in heli1, then you get a return value of -1
works like a charm! thanks a bunch
Good day. Is there a way to hide/show certain GUI element? I would like to hide some buttons before something is selected in listbox
ctrlSetFade
_pistolConfigs = "((configName (_x)) isKindof ['Pistol', configFile >> 'cfgWeapons']) && (getText (_x >> 'displayName') != '')" configClasses (configFile >> "cfgWeapons");
Is there a way to loop over all the pistols and make a class for each weapon?
class pistolNameHere {
};
Well its for the shop im using and i dont wanna define all the weapons manually so i just wanna loop over pistols, rifles, attachements etc and just give them all a base price based on what they are.
Example:
class rhsusf_acc_m14_bipod { <-- loop
price = 25; <-- default price
stock = 100;
};
Another example:
class cfgHALsStore {
containerTypes[] = {"LandVehicle", "Air", "Ship"};
containerRadius = 10;
currencySymbol = "$";
sellFactor = 0.5;
debug = 1;
class categories {
class launchers {
displayName = "Rocket Launchers";
picture = "a3\ui_f\data\gui\Rsc\RscDisplayArsenal\secondaryWeapon_ca.paa";
class launch_NLAW_F {
price = 2500;
stock = 100;
description = "<t color='#ff0000'>Where has my beer gone?</t>";
};
So you wanna export them so you can put them into a config file?
yea
copyToClipboard
or just loop over them all
Mmmm
No
I dont wanan to manually add it
i just want all pistols and give them all the same price.
Here are a few good example on how to mass export (by copying to the clipboard)
Then you just paste it into your config file
So there is no way to do something like
{
_x {
price = 25; <-- default price
stock = 100;
}
} forEach _pistols
?
damn
not sure how i would do this 

_pistols = "getnumber (_x >> 'type') isEqualTo 2 AND getnumber (_x >> 'scope') isEqualTo 2" configClasses (configfile >> 'CfgWeapons');
{_x} forEach _pistols;
How do i get the class name from a pistol ๐ค
morning chaps.. is there a recent all in one config output anywhere?
save me switching to diagnostic branch and using the sexy new diag_exportconfig
_pistols = "getnumber (_x >> 'type') isEqualTo 2 AND getnumber (_x >> 'scope') isEqualTo 2" configClasses (configfile >> 'CfgWeapons');
pistols = [];
{
format['%1 {
price = 200;
stock = 999;
};', configName _x];
} forEach _pistols;
This almost works but only returns one pistol -.-
does commands like drawPolygon only work on maps? or can i use them for regular displays too?
_pistolsCfg = "getnumber (_x >> 'type') isEqualTo 2 AND getnumber (_x >> 'scope') isEqualTo 2" configClasses (configfile >> 'CfgWeapons');
_pistols = "";
{
_pistols = _pistols + configName _x + endl + "{" + endl + " price = 200;" + endl + " stock = 999;" + endl + "};" + endl;
} forEach _pistolsCfg;
@heady quiver
hgun_ACPC2_F
{
price = 200;
stock = 999;
};
hgun_ACPC2_snds_F
{
price = 200;
stock = 999;
};
hgun_P07_F
{
price = 200;
stock = 999;
};```
@tough abyss What does the doc say?
this is for drawIcon idk about others
Syntax:
map drawIcon [texture, color, position, width, height, angle, text, shadow, textSize, font, align]
Parameters:
map: Control
texture: String - Icon texture
color: Array - Text and icon color in format [r,g,b,a]
position: Position2D, Position3D or Object
width: Number - Width of the icon (but not the text)
height: Number - Height of the icon (but not the text)
angle: Number - Rotation angle of the icon (but not the text)
text (Optional): String
shadow (Optional): Number or Boolean - 0 (false): no shadow, 1: shadow (for text), 2 (true): outline (works for text and for icon only if icon angle is 0)
textSize (Optional): Number - Size of the text in UI units (since Arma 3 v0.72)
font (Optional): String - (since Arma 3 v0.72)
align (Optional, default: "right"): String - "left", "right" or "center" (since Arma 3 v0.72)
Return Value:
Nothing
Your question was if it works on a display or only on map control
my bad i was using "display" incorrectly
yeah i meant a general control, not map specifically
No, only works for maps.
thats a shame
One more question:
_pistolsCfg = "getnumber (_x >> 'type') isEqualTo 1 AND getnumber (_x >> 'scope') isEqualTo 2" configClasses (configfile >> 'CfgWeapons');
this returns weapons now but some of those weapons have scopes is there a way to filter that?
srifle_DMR_01_ACO_F, srifle_DMR_01_MRCO_F, srifle_DMR_01_SOS_F, srifle_DMR_01_DMS_F <-- retrusn things like this
_pistolsCfg = "getnumber (_x >> 'type') isEqualTo 1 AND getnumber (_x >> 'scope') isEqualTo 2 AND (configName _x call BIS_fnc_baseWeapon == configName _x" configClasses (configfile >> 'CfgWeapons')
Can you find the mistake I did ? ๐
๐ค
Do not just copy paste, also read ๐
( issue
I guess that's the average time ppl can focus on something these days
sorry, what were we talking about?
_pistolsCfg = "getnumber (_x >> 'type') isEqualTo 1 AND getnumber (_x >> 'scope') isEqualTo 2 AND (if (isArray (_x >> 'muzzles')) then {configName _x call BIS_fnc_baseWeapon == configName _x} else {true})" configClasses (configfile >> 'CfgWeapons');
This is the updated code. We might need to add another check for muzzles, just to be safe
UH
Alright, tested and works 
Is there also a way of getting all magazines? or do i need to loop over each weapon to get the compatible mags?
Excuseme what's the context? Can you explain for the drunk?
(I ate some cocktails not a wine)
I want all magazines that are currently in the game.
Currently in-game, in the terms of configs or in mission?
config
Do the mostly the same with what R3vo wrote, but for CfgMagazines
lmfao i just crashed my game
_weaponsCfg = "getnumber (_x >> 'type') isEqualTo 1 AND getnumber (_x >> 'scope') isEqualTo 2 AND (if (isArray (_x >> 'muzzles')) then {configName _x call BIS_fnc_baseWeapon == configName _x} else {true})" configClasses (configfile >> 'CfgWeapons');
_weapons = "";
{
_magazines = [configName _x] call BIS_fnc_compatibleMagazines;
{
_weapons = _weapons + 'class ' + _x + endl + "{" + endl + " price = 100;" + endl + " stock = 999;" + endl + "};" + endl;
} forEach _magazines;
} forEach _weaponsCfg;
was trying to all mags from that other list
๐ง
Basically yes. You of course need to adjust the conditions if you wanted to get all personal weapon magazines
by personal weapon you mean what he holds?
oh no.
I think i know what you meant, im getting ammo for vehicles as wel lol
Yes, config file is a messy place 
Yea im getting a lot of shit now.
mags that are for vehicles, mags without images.
even stungrenades that are un useable
x)
BIS_fnc_itemType
"getNumber (_x >> 'scope') == 2 && getText (_x >> 'picture') != '' && getText (_x >> 'model') != ''" configClasses (configFile >> "CfgMagazines"
Should get you started
thats exactly what i needed
๐ฎ
Where can i found all the Cfg's ๐ค cuz i need attachments as wel.
is it just me or cant i find alot of information about weapon attachments.
Can i call a function i am currently in ?
function1 = { call function1 }; for example.
i guess i should try before asking
๐คฃ
yes you can. it's called a recursion. but it must have a proper condition to end, otherwise it'll loop forever
// Check if the location is already used before
if(_location in used_locations) then {
call createMissionLocations;
} else {
used_locations append [_location];
}
The only thing that might inf loop this is the fact that i run out of locations.
why on earth do you use append?
just use pushBack

oke changed it
x)
I got a lil problem btw, if you have some time
// Get random location
_location = call getMissionLocations;
_location = selectRandom _location;
// Name
_marker_name = format['task_%1_time_%2_marker', round random 9999, round time];
// Create marker
_markerstr = createMarker [_marker_name, _location];
_markerstr setMarkerType "mil_unknown";
_markerstr setMarkerColor "colorBLUFOR";
// Create trigger if player gets close start a mission
_trg = createTrigger ["EmptyDetector", _location];
_trg setTriggerArea [600, 600, 50, false];
_trg setTriggerActivation ["WEST", "PRESENT", false];
_trg setTriggerStatements ["this", "
'Bluefor entered the area' remoteExec ['systemChat'];
",
""]; // Check if bluefor is close, remove marker and call other function
// Check if the location is already used before
if(_location in used_locations) then {
call createMissionLocations;
} else {
used_locations pushBack [_location];
}
i want to delete that marker when a bluefor walks into the area but the problem is this function can be called multiple times.
you have to change it to:
used_locations pushBack _location;
_location = call getMissionLocations; why do you call here?
getMissionLocations = {
_locations = allMapMarkers;
_list = [];
{if(getMarkerType _x == 'ellipse') then {_list pushBack getMarkerPos _x;};} forEach _locations;
_list
};
_marker_name = format['task_%1_time_%2_marker', round random 9999, round time]; don't use random
Getting a list of locations based on markers
ok
Hello, how to create player absolute invincible on server? Make it invulnerable to hits from other players in MP?
player AddEventHandler ["HandleDamage", {False}];
player allowDammage false; ``` does not work
player allowDamage false;
Other players can kill me
but this invincible works when bomb hit player
other players can kill me, it looks like my god mode is not exists using player AddEventHandler ["HandleDamage", {False}]; player allowDammage false;
handleDamage should return number
any ideas?
yes - what Leopard said
also allowDamage has a local effect, remoteExec it
in arma 2*?
remoteExec is not exists in my game
oh, Arma 2
oh true
just use:
player AddEventHandler ["HandleDamage", {0}];
not work ๐ฆ
I try it, but others players can hit me
Leo, you know how i can pull it off?
where do you try it?
on server
are you the server?
then try it locally
same goes for allowDamage
you shouldn't try either of them on the server
ok, locally it works
I know
but how to use on server side this
humm
maybe use https://community.bistudio.com/wiki/Arma_2:_Multiplayer_Framework and rEXECVM with the allowDamage command in it
thanks, I try it!
honestly I don't fully understand what you're trying to do
if(_location in used_locations) then {
why do you create a new marker if it's already "used"?
wat?
"in hope"?!
xD
๐ฅ ๐จ
it's not a random process
why do you think you have to even do this?
just grab a location that is not being used
make each used_locations markers
instead of positions
_unused_locations = _locations - used_locations
then select random one of unused_locations
createMissionLocations = {
// Unused locations
_unused_locations = call getMissionLocations - used_locations;
// Get random location
_location = selectRandom _unused_locations;
// Name
_marker_name = format['task_%1_time_%2_marker', round random 9999, round time];
// Create marker
_markerstr = createMarker [_marker_name, _location];
_markerstr setMarkerType "mil_unknown";
_markerstr setMarkerColor "colorBLUFOR";
// Create trigger if player gets close start a mission
_trg = createTrigger ["EmptyDetector", _location];
_trg setTriggerArea [500, 500, 50, false];
_trg setTriggerActivation ["WEST", "PRESENT", false];
_trg setTriggerStatements ["this", "
'Bluefor entered the area' remoteExec ['systemChat'];
",
""]; // Check if bluefor is close, remove marker and call other function
// Add location to used locations
used_locations pushBack _location
};
Yes, this it really works, thanks!
what is getMissionLocations now?
the same
getMissionLocations = {
_locations = allMapMarkers;
_list = [];
{if(getMarkerType _x == 'ellipse') then {
_list pushBack getMarkerPos _x;
_x setMarkerAlpha 0;
};} forEach _locations;
_list
};
ah yea
// Used location
used_locations = [];
getMissionLocations = {
_locations = allMapMarkers;
_list = [];
{if(getMarkerType _x == 'ellipse') then {
_list pushBack _x;
_x setMarkerAlpha 0;
};} forEach _locations;
_list
};
createMissionLocations = {
// Unused locations
_unused_locations = call getMissionLocations - used_locations;
// Get random location
_marker = selectRandom _unused_locations;
_marker_pos = getMarkerPos _marker;
// Name
_marker_name = format['task_%1_time_%2_marker', round random 9999, round time];
// Create marker
_markerstr = createMarker [_marker_name, _marker_pos];
_markerstr setMarkerType "mil_unknown";
_markerstr setMarkerColor "colorBLUFOR";
// Create trigger if player gets close start a mission
_trg = createTrigger ["EmptyDetector", _marker_pos];
_trg setTriggerArea [500, 500, 50, false];
_trg setTriggerActivation ["WEST", "PRESENT", false];
_trg setTriggerStatements ["this", "
'Bluefor entered the area' remoteExec ['systemChat'];
",
""]; // Check if bluefor is close, remove marker and call other function
// Add location to used locations
used_locations pushBack _marker
};
now fix this:
marker_name = format['task%1_time_%2_marker', round random 9999, round time];
whats wrong with that
I asked before how i could make this and this was the answer i got
x)
gets to the door quickly
๐
๐ช๐โโ๏ธโ๏ธ
I dont see a problem cuz i can;t really never be the same.
well.
maybe 0.000000000000000000001%
But if you have a better option im all ears
you don't need to randomize it
๐ค
sounds good to me
createMissionLocations = {
// Unused locations
_unused_locations = call getMissionLocations - used_locations;
// Get random location
_marker = selectRandom _unused_locations;
_marker_pos = getMarkerPos _marker;
// Name
_marker_name = format['task_%1_marker', count used_locations];
// Create marker
_markerstr = createMarker [_marker_name, _marker_pos];
_markerstr setMarkerType "mil_unknown";
_markerstr setMarkerColor "colorBLUFOR";
// Create trigger if player gets close start a mission
_trg = createTrigger ["EmptyDetector", _marker_pos];
_trg setTriggerArea [500, 500, 50, false];
_trg setTriggerActivation ["WEST", "PRESENT", false];
_trg setTriggerStatements ["this", "
'Bluefor entered the area' remoteExec ['systemChat'];
",
""]; // Check if bluefor is close, remove marker and call other function
// Add location to used locations
used_locations pushBack _marker
};
Now my main question
x)
How the F can i remove that marker once a player walks into the area.
why do you use triggers for that?
because once they getting into the area this marker needs to go and a mission spawns.
I mean do you have a compelling reason not to use loops?
also how many triggers could you be dealing with at once?
mmm
- I dont know
- once it triggers it should get deleted (i want maximum of 3 triggers at a time)
1 at east random location (max: 3)
well if it's just 3 then I suppose it's fine
just use setVariable
to associate the marker with the trigger
then getVariable to delete it
setVariable
Yes, im listening / reading docu
lets say i have _myTruck setVariable ["myPublicVariable", 123, true]; doesnt it override when i call the function again?
is _myTruck the same thing as before?
in your case it's _trig
you're creating a new trigger in every call of that function
the variable is stored in the trigger's namespace
if you have hundreds of books, can't they all have Page 1?!
and each page1 content is different
when using magazinesAmmo whats the best way to determine which turret it belongs to? the command lumps all magazines info for all turrets into a single array.
https://community.bistudio.com/wiki/magazinesAllTurrets
Might be better to just use this instead.
oh yeah thats better. i was getting mixed up with all the close names.
I know
createMissionLocations = {
// Unused locations
_unused_locations = call getMissionLocations - used_locations;
// Get random location
_marker = selectRandom _unused_locations;
_marker_pos = getMarkerPos _marker;
// Name
_marker_name = format['task_%1_marker', count used_locations];
// Create marker
_markerstr = createMarker [_marker_name, _marker_pos];
_markerstr setMarkerType "mil_unknown";
_markerstr setMarkerColor "colorBLUFOR";
// Create trigger if player gets close start a mission
_trg = createTrigger ["EmptyDetector", _marker_pos];
_trg setVariable ["marker", _marker_name, true];
_trg setTriggerArea [500, 500, 50, false];
_trg setTriggerActivation ["WEST", "PRESENT", false];
_trg setTriggerStatements ["this", "
'Bluefor entered the area' remoteExec ['systemChat'];
",
""]; // Check if bluefor is close, remove marker and call other function
// Add location to used locations
used_locations pushBack _marker
};
So i set it like this yes?
you might want to use a more "sophisticated" name than just "marker"
but yeah
now just delete it inside the trigger statements
so I'm going to be calling some things a ton in a spawned loop. would it be better to set those single commands to a function contained within the script and use the function variable instead?
would adding a simple statement like if (isMultiplayer && isServer) ensure a script always works on a multiplayer server?
if (isMultiplayer && isServer) then {}; would make it so it only fires on the server machine and only when a multiplayer environment is detected. It does not determine if a script is going to work.
Option 1:
while {_cond} do {
//A lot of code
};
```Option 2:
```sqf
while {_cond} do {
execVM "myOtherScript.sqf";
};
```Option 1 or 2 in your specific case? It's an important difference. Option 1 is good because it doesn't compile the code every loop iteration, Option 2 is bad because `myOtherScript.sqf` is recompiled for every loop iteration.
I gotta retrieve that variable with getVariable 'current_marker'; right ?
thisTrigger getVariable ['current_marker', '']
more like
_this spawn {
while {true} do {
private _variable = command;
private _variable2 = command;
private _variable3 = command;
//etc
sleep 1;
};
};
//VERSUS
_this spawn {
private _fnc1 = {command};
private _fnc2 = {commmand};
private _fnc3 = {command};
while {true} do {
private _variable = call _fnc1;
private _variable2 = call _fnc2;
private _variable3 = call _fnc3;
//etc
sleep 1;
};
};
No difference I believe; code is only compiled once and call can be imagined as copy-paste.
but I just saw your comment that a while loop only compiles once, which is mainly what I was looking for
I thought it would be compiled every run
say I have an array [apple, pear, pear, coconut]. is there a way to detect the repeat of pear? so i can do a if (repeat of pear exists) then {}; statement?
if they are non-array, you can just subtract
_cntElement = count _array - count (_array - [_element]);
there is also another variant of count:
_cntElement = {_x isEqualTo _element} count _array;
```but it's slower than what I said (but works with array elements)
might be a little more complicated I think. thinking of how to modify your idea...
_array = [["CUP_20Rnd_TE1_Red_Tracer_120mmSABOT_M256_Cannon_M",[0],20,1.00001e+007,0],["CUP_20Rnd_TE1_Red_Tracer_120mmHE_M256_Cannon_M",[0],20,1.00001e+007,0],["CUP_1200Rnd_TE4_Red_Tracer_762x51_M240_M",[0],1200,1.00001e+007,0],["CUP_100Rnd_TE4_Red_Tracer_127x99_M",[0,0],100,1.00001e+007,0],["CUP_100Rnd_TE4_Red_Tracer_127x99_M",[0,0],100,1.00001e+007,0],["CUP_100Rnd_TE4_Red_Tracer_127x99_M",[0,0],100,1.00001e+007,0],["CUP_100Rnd_TE4_Red_Tracer_127x99_M",[0,0],100,1.00001e+007,0],["CUP_100Rnd_TE4_Red_Tracer_127x99_M",[0,0],100,1.00001e+007,0],["SmokeLauncherMag",[0,0],2,1.00001e+007,0]];
and I want to count how many "CUP_100Rnd_TE4_Red_Tracer_127x99_M" though I won't know what strings the arrays contain since I'm writing it for all vehicles
maybe go through every internal array and extract the first element using a forEach. then doing a comparison from there
_cntElement = {_x#0 == "CUP_100Rnd_TE4_Red_Tracer_127x99_M"} count _array;
and here I was, making some 10 lines of code for what you did in one lol
Hi leo can i also pass on a setVar on a eventhandler?
Q: are there by any chance any functions that can help to compute gradients? in particular, I have a case where I have some thresholds and would like to color them accordingly, i.e.
case 1) [[0, WHITE], [0.25, YELLOW], [0.65, ORANGE], [0.85, RED]]
case 2) [[0, WHITE], [-0.25, YELLOW], [-0.65, ORANGE], [-0.85, RED]] in a negative direction
case 3) [[0, WHITE], [0.25, BLUE], [0.5, GREEN]] in a positive direction
really both 2+3 are a scale of [-1,1], in two separate directions; i.e. case 3, let's say, gradient 0.2 would be a paler blue, 0.9 would be a stronger green, that sort of thing
You can. Oops thought you meant inside of.
Is there a way to script on public zeus nowerdays? Was planning to do a scripted op with a bunch of friends and random players because we don't have enough people
(*legally script, I know there's hax but I REALLY don't want to resort to those)
have you tried voting yourself as admin? I'm not sure if debug comes up when on admin anymore on public zeus.
Nope, it doesn't, they removed that with the tank dlc update
then afaik, nope. if only they loaded up ZEH or something on the public servers so you could at least have an execute box
AFAIK?
as far as i know
// Spawn HVT (Mission Objective)
_list = [_location, 30] call getHouseSpawnLocations;
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = units _group;
_hvt = selectRandom _hvt; // ?? How do i select the first unit from group
addMissionEventHandler ["EntityKilled", { // ?? Add hvt to handler
params ["_unit", "_killer", "_instigator", "_useEffects"];
systemChat 'hi';
if (_unit == _hvt && local _unit) then {
[player call BIS_fnc_taskCurrent, "SUCCEEDED"] call BIS_fnc_taskSetState;
[_mission, 'SUCCEEDED'] call BIS_fnc_taskSetState;
{ player say2D "cp_mission_accomplished_1"; [player, 1500] call HALs_money_fnc_addFunds; } remoteExec ["call"];
'Mission Completed.' remoteExec ['systemChat'];
'You have earned $1500.' remoteExec ['systemChat'];
};
}];
can anyone help me with this ๐
the first unit in the array or the leader unit?
well there is only one in there.
so just the first
x)
i thought _hvt = _hvt select 1
but my main problem is the eventhandler
But i checked the EventHandler page and it says: args (Optional): Array - additional arguments to be passed to the EH code. Available during code execution via _thisArgs variable. but when i do this it says it expected 2 and i gave 3.
๐
Does ace fire an event when stitching is started?
I see your issue. Let me finish cooking and I'll get it typed
i hope, im lost atm
x)
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = units _group;
_hvt = selectRandom _hvt; // ?? How do i select the first unit from group
_eh setVariable ["objective", _hvt, true];
_eh = addMissionEventHandler ["EntityKilled", { // ?? Add hvt to handler
params ["_unit", "_killer", "_instigator", "_useEffects"];
_hvt = _this getVariable ['objective'];
if (_unit == _hvt && local _unit) then {
// DO STUFF HERE IF HE KILLED
};
}];
๐งน
maybe @little raptor knows ^^ ?
i'm sure he does. be patient. this is an easy fix.
@heady quiver
https://community.bistudio.com/wiki/setVariable
All supported variable types:
Namespace, Object, Group, Team Member, Task (FSM Task), Location ( scripted only) Control and Display since Arma 3 v1.55.133553
you have a lot more errors than just that BTW
first of all _eh doesn't exist yet
second of all, _eh is a number
third of all _this is an array

just use a global variable

as usual
_mission from above doesn't exist from above either
but there can be multiple tasks again
like markers
per mission yes.
did you write all this? or are you copying it from somewhere else and trying to make it work for own applications?
im making it.
trying *
x)
@heady quiver instead of a global event handler like "entityKilled", attach a "killed" event handler to your object
another error I didn't notice is that _hvt is an array
to answer your other question, you need to place the _hvt in the argument section of addmissionevent handler
addMissionEventHandler ["EntityKilled",
{
params ["_unit", "_killer", "_instigator", "_useEffects"];
private _hvt = _thisArgs select 0;
},
[_hvt]
];
since you are going to use _hvt = units _group select 0 earlier, it makes it into a single string, so you need [] to turn it back into an array for the _thisArgs
i see.
but now leo showed me the other wa
y
_hvt addEventHandler ["Killed", {
systemChat 'he dead';
}];
you can do either. Assigning a killed handler to a unit, or using a entity killed mission handler that checks to see if the unit killed was the unit you want
yea....
im just responding to your full post about how to bring it into the missioneventhandler that you had a question on
yea thanks!
i mean there are so many ways of doing things x)
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = units _group;
_hvt = selectRandom _hvt;
// EventHandler
_hvt addEventHandler ["Killed", {
systemChat 'he dead';
}];
This seems to work
just be careful of locality
Yea..
Im trying yours now but same thing
addMissionEventHandler ["EntityKilled",
{
params ["_unit", "_killer", "_instigator", "_useEffects"];
private _hvt = _thisArgs select 0;
if (_unit == _hvt && local _unit) then {
systemChat 'you killed HVT';
}
},[_hvt]];
3 elements provided, 2 expected.
Unless the docu is wrong lol
oh i know why
that 3rd parameter is only in the dev client
Since Arma 3 v2.03.147276
i dont think we are at that version yet
how would i do it then ๐ค
your setVariable method
But that didnt work.
just do what I said
you mean the addEvent to object?
or the one with the array.
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = units _group;
_hvt = selectRandom _hvt;
// EventHandler
_hvt addEventHandler ["Killed", {
systemChat 'he dead';
}];
that one

// Create group with unit (HVT)
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = units _group;
_hvt = selectRandom _hvt;
// EventHandler
_killed_eh = _hvt addEventHandler ["Killed", {
// Do stuff here when dead
}];
_killed_eh setVariable ["task_name", _name, true];
HELP
i think you are over complicating things, but I don't know how you are setting up your tasks.
yeah, its returning a number, a number you can't do anything with
its not like its returning a object, or a logic to point to
the number is used for removing event handlers
you don't
Set it to the unit the EH is attached to
aah
// Create group with unit (HVT)
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = units _group;
_hvt = selectRandom _hvt;
_hvt setVariable ["task_name", _name, true];
// EventHandler
_hvt addEventHandler ["Killed", {
// get the variable and compare it with killed unit
// Do stuff here when dead
}];
well i need to retrieve the data now in the EH how do i do that?
and please```sqf
// turn
_hvt = units _group;
_hvt = selectRandom _hvt;
// into
_hvt = selectRandom units _group;
just _this getVariable ['task_name']; ?
you don't need to make that comparison... the killed is ATTACHED to the unit
oh yea srry x)
i meant
i need to retrieve the task name
// Create group with unit (HVT)
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = selectRandom units _group;
_hvt setVariable ["task_name", _name, true];
// EventHandler
_hvt addEventHandler ["Killed", {
// Get the task and finish it
}];
well do you know what the task name is that you are going to be retreiving?
is that what _name is referring to somewhere above?
i wont know the name thats why its gonna be setVariable (task_name)
yea
exactly.
then you pretty much know the rest then. you get the variable from _hvt that contains your name of the task, then you use that name in your taskcompleted setup
what does the wiki say ๐
_this select 0 or with params ["_unit", "_killer", "_instigator", "_useEffects"] and then using _unit
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];
so```sqf
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
private _taskName = _unit getVariable ["task_name", ""];
// rest of stuff here
}];
```as you can see, params names your arguments already; no need for _this select 0
private _taskName = _unit getVariable ["task_name", ""]; <-- this
i just needed to know how i could call something like that
_hvt does not exist in the EH, so it cannot be accessed
x)
if you add an EH to a unit, _unit will be that unit
aaah
โฆsorry if I make it sound obvious but that's how it is ๐ฌ ๐
No all good makes sense now.
this is MP compatible?
As long as that unit exists for all players then it should be fine right
you don't need to set the variable publicly btw, since you add the EH locally
and the MP compatibility will depend on what you will put in that code
It is not the right question to add for MP compatibility of your script.
You create the _hvt and event handler on same place(so same machine is executing this code, so it is yes MP compatible)
Here:
startKillMission = {
params['_location', '_name'];
// Create task
_name = format['%1_task',_name];
private _myTask = [west, _name, ['', 'Eliminate Target', 'kill'], objNull, true, 0, true, "kill"] call BIS_fnc_taskCreate;
[_name, _location] call BIS_fnc_taskSetDestination;
// Do mission stuff here
//[_location, 15] call spawnEnemyUnits;
// Spawn HVT (Mission Objective)
_list = [_location, 30] call getHouseSpawnLocations;
// Create group with unit (HVT)
_group = [selectRandom _list, east, ['CUP_O_INS_Story_Bardak'], [], [], []] call BIS_fnc_spawnGroup;
_hvt = selectRandom units _group;
_hvt setVariable ["task_name", _name, true];
// EventHandler
_hvt addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
private _taskName = _unit getVariable ["task_name", ""];
[_taskName, 'SUCCEEDED'] call BIS_fnc_taskSetState;
{ player say2D 'cp_mission_accomplished_1'; [player, 1500] call HALs_money_fnc_addFunds; } remoteExec ['call'];
'Mission Completed.' remoteExec ['systemChat'];
'You have earned $1500.' remoteExec ['systemChat'];
}];
};
This seems to be working for me.
Any suggestions that could be better ^^ ?
player say2D hmmโฆ where does this script run?
oh okay (playSound?)
yea that makes more sense
cuz player is not really saying it
x)
Alright, awesome thanks for the help guys.
๐
so I want to check performance on this script I wrote as it potentially has many instances depending on how many people sync my module. The performance test built into arma, will it go straight through and not test the spawn'ed part of code? whats the best way to test a loop like this?
it would be better if one script ran for a global array ofc, but otherwise it is not awful
wait
if !(local _vehicle) exitwith {
[[_vehicle, _time], hyp_fnc_runRearm] remoteExec ["call", 0];
};
```โฆ
@fair drum ๐จ
if !(local _vehicle) exitwith {
[_vehicle, _time] remoteExec ["hyp_fnc_runRearm", _vehicle];
};
``` ๐
lol probably just me being up at 4am last night. was trying to build in a check to reset the script if ownership of the vehicle changed
the check should also be done at the top of the while ^^
i had a check earlier than that which prevents a non local or null vehicle from even reaching that point I believe
while { sleep _time; alive _vehicle && local _vehicle } then
okay, noted ๐
you'll be safe that way
but also, if someone disconnects the script is lost
thats what i was trying to prevent
it should be the server that sends the function to execute to the current owner - safer that way
okay ill modify it at the module level to do that (currently the module is set to global)
ideally:
- run the function server-side
- only one script that checks an array
- added vehicles get into that array
- null/deleted vehicles get removed
- the server does a
forEach - the server
remoteExecs said function on the vehicle's owner (with remoteExec ["func", _vehicle])
okay, shouldn't be too hard of a change (besides doing it for all my previous modules oops lol)
// Add action to objective
[_objective,
"Place Explosive",
"\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\destroy_ca.paa","\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\destroy_ca.paa",
"_this distance _target < 30","_caller distance _target < 30",
{},{},{
null = [] spawn {
'30 seconds before detonation...' remoteExec ['systemChat'];
sleep 10;
'20 seconds before detonation...' remoteExec ['systemChat'];
sleep 10;
'10 seconds before detonation...' remoteExec ['systemChat'];
sleep 5;
{ player say2D "Beep_Target"; } remoteExec ["call"];
sleep 5;
_this allowDamage true;
_explosion = 'CUP_IED_V4' createVehicle getPos _this ;
_explosion setDamage 100;
_this setDamage 100;
};
},{
},[],5,0,false,false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _objective];
Question: how can i access _this if im in a spawn function.
[apple,pear,coconut] spawn {
params ["_apple", "_pear", "_coconut"];
};
// or
[apple,pear,coconut] spawn {
_this; //returns [apple,pear,coconut]
};
ye
salsa spawn {
_this; //returns salsa
};
i see.
But what if _this = _this
x)
because _this in the BIS_fnc_holdActionAdd is that object where the function is on.
salsa spawn {
_this spawn {
_this spawn {
_this spawn {
_this; //returns salsa
};
};
};
};

what i mean is
hold up
// Add action to objective
[_objective,
"Place Explosive",
"\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\destroy_ca.paa","\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\destroy_ca.paa",
"_this distance _target < 30","_caller distance _target < 30",
{},{},{
object = _this; // <-- this
null = [] spawn {
'30 seconds before detonation...' remoteExec ['systemChat'];
sleep 10;
'20 seconds before detonation...' remoteExec ['systemChat'];
sleep 10;
'10 seconds before detonation...' remoteExec ['systemChat'];
sleep 5;
{ player say2D "Beep_Target"; } remoteExec ["call"];
sleep 5;
_this allowDamage true;
_explosion = 'CUP_IED_V4' createVehicle getPos _objective;
_explosion setDamage 100;
_this setDamage 100;
};
},{
},[],5,0,false,false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _objective];
oh no.
its not _this its target
can i assign the repair and rearm capability to a custom vehicle?
[
1,
2,
3,
4,
5,
6,
{
//code here
},
8,
9,
10,
[argumentsToPassToScript],
12,
13,
14,
15,
16
] call BIS_fnc_holdActionAdd;
please really look at the wiki page, it's listed as the 11th parameter and it has a huge array of possible values you can use
yea will check
@fair drum
I can do _target but the problem is that i am in that spawn thingy
i can do deleteVehicle _target for example outside spawn {}
// Add action to objective
[_objective,
"Place Explosive",
"\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\destroy_ca.paa","\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\destroy_ca.paa",
"_this distance _target < 30","_caller distance _target < 30",
{},{},{
deleteVehicle _this; // <-- THIS WORKS
target spawn {
sleep 5;
deleteVehicle _this; // <-- THIS DOESNT WORKS
};
},{
},[_objective],3,0,false,false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _objective];
params ["_target", "_caller", "_actionID", "_arguments"];
_target spawn {
sleep 5;
deleteVehicle _this;
};
use params. every time if a command gives them. so you don't get unorganized
do you mean do the while loop evaluation for every vehicle on the server? then feeding the results to the client for the actual addMagazine or setWhatever function for a particular vehicle? or just getting the units that you need, then feeding the function that has the loops to the client and have the client do the evaluation loop and commands?
Howdy! I am currently working on ACV from scratch got my model ingame and its amphibous and all that, for my armaments i have a 30mm cannon and coaxial machine gun. While on water it won't fire the main gun but the coaxial gun will fire. Any suggestions on how I would get he main gun to fire while its on water? Don't know what script or if i need a certain code to allow for this.
curious, did you import a config from a previous vehicle then modify it?
More or less inherited values from the Badger IFV only thing I ended up changing was armor values. @fair drum
I would think this is a config issue only. Maybe try over at #arma3_model or #arma3_config
how do I check what side a player is on?
i want my code to go something like this:
if player is side Blufor then {
//code code code code code
}
else {
//code code code code code
}
side player
ok
can I do:
if side player = blufor then {
//code code code
}
else {
//code code code
};
@warm hedge
= is to declare not to compare, == instead
ok
do I need to put the "if" condition inside parenthesis like this:
if (side player == blufor) then {
//code code code
}
else {
//code code code
};
?
@warm hedge
I mean to create a function that refill the vehicle (the while-loop content) and to run the while server-side
Im getting a problem with this code. The systemChat and playSound are not working for players on the independent side
waitUntil {!isnull player};
sleep 5;
if (side player == blufor) then {
systemChat "The Rebels are attacking the APD Headquarters! Guard the transport vehicle!";
systemChat "Stay inside the blue area around the HQ marked on the map!";
playSound "FD_Finish_F";
while { true } do {
waitUntil { sleep 1; alive player };
if !(player inArea "APDHeadquarters") then {
player setDamage 1;
};
};
};
else {
systemChat "You are attacking the APD Headquarters! Steal the transport vehicle and deliver it safely back to the Rebel Base!";
playSound "FD_Finish_F";
};
LOL
that's why ๐
i just noticed that
of course, it is valid in SQF, no errors ๐
wait a minute
do i just need to get rid of that extra };?
its supposed to be like if (boolean) then { shit } else {other shit};, right?
ohhh
it's the ; that stops it
if you indented properly :U
lol
if (condition) then {
// something
} else {
// something
};
// or
if (condition) then
{
// something
}
else
{
// something
};
ok
oh yeah and heres the other thing
_transport = allMissionObjects "B_Truck_01_ammo_F";
{
while { true } do {
sleep 1;
if (_x inArea "RebelBase") then {
endMisson "END1";
};
};
} forEach _transport;
it is supposed to end the mission when they drive the vehicle inside the zone, but nothing happens
i am not sure if I am doing that right tho
you have exhausted your free support options (1 per week)
to enhance your range of support, please proceed to the Arma supported pack (5$/month)
lol
itโฆ will end the misson when one truck happens to be in there
it'sโฆ awful ๐
_truck = TheTruck;
waitUntil { sleep 1; _truck inArea "RebelBase" };
[] spawn BIS_fnc_endMissionServer;
ah
nice
yoink
_truck = Transport;
waitUntil { sleep 1; _truck inArea "RebelBase" };
[] spawn BIS_fnc_endMissionServer;
ohhh
i have to use the variable name
i completely forgot that variable names existed
when i wrote that
_transport = Transport;
waitUntil { sleep 1; _transport inArea "RebelBase" };
[] spawn BIS_fnc_endMissionServer;
so that ^ should work? if the truck's variable name is Transport
Why assign it to a local var if you have a global one already?
Just don't name it "Transport"
name it "TRIO_Transport"
Otherwise chances are high your variable gets overwritten by a mod or somthing
nah we good
Is there a clean way to detect when somebody enters a UAV view? Using CBA if that helps ๐
Please, help us, We're frickin' stuck with this problem. I don't know what we did wrong. The idea is, that a sound should play when trigger is hit.
Would help if you tell us what you tried so far.
Wait a sec, I was preparing some screenshots.
It does not work. I don't know why exactly.
When trigger is activated, the sound does not play. It just gives an error that it couldn't find the sound file.
Because the file path you've provided in description.ext is wrong
It points at sound\dialog_0_officer_0.ogg but the actual file isn't in a subfolder called sound
It still gives me this error
The file path is now correct @hallow mortar
But it still does not work.
Well now you've put description.ext in the sound folder so it's probably not reading it
description.ext always goes in the main mission folder
Hello! I hope i'm in the right place.. I'm attempting to make a script provide a medical-only arsenal for a gamemode, but i'm not sure how to do so
nearEntities ["Man", 160];
How do i use NearEntities of "Man" to select all sides but BLUFOR?
(nearEntities ["Man", 160]) select {side _x == blufor};```
Specifically i'm wondering about how to set it up so the arsenalbox is restricted to the medical items in the misc tab, i'm running ACE fyi
wouldn't that select BLUFOR only?
Yes, it is possible, Ossom.
Thank you, POLPOX.
I have a script. I will send you pastebin for it. Wait a min
๐
DM's open
rip your inbox
Hence typically having it closed lol
Afternoon fellas, I have a small problem.
I would like to generate an array containing objects which have only a specific string in their var name (not classname).
E.g. A list of all objects who have 'specItem' in their varname, so objects named 'specItem_1', 'specItem_2', 'specItem3' will be collected into the array, but objects with 'spec_Item', or 'item' will not be collected.
"string" in "string2"
will this work for objects?
varname is just a string
oh okay then
for some reason running _isInString = "foo" in "foobar"; in the debug console gives a generic error
It's not that line
I'm sorry but I don't understand
This line cannot give an error, it's caused by something else.
It's the only line in the console, I tested it on a new mission
Then validate your game files
"string" in "string" also does the same thing
Are you running some really old build or something?
Hi, does anyone know how i can keep a map marker on a unit's position even when he moves?
Works for me, [0.6] spawn TEST_fnc_setOvercast; gave me Overcast: 0.6 in system chat.
With a while-loop.
Or EachFrame type of EH
Which one is more efficient?
Doesn't have to be spot on, could be maybe every 5 seconds update?
Unless its not a problem to keep checking it.
If it's not supposed to update every single frame, while is better
Thanks ๐
Also when i have this in my init.sqf : nul = [] execVM "functions\locations.sqf";
There is a function in there called createMissionLocations how can i call that function the the same file? (init.sqf)
Just multiple execVMs?
You can't, define the function properly and you can.
// Start default locations
if(isServer) then {
for "_i" from 1 to 3 do {
// call createMissionLocations;
}
};
this is what i mean.
When the mission / server is loaded i want it to execute 3 times that function.
Define the function using the functions framework and you can do just that.
it is..
Or, just need to createMissionLocations = {bra bra...}; or sqf createMissionLocations = compile preprocessFileLineNumbers "theFunctionFile.sqf"
Yeah... maybe we're not getting what you're meaning
the function is there.
there are multiple functions in there but the one createMissionLocations is the one i want to call in the init.sqf file .
You don't know when execVM actually executes the code, so you can't just use the function after your execVM line because it might not be defined yet.
Guess you could waitUntil
call is better
Or define your functions properly 
like?
execVM and spawn do execute scripts apparently, but... they're not do their job in THE FRAME. call on the other hand, will do
i can call a file?
call compile preprocessFileLineNumbers "function.sqf" longer than just an execVM but should work
Yea i need to look into that stuff
https://community.bistudio.com/wiki/Scheduler
You can read this article to see what's up between spawn and call
yes this worked.
The functions framework does all this stuff for you and you can just use call createMissionLocations; in init.sqf without having to compile your function three times to run it three times.
yea that would be better but kinda new to that
Basically you make a happy little CfgFunctions in your description.ext following the specifications described on the wiki page and that's it.
But i might make happy little accidents 
We all do, but then we tinker with our code until it works (or ask someone for help)
ty - had a second TEST_fnc_setOvercast function to overwrite the first ๐ต
just teleport your marker on a loop. one to five second intervall is mostly fine, sometimes you even want WAY longer delays. 5 minutes for marking own teams in the AO, so you know roughly where they are, but not immersion breaking precise-realtime
yea
at the spawnGroup function it says skillRange: Array of Numbers - (Optional, default []) skill range format [min, max] is it between 0 and 1 ?
cuz right now they ai are aimbotting me
should be 0, 1 yes
_group = [_rnd_pos, east, [selectRandom call getEnemyUnitList], [], [], [0.1, 0.4]] call BIS_fnc_spawnGroup;
like this ๐ ?
[selectRandom call getEnemyUnitList] what
that syntax is wrong.
check selectRandom again, then what params the function want
why are you not naming your functions with fn_ or fnc_?
dunno
๐
oh, a bs function
i was reading through ACE's coding format rules and they use fnc_balls_face
Hello, how to globally get all players on server and for example use playMove at him?
in arma 2 on dedicated server
Bob Ross FTW.
If you can't fall asleep, just watch him painting and talking like he's high
Can't use allPlayers in A2, so you gotta go with allUnits and isPlayer.
it is globally works?
without call RE, or any things for Multiplayer working?
According to the documentation we have, those commands should work on every machine, yes.
how to playMove globally?
I can't tell you how to actually do it because I don't know how remote execution in A2 works (I don't even have A2), but according to https://community.bistudio.com/wiki/playMove, playMove only takes local arguments, meaning you have to execute playMove on the machine which the animated unit is local to.
_objective addEventHandler ["EachFrame", {
private _marker = _this getVariable ["markerCargo", ""]; // ??? cant be _unit
}
has no params how can i get the var ๐ค
https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#EachFrame
EachFrame is a Mission EH, you can't add it to a specific object.
oh fuck
guess gotta use a while loop
So if i call a function with a while loop to constantly update the vehicle's position and then couple minutes later i call that function again thats overwrites the other one right
Well yes, unless the while loop is still running
so lets say i call it, and i start the while loop.
i can call the same function and then i got 2 while loops at the same time/
Yes
more like this?
yes (butโฆ why the switch case with ONE case? ๐)
there's more, just left it all out for size
i don't expect anyone to read through mountains when i have a focused thing
and that's actually nice of you!
here, you are still creating a single spawn for every vehicle
you should go through the array (_syncedEntities), remove dead entities, then remoteExec the thing, in the same thread
a.k.a```sqf
[_syncedEntities] spawn {
params ["_syncedEntities"];
while { !(_syncedEntities isEqualTo []) } do
{
_syncedEntities = _syncedEntities select { canMove _x };
{
// do stuff remoteExec ["func", _x];
} forEach _syncedEntities;
};
};
he wants a repeat every x seconds
isNotEqualTo 
isDifferentTo
oh yes, I thought it was still in dev ๐
best command ever made
i see. my second case was if _persistence was true and it used the classes of the vehicles instead and added a loop check to add more vehicles of that class to the pool to re execute the function in case you were wondering
okie
just use one thread to remote exec, the less threads the bettererest ๐
startCargoMission = {
params['_location', '_name'];
// Random pos and nearest road
_rndLocation = [call BIS_fnc_randomPos, 5000] call BIS_fnc_nearestRoad;
// Create Objective
_objective = 'CUP_O_Ural_CHDKZ' createVehicle getPos _rndLocation;
// Create marker
_marker_name = format['task_%1_marker_cargo', count used_locations];
_markerstr = createMarker ['Cargo', getPos _rndLocation];
_markerstr setMarkerType "o_unknown";
_markerstr setMarkerText "Cargo Supply";
// Set variable
_objective setVariable ["markerCargo", _marker_name, true];
while{true} do { // while loop
sleep 1;
_pos = getPos _objective;
_markerstr setMarkerPos _pos;
if(!alive _objective) then {
// Delete marker here and stop while loop
}
};
};
Can anyone help me ^^
with what in particular
whats the error? always list the error lol
can't sleep in unscheduled
oh, its cause you arent in a scheduled environment
just leave out the null =
don't need it on A3
but you are going to have to feed _objective, and _markerstr to the spawn
you forget the sleep?
no
while{true} do { // while loop
[_objective, _markerstr] spawn {
sleep 1;
_pos = getPos _objective;
_markerstr setMarkerPos _pos;
if(!alive _objective) then {
// Delete marker here and stop while loop
}
}
};
ah
That's not the main problem ๐
๐ฟ ๐
๐ฅ
you can cook popcorn on his pc
x)
I checked and yesterday we did this _target spawn {
but now i have 2 vars ๐ค
so? pass an array instead
[_objective, _markerstr] spawn {
while{true} do { // while loop
sleep 1;
_pos = getPos _objective;
_markerstr setMarkerPos _pos;
if(!alive _objective) then {
// Delete marker here and stop while loop
}
};
}
aren't i doing that here?
yea, but you're missing params
[_objective, _markerstr] spawn {
params['_objective', '_markerstr'];
while{true} do { // while loop
sleep 1;
_pos = getPos _objective;
_markerstr setMarkerPos _pos;
if(!alive _objective) then {
// Delete marker here and stop while loop
}
};
}
yea works
cewl
now i just need to exitWith or breakout ๐ค
you can move the alive check into while condition, and run code you want after the while loop, essentially same concept
instead of true i meant
just realised what you meant
but how ๐ค
problem is
that function can be called twice.
so 2 trucks.
yeah, so?
that not a problem?
doesn't change anything
oke ocol
cool *
[_objective, _markerstr] spawn {
params['_objective', '_markerstr'];
while{alive _objective} do { // while loop
sleep 1;
_pos = getPos _objective;
_markerstr setMarkerPos _pos;
};
deleteMarker _markerstr;
};
seems to work

uhm
Is it possible that i just corrupted my mission lol
How can I go about changing the suborbinates of an ORBAT with https://community.bistudio.com/wiki/BIS_fnc_ORBATSetGroupParams
https://community.bistudio.com/wiki/Arma_3:_ORBAT_Viewer has subordinates[] = {2ndBCT}; // Subordinates, searched on the same level as this class. yet I cannot figure it out for the set
I told you to use event handlers
nvm
Got it working tho.
I didn't see the setMatkerPos
ah ok
clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
clearItemCargoGlobal _vehicle;
clearBackpackCargo _vehicle;
This a good way to remove all items from a vehicle?
I believe that this is the only way, yes.
clearBackpackCargoGlobal*
Yea not sure if you've got them all ๐คทโโ๏ธ
if I'm remoteExec to potentially many objects' clients every second, wouldn't that clog up the network?
that's what the server is for ๐
how to insert " in text
""
systemChat """Hello"", he said."; //"Hello", he said.
hint "this is ""quoted""";
// or
hint 'this is "quoted"';
oh thanks
guys.
I asked before if i could call my 'cargo' function multiple times but that doesnt seem to be the case
?
My goal is to spawn cargo vehicles with a marker on the map for them (Which works now) but i can't call it again nothing happends (or atleast not showing on map)
Any reason why i can't call it twice or have 2 vehicles drive arround?
The reason is that you forgot to use your dynamic marker name.
Hello, i have a custom grenade, but when i add it to player - he can't use it, need to drop on the ground and take again.
And just after that - grenade is able to use.
When press "F" to change ammo type to grenade - nothing is changes
Is possible to somehow make it able to use without drop to the ground?
whats the script to make characters keep nvgs on for pics
Q: Is BIS_fnc_objectVar guaranteed to be the same after restarting the mission?
Nvm, it obviously couldn't be with regards to objects created while the mission is running.
The example shows that the variable is part of the missionNamespace, that's another hint.
Well yeah but I was thinking since stuff placed in the editor is listed and initalized (AFAIK) in the same order each time...
if the netID of an object is the same then objectVar would give the same result each time...
but yeah
dynamic objects screws it all up
Can always look at the source code of BIS functions
mhm it's netID they are using to build the variable name
quick question is there any command to force AI vehicle commander's to use smoke?
yup, grab the smoke magazine class and use one of the force fire commands
okay thanks
hello all was wondering if someone could help me. i am editing and intro and i would like to make the text bigger
titleText [" T E S T", "BLACK IN",9999];
titleText ["<t size='10'> T E S T</t>", "BLACK IN",9999];
``` try this and increase size when needed
that didnt work it shows this
<t size='10'> T E S T</t>
Arma 2?
@pine solstice 9999, false, true]
you need to set the isStructuredText flag
my fault 
yes. You are demoted to rank 41 nao
noooo.... I lost my 42 status
yes


