#arma3_scripting
1 messages Β· Page 125 of 1
Well Lou explained better how to use it.
can you somehow get pointer to the debris left from destroyed building?
I mean debris that belongs to the destroyed building
@proven charm Yes, using the BuildingChanged mission event handler.
Bear in mind that it won't work with BIS_fnc_createRuin.
Is there a way to use setObjectTexture on objects that do not have hiddenSelections? or some other way to color the object?
no
and got the memory leak fixed
Sweet, I'd consider this to be low level complete. You can call sqf functions, get values, get data out of values, and free memory.
It is also thread safe
what are you doing?
void threaded_invoke_demo() {
while (true) {
game_value player = invoker::get().invoke_raw("player");
game_value pos_val = invoker::get().invoke_raw("getpos", &player);
game_data_array *pos = (game_data_array *)pos_val.data;
float x = ((game_data_number *)pos->data[0].data)->number;
float y = ((game_data_number *)pos->data[1].data)->number;
float z = ((game_data_number *)pos->data[2].data)->number;
invoker::get().release_value(&player);
invoker::get().release_value(&pos_val);
LOG(DEBUG) << "Thread ID " << std::this_thread::get_id() << " Player Pos: [" << x << "," << y << "," << z << "]";
Sleep(10);
}
}
^ that is what i am doing :D
You can attach a user texture object and set the texture on that.
thx π
How come you can have Explosion event handler but not HitPart with _isDirect=false? π€
Just noticed this for a first time
First shot: Explosion only
Second shot: HitPart (both for _isDirect being true and false), then Explosion
Quick question does anybody know how to extend turret of a ED drone ? via script ?
elevatePeriscope for up/down, I think. Not sure about forward/back.
So, more testing, looks like this happens if explosion damage is miniscule, you get Explosion, HandleDamage but no HitPart for some reason
17:55:13 ---------------------------------------------------------
17:55:13 "Frame 214804: HandleDamageVehicle: C_Hatchback_01_sport_F (ALIVE=true)"
17:55:13 ["13ddaf30080# 1782913: hatchback_01_f.p3d (C_Hatchback_01_sport_F)","wheel_2_2_steering",0.00864477,"B Alpha 1-2:1 (Sa-Matra) (B_MBT_01_cannon_F)","Sh_120mm_APFSDS_Tracer_Red",3,"B Alpha 1-2:1 (Sa-Matra) (B_Soldier_F)","hitrf2wheel",false]
17:55:13 ---------------------------------------------------------
17:55:13 "Frame 214804: Explosion: C_Hatchback_01_sport_F"
17:55:13 ["13ddaf30080# 1782913: hatchback_01_f.p3d (C_Hatchback_01_sport_F)",0,"1782915: shell_tracer_red.p3d (Sh_120mm_APFSDS_Tracer_Red)"]
0.008 damage to wheels
Damn this sucks, gonna have to account for this edge case now
Damage only happens to wheels (and 0 total), maybe its some hardcoded behavior to destroy car wheels, thus skip of HitPart?
Bigger explosion properly triggers all event handlers
Guess this 0 damage of Explosion makes the engine skip HitPart? Yet this 0 does a tiny bit of damage to wheels.
I wonder what this 0 in Explosion even means then
Stable too?
Tested on stable, doubt its any different on dev
I was just double checking if it's related to my changes
How I tested it:
- Hatchback and Slammer
- Add all 3 EHs to Hatchback (HitPart, Explosion, HandleDamage)
- Shoot AP round close to Hatchback into the ground
whats the most simple/reliable way to make something from a mod to be executed clientside once a mission starts/once the player is in the mission?
postInit via cfgFunctions?
whats your github
Verox-
with a -
wiith the tac at the ne
dyeah
Someone from germany stole Verox : <
He never even commits
Only reasonable way really?
Awesome, thanks nou : D
i think ima spend the rest of the night commenting
does the command ctrlSetAngle not work for a progress bar using RscProgress ?
Syntax: control ctrlSetAngle [angle, centerX, centerY, now] Parameters: control: Control - picture control
ah so guess it does only work for pictures?
Yes, it should work only for pictures
Be pretty cool if there was rotation support for other control types though
Could someone advise how to go about a following problem?
I want a script that attaches an action to vehicles to be executed on both vehicles placed in editor and on those placed in zeus session. For no I tried to go around it this way:
if(typeOf _x in tinyCargoSize) then {
[ _x, 2] call ace_cargo_fnc_setSpace;
[_x, "vehicle", 0, 0] execVM "DNT_supplies\DNT_createSupplies.sqf"; //Claim is only available at the beggining but it dissapears after aborting and joining again
_x addMPEventHandler ["MPKilled",{
params ["_unit", "_killer", "_instigator", "_useEffects"];
[0,_x]remoteExec ["removeAllActions"];
[_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";
_unit removeMPEventHandler ["MPKilled", 0];
}
];
};
... more lines similar to those above
}forEach vehicles; //This part is responsible for executing code on vehicles placed in Editor
{
_x addEventHandler ["CuratorObjectPlaced",{
params ["_curator", "_entity"];
private _targetType = typeOf _entity;
if(_targetType in tinyCargoSize) then {
[[_entity, "vehicle", 0, 0],"DNT_supplies\DNT_createSupplies.sqf"] remoteExec ["execVM"];
[_entity, 2] call ace_cargo_fnc_setSpace;
_entity addMPEventHandler ["MPKilled",{params ["_unit", "_killer", "_instigator", "_useEffects"];
[0,_unit]remoteExec ["removeAllActions"];
[_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";
_unit removeMPEventHandler ["MPKilled", 0];
}
];
};
... more lines similar to those abov
}forEach allCurators; //This part is responsible for executing code on vehicles placed by zeus```
Problem with this is I'm getting weird behavior in MP like for example actions are only seen by first player joining and then after respawn they dissapear and so on. Ones that are in MPKilled eventhanlder works fine though so I wonder whether it would be possible to achieve similar goal using some different event handler?
I noticed there is an EH "Init" but I'm not sure how to use it as it's limited to use in config files only according to Biki?
vehicles is local so it can lead to weird locality issues https://community.bistudio.com/wiki/vehicles
its quite slow, but probably _vehicles = [worldsize/2, worldsize/2] nearobjects worldsize will work better
That's faster i think
{
} forEach entities [["Car","Helicopter","Truck_F","Ship","Tank"], []];
vehicles returns more than just driveable vehicles, it also returns static objects
Yeah ik, but later I filter the vics I want anyway, I have desired vics divided into arrays like here if(_targetType in tinyCargoSize) then {...
Does anyone know how to return a number from a script?
I've made a script that gets a players role description and then sets a variable to a number based on the result. I just need to somehow get that result into the trigger that calls it.
this is the basic script I used just for testing:
myNumberFunction = {
// Your logic to calculate the number
// For example, let's say you want to return the result of adding two numbers
_result = 5 + 3;
// Use the return statement to return the result
_result
};
so in the trigger that calls this script we want to get "_result"
hint format["Result: %1", call myNumberFunction];
hey everyone, i remember finding a script that made it so all curator spawned units would be disabled from fleeing, but i lost it on my old hard drive and can no longer find it
chat gpt?
Is this from the wiki then?
Excessive amount of comments for each line points at script being generated by ChatGPT
I don't know what chatgpt is
Q: this morning about HashMapObjects, and in particular about #Flags, what are they, and are they enumerated, documented, apart from createHashMapObject wiki page? thanks...
where did you get the script then?
a friend who has poor internet connection he might have gone to the wiki maybe?
that's pretty much it
plus
https://feedback.bistudio.com/T170647#2421993
hmm I see... thanks...
Hello. Why does this code endlessly create a Speed ON action and not disable acceleration by Speed OFF?
_uid = getPlayerUID player;
_name = name player;
_ULTRA_UID = ["Deleted","Deleted"];
if (((_name find "TO" != -1 or name player find "TOS" !=-1) || (_uid in _ULTRA_UID)) && (alive player)) then {
removeMissionEventHandler ["EachFrame",SKX_speedster];
SKX_SpeedyON = player addAction ["<t color='#f4e541'>Speed ON</t>",
{
params["_Speedy"];
//["Speedy"] call ace_advanced_fatigue_fnc_removeDutyFactor;
["Speedy",0.48] call ace_advanced_fatigue_fnc_addDutyFactor;
SKX_speedster = addMissionEventHandler ["EachFrame",
{
player setAnimSpeedCoef 1.5;
}];
_speedy removeAction SKX_SpeedyON;
SKX_SpeedyOFF = _Speedy addAction ["<t color='#f44167'>Speed OFF</t>",
{
params["_Speedy"];
["Speedy"] call ace_advanced_fatigue_fnc_removeDutyFactor;
["Speedy",1] call ace_advanced_fatigue_fnc_addDutyFactor;
_speedy removeAction SKX_SpeedyOFF;
removeMissionEventHandler ["EachFrame",SKX_speedster];
sleep 2;
["Speedy"] call ace_advanced_fatigue_fnc_removeDutyFactor;
_speedy execVM "scripts\arf\moveSpeed.sqf";
},[1],10,false,true,""];
},[1],10,false,true,""];
};
I'm making a mission and want a trigger to check if two players are present before playing a music track.
The current code I have looks like this (image 1), the stuff between the red lines is what I'm concerned with, everything else works. It allows me to input this without throwing an error, but upon triggering it in the mission I get this error (image 2), any tips?
Sorry I can't type in the code like you, not currently at my PC, Thank you :)
if (this && Z && ...```
Your issue is here. `Z` is an object (I assume, since you're doing setCaptive on it). `&&` requires the code on both sides of it to evaluate to either `true` or `false` (Boolean data type). You're providing it with something that evaluates to an Object data type.
the issue is that this is not defined
There are two issues π€·
that's also an issue, but not what the error says
Well, you can just remove the reference to this (in On Activation) entirely - you don't need to worry about whether the trigger's condition is satisfied, because the trigger wouldn't have activated if it wasn't
is it possible to have multiple on activation in a trigger, for example i have four objects (cargo 1-4) and i want each of them to be teleported using setPos, how do I set up the condition for each object to be teleported individually when it is entered in the trigger area
Z is the name for one of the players (Z for Zeus), what would a correct usage here look like? Or am I so off that there is none lol?
I'm booting the game now so I'll see soon if removing this works
You can't have multiple On Activations.
You can set up the trigger so that it doesn't actually matter which object activates it.
// Condition
([box1, box2, ...] findIf {_x in thisList}) > -1
// On Activation
{
// if they each have a separate specific target pos, this is a little more complicated, but it can be done
_x setPosASL destinationPosHere;
} forEach ([box1, box2, ...] inAreaArray thisTrigger]);```
I assume you want to check if both Z and...the other one...are in the area.
If that's the case, you're close. The problem is that you can't do this:
Z && player2 in thisList```
because that's not what `&&` does. It can't do `(x and y) in thisList`. It's `condition1 and condition2`. The two sides are separate checks.
So you'd need this:
```sqf
Z in thisList && player2 in thisList```
yes I want to only play it once both players are present in the area
I will try this in a moment, thank you so much
So my code now looks like this (btw how do you do those fancy text boxes?), and no longer throws an error, however it still doesn't play the music?
UndercoverZ enableSimulation disable;
Z setcaptive false;
if (Z in thisList && Infil1 in thisList) then {
playMusic AmbientTrack01a_F_Tacops;
};
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
"quotes", not (parentheses)
oh yeah sorry I misremembered the name 
Q: on HashMapObject, how would I facilitate calling a #base method from the context of the same derived method?
So my trigger code now looks like this, again no errors, but also no music, I've tried directing the playMusic function to the tracks actual file placement /A3/Music etc but that didn't work either.
UndercoverZ enableSimulation disable;
Z setcaptive false;
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
};
my music volume is on, just in case 
Add some systemChat at various places to indicate which bits are being executed and which aren't
Oh hold on
enableSimulation, you can't use literally the word disable unless you saved a bool to a variable with that name
It has to be a Boolean value, true or false
oh I saw somewhere that disable was usable but yeah that makes sense
I'm very much new to this so stuff like that I have no clue of π
systemchat is just this right
systemChat "Message"
Yes, but don't forget ; for end of line
where does systemchat show messages?
cause I didn't see any at all
nvm I was editing the wrong trigger 
It now looks like this, however the music is still not playing... On the plus side, the trigger and enemy script weren't actually working before, I just kinda assumed they were without testing it really, but now they are! so thank you very much! 
UndercoverZ enableSimulation false;
systemChat "Trigger deactivated";
Z setcaptive false;
systemchat "Enemy set";
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
};
systemchat "Music playing";
all the systemChat messages are shown
put in if
Move the "music playing" systemChat inside the then { };.
At the moment, if the if condition fails, the playMusic will be skipped but the systemChat will still be sent
Based on the systemChats that are being seen, I think the if condition is probably failing
yeah ok I low-key assumed that would be the case, but I just tried to make it as simple as possible for my pea brain
Hey! Quick one here that I'm struggling with. Is there a way to select a random number between 2 numbers that isn't weighted? I'm looking between -90 and 90, but adding 0 to mid makes most results come out around that value (obviously π )
UndercoverZ enableSimulation false;
systemChat "Trigger deactivated";
Z setcaptive false;
systemchat "Enemy set";
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
systemchat "Music playing";
};
This good?
yes
yeah the music playing systemchat is not being shown now
There's probably a better way, but selectRandom [random 90, random -90];
It doesn't have to be ridiculously optimised, it's just for a little thing. Thanks! π
(random 180) - 90
what's wrong with random [-90, 0, 90]?
That's weighted towards 0, and they want an even distribution
It's gaussian according to the description.
can't talk in too much depth now as am a team leader. check the trigger conditions to make sure that Z and Infil1 can actually be included in thisList - e.g. OPFOR Present trigger won't detect BLUFOR units
also Zeus modules don't move when the Zeus camera does so be sure you're checking the right thing
Could this not working have something to do with the activation and/or condition text? Those two are currently
Activation: Owner only
and Condition: this
I'm the OP asking weather a trigger can have multiple on Activations. Regarding the objects having multiple destination you said i could be done, could you please elaborate on that for me
You can easily check that with inArea command
systemChat format ["Z in thisList: %1, Infil1 in thisList: %2", Z in thisList, Infil1 in thisList];
systemChat format ["Z in inArea: %1, Infil1 inArea: %2", Z inArea thisTrigger, Infil1 inArea thisTrigger];
wait I'm confused what does this do?
i will systemChat conditions of Z in thisList, Infil1 in this and another way check is your object in area of trigger, is inArea.
Like Nikko said, if you have other side that actives, it wont show up in thisList. But inArea it will.
wait so I should change from thisList to inArea?
UndercoverZ enableSimulation false;
systemChat "Trigger deactivated";
Z setcaptive false;
systemchat "Enemy set";
systemChat format ["Z in thisList: %1, Infil1 in thisList: %2", Z in thisList, Infil1 in thisList];
systemChat format ["Z in inArea: %1, Infil1 inArea: %2", Z inArea thisTrigger, Infil1 inArea thisTrigger];
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
systemchat "Music playing";
};
if (Z inArea thisTrigger && Infil1 inArea thisTrigger) then {
playMusic "AmbientTrack01a_F_Tacops";
systemchat "Units inArea - Music playing";
};
wait isn't thisList and inArea doing the same thing here? wouldn't I only need one?
Yes. You will need only that one which work.
Just for example/ for the debug. You will see which one works.
And just delete parts that you do not need
aight thank you :)
So the trigger now looks like this (i decided to separate them and have one trigger for the music and one for the undercover script, just to make it a bit simpler)
//Activation = Anybody
//Condition
Z in thisList && Infil1 in thisList
//On Activation
systemchat "Trigger fired";
systemChat format ["Z in thisList: %1, Infil1 in thisList: %2", Z in thisList, Infil1 in thisList];
systemChat format ["Z in inArea: %1, Infil1 inArea: %2", Z inArea thisTrigger, Infil1 inArea thisTrigger];
if (Z in thisList && Infil1 in thisList) then {
playMusic "AmbientTrack01a_F_Tacops";
systemchat "Music playing";
};
if (Z inArea thisTrigger && Infil1 inArea thisTrigger) then {
playMusic "AmbientTrack01a_F_Tacops";
systemchat "Units inArea - Music playing";
};
inArea worked! thank you so much!
π₯³
ok so even thisList works now??? I removed the entire section of inArea just to see and it's still playing? what kinda wizardry did you do???
how would I go about making this a continuous evaluation? as in the rest of the script will execute without this until both players are in the area, and without the trigger being reactivated this will activate?
if (Z inArea thisTrigger && Infil1 inArea thisTrigger) then {
playMusic "AmbientTrack01a_F_Tacops";
systemchat "Units inArea - Music playing";
};
if it's even possible
is someone know how to get size of object in X and Y coordinates ?
what class should I use to filter anything that can't assign loadout ( objects, vehicles, bunnies, snakes, ... ) ?
for now I have
if ( not ( _unit isKindOf "CaManBase" ) ) exitWith {};
what class should I use to eliminate rabbits or any units, that I can't use loadout on ?
BIS_fnc_boundingBoxDimensions
it returns not correct dimensions. I need a size of marker like this one in 3den
Depending on the model, you might get more accurate information using https://community.bistudio.com/wiki/boundingBoxReal. BIS_fnc_boundingBoxDimensions is from before the more precise syntaxes were available.
ty. Have tried ClipGeometry as value for boundingBoxReal and it has return what i want
Does anyone see what's wrong here
{
_x setPos [4727.579,1853.876,0.067];
} forEach ([cargo_1, cargo_2,cargo_3, cargo_4, cargo_5, cargo_6] inAreaArray thisTrigger]);
I'm getting an error saying i'm missing a ")"
It's actually an extra ] after thisTrigger
sorry its still saying error
Aren't you missing the };?
So it should look like this instead?
{
_x setPos [4727.579,1853.876,0.067];
forEach ([cargo_1, cargo_2,cargo_3, cargo_4, cargo_5, cargo_6] inAreaArray thisTrigger]);
};
I'm a total amateur so I have no clue if it might help but that's the first thing I saw
That didn't work either now i'm missing a ;
{
_x setPosATL [4727.579,1853.876,0.067];
} forEach ([cargo_1, cargo_2,cargo_3, cargo_4, cargo_5, cargo_6] inAreaArray thisTrigger); // β extra "]" after thisTrigger
{
_x setVehiclePosition [4727.579, 1853.876, 0.067]; // might I add
} forEach ([cargo_1, cargo_2,cargo_3, cargo_4, cargo_5, cargo_6] inAreaArray thisTrigger);
No, the } was in the correct place, before forEach.
Shortened to show more clearly:
{
code
} forEach [];```
Lou described the problem accurately
* and so did I :U
@hallow mortar & @winter rose thank you, yes you were both correct there was an error on my end and i didn't noticed
as far as i can tell by looking at everything on the web this should work but the addCuratorEditableObjects gives an any type error.
what am i doing wrong here?
there are units in the group
_infantryGroup = createGroup [east, true];
{
_unitsAray = units _infantryGroup;
_x addCuratorEditableObjects [_unitsAray select _forEachIndex, false];
} forEach allCurators;
Which line throws the error?
23:18:56 Error in expression <{
_unitsAray = units _infantryGroup;
_x addCuratorEditableObjects [_unitsAray se>
23:18:56 Error position: <addCuratorEditableObjects [_unitsAray se>
23:18:56 Error Type Object, expected Array
23:18:56 File new_3.sqf..., line 29
Ah well I see. addCuratorEditableObjects does not take an object but an array, so no need to use select there, if your intention is to make the entire units of _infantryGroup editable
Your idea of the code is actually broken, though. Even if it does throw no error, it is going to add nothing to curators
i see that fixed it thanks
Anybody likes the idea of OBJECT = OBJECT || OBJECT?
private _unit_or_vehicle = if(isNull _from_unit) then {_from_vehicle} else {_from_unit};
```=>
```sqf
private _unit_or_vehicle = _from_unit || _from_vehicle;
More complex example:
private _unit_or_vehicle_or_player = _from_unit || _from_vehicle || player;
So if X is null, X || Y should return Y, otherwise X?
Not sure if there is a reason to limit this functionality for OBJECTs if we have one
Yeah, it could work with other null-able types
|| might be a bit confusing since people could expect it return boolean
Maybe ifNull is a better name to disassociate from booleans
Honestly I don't think an operator should be used in this idea
private _entity = _unit ifNull player;
Not a hard job for a SQF function, though
private _unit_or_vehicle_or_player = _from_unit ifNull _from_vehicle ifNull player;
notNull [X, Y, Z]``` or... dunno, whatever the name is
selectNotNull?
I like it being binary command though, trying to avoid creating arrays as much as possible
muh microseconds
findIf + select functionality is something good to have actually
Felt a need for that several times too
Otherwise you have to put the array and index into variables to then do select
I mean combine two commands into one. Instead of returning the index, return the value there instead
I think that is a better way to implement your idea
Had a need for opposite for selectMax/selectMin few times too
but not in performance critical part
Of course I'm not a coder nor Bohemian so yeah, just throw a ticket and pray
If SimpleVM could do that very fast, then why not
[_from_unit, _from_vehicle, player] selectFindIf {!isNull _x}
Wonder if it will be faster than say
_from_unit ifNull _from_vehicle ifNull player
Meant findMax/findMin to get the index
I actually just realized I really don't know what is Simple VM is, I guess
It supposed to optimise single command iterators to run without creating script context for each iteration
I'm still not sure if it works and how well it works, waiting for docs from dedmen to explain it exactly
selectFindIf won't return null if all are null though
gonna have to check for isNil later for default value
There an eventhandler to handle when a prop gets hit?
EPEContactStart?
Would bullets trigger that?
Did indeed work, thanks kj
how do you make guy sit on correct direction when sitting on char? I have this: ```sqf
[_off,"SIT"] call BIS_fnc_ambientAnim;
_off attachTo [_chair, [0, 0, 0]];
_off setdir (getdir _chair);
attachTo'd setDir is relative to the attached object here
that's bit over my head but thx
For a simple direction like facing the right way on a chair, you just need to know that 0 is now whichever way the chair model considers to be forward
So depending on whether the chair is oriented forwards, backwards, or sideways in its model space, you'll need either 0, 90, 180, or 270; objects aren't usually oriented at odd angles.
https://github.com/JonnyPtn/SFML-DOOM
It be possible to launch DOOM inside ArmA 3?
By using some dlls, I guess
Technically yes. But it's not easy
You can't show it in A3 itself. But you can show it as an overlay
Weren't some life mods rendering a browser into a texture so it displayed youtube videos or something?
Probably can be done the same way
Well you can render it to a texture but you can't display it directly
If they were rendering to a texture they probably used a temp file to load it into Arma
You can't really do that with a game
if you can change the engine rate for doom you can probably slow it down enough
bonus points if you put it onto one of the mfd for a blackhawk
selectFirst ?
I have done some benchmarks.
It'll be enabled in stable 2.18. No problems found so far in the current version.
And I don't think docs would provide much insight. I can document what is needed to make it work, but not really what it does or how well it does it
Not yet. I wanted to add that option.
Technically we are not limited to letting only the game itself render to a UiOnTexture. Extensions could render onto it too if they set up DirectX context stuff. They just currently cannot get a reference to the texture.
But I don't have time to do that so that might not become a thing
Great command name idea
I still like binary command that returns null if both operands are null
selectFirst would return nil
private _unit_or_vehicle = if(isNull _from_unit) then {_from_vehicle} else {_from_unit};
```vs
```sqf
private _unit_or_vehicle = _from_unit ifNull _from_vehicle;
```vs
```sqf
private _unit_or_vehicle = [_from_unit, _from_vehicle] selectFirst {!isNull _x};
if(isNil"_unit_or_vehicle") then {_unit_or_vehicle = objNull};
_arr selectFirst {} param [0, objNull]
ifNull could accept any types, check if both operands are of same type and of null-able types
Hmm, could be faster than isNil check in my example π€
Ofc it is
Stupid name
or, || could be confusing when reading the code and thinking if these are bools or not
|ifNull|
OBJECT Β―\_(γ)_/Β― OBJECT
private _unit_or_vehicle = _from_unit Β―\_(γ)_/Β― _from_vehicle;
Well it's still a good method name for hashmap objs
But in this case you have nil
So it won't work anyway
The idea was "if null then second null"
left operand or if null, then right operand
if both are null then result will be null
hello
i currently have a script here thats tied to a trigger
i was told that it will not run on a dedicated server can anyone help he convert it ?
_screen = "Monitor_1" createVehicle (player modelToWorld [0, 10, 0]);
_screen setObjectTextureGlobal [0, _video];
[_video, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false]; ```
fyi my coding skills are non existent
trigger's activation field?
// Only do stuff on server to ensure stuff only runs once
if(isServer) then {
// Abandon script if monitor already exists
if(alive(thisTrigger getVariable ["screen", objNull])) exitWith {};
// Get players from list of entities that triggered the trigger
private _players = thisList select {isPlayer _x};
if(count _players > 0) then {
// If there are any players in the trigger, use first one to spawn the monitor near them
private _player = _players select 0;
// Spawn monitor and save it into trigger so it knows there is already one
private _screen = createVehicle ["Monitor_1", _player modelToWorld [0,10,0], [], 0, ""];
thisTrigger setVariable ["screen", _screen];
// Setup the video
private _video = "imgs\Uav_Intel.ogv";
_screen setObjectTextureGlobal [0, _video];
[_video, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false];
};
};
Wrote this, didn't test
might work
whoops sorry this is whats in the triggers activaion field
Monitor_1 setObjectTextureGlobal [0,_video];;
_screen setObjectTexture [0, _video];
[_video, [10, 10]] call BIS_fnc_playVideo;```
hm ok
umm what if the monitor is already spawned in only this is needed right ?
_screen setObjectTextureGlobal [0, _video];
[_video, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false];
};
}; ```
ok so i modified your script a bit so it playes on a monitor that is already spawned in
private _video = "imgs\Uav_Intel.ogv";
_screen = Monitor_1 setObjectTextureGlobal [0,_video];
_screen setObjectTextureGlobal [0, _video];
[_video, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false];
}; ```
it plays fine
[_arr selectFirst {}] param [0, objNull]
iam guessing this will work in a dedicated server now ?
and 1 last thing is the addaction commands on the laptop that is tied to the trigger
this addACtion ["Stop Video", "Intel_Trigger = false"];
[missionNamespace, "BIS_fnc_playVideo_stopped", {
Intel_Trigger = false;
}] call BIS_fnc_addScriptedEventHandler; ```
how do i convert this so it runs on a dedicated server
i keep trying and seem to get nowhere
It doesn't look like it should be running on the server.
can i make a "call fn_functionnameexample", happen only if a player is certain side?
if(_playerSide == west) then { call fn_functionnameexample; };
if (_playerSide == west) then fn_functionnameexample;
:pog:
@grizzled cliff is that a private repo?
weird way of calling function π can u pass args to that?
yah
:(
It's exactly the same as what you wrote
i.e. it will see the parent scope _this
I would also love a peek
peek
i know just saying. and u cant really "pass" arguments to it
If you set it to an org I think you can fiddle with the groups enough to make it non-write
Don't you have to approve push requests though?
What's a reliable way to run a function on each player, including those that respawn and that join-in-progress? I'm trying to let people share their money via ACE actions, so I've written a function to add those actions to a given player. Here are the ideas I've thought of:
- Looping through players in initPlayerLocal.sqf
JIP players won't be available so that won't do remoteExecthe function globally in initPlayerLocal.sqf
Given that the player object changes during respawn, and therefore their netId does too, I assume this would eventually stop working for JIP clientsremoteExecthe function globally in onPlayerRespawn.sqf (whererespawnOnStart = 0)
This is what I'm going with, but I'm a bit concerned about causing excessive network traffic. This would be called multiple times for the same player so I'm setting a local variable on each player in the function to make sure the actions aren't added more than once.
Not with private repos, you can only add people as contributors which have write access
remoteExecCall with jip flag from server, in that function also add Respawn EH
yah
Or don't remoteExec at all and just run it from both onPlayerRespawn and initPlayerLocal.
ALTHOUGH you could use the new protected branch thing
I'm not sure how that works fully though
just wait until its public, which should be soon :P only want to add people i almost entirely trust, verox happens to just barely be one of them :D
Hmm, I might have misworded my initial question as I'm not sure how either approach would handle my situation correctly. Because adding actions is local, I need my function to run locally, on each client, against every other player, and preferably once.
so with a single remoteExecCall + Respawn EH, JIP players would still need a way to register their player actions, and for calling directly in onPlayerRespawn/initPlayerLocal, I would need to broadcast that to JIP players as well
well, whatever you want to do, I have no interest in fiddling with it. I have enough experience with git to not screw it up accidentally either.
Then you'll need to JIP remoteExec the action in both onPlayerRespawn and initPlayerLocal.
is it possible to display allPlayers even if they are not grouped using this [] call BIS_fnc_groupIndicator;
With respawnOnStart = 0 I can skip initPlayerLocal right? I guess what I'm doing now is the most sane option. Perhaps for unrelated features that need this process, I'll consolidate them to one function to reduce the burden on JIP queue
I wouldn't worry about having one JIP queue entry per player. Just make sure that you're not passing a load of duplicated data in the call.
Hence remoteExecing an addAction directly is bad, remoteExecing a simple function that then calls addAction is good. That function can also do an existence check on the target unit and clear the JIP entry if it's gone.
umm how does one add remoteExec to this :
this addAction["Pick up Classified_Documents", "deleteVehicle Classified_Documents;"]
You wouldn't, because it's in an editor init box and so it runs everywhere.
or rather, you shouldn't
you can
but be prepared for 20 trillion billion million actions
i didn't quite get you. I have it in the init box of the object "Classified_Documents"
You dont have to and shudnt remote execute code in init of a object that you placed in eden editor because it would duplicated per player and you dont want that. And why you dont need to do that is becouse everyplayer will have that code localy on their machine.
You can watch this video it goes a bit in detail on locality of code:
https://www.youtube.com/watch?time_continue=718&v=-hz0SoS95VY&embeds_euri=https%3A%2F%2Fdiscord.com%2F&feature=emb_logo&ab_channel=Vestarr
Join the discord!
https://discord.gg/wCUqFxs
Consider supporting me as a modder/creator
Paypal: thevestarr@gmail.com
This video is just an introduction to multiplayer scripting in ARMA 3.
It's a huge topic and it's barely scratching the surface.
Resources:
https://community.bistudio.com/wiki/Multiplayer_Scripting
https://community.bistudio.co...
That function can also do an existence check on the target unit and clear the JIP entry if it's gone.
An existence check like checking if the player unit is dead? I used the player object as the JIP ID and enabled the built-in garbage collection so I imagine the entry would clean itself up at some point
It would, but you can only do that once.
You can do it in a mission as long as you know you're not going to use that object as a JIP ID for any other JIP.
ah i didnt think of that
In a mod you have to make custom JIP IDs, otherwise you'll break stuff.
And then you don't get the automatic cleanup.
kind of inconvenient, but I guess it's not too hard to future-proof: sqf // onPlayerRespawn.sqf [_newUnit] remoteExec [ "SHZ_fnc_initMoneyShareActions", SHZ_globalPlayerTarget, (_newUnit call BIS_fnc_netId) + ":SHZ_moneyShare" ]; sqf // onPlayerKilled.sqf remoteExec ["", (_oldUnit call BIS_fnc_netId) + ":SHZ_moneyShare"]; (also added a HandleDisconnect handler on server)
I don't understand why this trigger doesn't execute the reveal command at all, as I don't see the systemChat nor the AI show the desired behaviour
systemChat "Trigger activated";
{
//EnemyS is variable name of enemy group I want to see the players Spot, Snip and Odin (also variable names)
_EnemyS reveal [_Spot, 4];
_EnemyS reveal [_Snip, 4];
_EnemyS reveal [_Odin, 4];
systemChat "Players spotted by AI";
};
- Putting code inside a Code data type (denoted by
{ }) is meant for "saving it for later" - not executing it right now, just putting it in a container that you can then do stuff with, like passing it to a command for the command to use. You don't need to do that if you just want to have code that's executed normally. - All the variables you're trying to reference are local scope variables (prefixed with
_). If they aren't defined in the trigger code, then they won't exist in this scope. Editor object variable names are global scope variables (no_); local scope variables defined in other scripts need special handling to pass them to other scopes.
See I thought { } meant it would be executed at once but together when an if condition isn't given.
Code is already executed as fast as possible.
thank you once again! I'll check if it runs now
thank you that worked! now I have an issue with one of the units in the group (only two AI) not firing at the players but I doubt that has anything to do with the script π
hey im looking for a command for my debug console to end load screen. Ive got players joining the server and getting load screen
endLoadingScreen?
This is so weird. A while loop works if its condition is true when initially executed but won't work if it's started and then the condition becomes true later....
private _radWarn = "<t color='#ff0000' size='3' font='EtelkaMonospaceProBold'>RADIATION WARNING</t><br/>
<t color='#ff0000' size='1.5' font='EtelkaMonospaceProBold'>LEAVE THE AFFECTED AREA IMMEDIATELY</t><br/>";
private _rwning = "f";
while {player getVariable ["HUD_RadWarning",false]; } do {
_rwning = "radWarn" cutText [_radWarn, "PLAIN NOFADE", -1, true, true];
UIsleep 0.7;
_rwning = "radWarn" cutText ["", "PLAIN NOFADE", -1, true, true];
UIsleep 0.7;
};```
This? Remove the quote too```sqf
while (player getVariable ["HUD_RadWarning", false]) do {};
Where {} is code block
A while will not run anything if the while does see the condition is false in the first iteration
It won't keep checking?
No
Is there any way to get a while that WILL keep checking?
No, while condition requires {} code block
What is the goal anyways?
while {true} do { if (player getVariable ["HUD_RadWarning", false]) then {} }
This ugly way?
display hud radiation warning when inside of a given trigger area
Note that, while requires to re-evaluate the boolean again and again so just a boolean will not work for it, thus a code is required
So if you're in a trigger, will show a text? Then just execute it in a trigger's activation?
It's a flashing cutText
and as is if you step into the trigger it flips the Variable
This way?
With waitUntil I guess
Might as well spawn a thread alongside flipping that flag
Depends on how you have stuff setup though
Anyway to detect if a projectile is a rocket/missile?
getAllMissiles = ("toLowerANSI getText (_x >> 'simulation') == 'shotMissile'"configClasses (configfile >> "CfgAmmo")) apply {configName _x};
You can check it like this.
Based
== is already case insensitive
You can just use configOf to get which is the projectile class
Using fired and hitPart for this so i do have the projectile class, just a matter of checking if it was a missile that was the problem, Backup plan was to just add a hitPart handler to the missile launched with IncomingMissile
in ARRAY search is slow though
Hashmaps are perfect for this
I am reading the handleDamage eventhandlers description and I eventually get to this linked page
https://forums.bohemia.net/forums/topic/205515-handledamage-event-handler-explained/
I dont quite understand the part that says
The "" part is the reason why consecutive leg hits are fatal.
casue how would just shooting the leg cause the unit to die if?
"legs": Unit doesn't die with damage to this part
The majority of the information in this thread has been extracted from @celerys original post which can be viewed here: This thread is an updated version of the above post, addressing all outdated information. If anyone notices any incorrect information in this new one or has anything that should...
He means that even if you shoot already destroyed (damage >= 1) legs, you will still get overall damage increasing until you die.
This is true for any vehicle really, if you shoot already destroyed hit point enough, some damage is still applied to total damage which will eventually kill the vehicle
unless its configured to never get overall damage under normal circumstances (lots of RHS vehicles)
if (_hitSelection isEqualTo "") then {damage _unit} else {_unit getHit _hitSelection};ο»Ώ
```This example in the post is wrong way of doing it
getHitIndex been a thing since 2015
Next example is not ideal either, operating selection names is unreliable way of doing it
Unless you know selection names exactly
Back in the day some vanilla Arma 3 uniforms had slighting different selection names for same hit point
This was fixed but you have to account for mods where they might not follow same naming
hit part index and hit point name are most reliable ways of dealing with damage
Many hit point names are hardcoded in the engine so you can always expect them to be called exactly that
I probably should do a write up on all this as I've been super deep into it all recently
But I probably wont
So for example sake, its like 5% of the damage that is done on the leg is applied to the global characters leg. How can I tell how much of that leg damage is applied to the overall health of a unit? I am a little confused on which event handler to use for that
now is that done via scripting, or with config with passthrough values?
armor, passthrough, etc.
I think this also applies to characters
I'm not sure there is an exact formula somewhere, but the idea is that if you hit some part, some of the damage is added to overall damage
Even if you keep shooting completely destroyed part, overall damage will keep increasing
Just realized what a dummy I am and simply using find was almost twice faster:
s = "#crash"; a = [0,1]; [diag_codePerformance [{s select a == "#"}], diag_codePerformance [{s select [0,1] == "#"}], diag_codePerformance [{s find "#" == 0}]]
```=> `[[0.000520693,100000],[0.000600811,100000],[0.000385165,100000]]`
```sqf
s = "ATMine_Range_Ammo"; a = [0,1]; [diag_codePerformance [{s select a == "#"}], diag_codePerformance [{s select [0,1] == "#"}], diag_codePerformance [{s find "#" == 0}]]
```=> `[[0.00051952,100000],[0.000595196,100000],[0.000385103,100000]]`
*1/3 times faster than inline array select
armorStructural is a big one for reducing global damage
Do the TurnIn/TurnOut event handlers supersede their actions or do they fire before?
are the proxies on vestContainer supposed to change with different vests? they seem to be the same for all regardless of if they have a holster or not etc 
after
Would then canHideGunner = -1 enable full script handling of those actions?
Try it?
@grizzled cliff sweeet
Do the texts in AddAction support non-english characters?
addAction is not a concern but how a font in A3 works in generally. Usually Latin Alphabet + Kyrilic + some multiple accent alphabets + CJKs
How would I make so that whenever a specific vehicle is destroyed the mission obj turns to "completed" ?
Like end mission -> complete?
no more like obj -> complete
Okay, so you want to create a task , and when object x is destroyed it will be completed?
yes
basically story short:
My guys are progressing and recently captured an airbase, and got intel on possibly some PMC group arriving, they want to take down the heli, but there's 3 and they need to take down the cargo one. Problem, the three helis are similar.
So they can either take the right one or destroy the right one, for it to be complete.
endMission
... Not a mission end.
https://youtu.be/1cqnrHnzHfQ?si=MVeMzUFLcgw52d3m
Pretty simple video on how to set up task modules.
And you need to define the trigger condition to check if the heli x is not alive or player is the driver of the vehicle.
Appreciate it
also can you like modify a script mid-game like for example "pickup.sqf" and execute it from the extended debug console ?
no
appreciate it
not unless youre creating the function by preprocessfilenumbers or whatever the command is
seems to have no effect for Wheeled_APC_F but completely disables the option when set in Truck_F. Didn't affect the brief fade to black before movement to action but perhaps that is a lod configuration thing.
is it possible to display allPlayers/allUnits even if they are not grouped to the player using this [] call BIS_fnc_groupIndicator;?
i want to display all units but it only displays the units grouped to the player
It's called groupIndicator, so I'm guessing that's how it's supposed to be
yes i tried to change the function but could not get it work
from what I see all you have to do is change units player to allUnits in the function
weird i tried yesterday exactly this and it didn't work, trying again
does it work without modification?
_this = _this param [1,[]];
switch _mode do {
case "Init": {
disableserialization;
_display = _this select 0;
_map = _display displayctrl 116601;
you're not providing a display to this
hmm sry i dident understand what you mean π€
Read the part I showed
It expects you to pass a display.
idk which display it is tho
But it should have a map control with idc 116601
me neither xD, nevermind i guess it's not the effort worth
the unit icons, it displays my icon but not the other units icon
I mean where does it show them?
how do you call the function?
that doesn't mean it'll use your function. see:
when you pass an empty array it just exits, and uses the onLoad event of RscGroupIndicator to call the function (which calls the BIS function)
so if you want to get it to work you should also create your own RscTitle
ah okay, i understand, sounds complicated but thank you for explaining it to me
mission
import RscGroupIndicator from RscTitles;
class RscTitles
{
class ParadoxGroupIndicator : RscGroupIndicator
{
onLoad = "['Init',_this] call (uinamespace getvariable 'PARADOX_fnc_indicator')";
onUnload = "['Exit',_this] call (uinamespace getvariable 'PARADOX_fnc_indicator')";
};
};
use this in description.ext
then change the first line of the function:
if (count _this == 0) exitwith {([] call bis_fnc_rscLayer) cutrsc ["ParadoxGroupIndicator","plain",0,false];};
and line 32:
_map ctrladdeventhandler ["draw","with uinamespace do {['Draw',_this] call PARADOX_fnc_indicator;};"];
this is very kind of you, thank you very much for the help 
Hi, i have a question, i tried this addEventHandler ["HandleDamage", {0}]; inside a singleplayer mission, the event get called but the unit still die when i shoot it, is that normal ? I thought "0" will prevent it to be damaged but for me it's not working
do you use mods?
great overlay, did you made the mask graphic?
yeah i'm using mods, i didn't even think about that, you think that can come from a mod ?
I will try without mods to see if that was the problem but probably
does the unit die / take damage any time you shoot it?
if so yes, it's because of a mod
yeah, i tried "one shot" and multiple shots and yeah, the damage are not stopped
execution location will also affect your unit, as "this" is context sensitive afterall
I assumed by:
the event get called
you mean you did try a systemChat or something in the EH code?
i tried a "hint" yeah
because i wanted to see what was the _damage argument value
btw i tried without some mods and yeah now it's working so thank you
Hello. Does anyone have a script (or function) that allows you to enable crosshair when it is disabled in the difficulty settings?
it's not possible
And if turn it off for everyone who is not in the array?
Hey. Anyone know how to enable/disable ai simulation for a whole group through script?
Thank youu
Is there any way to get OR set a helicopter gunner's turret direction
lockCameraTo
Hmm, no way to set the rotation like on the pilot cam?
Pilot cam can be set in a different way
https://community.bistudio.com/wiki/setPilotCameraDirection
Such commands can help
I said "like on the pilot cam" i.e. "as if this were a pilot cam, which has the command I want"
apologies for any musunderstanding
I'm wishing there was a way to set a turret's position to 0,0
(as in, perfectly straight out in front)
Attach an invisible object in front of the vehicle and lockCameraTo it? It's not a great solution but we don't have a great deal of direct control over turrets.
https://community.bistudio.com/wiki/setTurretLimits could also potentially help, but because of how its arc definitions work, it may not be possible to get what you want.
I'm messing around with subtitles and wanted to test BIS_fnc_showSubtitle, so I put ```sqf
["CROSSROAD", "Mission is a go, I repeat, mission is a go, Crossroad, out."] spawn BIS_fnc_showSubtitle;
in a blufor present trigger. It's right from the wiki page of the function but it didn't work, and I didn't get any error messages. I'm assuming I'm doing something really stupid but I could use some help π
Putting in the debug console gives me this
private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'BIS_fnc_showSubtitle'} else {_```
Which I don't know what to make of
Looks like a stringified script thread, its normal
This code works btw, looks like your trigger doesn't trigger
add something like diag_log and see if it prints into RPT
Is there a way to execute server commands such as changing a mission with scripts?
yes but you need to elaborate on what you want specifically
I just want to let players change the mission from like an add action
you can use https://community.bistudio.com/wiki/Multiplayer_Server_Commands if you are admin or whitelisted in server .ext or config iirc or use https://community.bistudio.com/wiki/BIS_fnc_endMission to end a mission
change the gamemode?
No like mission file
i believe its possible but do you own or have tcadmin etc access to the server and have .ext/.cfg setup?
"password" serverCommand "#mission file.Altis Custom"
your script is gonna need your server.cfg password though
Read alt syntax: https://community.bistudio.com/wiki/serverCommand
i thought servercommand was unreliable if coming from an object's init even if preplaced?
why do you want serverCommand right in the object's init? π€
how he is describing it coming from an addaction
Anyway, maybe object's init is too early for whatever command you're trying to execute
As long as you supply right password and command, source doesn't matter
addAction is client-side so you'll have to query the server to do it
exposing password to clients is a no-no
so you'll need to have it hidden somehow
Through server-side only addon
this reminds me of people in pub zeus using hold action bi functions and one of the options instead of bothering to remotexec addactions
I am trying to calculate velocity for flare going down to ground based on time and distance. Problem is that flare getting way too fast to the ground.
private _time = 30; // 30 seconds in air
private _height = 100;
private _pos = [0, 0, _height];
private _distance = _height - 50; // flare should fly from from 100m to 50m and then delete
private _velocity = _distance / _time; // CALCULATION
private _flare = createVehicle ["F_20mm_Red_Infinite", _pos, [], 0, "NONE"];
_flare setPosATL _pos;
_flare setVelocity [0, 0, -_velocity]; // SET VELOCITY
sleep _time;
deleteVehicle _flare;
it sorta looks like you're trying to set its velocity and position not calculate it
I am calculating velocity so I can set it for time and distance flare needed to be in air
you'll probably need to set velocity each frame
in order to set it you need to calculate it
as gravity\whatever rules there are for flares accelerate it
which probably still won't be precise
because engine probably adds gravity and then moves the entity on the same frame, not sure
should I just setPosATL each frame ( or sleep 0.05 ) ?
no need for velocity in that case
sleep wont produce smooth movement
You can try sleep with setVelocity
Won't be precise but at least smooth as engine handles the position
Lazy solution of running a scheduled thread also works, just tested it:
private _time = 30;
private _height = 100;
private _pos = player modelToWorld [0, 0, _height];
private _distance = _height - 50;
private _velocity = [0, 0, -_distance / _time];
private _flare = createVehicle ["F_20mm_Red_Infinite", _pos, [], 0, "CAN_COLLIDE"];
_flare setPosATL _pos;
_flare setVelocity _velocity;
[_flare, _velocity, diag_tickTime + _time] spawn {
params ["_flare", "_velocity", "_time"];
waitUntil {
_flare setVelocity _velocity;
systemChat str (getPosATL _flare select 2);
diag_tickTime > _time;
};
deleteVehicle _flare;
};
ends close to target height
will be less accurate with clogged scheduler
turn that into each frame and it will be good enough
the issue here is overriding engine behavior
trying to do it in vanilla if possible
Given that the projectile is affected by gravity, could setMass change its rate of descent, or is that purely controlled by other properties?
with that, wondering if I should just spawn flare for each client, and not on server
good point about locality actually, flare will appear jumping up and down if you correct its position only on the server
To expand on this lazy solution just broadcast same thread arguments
except with serverTIme instead of diag_tickTime
no need to continously update it
[[_flare, _velocity, serverTime + _time], {
params ["_flare", "_velocity", "_time"];
waitUntil {
_flare setVelocity _velocity;
systemChat str (getPosATL _flare select 2);
serverTime > _time;
};
deleteVehicle _flare;
}] remoteExecCall ["spawn", 0, _flare];
I am familiar with CBA, but that will create additional mod dependencies to mission, where I want to avoid that
why re-invent the wheel ?
CBA is definitely an overkill for something this basic
It will be smooth with setVelocity
Just not precise
CT_OBJECT
but it is very limited
You could probably RTT it on a local-only user texture object, attached to the player's face. I wouldn't describe that as a great idea though
Oh you meant into world space
then RTT and ui2texture
You can render something onto CT_OBJECT so that it separate from world space
but I remember it being very limited, there are lighting issues, etc.
should I replace serverTime with this ? for SP
private _serverTime = [time, serverTime] select isDedicated;
or better yet
private _serverTime = [time, serverTime] select isMultiplayer;
Yeah, use time for SP
how can I format numbers in logs to be readable ? example: 1e+010 to 10000000000. using diag_log and format for some big vales
BIS_fnc_numberText comes in mind, but does not work with floating point numbers.
toFixed
check the wiki
do I need to remoteExecCall this on all ( 0 ), should it be just a server ( 2 ) ? setVelocity has GE
if global, it needs to be executed once - otherwise suffer a call multiplied by the number of machines
[[_flare, _velocity, _time], {
params ["_flare", "_velocity", "_time"];
_time = time + _time; // define it server-side for better accuracy
waitUntil {
sleep 0.01;
_flare setVelocity _velocity;
// systemChat str (getPosATL _flare select 2);
time > _time;
};
deleteVehicle _flare;
}] remoteExecCall ["spawn", 2, _flare];
0 will also include that server that spawned the flare because it also needs to set the velocity
time has to be defined outside of spawn (in arguments) by whoever creates the flare and broadcasts the code
The idea is to have each client do their own setVelocity for maximal smoothness
I guess that sleep won't hurt
that's what I made, the client provides the lifetime and the server uses its own time π
ah, if each client does that then⦠it would require some if (isServer) here and there
ooor a Function π
deleteVehicle should be wrappen in if(local _flare) too btw
or this script remoteExec'ing setVelocityβ¦
I have an array like this:
[vehicle1 [unit1, unit2], vehicle2 [unit1, unit2] ... vehicle14 [unit1, unit2]]
What I am trying to do is have 2 AI units (unit1, and unit2) to get inside their corresponding vehicle (vehicle 1, vehicle 2, vehicle 3...) using a for condition. I have no idea if this is correct or how to setup the for loop for this action.
I've added them on the array like this:```sqf
// Vehicle Array
vehicle_Land = [];
// Have empty vehicles be pushed into this stack
vehicle_Land pushBack this;
// Have AI assigned to these vehicles
(vehicle_Land select 1) pushBack this;
// repeate the steps for other vehicles and units assigned
Broadcasting the script is a one time thing though, compared to regular REs
hence the italics, it wouldn't be nice π
where do you run this code?
init field?
what do you mean by "for condition"?
The vehicle_Land = [] array is put in the mission init field.
The vehicle_Land pushBack this are done in the respective vehicle's init field.
The (vehicle_Land select 1) pushBack this; are done in the respective unit's init field.
The idea is have 20 AI located in a building run up to their designated vehicles and mount up to go to a waypoint.
Once a variable (callfor_Reinforcement) is returned true, these AI units will mount up and go to that waypoint.
I thought of using the for condition to recursively make individual AIs of each assigned vehicle to get inside them.
π€
for "_i" from 0 to (count _array) step 2 do
{
private _vehicle = _array select _i;
private _soldiers = _array select (_i + 1);
};
```π¬
Can you get sync links that you setup in editor through scripts?
I looked at the addVehicle and orderGetIn commands, but couldn't find an example in the wiki as to how they actually work in this scenario.
but if they are groups, I would recommend using groups
How do you even want to define which units belong to which vehicle in the editor?
I place down units and empty vehicles manually.
I create an array for the empty vehicles vehicle_Land and pushBack the empty vehicles into that array.
I then select the 2 AI for each vehicle and add in their init fields (vehicle_Land select 1) pushBack so it becomes a nested array.
the issue with init fields is unpredictable order
If there is a better way, I'm all ears.
Objective: Have AI mount vehicle and go to a position
Objects at hand: 20 AI and 10 Empty Vehicles
waypoints?
are they all in same group or you group 2 units together?
Each 2 Units are of 1 group. There are 10 AI groups.
I tried to do waypoints from script perspective but couldn't figure out how (the wiki only explains the syntax).
I thought you could like CTRL+drag a vehicle to be synced with a group or something but apparently its not a thing 
you could just use waypoints, no scripting?
anyway both are valid ways to get to what you want
My scripting brain breaks when I try to think of doing something in the editor 
No way to easily point one thing at another, no way to ensure execution order
When I do that, the getIn works fine, but having the AI move to a waypoint after they get in without disembarking from the vehicle is where next trouble is.
Here is how I think it can be done the easiest way:
- Name vehicles something (like
reinforcement_vehicle_1,reinforcement_vehicle_2, ...) - Name a single unit in each group something (like
reinforcement_group_1,reinforcement_group_2, etc.) - In
init.sqfhave the following:
reinforcementSetup1 = [
[reinforcement_vehicle_1, reinforcement_group_1]
,[reinforcement_vehicle_2, reinforcement_group_2]
,...
];
startReinforcements = {
params ["_setup", "_move_to"];
{
_x params ["_vehicle", "_unit"];
private _group = group _unit;
_group addVehicle _vehicle;
_group move _move_to;
} forEach _setup;
};
and then when you'll want to alert your group execute:
[reinforcementSetup1, getPos player] call startReinforcements;
getPosATL*
ASLtoAGL getPosASL player π€
Thanks I'll try it out and wok on this.
Hello, help a beginner)
my code...
_vehicleObject = _type createVehicle (_pos);
while {player getVariable ["myVariable", false]} do {
my code...
sleep 1;
};
deleteVehicle _vehicleObject;```
everything works as it should here
I need to add a check _type
something like that
```if !(_type isEqualTo "") then
{
_vehicleObject = _type createVehicle (_pos);
};```
but as soon as I do this, the car is not deleted, I understand that I need to display the car name, but I donβt understand how to do it
you need to declare the _vehicleObject in the parent scope, otherwise it disappears after the if scope
private _vehicleObject = objNull;
if (_type isNotEqualTo "") then
{
_vehicleObject = _type createVehicle _pos;
};
// ...
deleteVehicle _vehicleObject;
```see https://community.bistudio.com/wiki/Variables#Local_Variables_Scope
wow thanks, I didn't think of that and was assigning it inside the ifπ
I have the following addAction to mark few hostiles as traitors and start in-fighting within the OPFOR units. This works when I already fill the turnedunits stack with AI but I want to have this run dynamically within the radius defined and it should count vehicles as 1 unit instead of individual units inside it. Any idea how?sqf Satscreen1 addAction[ "Mark Hostiles as Traitors", { commsintercept = false; publicVariable "commsintercept"; params ["_target", "_caller", "_id", "_args"]; turnedunits call BIS_fnc_arrayShuffle; publicVariable "turnedunits"; private _halfcap = floor (count turnedunits) / 10; for "_i" from 0 to _halfcap do { (turnedunits select _i) join grpNull; uiSleep 2; (turnedunits select _i) addRating -8000; }; }, nil, 1.5, true, true, "", "commsintercept", 5, false, "", "" ];
does anybody know the scripts to put up images on billboards in the eden editor? I'm kinda stuck of what to do
this setObjectTexture [0, "\a3\missions_f_aow\data\img\artwork\landscape\showcase_aow_picture_108_co.paa"];```
+"
this setObjectTexture [+"0, \a3\missions_f_aow\data\img\artwork\landscape\showcase_aow_picture_108_co.paa"];
you monster
is that right?
this setObjectTexture [0, "\a3\missions_f_aow\data\img\artwork\landscape\showcase_aow_picture_108_co.paa"];
this setObjectTexture [0, "\a3\missions_f_aow\data\img\artwork\landscape\showcase_aow_picture_108_co.paa"];
you threw me off with this
oh yea forgot the quotes 
Figured a possible solution - sqf Satscreen1 addAction[ "Mark Hostiles as Traitors", { commsintercept = false; publicVariable "commsintercept"; params ["_target", "_caller", "_id", "_args"]; { _unit = _x; _grp = group _x; if ([10543.655, 4104.327, 0] distance _x < 1504) then { if (side _x == east) then { turnedunits pushBack _x; }; }; } forEach allUnits; turnedunits call BIS_fnc_arrayShuffle; publicVariable "turnedunits"; private _halfcap = floor (count turnedunits) / 10; for "_i" from 0 to _halfcap do { _unit = (turnedunits select _i); _grp = group (turnedunits select _i); if (_unit == vehicle _unit) then { { _x addRating -8000; } forEach units _grp; } else { _unit addRating -8000; } uiSleep 2; }; }, nil, 1.5, true, true, "", "commsintercept", 5, false, "", "" ];
anyone knows of a way to check if a player is in water and swimming?
Sorry Iβm a pretty new to scripting, where do I put that?
Hello guys
On my modded server
Is it normal that getUnitLoadout command returns something different when executed server-side xor client-side?
For instance, items in my backpack (_loadout#5) got duplicated on server perspective whereas everything works fine when executed locally
Client (_unit = player):
{
"B_Carryall_blk",
{
{
"ACE_rope6",
1
}
}
}
Server (_unit = player call BIS_fnc_objectFromNetId):
{
"B_Carryall_blk",
{
{
"ACE_rope6",
2
}
}
}
somewhere in a mod there is a copytoclipboard str diag_activeSqfScripts on something like a oneach frame... its the worst torture ive seen to an Editor
how are you calling it? getunitloadout _unit ?
yes, and I got _unit by using BIS_fnc_objectFromNetId server-side
so I am sure this is the same exact object I am dealing with
alright I will check, thanks for the advice
it can be a locality issue, setitem and other stuff are local, so for some reason you ccan have a magazine, that the other ppl or server dont "have"
i didnt say it for your code lol, it just happend to me π
yeah, I checked the doc and no locality hint was provided so I wondered if this was a bug
I have to check it anyway, this is probably a mod conflict
well... funfact if you use developer tools, the stuff you have on the vanilla console still executes π
I have 2 objects with known dimensions. I want to have _object2 attach to _object1 and rotate _object1 to right ( do a full circle ). How to attachTo _object2 to _object1 so it follows _object1 axis ?
private _dir = getDir _object1;
_object2 attachTo [_object1, [0, 0, 0]];
_object2 setDir _angle;
private _angle = 0;
while { alive _object1 } do
{
_dir = _dir + 1; // not worry about full rotation yet
_object2 setDir _dir;
sleep 1;
};
Hello, how can I make a specific AI take damage and become unconscious but not die with ACE Medical?
so it follows _object1 axis ?
attached objects already do follow the "axis" of the object they're attached to
but I guess you mean something else
_object2 should rotate (to right) attached to object1 facing out
like cone, but center of object2 is not on base of the cone, but in middle, and when setting dir to objec2, it is just rotating, but not facing out
can you show an in game screenshot? I don't think I follow
you mean you want to rotate the up vector?
ah nvm I get what you mean now
I don't recommend attaching the object for this
because you have to detach and reattach (iirc setting position doesn't work on attached objects)
Hey- does anyone know how the 'position' config parameter for ACE_Actions in CfgVehicles works? I'm reading the ACE framework article but the example it gives is pretty limited https://ace3.acemod.org/wiki/framework/interactionmenu-framework#36-advanced-example
with attaching it becomes like this (it has to be reattached):
private _angle = 0;
private _offset = 25;
while { alive _object1 } do
{
_dir = _dir + 1; // not worry about full rotation yet
_object2 attachTo [_object1, [_offset * sin _dir, _offset * cos _dir, 0]];
_object2 setDir _dir;
sleep 1;
};
It printed into the rpt file, so Idk why it's not popping up
yeah the code I posted should fix it
but it'll probably look bad (due to detaching and reattaching)
probably offset is off
Any help with ACE Actions config? My guys are depending on me to get a fix out for some of our vehicles π
try with:
private _dir = 0;
private _offset = 25;
while { alive _object1 } do
{
_dir = _dir + 1; // not worry about full rotation yet
_object2 attachTo [_object1, [_offset * sin _dir, _offset * cos _dir, 0]];
_object2 setDir (_dir - 90);
sleep 1;
};
idk but probably:
position[] = {x,y,z};
actually it says string
"External Base Actions Only, Code to return a position in model cords (priority over selection)"
so position = "[x,y,z]"
Maybe? But idk if it has to be calculated based on eyePos location
The usual entry for most vics is this:
position = "[_target, ace_interact_menu_cameraPosASL] call ace_interaction_fnc_getVehiclePosComplex";```
I went digging in ACE and found this: https://github.com/acemod/ACE3/blob/1649422cbd12509ac14a1b8c10bb76218cdd21cc/addons/interaction/functions/fnc_getVehiclePosComplex.sqf
well what I wrote gives a fixed position
if you want a dynamic position you need a function (or just type the whole code in there...)
Yeah- I'm not sure how to go about that, or if ACE already has a function for it
idk if it has to be calculated based on eyePos location
if that position defines where the actions shows, it shouldn't depend on eyePos
you can also try this: "_target worldToModel unitAimPosition _target" (or unitAimPositionVisual)
Based! I will try this next
Loading the game now, will see if the base fix of just putting model coords in will work
Didn't work- let me try it
what is the problem exactly?
I put the coords in as like position = "[198487,13984874,4871871`]" (numbers random, actual was based off model coords) and it didn't show up where I needed it to
your coords are wrong
I know, those coords are junk
also there's a `
Testing this now
Didn't work
It doesn't
It only appears if I use ^this code
_dir + 0
what is it following exactly? what is _object1?
_object2 setDir (_dir - 0);
- 0?
rotating object inside building
Subtracting zero from a number is unlikely to do anything useful
yes, just added it there for reference, as which offset to use
then your object is probably too big
Wait! I got some results
I think it's because I had another entry, 'selection', set the wrong way
selection should be empty
the wiki page said it takes precedence over position iirc
position String (of code) External Base Actions Only, Code to return a position in model cords (priority over selection)
looks like it was the opposite
Yeah, this may be an 'I'm stupid' moment if this works the way I think it will
surfaceIsWater, ASL z == 0, vehicle player == player?
Is there any reason why this wouldn't work? It's not for me rn and I'm lost as to why
Alright, think I got it mostly working
I overestimated the complexity of it, it's just model coords and not anything else fancy
Wish I could get just- selections figured out, but ah well
thanks cptnnick, ASL z < 1 and vehicle player == player is good enough for the check I think
Well... almost got it
It only shows up when I'm backwards from the front of the vehicle? Which is weird
It works when I look backwards and down in the vehicle, but...
Nowhere to be found when I look at it normally
Current code is this (I know it's janky, looking for suggestions)
position = "_d = _target selectionPosition ['pos driver','memory','AveragePoint']; _d set [2,_d#2+2]; _d";
@little raptor Any advice? π
position's a keyword, isn't it?
I assume you mean something like _position = call { that stuff in the quotes };
If you want a single statement that does the +2 z then there's _target selectionPosition [whatever] vectorAdd [0,0,2]
Yeah, you can't use position as a variable name because it's already a command name
Oh, no, I see, this is config stuff, you're not using it as a variable name
That's not the issue then
oh, config. Ugh.
Should work then assuming that _target exists?
This is what I have so far:
class ACE_Actions: ACE_Actions
{
class Test_Action_1
{
condition = "true";
displayName = "Get in Pilot's Seat";
icon = "\a3\ui_f\data\igui\cfg\actions\obsolete\ui_action_getin_ca.paa";
statement = "_player moveInDriver _target; hint 'Worked!';";
distance = 5;
//position = "[_target, ace_interact_menu_cameraPosASL] call ace_interaction_fnc_getVehiclePosComplex";
//position = "_d = _target selectionPosition ['pos driver','memory','AveragePoint']; _d set [2,_d#2+2]; _d";
//position = "[0,11.3,-1.9]"; //"[-0.46,11.2,-1.8]";
selection = "pos driver";
};
Based off of this framework:
I'm ripping my hair out trying to figure it out
It works somewhat, insofar as the ACE interact point shows up SOMETIMES
But only when I look at it at weird angles
Does it work as expected with selection = "pos driver" instead of the position?
Basically, as per framework, position overrides selection
But is required?
I've tried like a dozen permutations of position = X and selection = X
What I've narrowed it down to is the ACE interact showing up, but ONLY when looking backwards towards the tail of the vehicle
Which isn't very helpful for boarding a vehicle in a hurry
TL;DR: Kind of? But not as intended
well, I don't know where you want it to be or where it is.
Well
It's where I want it to be- I can only ACE interact with it when I face it at certain angles
Which is not at all what I want
I'd post pics in here, but uh, copypaste doesn't seem to be enabled
You need to do the verification (see #βrole-selection ) to upload files
Oh!
Sick!
One sec
So basically- you can kind of juuuuust see it on the edge of the screen
However, it doesn't appear when I look at it straight on
Only when I look at it when facing +90 or -90 degrees from the vehicle's axis
Aren't you trying to put it 2m above the pilot?
Does CfgRemoteExec's server means any server or dedicated server only?
/*
Allowed targets:
0 - can target all machines (default)
1 - can only target clients, execution on the server is denied
2 - can only target the server, execution on clients is denied
Any other value will be treated as 0.
*/
allowedTargets = 0;
Any server
Hi, I need help. I want to ensure that all units within the trigger's range are destroyed except buildings and vegetation. when I type this, nothing happens "{_x Setdammage 0} Foreach thislist;"
Something like this might work:
private _allUnitsInTriggerArea = allUnits apply {_x inArea thisTrigger};
{
if(alive _x && !(isPlayer _x)) then {
_x setDamage 1;
};
}foreach _allUnitsInTriggerArea;
``` I havent tested this.
thx mate i will try now π
i have this π¦
maybe you can modify this script. because he also destroys buildings and trees {_x setdamage 1; } foreach nearestObjects [getMarkerPos "yourmakername", [],500]; ?
try putting () around alive _x and yea you could also kill all objects with that command:
ok
Nvm fixed the typo in the syntax Before:sqf _unit join grpNull; After: sqf [_unit] join grpNull;
like this ???? not workin π¦
private _allUnitsInTriggerArea = allUnits apply {_x inArea thisTrigger};
{
if((alive _x) && !(isPlayer _x)) then {
_x setDamage 1;
};
}foreach _allUnitsInTriggerArea;
for testing you could just try this:
private _allUnitsInTriggerArea = allUnits apply {_x inArea thisTrigger};
{
if(alive _x) then {
_x setDamage 1;
};
}foreach _allUnitsInTriggerArea;
This will kill every alive unit even players.
unfortunately it still doesn't work :*, can you help me rearrange this script because I don't know how to write it to destroy people, cars, tanks, etc. "{_x setdamage 1; } foreach nearestObjects [getMarkerPos "yourmakername", [],500];" ???
The error doesn't make sense in my opinion. Are you trying to execute the script at mission start?
yes , when unit enter in trigger
I remember having an issue with allUnits or allPlayers until I realized that the command starts working only about 30 seconds after mission start, don't know if that's the case still
I found it here:
private _allUnitsInTriggerArea = allUnits inAreaArray thisTrigger;
{
if(alive _x && !(isPlayer _x)) then {
_x setDamage 1;
};
}foreach _allUnitsInTriggerArea;
InArea returns bool so it would return array of bools.
work perfect :))) respect for yu and thanks. Best regards mate
And can it somehow be added to it so that it also destroys vehicles? Because now he only kills people I know I'm complaining and I'm sorry ;p
private _allUnitsInTriggerArea = allUnits inAreaArray thisTrigger;
private _allVehiclesInTriggeArea = vehicles inAreaArray thisTrigger;
{
if(alive _x && !(isPlayer _x)) then {
_x setDamage 1;
};
}foreach _allUnitsInTriggerArea;
{
_x setDamage 1;
}foreach _allVehiclesInTriggeArea;
Btw if you want to kill players as well remove !(isplayer _x) in the if and it will kill everybody players and AI.
thank you very much .. from . Yesterday I downloaded the pdf toturial of scripting and tomorrow I will start reading it because there is a lot of it. Thank you
I've got bunch of units in an array and I want to delete the specific units from the array if they satisfy a condition. Any ideas how?
for "_i" from 0 to _halfcap do
{
_unit = (turnedunits select _i);
_grp = group (turnedunits select _i);
if (_unit == vehicle _unit) then
{
_newgroup = createGroup [independent, true];
{
_x joinSilent _newgroup;
_x addRating -8000;
turnedunits = turnedunits - _x; // Basically, remove the entire group from the 'turnedunits' array if they exist
} forEach units _grp;
} else
{
_newgroup = createGroup [independent, true];
[_unit] join _newgroup;
_unit addRating -8000;
};
uiSleep 0.5;
};```
select?
_arr select {str _x isEqualTo "kjwisawesome"}
I completely forgot about that π
Ye after unplugging my mind for a minute I concluded to this:
turnedunits deleteAt (turnedunits find _x);```
since you're doing this _unit = (turnedunits select _i);, using deleteAt will invalidate the indices
you should either use select or save everything you want to delete in an array and use - (turnedunits = turnedunits - _toDelete where _toDelete is an array)
Yea I setup two arrays, one raw to perform the slice an dice and other to store the results as turnedunits
I mean you're iterating forward. let's say you delete something at index 0. now everything in the array get shifted backwards
in the next iteration you want to do turnedunits select 1 but you will have skipped the item that was previously here (it got moved to index 0)
deleteAt returns the index?
deleteAt returns the item that was deleted
another issue is that since the array size has gotten smaller, future indices will move past the end, and you'll get an invalid index error
forEachReversed to the rescue
Check example 2 @ https://community.bistudio.com/wiki/forEachReversed explaining the same thing
is there a way to check if player standing in light ? ( not sun, but source of light: flashlight, floodlights, lamp, ... )
You could check if the nearestObject to the player is a lightsource
that can give false positives
can stand behind it
can be 2nd closest object
Maybe crosschecking the position of the player with the Vector3D of light direction? getLighting. Alternatively, you could check if if a position is in a shadow (Check the comment in the same wiki)
maybe if that help, light souce is directional, not radial
In arma3 how can use http request?
checking posibility of using lineIntersects or checkVisibility
An unoptimized solution would be to get nearestobjects around a player (say 25m) and then get its lighting values from getLighting and then cross checking its vector direction to that of the player.
I can control number light sources I want to check against player]
If you have a list of lightsources you want to cross check on, then get its lighting direction via getLighting and then compare it with player pos
Actually, the getLightingAt is what you need through and through.
Ref - Example 1: getLightingAt player and compare the _ambientLightBrightness and _dynamicLightBrightness to check if the player is standing in a light.
No need for complex mathematics 
can I track back, from which light source is player standing in ?
With just getLightingAt - dont think so.
You can make triggers in those light areas
Hi guys,
I am trying to figure out how to create a script that will force player into a first person after they leave main base, they can have 3d person at base but not outside
I have placed a trigger that if not present, it will start the script forcing the player to be in first person
while {(true)} do
{
if (alive player && cameraView == "External")
then
{
player switchCamera "Internal";
};
sleep 1;
};
I find arma 3 scripting hard lol, any help with this simple script? :(
you can't suspend the script in trigger statements
what you want is usually done using an each frame loop
if (missionNamespace getVariable ["Joki_eachFrame", -1] >= 0) exitWith {};
Joki_eachFrame = addMissionEventHandler ["EachFrame", {
if (cameraView != "Internal") then
{
vehicle player switchCamera "Internal";
};
}];
I found another problem in this. The AI seems to get into the vehicle fine but then does not move to the waypoint. Running the script again works, but it seems to be a strange issue? (Adding a timer also did not work).
can't help you with waypoints, I'm bad with AIs
With exitwith you exit the current scope you are in plus you can run aditional code if needed. With break to you need to name scopes and to exit you need to refrence specific scope with no aditional code to add in case you exit the scope.
it won't see your scope name, so it won't work
also why write so much code when there's a simpler way?!
exitWith{} just gives me goto instruction vibes.
what you wrote gives me goto vibes
exitWith looks likereturn(but not the same thing ofc)
Its breakWith
that's for loops
oh wait, its just for iterators
because there's no such thing as "function" in Arma
breakOut has binary version with left operand being return value
i.e. no way to tell where you return to
that is the definition of a function yes, but in SQF "functions" don't have any distinction from "scopes" (aka "CODE" type)
a scope {} creates a code
when you assign it to a var you just call it a "function"
no. spawn creates a new context
that's a different thing
what I mean is that {} creates a new "variable" of type "code"
if _something then {}
you can just write
_code = {};
if _something then _code
so as you can see, it makes no sense to have return in SQF
fnc =
{
_code = { return true; }; // return to where?!
if _something then _code
};
you can probably implement return using preprocessor macros tho:
#define return(x) (x) breakOut "fnc"
#define BEGIN_FNC scopeName "fnc"
fnc =
{
BEGIN_FNC;
_code = { return(true); };
if _something then _code
};
looks weird tho 
wrap it into a do while and breakWith π
(Actually I think we don't have do while do we?)
Maybe just foreach with one element? π€
What's the difference between do while and while do (which we do have)?
I think is in https://community.bistudio.com/wiki/breakWith
uhhhhhhhhhhh
#define return(x) (x) breakOut "fnc"
#define func(x) x = { scopeName "fnc";
#define endf };
func(myFunction)
_code = { return(true); };
if _something then _code
endf

interesting
@winter rose
Tell me please again if itβs not difficult
there is a code (client):
etc...
while {(!isNil {missionNamespace getVariable "MyVariable"})} do {};
deleteVehicle _vehicleObject;```
the car is removed immediately, but if I wrap all the code in [] spawn , then everything works.
there is a code (server):
```params ["_sessionID"];
private _player = _sessionID call ExileServer_system_session_getPlayerObject;
my code...
_vehicleObject = [_veh, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
while {(!isNil {missionNamespace getVariable "MyVariable"})} do {};
deleteVehicle _vehicleObject;```
how to use [] spawn here?
I want to achieve this:
spawned the car, then wait until the missionNamespace getVariableis = isNil and delete the car
don't use while without sleep. or just use waitUntil
okay
[] spawn {
_vehicleObject = _type createVehicle (_pos);
etc...
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;
};
everything is working
but how should I use [] spawn {
code (server):
[] spawn {
params ["_sessionID"];
private _player = _sessionID call ExileServer_system_session_getPlayerObject;
my code...
_vehicleObject = [_veh, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;
};
Error Undefined variable in expression
post the whole code. where did you define _type and _pos?
params ["_sessionID"];
private _player = _sessionID call ExileServer_system_session_getPlayerObject;
_vehclass = "Exile_Car_Volha_Blue";
_pos = (getPos _player) findEmptyPosition [10, 50, _vehclass];
_vehicleObject = [_vehclass, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;
if you remove the line deleteVehicle car appears
where do you run it from tho?
if it worked without the waitUntil then this should work too
_this spawn {
params ["_sessionID"];
private _player = _sessionID call ExileServer_system_session_getPlayerObject;
_vehclass = "Exile_Car_Volha_Blue";
_pos = (getPos _player) findEmptyPosition [10, 50, _vehclass];
_vehicleObject = [_vehclass, _pos, (random 360), true, "0000"] call ExileServer_object_vehicle_createPersistentVehicle;
waitUntil { (isNil {missionNamespace getVariable "MyVariable"}) };
deleteVehicle _vehicleObject;
};
It worked
How i can post the api in arma3 script ?
Is there an alternative for addPublicVariableEventHandler since is deprecated since introduction of remoteExec ?
I usually do missionNamespace setVariable ["TAG_variable", "value", true] on server. Is there some way to listen for change of TAG_variable value? ( other than loop )
So I have a script that applies an addAction to all civilians on a server. My community uses ALiVE so it has to be run whenever new civs spawn in. However, there's a possibility that the addAction can be applied to a unit that already has it, which makes it have a duplicate one. I'm curious if there's a way to check and see if a unit already has the addAction applied so I can prevent that from happening. The best idea I have is to assign a variable to each unit and filter out the units that have that variable? Not sure how to do that when there's 20-30 civs spawned at a time tho
// yourScript.sqf
if ( _unit getVariable ["TAG_actionAdded", false] isEqualTo false ) exitWith {};
_unit setVariable ["TAG_actionAdded", true, true];
// add your action here
You can shorten that a little:
if (_unit getVariable ["TAG_actionAdded",false]) exitWith {};```
Yes. addPublicVariableEventHandler is the way.
The logic here is backwards btw. This will exit (and not add the action) if TAG_actionAdded is false or not defined. You want to exit if the variable is true, because it's set true when the action is added.
Depending on how this is done, for example if you're using a forEach to go through all the units, you might not want to use exitWith.
{
if (_x getVariable ["TAG_actionAdded",false]) then {continue};
_x setVariable ["TAG_actionAdded",true,true];
// now add the action. If the script is running only on the server, then remember to remoteExec the action.
} forEach _yourListOfCivilians;```
Awesome :) I'm extremely new to scripting so I appreciate ya'll
code
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
Ok, I need a simple script to check wether a player is in a vehicle, and then make him captive, but remove captive status as soon as he exits the vehicle (basically make the opfor not fire at the car while the player is inside.
Something along the lines of
waituntil {sleep 2; player in (crew rescar1)};
player setcaptive 1;
hint "Player captive";
waituntil {sleep 2; player not in (crew rescar1)};
player setcaptive 0;
hint "Player not captive";
But I can't get it to work properly.
I need a snippet so I can paste it in the init of any vehicle of my choice.
Any guidance?
You can't use waitUntil in editor init scope.
id change the waituntil to this:
waituntil {sleep 2; vehicle player != player};
So you'd either have to spawn that, or better, use GetIn/GetOut event handlers.
Best method depends on whether it's supposed to be vehicle-specific or not.
I just need a generic code to paste to any init, like quick and dirty style
0 spaw {
waituntil {sleep 2; vehicle player != player};
player setcaptive 1;
hint "Player captive";
waituntil {sleep 2; vehicle player == player};
player setcaptive 0;
hint "Player not captive";
};
try this
Thanks, works once, but how do I loop it?
0 spaw {
while {true} do {
waituntil {sleep 2; vehicle player != player};
player setcaptive 1;
hint "Player captive";
waituntil {sleep 2; vehicle player == player};
player setcaptive 0;
hint "Player not captive";
sleep 1;
};
};
spawn
oops
Just don't use it in a real MP mission :P
Nah, I'm mostly making SP missions for my own amusement
I tend to branch out exponentially when making MP missions lol
They grow out of proportion in a hurry
Also, I remember from the early arma 1 days, a script that sort of did the same thing, but with a pistol. The script set player captive when he consealed the gun (which where then removed from inventory), and removed captive when the gun (stored in a variable) was replaced with the player.
Anyone know of any surviving caches of old scripts?
In arma3 donβt have https request? How I can make discord log or send webhook to discord?
Git is love git is life, best version control tool ever.
svn is bae
No repo corruption in git and the repos are lighter huehuehue.
ASLW maybe
could someone help me with something
i want to add ace's defuse function to a an object
if it's your own variable you can just remoteExecCall a function that changes the value
I'm getting an error saying _unit is undefined for _unitName = name _unit;.
_this doesn't work, I've tried putting it in other places, but Im just lost. Could use some help :)
["Civilian", "init",
{
_civs = allUnits select {side _x == civilian && side _x != playerSide && incapacitatedState _x != "UNCONSCIOUS" && captive _x != true };
{
private _unit = _x;
if (_unit getVariable ["TAG_actionAdded",false]) then {continue};
_unit setVariable ["TAG_actionAdded",true,true];
_unit addAction [
"Have you seen any enemies nearby?",
{
private _enemyDetected = [_this select 0] call BIS_fnc_enemyDetected; private _unitName = name _unit;
if (_enemyDetected)
then {
titleText [format ["<t align = 'center' shadow = '2' color='#FFC0CB' size='1.5' font='PuristaBold' >%1</t>", _unitName],"PLAIN DOWN", -1, true, true];
titleText ["<t align = 'center' shadow = '2' valign = 'bottom' color='#ffffff' size='1.5' font='PuristaBold' shadow = '2' >Yeah I seen them fucks, what's it to you?</t>", "PLAIN DOWN", -1, true, true];}
else {
titleText [format ["<t align = 'center' shadow = '2' color='#FFC0CB' size='1.5' font='PuristaBold' >%1</t>", _unitName],"PLAIN DOWN", -1, true, true];
titleText ["<t align = 'center' shadow = '2' valign = 'bottom' color='#ffffff' size='1.5' font='PuristaBold' shadow = '2' >Bad guys? Fuck man I'm just minding my own damn business I ain't no rat.</t>", "PLAIN DOWN", -1, true, true];}
},
nil,
1.5,
true,
true,
"",
"true",
5,
false,
"",
""
];
} forEach _civs;
}, true, [], true
] call CBA_fnc_addClassEventHandler;
The goal is to have the civ's name pop up as the first titleText
@tough abyss The error message said it was expecting a location or object and got an array for _this select 0
Order of operations, it's doing (name _this) select 0
https://community.bistudio.com/wiki/Order_of_Precedence
You can use ( ) to force it to interpret commands in the correct order, e.g. name (_this select 0);
welp it got rid of the error but the name didn't show up :(
"Deprecated" feels like the wrong word. I would assume that the function will still work as it does for as long as Arma 3 exists. The point's more that remoteExec is better for many things that used to be done with public variable EHs.
@still forum thanks!
How can send to webhook?
underwater is only used for objects
isSwimming is mentioned on that page tho
forgot about that one :P
there is no isSwimming command... the underwater command just returns if the unit is in swimming state not wether its underwater
if you wanted your mission to send information to a remote web server (kills/deaths happening in the mission for example), how would you do that ?
exploiting htmlLoad might be a solution but maybe there's a more straightforward answer ?
htmlLoad or making your own Extension...
You can try checking if player animation has "SwimmingActions" in "actions" in config
@round scroll
Or simply check if the unit's head is underwater ?
Well unit might not be in swimming animation under water for whatever reason (animation transition, forced animation, glitch, etc.)
getText(configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "actions") find "SwimmingActions" >= 0
here is animation check anyway
hello I think I have an issue with some script code. the code I'll post is made to be executed from an init of an object like a oil spill and the thing I saw is that it was only working for the zeus and not the players.
Eg the players weren't hunted by the AA missiles that came raining but the zeus if he tried it himself would be hunted by them
I'll post pastebin soon when arma opens
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
so I want it to read where any player is and act accordingly
but so far it only worked for zeus who put them down
by that I mean the zeus was hunted by the AA missiles but the rest weren't
There is a difference between how init field code works for Editor-placed objects and for Zeus-placed objects.
When an object that was placed in the Editor runs its init field, the code is executed on all machines when the mission starts or when they JIP.
When an object is placed by Zeus (via saved composition), its init field code is executed only on the machine that placed it. If you need it to run on other machines too, you need to remoteExec it - or redesign the code so it doesn't need to run on every machine.
the code needs to is the issue
is there a way to make it so it runs on the server and the server spawns the missiles on the player. Or the server sends the commands to the player machine to be ran locally. Also how would I run that whole function in remoteexec. Commands are nderstandable but if checks?
Thanks for your assistance
If you choose remoteExec, don't remoteExec each command individually. Make a function and remoteExec the function.
Redesigning the code to work from one machine is complex and I'm not going to do it for you, but it should be possible. forEach playableUnits comes to mind as a starting point - stop referencing player and start referencing _x
so could I do the
{"Whole function"}foreach units player```
and all player checks could go as _x
instead of player eg:
if((vehicle _x iskindof "Plane") && (side _x == west))then{ ```
units player returns only units that are in the same group as the local player. I don't think that's what you want. You said you wanted to target all players, which is why I suggested using playableUnits.
When I get back home I'll have another question
@lone glade totally forgot that
https://xkcd.com/1597/
https://xkcd.com/1296/
in regards of "git is love"
That's skrubs using git
No. I guess it's called scripted light, not config defined one
It is. And you cannot through script
No config values can be overwritten on the fly, as you already know
Hello people, i have a question about hint function in multiplayer.
hint "123";
it will be send only to one player, but how to define, who is that player?
http://chris.beams.io/posts/git-commit/ for commits, http://git-scm.com/book/en/v2 for learning how to use it.
now git gud
Use remoteExec and _target is your client where you want it to be executed.
https://community.bistudio.com/wiki/remoteExec
Just to make sure with foreach command
The zeus/server calls the function and gets data for each user
in my case I have let's say 3 players
"cool. How do we use it?" "No idea. Just memorize these shell comands and type them to sync up."
It will do the function for me, then for my second and third player
cause I tell the server to get data for each playable unit
q.e.d.
Hello,
Question regarding simple issue. I wanted players which spawn on specific position, to be teleported to specific vehicles as soon as mission start. In order to do that I placed next code in each of players init.
this moveInCargo V1;
When tested in SP and MP from editor it worked properly.
When I tested it on dedicated server with 2-3 players it also worked.
When mission started with 40 players on server, no one was teleported to their vehicles.
Does anyone know what is issue and what can I do to solve it?
Is this entire init field?
unless you got a neat client or ide plugin doing all the work
True
Init field is a pretty bad place to have your scripts, its global executing including for JIP players
Thought moveInCargo requires unit to be local π€
That is also my thought, and when I did it with limited number of players it worked, but once bunch of us joined it didnt worked for anyone.
These are player units you choose in lobby, right?
True
So we pick slots, we enter map for briefing and then go inside game.
Tweaked it a little
Hm
More tweaks
- If client is not a dedicated server (will have a player unit)
- Spawn a thread and wait until player loads (
player == player) and locality arrives from the server (local player) - Then if this particular editor unit is the player, do move in cargo.
Potential issue: If player joins later in the game into that unit and it was AI, they'll teleport into the vehicle
If your mission supports players turning into AI when they leave and JIP, I can account for that too
if(!isDedicated) then {this spawn {waitUntil{local player}; if(player == _this) then {_this moveInCargo V1}}};
Removed player == player as local player should cover both already
Thank you.
If I correctly undrstood, you are speaking if AI is enabled for playable units? We keep that one disabled.
Yes, that. I guess it should be fine then.
Ok, thank you again, I will test this one.
While we are on topic, another question. On same mission I have a trigger with Server Only option checked, activated by anyPlayer and next code inside onActivation field:
AIV_1 setFuel 1;
Again, it worked normally in SP/MP but on dedicated it didnt, so I needed to uncheck Server Only option. Is this a correct way to do this, or I did something wrong.
Why was it server only?
I try to use server only to avoid unnecessary executions on other clients, basicly I understood that is correct way to do for playing on dedicated server with larger number of players.
So the idea of trigger that some player unit enters it and it refuels some vehicle? Or do you have another condition to check if that vehicle is also in the trigger?
As for optimization concerns, I don't think its a big deal unless you have 1000 of these triggers or very complex condition in them.
Yes, as HC is not working properly with AI waypoints skipped by triggers, I took out fuel from vehicles and then I refuel them when any player steps in into trigger. I dont have any other condition to check if that vehicle is in that same trigger.
having that trigger global should be fine, its a drop in the ocean performance-wise
Thanks one more time.
I have one last, as it concerns me in a same way as the first question with moveInCargo. I use LAMBS AI mod and HC on my server. Due to that if I want AI to stay static, I need to turn off LAMBS for it and execute command for DisableAI. For that purpose I made a small script so I dont need to write whole code for each AI unit separatly.
This is code:
Private _Target = _this select 0;
if ( local _Target ) then {
waitUntil { time > 0; };
_Target setVariable ["lambs_danger_disableAI", true, true];
_Target disableAI "PATH";
_Target setunitpos "UP";
_Target forceSpeed 0;
};```
Is it ok if I call this script from AI unit init using only this code?
```sqf
this call {[_this] execVM "Disable_Move.sqf";};
Looks fine
I dont need to use something like:
if (!isDedicated) then
or
if (Local _this) then
?
no it will be fine
isDedicated check in case of units is done to never reach local player waitUntil, becuse it will never resolve on dedicated server as it never has a player unit
Thank you for your fast responses and help, I appreciate it.
Trying to get this as a line of code that players can use on an Item...
this addAction ["Its just a weather balloon agent Mulder, {
params ["0 setFog [0,0,0];
who wrote thatβ¦
Any time you open a thing, be it starting a string with ", starting a code block with {, or starting an array with [, there must be an equivalent close - another ", a }, or a ] as appropriate
Also you've got a random params [ hanging out that doesn't seem necessary in the context of what you're doing, even if it was done properly
Yea If anyone knows how to write that line of code that would make It useful.
Please don't DM me. This is the channel to discuss scripting problems. Posting here allows everyone to help.
this addAction ["Its just a weather balloon agent Mulder", {
0 setFog [0,0,0];
}];
```should be enough.
Thank you good sir.
Hey one last thing. I notice that they can activate the object from far away. Is there a line of code that can be added that reduce the click distance to 1m?
yes
see https://community.bistudio.com/wiki/addAction:
this addAction
[
"title", // title
{
params ["_target", "_caller", "_actionId", "_arguments"]; // script
},
nil, // arguments
1.5, // priority
true, // showWindow
true, // hideOnUse
"", // shortcut
"true", // condition
50, // radius
false, // unconscious
"", // selection
"" // memoryPoint
];
Thank you very much.
so basically,
this addAction
[
"It's just a weather balloon, agent Mulder", // title
{
0 setFog [0, 0, 0];
},
nil, // arguments
1.5, // priority
true, // showWindow
true, // hideOnUse
"", // shortcut
"true", // condition
3 // radius
];
Thank you very much once again. This will help a bunch.
Saying Invalid experssion.