#arma3_scripting
1 messages ยท Page 53 of 1
me 2 weeks into just making an object move and teleport me onto another cube in the same spot but this new cube doesnt move
How do I add a draw event handler on GPS map that is similar to main map draw EH? I have GPS routing working on main map and in dedicated dialog but I need to add the route to (default) GPS too
As an initial experiment, I tried changing this sqf (findDisplay 46) displayAddEventHandler ["KeyDown",gps_menu_fnc_handleQuickNavActions]; ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw",gps_menu_fnc_drawPath]; to this: ```sqf
(findDisplay 46) displayAddEventHandler ["KeyDown",gps_menu_fnc_handleQuickNavActions];
waitUntil {!isNull (uiNamespace getVariable ["RscCustomInfoMiniMap", displayNull])};
disableSerialization;
private _display = uiNamespace getVariable ["RscCustomInfoMiniMap", displayNull];
private _miniMapControlGroup = _display displayCtrl 13301;
private _miniMap = _miniMapControlGroup controlsGroupCtrl 101;
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw",gps_menu_fnc_drawPath];
_miniMap ctrlAddEventHandler ["Draw",gps_menu_fnc_drawPath];
(side note: don't use gps_menu_fnc_drawPath directly as it copies the code in there - instead, use _this call gps_menu_fnc_drawPath)
@tender fossil uiNamespace getVariable ["IGUI_displays", []] select {ctrlIDD _x == ctrlIDD(uiNamespace getVariable "RscCustomInfoMiniMap")}
Some GPS displays initialize first time when you get into the vehicle
so you might have to check for new displays each time vehicle changes
How would I proceed from there? I'm very confused since this is totally new area to me ๐
okay, bit of a niche question here that im quite stuck with
how would i convert a velocity of [-200,0,0] to be relative to a vehicle model when I cannot use modelspace? Need to have relative velocities of one object to another when teleporting the object and updating its speed
im going to draw a diagram one moment
hopefully this helps to explain my issue
Currently I'm just using velocityModelspace of 1 but it doesn't work if 2 is in motion due to it missing the relative velocity
setVelocityModelSpace / setVelocity ?
as explained at the bottom the two may be at different orientations when the teleport happens
sorry, "the two" meaning 2 and 3
on the surface it appears to be a really simple thing to do lol
so what are you trying to achieve?
๐ฟ
2 is perceived to be a stationary observer of 1 as far as this script is concerned, but 2 is actually in motion.
I teleport 1 from its relative position to 2 onto the same relative position to 3, but 3 is not in motion.
My problem is that it appears that 1 has lost speed due to the speed of 2 not being added to the speed of 1 when it is teleported as 3 is now not in motion. Similar thing to 2 suddenly stopping
This is surprisingly difficult to explain lmao
just convert everything to model space of one of the objects ๐คทโโ๏ธ
well it sure is over my head XD
Like I said it's deceptively complex lol
_velocity1modelspace2 = obj2 worldToModel (getPosWorld obj2 vectorAdd velocity obj 1);
_total1relativeto2 = _velocity1modelspace2 vectorAdd velocityModelSpace obj2;
```or something like that
and _velocityAfterTP = obj3 modelToWorld _total1relativeto2;
I'm now confused why is position calculations involved for this
to calculate velocity of object1 in modelspace of object 2 ๐คทโโ๏ธ
as worldToModel takes world coordinates as its input ๐คทโโ๏ธ
I'm still confused but I'll try it anyway
ah heres the issue
I can't use velocityModelSpace obj2 as it's a static object being moved with setVelocityTransformation
Any obj2 velocity has to be xyz because calculating modelspace velocity on each frame probably isnt very performant
{
if(isNil{_x getVariable "my_draw_eh"}) then {
_x setVariable ["my_draw_eh", _x ctrlAddEventHandler ["Draw", {call gps_menu_fnc_drawPath}]];
};
} forEach (
uiNamespace getVariable ["IGUI_displays", []]
select {ctrlIDD _x == ctrlIDD(uiNamespace getVariable "RscCustomInfoMiniMap")}
apply {_x displayCtrl 101}
);
Run this each time you change vehicle
jolly quadratic spline fun 
also, vectorAdd was most likely an error and vectorSub was actually needed there 
The velocity param doesn't do much in SP, but in MP, provided the velocity component is set correctly, it helps the engine to figure out what the next position of the moving object should be on other clients.
sounds kinda sus for spline application, let me actually check
im using sqf private _shipLastPos = temp1 getVariable ["KJW_CapitalShips_LastPos",[0,0,0]]; private _shipPos = getPosASL temp1; private _shipVel = (_shipLastPos vectorDiff _shipPos) vectorMultiply 1/diag_deltaTime; temp1 setVariable ["KJW_CapitalShips_LastPos", _shipPos]; temp1 setVariable ["KJW_CapitalShips_Velocity",_shipVel]; in an eachframe to get the velocity of temp1 (2 in the diagram)
well
"velocity"
aww, for cat's sake, i suck at reading and "quadratic spline" was proposed as a thing user/coder can implement themselves 
and setVelocityTransformation itself is claimed to be dumb linear interpolation
its linear? was under the impression it was quadratic 
If curve is needed, then it should be constructed from multiple straight sections or by dynamically changing value of position params during the interpolation cycle
"bruh" intensifies
well that throws a spanner in my hopes for making the cube curve between points
guess its turning before moving because fuck that
add 2 invisible objects, setVelocityTransformation inv1 between point1 and point 2, setVelocityTransform inv2 between point2 and point 3, setVelocityTransform actual object between inv1 and inv2. With the same _interval argument in all transforms ๐คทโโ๏ธ
literally this
oh so two transforms at the same time?
three
ah -- either way it doesn't solve my issue at the moment either ๐
kek
why couldnt einstein have written in sqf
dumb question, but does anyone know a script that make a vehicles engine invincible to damage?
and only the engine?
my take on things is:
a) you need to have velocities of **all **objects in at least one common coordinate space
b) you transform it to obj2 model space
c) you apply it in obj3 model space
๐คทโโ๏ธ
I have them all in the same coordinate space insofar as velocity goes but I can't do anything with velocitymodelspace for obj2 or 3
initPlayerLocal.sqf: ```sqf
[] spawn {
while {true} do {
{
if(isNil{_x getVariable "gps_showOnGPS_loaded"}) then {
_x setVariable ["gps_showOnGPS_loaded", {_x ctrlSetEventHandler ["Draw", {call gps_menu_fnc_drawPath}]}];
diag_log "Something happening";
} else {
diag_log "gps_showOnGPS_loaded is already defined!"
};
} forEach (
uiNamespace getVariable ["IGUI_displays", []]
select {ctrlIDD _x == ctrlIDD(uiNamespace getVariable "RscCustomInfoMiniMap")}
apply {_x displayCtrl 101}
);
sleep 10;
};
};
I added some diag_log like you see and replaced the `ctrlAddEventHandler` with `ctrlSetEventHandler` since I'm just looping it as a cheap test. Or is it the source of bug of still nothing showing on GPS?
This is the RPT: ```18:40:55 "GPS (Unknown file): Compiling functions..."
18:40:55 "GPS (Unknown file): Compiling functions done"
18:40:55 "GPS Core (Unknown file): Compiling functions..."
18:40:55 "GPS Core (Unknown file): Compiling functions done"
18:40:55 "GPS Core (fn_mapRoutes.sqf): <<< MapRoutes init >>>"
18:40:55 "GPS Core (fn_mapRoutes.sqf): getting roads ..."
18:40:55 "GPS Core (fn_mapRoutes.sqf): done in 0"
18:40:55 "GPS Core (fn_mapRoutes.sqf): mapping road intersect ..."
18:40:55 "gps_showOnGPS_loaded is already defined!"
18:40:55 "Something happening"
18:40:56 "GPS Core (fn_mapRoutes.sqf): done in 1"
18:40:56 "GPS Core (fn_mapRoutes.sqf): mapping node values ..."
18:40:56 "GPS Core (fn_mapRoutes.sqf): done in 1"
18:40:56 "GPS Core (fn_mapRoutes.sqf): Maproutes init done in 2s"
18:41:09 "gps_showOnGPS_loaded is already defined!"
18:41:09 "gps_showOnGPS_loaded is already defined!"
@sharp arch Can be done with a handleDamage EH, although it has to be the last one attached to override the output damage.
Could it also be done with setHit and getHit ?
as for why use positions in velocity calculations: getPosWorld obj2 is [0,0,0] of model space coordinates of obj2 converted to world space. Then i add world space velocity: (getPosWorld obj2 vectorAdd velocity obj 1). Then i convert back to obj2 model space: obj2 worldToModel (getPosWorld obj2 vectorAdd velocity obj 1).
@fleet sand Not sure, might be too slow to prevent knock-on effects.
if you don't have model space velocity of obj2 but its world-space velocity is available - you need to do something like obj2 worldToModel ((getPosWorld obj2 vectorSub _obj2WorldSpaceVelocity) vectorAdd velocity obj 1) 
Like RHS vehicles will explode if you hit the engine twice.
I am now entirely lost lmfao
what would that return? modelspace velocity of obj1 relative to obj2 as stationary observer?
relative velocity of obj1 in modelspace of obj2 if i haven't derped anywhere
and then how would I end up applying that to obj1?
_newVelocity = (obj3 modelToWorld _thatGoddamnThing) vectorSub getPosWorld obj3;
obj1 setVelocity _newVelocity;```
ok i will try that thank you lmfao
I assume you mean vectorDiff instead of vectorSub too right
yeah, totally
_x setVariable ["gps_showOnGPS_loaded", { <- { you're setting a function, not return of the event handler addition
Also use ctrlAddEventHandler, ctrlSetEventHandler overwrites everything is outdated
I think it's subtracting instead of adding somewhere
Let me double check
I don't think so actually
wait yes it is
private _newVelThing = temp1 worldToModel ((getPosWorld temp1 vectorDiff (temp1 getVariable ["KJW_CapitalShips_Velocity",[0,0,0]])) vectorAdd velocity vehicle player);
private _newVelocity = (temp2 modelToWorld _newVelThing) vectorDiff getPosWorld temp2;
vehicle player setVelocity _newVelocity;```
is what I'm doing
so what looks wrong?
It's decreasing velocity when both are moving towards one another and increasing when both are moving the same direction
I'll try get a clip
i'd say here private _shipVel = (_shipLastPos vectorDiff _shipPos) vectorMultiply 1/diag_deltaTime;, kek
What's up with it?
as velocity is usually described as "(new position - old position) / time" and you seem to have it reversed
oh of course
i'll try swap
omg
let me just test the other way around but i think that is it
Hey, does anybody know how I might go about a mission specific disabling of blood?
I know its an in-game option to turn blood off, at client level, but forcing it on the server is a simple way to add a bit of believability to Simunition Training if it can be done! Thanks ๐
disabling of blood or damage?
blood specifically, still want them to take damage as usual
you using ACE medical?
Yeah mate
Sorry I should probably clarify, I mean the visual presence of blood not the blood system
I tried doing this a while ago and couldn't find an easy way to do it without destroying performance
May be worth asking in ACE discord ( #channel_invites_list ) though
Cheers mate! Will ask there ๐
my thing is solved thank you artemoz the genius
addUserActionEventHandler ["headlights", "Activate",
{
_flashlight = player getVariable ['flashlight', objNull];
if (!(isNull _flashlight)) then
{
player setVariable ['flashlight', objNull, true];
playSound3D ["A3\missions_f\data\sounds\click.wss", player];
deleteVehicle _flashlight;
player setVariable ["FlashLightOn", false, true];
removeAllMissionEventHandlers "EachFrame";
}
else
{
_flashlight = "#lightreflector" createVehicle [0,0,0];
_flashlight attachTo [player, [0,0.05,0.05], "pilot"];
player setVariable ["FlashLightOn", true, true];
addMissionEventHandler ["EachFrame",
{
_flashlight = player getVariable 'flashlight';
_lightVecDir = getCameraViewDirection player;
_p = asin (_lightVecDir #2);
_dir = (((_lightVecDir #0) atan2 (_lightVecDir #1)) + 360) mod 360;
_flashlight setVectorDirAndUp
[
[0,1,_lightVecDir #2],[[0, -sin _p, cos _p], - _dir] call BIS_fnc_rotateVector2D
];
}];
[_flashlight, [60, 15, 4]] remoteExec ["setLightConePars", 0];
[_flashlight, [2, 2, 2, 2, 2, 25]] remoteExec ["setLightAttenuation", 0];
[_flashlight, 500] remoteExec ["setLightIntensity", 0];
[_flashlight, [0,0,0]] remoteExec ["setLightAmbient", 0];
[_flashlight, [2,2,2]] remoteExec ["setLightColor", 0];
[_flashlight, true] remoteExec ["setLightUseFlare", 0];
[_flashlight, 0.5] remoteExec ["setLightFlareSize", 0];
[_flashlight, 500] remoteExec ["setLightFlareMaxDistance", 0];
player setVariable ['flashlight', _flashlight, true];
playSound3D ["A3\missions_f\data\sounds\click.wss", player];
};
}];
is the EachFrame eventhandler right or is there a better way to move the light according to the head movement?
Does anybody have an idea what's wrong with my Functions library?
https://cdn.discordapp.com/attachments/714773557628108831/1081994816285573170/image.png
https://cdn.discordapp.com/attachments/714773557628108831/1081993922705895515/image.png
description.ext:
class cfgFunctions
{
#include "functions\functions.hpp"
};
this is what I get:
You seem to have CfgFunction as the root of your hpp
I understand now, thanks!
Making the resulting description.ext have class CfgFunctions { class CfgFunctions { class LDR...
Ill try to fix it now
Did you try attaching a light to the head instead of updating position each frame ?
yes, but making the light follow the bone rotation is not accurate if the player goes into crouch or prone position
I got this from a webknight myb this could help you. This creates light at the wrist location and it follows that bone.
player addAction
[
"<t color='#8B0000' size='1.2' font = 'PuristaSemibold'>Enable/Disable SHF flashlight</t>",
{
params ["_target", "_caller", "_actionId", "_arguments"];
if !(isNil {player getVariable "SHF_Enabled"}) exitWith {player setVariable ["SHF_Enabled",nil,true];};
player setVariable ["SHF_Enabled",1,true];
[player,{
_smlfirelight = "#lightpoint" createVehicle (getpos _this);
_smlfirelight attachto [_this,[0,0,0.05],"LeftForeArmRoll",true];
_smlfirelight setLightAmbient [0.4,0,0];
_smlfirelight setLightColor [0.4,0,0];
_smlfirelight setLightBrightness 0.4;
_smlfirelight setLightUseFlare true;
_smlfirelight setLightFlareSize 1;
_smlfirelight setLightFlareMaxDistance 100;
waitUntil {
if (isNull _this) exitWith { true };
(isNil {_this getVariable "SHF_Enabled"})
};
deleteVehicle _smlfirelight;
}] remoteExec ["spawn", [0, -2] select isDedicated];
},
nil,
1.5,
true,
true,
"",
"",
5,
false,
"",
""
];
Why does this AA missile nerfing script not work?
in placed jet init field:
[this] call LDR_fnc_spawnJet;
in fn_spawnJet.sqf:
params ["_respawnTemplateJet"];
if (isServer) then {
_respawnTemplateJet addEventHandler ["Getin", {
params ["_respawnTemplateJet", "", "_playerUnit"];
_spawnMarker = "sp1";
private _jet = createvehicle[(typeOf(_respawnTemplateJet)), getmarkerPos _spawnMarker, [], 100, "FLY"];
[_jet, _playerUnit] remoteExec ["LDR_fnc_moveplayerinJet", _playerUnit];
[_jet] call LDR_fnc_playerJetMissileNerf;
}];
};
in fn_playerJetMissileNerf.sqf
params ["_jet"];
_jet addEventHandler ["Handledamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitindex", "_instigator", "_hitPoint"];
_aaMissiles = ["", "ammo_Missile_BIM9X", "ammo_Missile_AMRAAM_C", "ammo_Missile_AMRAAM_D", "ammo_Missile_AA_R73", "ammo_Missile_AA_R77", "ammo_Missile_rim116", "ammo_Missile_rim162", "M_Air_AA", "M_Air_AA_MI02", "M_Air_AA_MI06", "M_Zephyr" ];
if (_projectile in _aaMissiles) exitwith {
systemChat ("- " + str _projectile + "::" + str _damage);
// _damage / 100
0
};
systemChat ("+ " + str _projectile + "::" + str _damage);
_damage
}];
From the systemchat messages, there are none with '+ projectile::00'
all are '-...'
meaning the damage should be nerfed (hopefully)
Looks like you're adding the HandleDamage EH on the server?
Does it need to be local?
and to who
the player or the vehicle
When a player gets in a vehicle as driver/pilot, the vehicle switches locality to their machine.
I changed:
[_jet] call LDR_fnc_playerJetMissileNerf";
to
[_jet] remoteExec ["LDR_fnc_playerJetMissileNerf", 0];
but only the host player is invincible
IF ISSERVER
yes but then I use remoteExec 0
which I believe is server+clients
where did you do so?
here
that image is not the final code, right?
No
ok ok
I'll send the final code now to remove confusion
I don't get why the server is creating another jet in the init field for a jet.
params ["_respawnTemplateJet"];
if (isServer) then {
_respawnTemplateJet addEventHandler ["Getin", {
params ["_respawnTemplateJet", "", "_playerUnit"];
_spawnMarker = "sp1";
private _jet = createvehicle[(typeOf(_respawnTemplateJet)), getmarkerPos _spawnMarker, [], 100, "FLY"];
[_jet, _playerUnit] remoteExec ["LDR_fnc_moveplayerinJet", _playerUnit];
[_jet] remoteExec ["LDR_fnc_playerJetMissileNerf", 0];
}];
};
When you get in the "template" jet, the server creates another one in the sky and teleports the player
Yep, that's why I'm crying constantly about locality
And all that inside the event handler? Radical
Yes. I haven't sent the entire eventhandler here
Should I send it?
uh :P
lol too big
Here:
params ["_respawnTemplateJet"];
if (isServer) then {
_respawnTemplateJet addEventHandler ["Getin", {
params ["_respawnTemplateJet", "", "_playerUnit"];
moveOut _playerUnit;
systemChat "[DEBUG] Jet spawned!";
_spawnMarker = selectRandom (["sp1", "sp2", "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp9", "sp10", "sp11", "sp12", "sp13", "sp14", "sp15", "sp16"] - [missionnamespace getVariable "lastspawn"]);
missionnamespace setVariable ["lastspawn", _spawnMarker];
private _jet = createvehicle[(typeOf(_respawnTemplateJet)), getmarkerPos _spawnMarker, [], 100, "FLY"];
{
_jet removeWeapon _x;
} forEach weapons _
{
_jet addWeapon _x;
} forEach weapons _respawnTemplateJet;
{
_jet removeMagazines _x;
} forEach magazines _jet;
for "_i" from 1 to count getPylonmagazines _respawnTemplateJet do {
_jet setPylonLoadout [_i, (getPylonmagazines _respawnTemplateJet) select _i - 1, true];
};
{
if ! (_x in getPylonmagazines _jet) then {
_jet addMagazine _x;
};
} forEach magazines _respawnTemplateJet;
_jet setDir (_jet getRelDir worldCenter);
_jet setPos [(getPos _jet) select 0, (getPos _jet) select 1, 850];
// height
_maxspeed = getNumber (configFile >> "Cfgvehicles" >> (typeOf _jet) >> "maxspeed");
_jet setvelocity [_maxspeed / 3 * (sin (getDir _jet)), _maxspeed / 3 * (cos (getDir _jet)), 0];
// velocity
[_jet, _playerUnit] remoteExec ["LDR_fnc_moveplayerinJet", _playerUnit];
[_jet] remoteExec ["LDR_fnc_playerJetMissileNerf", 0];
{
_x addcuratorEditableObjects [[_jet], true];
_x addcuratorEditableObjects [[_jet], true];
} forEach allCurators;
_jet setVariable["isJet", true, true];
}];
};
Does that missile nerf function definitely exist on clients?
Yes, it is in CfgFunctions
client and server can have different CfgFunctions :P
how
Although if it's a mission it should be fine.
You get no systemChats on clients from the nerf function either?
correct
I even changed the code for easier debugging:
_jet addEventHandler ["Handledamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitindex", "_instigator", "_hitPoint"];
0
}];
only host doesn't die
I'd definitely keep the systemchat...
Trouble is that subsequent handledamage event handlers will block the return-override functionality.
I don't understand what that means
never mind. If the systemchat isn't firing then it doesn't matter.
will test with this
params ["_jet"];
_jet addEventHandler ["Handledamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitindex", "_instigator", "_hitPoint"];
systemChat ("HIT! with possible damage " + _damage);
0
}];
im so confused
ah, str _damage
I've reduced my code to this: ```sqf
[] spawn {
waitUntil {!isNull (uiNamespace getVariable ["RscCustomInfoMiniMap", displayNull])};
while {true} do {
{
if(isNil{_x getVariable "gps_showOnGPS"}) then {
_x setVariable ["gps_showOnGPS", _x ctrlAddEventHandler ["Draw",{call gps_menu_fnc_drawPath}]];
diag_log format ["Added event handler [gps_showOnGPS] to control %1", _x];
} else {
diag_log format ["[gps_showOnGPS] is already defined for control: %1", _x];
};
} forEach (
uiNamespace getVariable ["IGUI_displays", []]
select {ctrlIDD _x == ctrlIDD(uiNamespace getVariable "RscCustomInfoMiniMap")}
apply {_x displayCtrl 101}
);
sleep 7;
};
};
This is the RPT output:
```sqf
21:11:05 "[gps_showOnGPS] is already defined for control: Control #101"
21:11:05 "[gps_showOnGPS] is already defined for control: Control #101"
21:11:12 "[gps_showOnGPS] is already defined for control: Control #101"
21:11:12 "[gps_showOnGPS] is already defined for control: Control #101"
But nothing gets drawn on the GPS
While the path gets drawn on the map just like before
The systemChat doesn't get displayed which means the eventhandler is not attaching
Hey guys, how can I make these things true in a PVP mission:
- Sectors that are captured faster if you have a certain item in your inventory
- Respawns akin to COD where certain respawns are disabled if there's too many enemies (or enable ONLY the one with the highest average distance from the enemies for that faction) around them that can be used by either side scattered across the map
yes.
is there something that can't run remoteExec
Not unless you block it with CfgRemoteExec, no.
I'd stick another systemChat at the top of that nerf function.
or preferably put diag_logs everywhere to check the flow.
Currently you don't know whether it's the EH not firing or the function not being called.
I just tested, the function is not getting called
I think I found the issue
the whole isServer thing
because the client cant reach remoteExec
he is stopped that when he hits the isServer
lol
Isn't that the point? GetIn is a global EH, so you only want to install it on the server.
Oh that's an EH i forgot
my point is completely invalid
Disregard
I just tested, the function is not getting called
I think I found the issue
the whole isServer thing
because the client cant reach remoteExec
he is stopped that when he hits the isServer
lol
if is server:
add EH
create jet
tp player to jet
remoteExec nerfJet 0
this is what's written rn
I have no idea why it's not working
If you run vehicle player getVariable "isJet", does it return true?
Just checking that you're actually getting to the end of the GetIn EH.
Honestly this feels like an "editing the wrong code" error at this point.
RemoteExec 0 just works.
If I replace the ctrlAddEventHandler code (Draw EH) with e.g. {hint "Oh geez";}, it works. But when I call the function gps_menu_fnc_drawPath, it doesn't work. What could be wrong?
So this works: sqf _x setVariable ["gps_showOnGPS", _x ctrlAddEventHandler ["Draw",{hint "Oh geez"}]]; and this doesn't work: ```sqf
_x setVariable ["gps_showOnGPS", _x ctrlAddEventHandler ["Draw",{call gps_menu_fnc_drawPath}]];
But the same function works great when it's called on map! Why 
I'm hesitating to call it a bug because this is wildly unfamiliar area to me for now at least, but it starts to look like it. Or could it have something to do with namespaces or locality (?)
Also; no errors in RPT apart from ```21:16:38 Warning Message: '/' is not a value
21:16:39 Warning Message: Resource title gps_hud not found
21:16:45 Warning Message: Resource title gps_quickNav not found
Those do look bad though, but I have no idea whether they're of importance here
["#######"] remoteExec ["systemChat", 0];
With this at the end, it works
I can reach the code
I added debug logging to the gps_menu_fnc_drawPath: ```sqf
params [
"_ctrl",
["_isHUD",false,[false]]
];
_color = ["marker_color"] call gps_fnc_getSetting;
_colorTexture = _color call bis_fnc_colorRGBATOTexture;
_dir = getDir player;
diag_log format ["DRAWPATH.sqf: Currently active control: [%1]", _ctrl];
RPT print after that is: ```21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
21:49:09 "DRAWPATH.sqf: Currently active control: [Control #101]"
And it changes to #51 with map open, #2201 with the GPS itself open etc. so I really start to suspect that it's a bug
Can anyone confirm?
How can I pass parameters to:
{...} remoteExec ["call", 0];
I want this: [...] call {...} in remoteExec without using a function
[argLeft, argRight]
Here's the gps_menu_fnc_drawPath: https://sqfbin.com/abevoyepokuruxovacex
Does it use some commands that work on actual map only? I tried to google about ctrlMapScale and such but didn't find anything
I mean where should I put it in the remote exec
like this?
[[arg1, arg2], {...}] remoteExec ["call", 0];
yes
Is it possible to hide trees from AI pathfinding?
Id like ai tanks to ram trees but they are very reluctant to do it
you can try setDriveOnPath
also set their behavior to combat
are you sure?
also this is for Arma 3 right?
Yes, this time for Arma 3 ๐
Yes, I'm watching it update live from RPT viewer
thanks this seems useful!
Could someone help me with eventhandlers please. How can I add a FiredNear eventhandler to my squad AI which enable AI autotarget if a shot is fired nearby?
did you try logging _toDraw after select?
which part do you need help with?
I tested the following code to see if it works but it does not:
I tested the following code to see if it works but it does not.
params ["_unit"];
_x addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
_x enableAI "AUTOTARGET";
_x enableAI "TARGET";
_x enableAI "WEAPONAIM";
_x setcombatmode "GREEN";
hint 'Fired EH added!'; [] spawn {sleep 3; hintSilent ''};
}forEach (units group player)];
Ha! The array becomes empty then with GPS, but not with map. So I guess the *map* commands are not working in case of GPS?
22:18:10 [1680978: ,1680979: ,1680980: ,1680981: ,1680982: ,1680983: ,1680984: ,1680985: ,1680986: ,1680987: ,1680988: ,1680989: ,1680990: ,1680991: ,1678915: ,1678916: ,1678917: ,1678918: ,1678919: ,1678920: ,1676322: ,1676321: ,1676320: ,1676319: ,1676318: ,1676317: ,1676316: ,1676315: ,1676314: ,1676313: ,1676312: ,1676311: ,1676310: ,1677663: ,1677664: ,1677665: ]
22:18:10 [1680978: ,1680979: ,1680980: ,1680981: ,1680982: ,1680983: ,1680984: ,1680985: ,1680986: ,1680987: ,1680988: ,1680989: ,1680990: ,1680991: ,1678915: ,1678916: ,1678917: ,1678918: ,1678919: ,1678920: ,1676322: ,1676321: ,1676320: ,1676319: ,1676318: ,1676317: ,1676316: ,1676315: ,1676314: ,1676313: ,1676312: ,1676311: ,1676310: ,1677663: ,1677664: ,1677665: ]
22:18:10 "DRAWPATH.sqf: Currently active control: [Control #101]"
22:18:10 [1680978: ,1680979: ,1680980: ,1680981: ,1680982: ,1680983: ,1680984: ,1680985: ,1680986: ,1680987: ,1680988: ,1680989: ,1680990: ,1680991: ,1678915: ,1678916: ,1678917: ,1678918: ,1678919: ,1678920: ,1676322: ,1676321: ,1676320: ,1676319: ,1676318: ,1676317: ,1676316: ,1676315: ,1676314: ,1676313: ,1676312: ,1676311: ,1676310: ,1677663: ,1677664: ,1677665: ]
22:18:10 []
(The empty array is from): ```sqf
_lastRoad = _toDraw select (count _toDraw - 1);
_scale = ctrlMapScale _ctrl;
_lookingAT = [_ctrl ctrlMapScreenToWorld [0.5,0.5],getPosATL player] select _isHUD;
_toDraw = _toDraw select {
_x distance _lookingAT <= (_scale * 10000)
};
diag_log _toDraw;
My objective is to enableAI when a shot is fired nearby the squad
As I disable AI during a certain move command
scale doesn't seem to work then
Is it replaceable?
or the problem is _lookingAt
dunno. log them too
well you're using Fired EH not FiredNear. also you're not using params correctly. and your EH code syntax is wrong too
Code: ```sqf
diag_log format ["DRAWPATH.sqf: Currently active control: [%1]", _ctrl];
_toDraw = missionNamespace getVariable ["gps_draw_points",[]];
diag_log _toDraw;
if (_toDraw isEqualTo []) exitWith {};
_lastRoad = _toDraw select (count _toDraw - 1);
diag_log format ["_lastRoad: %1", _lastRoad];
_scale = ctrlMapScale _ctrl;
diag_log format ["_scale: %1", _scale];
_lookingAT = [_ctrl ctrlMapScreenToWorld [0.5,0.5],getPosATL player] select _isHUD;
diag_log format ["_lookingAT: %1", _lookingAT];
_toDraw = _toDraw select {
_x distance _lookingAT <= (_scale * 10000)
};
diag_log format ["_toDraw after select: %1", _toDraw];
RPT output: ```22:27:52 "DRAWPATH.sqf: Currently active control: [Control #101]"
22:27:52 [1680978: ,1680979: ,1680980: ,1680981: ,1680982: ,1680983: ,1680984: ,1680985: ,1680986: ,1680987: ,1680988: ,1680989: ,1680990: ,1680991: ,1678915: ,1678914: ,1678913: ,1678912: ,1678911: ,1678910: ,1678909: ,1678908: ,1678907: ,1678906: ,1678905: ,1678904: ,1678903: ,1678902: ,1678901: ,1678900: ,1678899: ,1678898: ,1678897: ,1678896: ,1678895: ,1678894: ,1678893: ,1678892: ]
22:27:52 "_lastRoad: 1678892: "
22:27:52 "_scale: 0.0467415"
22:27:52 "_lookingAT: [8394.22,8105.85]"
22:27:52 "_toDraw after select: []"
So ehh
{
if (_x getVariable ["my_firedNearEH", -1] >= 0) then {continue};
_EH = _x addEventHandler ["FiredNear", {
params ["_unit", "_firer", "_distance"];
if ([side _unit, side _firer] call BIS_fnc_sideIsEnemy && _distance < 50) then {
_unit enableAI "AUTOTARGET";
};
}];
_x setVariable ["my_firedNearEH", _EH];
} forEach (units player - [player]);
@modern meteor
use distance2D. also that 10000 seems arbitrary
I've included a distance check too. remove it if you don't want it
Same result with distance2D
!
@tender fossil :
_worldSize = worldSize;
_scale = ctrlMapScale _mapCtrl;
_dist = _scale*_worldSize/8192*250;
that's how I measure distance with scale in my mod
Getting a few errors with the code. No unray syntax and undefined _EH
Not sure what this means
fixed
typo
I increased the sqf _x distance _lookingAT <= (_scale * 10000) with ```sqf
_x distance _lookingAT <= (_scale * 100000)
this comes from an older experiment of mine but I think it might not be 100% correct (also idk what 250 means now ๐ )
Im struggling with a very simple thing - I want to place an inventory item on the ground to be picked up, but it's not listed in the Props in the editor
can I place another inventory item and force it to be replaced with the item I want?
I remember changing the weapon that is laying on the ground with scripts via addWeaponCargo I think but not sure if that'd work in this case
Hmm. Maybe it has changed? This doesn't work: ```sqf
private _worldSize = worldSize;
private _scale = ctrlMapScale _ctrl;
private _dist = _scale*_worldSize/8192*250;
_toDraw = _toDraw select {
_x distance2D _lookingAT <= (_dist)
};
It broke the map routing too. Arma...
Thank you, would this also trigger if the player fires? Or only if the enemy fires?
enemy only
well log dist 
_dist gets values approx between 10 and 1000 with this method
And the script seems to need something between 10000 and 100000 to work properly. Absolutely no idea why ๐
How could I adapt it to add the player as a trigger too?
scale multiplier or dist?
if dist, your code is wrong
Whoops, meant _scale multiplier.
Ah, well I was wondering. Where's the error?
then it's due to what I said before. you need to get the scale multiplier from the map config
there are 2 properties iirc
minScale and maxScale
remove the condition
Thank you. Regarding the distance, can I use any number here? I guess this is the radius within the shots needs to be fired?
Is there any documentation about these? My google-fu doesn't work today it seems
I.e. how do I retrieve them ๐
https://community.bistudio.com/wiki/Arma_3:_CfgWorlds_Config_Reference wasn't helpful this time
yes. like I said you can just remove the whole condition
Thanks Leopard
{
if (_x getVariable ["my_firedNearEH", -1] >= 0) then {continue};
_EH = _x addEventHandler ["FiredNear", {
params ["_unit"];
_unit enableAI "AUTOTARGET";
}];
_x setVariable ["my_firedNearEH", _EH];
} forEach (units player - [player]);
that has nothing to do with it
it's in control config
not world
Ah, I see. Continues google-fu'ing
Yeah ๐
well you don't need to know what they mean. just find the one for map and the one for gps. then use one as the reference to correct the other
Does GPS use CT_MAP_MAIN as well?
that's not really important but yes. all maps either use map or main map
what you should look for is the config of GPS display
Yes, I'm figuring out how to do that ๐
Create GroundWeaponHolder_Scripted to hold what you need.
Any hint how to do that? I'm new to this side of Arma scripting 
I managed to print the main config file but didn't find anything interesting there
what's the IDD of GPS display?
how do you even fetch its map ctrl?
The IDD is 133 and I think I managed to fetch the control, so hmm
well that's the way to get its config then
you know the IDD. you find a display whose IDD=133
then you just look at its controls
Thanks for help. I think I have to stop now, migraine getting more intensive from lots of trial and error ๐
Well, one more try before I quit. I'm quite close I think. sqf configProperties [(ctrlClassName (_miniMapControls select 0)), "true", true] (...doesn't work though apart from the ctrlClassName part. I'd just like to know the config entries so I can find the correct one)
well you're just assuming that the control config is in main config root
Hmm. How do I retrieve where it is? I guess it's some config command
like I said: do a config search for all disps with IDD=133
then find the controls
CA_MiniMap is the GPS map
That's the problem; I don't know how to search configs ๐
get a config dump then search via a text editor
Trying to figure it out though
or use my mod Advanced Developer Tools, which allows config search in game (it's slow tho)
also I already showed you where it is. you don't need to search
configFile >> "RscMiniMap" >> "controlsBackground" >> "MiniMap" >> "Controls" >> "CA_MiniMap"
Yeah, I just want to learn ๐ I found the value now I think, just need to get it in right format
There we go! ``` 0:24:16 "_lastRoad: 1677718: "
0:24:16 "_scale: 0.0467415"
0:24:16 "_lookingAT: [8394.22,8105.85]"
0:24:16 "_configMiniMapSizeMin: 0.001"
0:24:16 "_configMiniMapSizeMax: 1"
well the question is is that even what you want tho? ๐

Should I normalize the scale/scale multiplier values based on the config?
before I say anything let me ask another question: what is the point of using scale anyway?
Can someone with experience using HandleDamage help me out with this? Whatever I do, my jet gets destroyed.
It is sure that the event runs.
There is always some invisible force killing the jet unknown to me after a missile hit
_jet addEventHandler ["Handledamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitindex", "_instigator", "_hitPoint"];
_aaMissiles = ["ammo_Missile_BIM9X", "ammo_Missile_AMRAAM_C", "ammo_Missile_AMRAAM_D", "ammo_Missile_AA_R73", "ammo_Missile_AA_R77", "ammo_Missile_rim116", "ammo_Missile_rim162", "M_Air_AA", "M_Air_AA_MI02", "M_Air_AA_MI06", "M_Zephyr" ];
systemChat (_projectile + " hit and dealt damage " + str _damage + ". Vehicle health is at " + str damage _unit);
if (_projectile in _aaMissiles) exitwith {
0 // Never instantly kill - require 2-4 missiles to disable jet (nerf missile damage)
};
_damage // Plane cannons should remain as effective as they are now
}];
@meager granite
as wiki says, don't use exitWith in EH codes directly
either wrap it in call {}, or return:
if (_projectile in _aaMissiles) then {
0 // Never instantly kill - require 2-4 missiles to disable jet (nerf missile damage)
} else {
_damage
}
Good question ๐ This seems to work: ```sqf
private _worldSize = worldName call BIS_fnc_mapSize;
private _scale = ctrlMapScale _ctrl;
private _dist = _scale*_worldSize/8192*250;
// ...
_toDraw = _toDraw select {
_x distance2D _lookingAT <= (_dist * (_configMiniMapSizeMax / _configMiniMapSizeMin))
};

it's wrong
interestingly instead of adding up the damage I think it "sets" the damage. For instance it's as if it's not decreasing the vehicle's health but setting it (100-> 70-> 70 and not 100 -> 70 -> 40)
does this make sense
idk what you mean
the damage you turn in handleDamage is the final damage iirc
not the added damage
Oooh
so you should return _unit getHitIndex _hitindex if you want no damage
also check if hitIndex is negative or not
or _unit getHitIndex _hitindex + (_damage/2)
_damage is the FINAL damage
Oh yeah
00:48 brain moment
heh
Hmm I got confused
how should these two look if I want to do the things in the comments
if (_projectile in _aaMissiles) then {
0 // Never instantly kill - require 2-4 missiles to disable jet (nerf missile damage)
} else {
_damage // Have the normal cannon damage
}
Still hung up on this if anyone has any suggestions ๐ค
Any closer? ๐ ```sqf
private _dist = _worldSize * (_configMiniMapSizeMax / _configMiniMapSizeMin) / _scale;
// ...
_toDraw = _toDraw select {
_x distance2D _lookingAT <= (_dist)
};
_oldDmg = if (_hitIndex < 0) then {damage _unit} else {_unit getHitIndex _hitIndex};
_deltaDmg = _damage - _oldDmg;
_oldDmg + _deltaDmg / 4;
how do you hide it?
Thank you
that's for the 0 case ofc
The 0 case?
return 0
ah
I've made it return 1/4 damage tho
require 2-4 missiles to disable jet (nerf missile damage)
I'll try to understand it brb
well log _dist. why do you just try it randomly?!
I'm sure _dist is ridiculously large now
I'm measuring it but I don't know which values I should be aiming for
Well, more than 10000 at least
I meant log it
10000 is like spanning the whole map
it makes no sense
It doesn't work if it's 10000
Does this make the code complete:
if (_projectile in _aaMissiles) then {
// Never instantly kill - require 2-4 missiles to disable jet (nerf missile damage)
_oldDmg = if (_hitindex < 0) then {
damage _unit
} else {
_unit getHitindex _hitindex
};
_deltaDmg = _damage - _oldDmg;
_oldDmg + _deltaDmg / 4;
} else {
// Have the normal plane cannon damage
_damage
}
(Nerf missiles and keep everything else such as cannons not nerfed)
again I'm talking about dist. not scale
don't confuse the 2
well it looks fine
try it
private _dist = _worldSize * (_configMiniMapSizeMin / _configMiniMapSizeMax) / _scale;
private _distMultiplied = _dist * 1000;
_toDraw = _toDraw select {
_x distance2D _lookingAT <= (_distMultiplied)
};
``` works fine now and the `_distMultiplied` stays same, but I still don't know what values should I be aiming for
(_distMultiplied is about 320k now)
If _distMultiplied is well below 100000, the script stops working. I don't have the slightest clue why ๐
then your code is wrong
you're essentially not filtering anything at all
Yes, I'm wondering the same. This is code from https://github.com/AmauryD/A3GPS btw
_distMultiplied is about 320k now
there's not much to wonder. Arma 3 maps are at most 30-50 Km wide
you say 320 Km
that's like saying anywhere on map
so I think your lookingAT is wrong
or _x is null
log the distances too
diag_log (_toDraw apply {_x distance2D _lookingAT})
and diag_log _lookingAT
// below: _toDraw apply {_x distance2D _lookingAT}
1:18:59 [769.404,790.701,813.246,837.914,862.914,887.71,912.876,937.797,960.843,984.612,1009.29,1031.68,1052.85,1067.81,1076.38,1092.26,1104.48,1113.06,1132.67,1164.07,1182.57,1197.87,1226.97,1252.35,1268.99,1286.03,1304.24,1325.39,1351.18,1379.86,1404.82,1426.66,1450.95,1476.33,1501.46,1524.97,1552.41,1578.17]
Hello everyone ! I'm trying to make a unit transmit a message over the radio. In description.ext I have this:
class CfgRadio
{
sounds[] = {apc_lost_first_1};
class apc_lost_first_1
{
name = "apc_lost_first_1";
sound[] = {"rs\apc_lost_first_1.ogg", db+0, 1.0};
title = "Oh no, it seems like we've lost one of the APCs! Try not to lose the second one.";
};
}```
my problem is, when I call
```sqf
theBoss sideRadio "apc_lost_first_1";
nothing happens ๐ฆ what am I doing wrong?
idk it looks correctish 
sounds should be empty
change volume to 1
and check if path is correct
Sorry on mobile no code things
showCommandingMenu โrscMainMenuโ;
showCommandingMenu โโ;
^use this to hide the action menu.
Tried showCommandingMenu โ#ACTIONโ; to show it and also groupRootMenu. But thats where I find you have to right click to close said menu before the action wheel becomes available again
thank you! I've done this but sadly it had no effect
I've also tried putting \ in front of the path but it did not help either ๐ฆ I wish arma would give an error message if something is wrong
Okay, that makes sense why nothing shows up,
But even using groupRootMenu, which shows something on the screen, Iโm assuming itโs encountering the same behaviour where a menu is open so the player has to close that to show the scroll wheel.
I donโt need to open the scroll wheel via script per se, but having to right click before it works is confusing to the player
Sorry if this isnโt making much sense, havenโt had my coffee yet ๐
@tender fossil What are you trying to do anyways?
With the _configMiniMapSizeMin stuff
Had a look at the code, I guess you wanted to reduce FPS impact from having GPS open?
I just spent 2 weeks squeezing as much performance out of my map Draw routine doing performance tests on each possible approach
The fastest way to select elements to draw is to position and resize a location each frame that would cover the whole control and then do inAreaArray on a list of your objects/positions with that location
Also preload and precalculate as much as possible so Draw is just a matter of iterating array of drawRectangle arrays
Tried to implement a smarter way to make GPS pathfinding algorithm work with GPS properly, it acted a bit weirdly. But it's working somewhat now
Yeah, I can imagine Draw being very expensive
There is also https://community.bistudio.com/wiki/setMarkerPolylineLocal now
So you can draw shaped lines
That's nice!
Only through markers though, no draw*
Btw, does anyone know whether it's possible to retrieve the status of the emergency/blue lights of emergency vehicles in real time? I'd like to hack together better lightning effect for them. It would be just nice to sync the light effects with the actual lights on the vehicle ๐
Like this but synchronized. It's easy to see that the difference is quite dramatic even with different lighting conditions
Check animationList for animations in vehicle's class, then check them with animationPhase
Hmm, I was looking at the configs but didn't fully understand the format. I'll try it again with your tips, thanks! ๐
neat idea
i guess this is like resizing the location to fit the shown map area on screen
Yes
private _location = _map getVariable "koth_map_location";
private _map_dir = _map getVariable ["map_dir", 0];
private _map_aim = _map ctrlMapWorldToScreen client_mapDraw_nullPosition;
if(_map_aim isNotEqualTo (_location getVariable "aim")) then {
_location setVariable ["aim", _map_aim];
ctrlPosition _map params ["_map_x", "_map_y", "_map_w", "_map_h"];
private _map_top_left = _map ctrlMapScreenToWorld [_map_x, _map_y];
private _map_bottom_left = _map ctrlMapScreenToWorld [_map_x, _map_y - _map_h];
private _map_top_right = _map ctrlMapScreenToWorld [_map_x + _map_w, _map_y];
private _map_center = _map ctrlMapScreenToWorld [_map_x + _map_w / 2, _map_y + _map_h / 2];
private _dir_vector = _map_bottom_left vectorFromTo _map_top_left;
if(_dir_vector select 0 == 0) then {
_map_dir = 0;
} else {
_map_dir = if([0,1] vectorCrossProduct _dir_vector select 2 > 0) then {
acos([0,1] vectorCos _dir_vector) - 180
} else {
180 - acos([0,1] vectorCos _dir_vector)
};
};
_map setVariable ["map_dir", _map_dir];
private _a = ((_map_top_left vectorDistance _map_top_right) / 2) + _scale * 1000;
private _b = ((_map_bottom_left vectorDistance _map_top_left) / 2) + _scale * 1000;
_location setPosition _map_center;
_location setSize [_a, _b];
_location setDirection -_map_dir;
};
Might as well just share my results
on mobile, is there any command for map similar to โworldtoscreenโ which returns [] for pos off screen
When assigning "Draw" event handler, also create a location for each map control, koth_map_location, also default aim
ctrlMapWorldToScreen
_scale * 1000 is a bit of a buffer here
This code also covers rotating GPS with R.Ctrl + ]
With new ctrlMapDir it can be cut down a bit
does it make sense for you to only eval the array every n frames and cache the result
Which array?
so you are operating on an array var for a few frames
list of stuff to draw, inareaarray result
like i only update the entities list every ~3 seconds, to save some cpu
Maybe, but i wouldn't, so load is even
fair
From my experience the most of the load with map drawing is feeding arma draw* command arrays
i think your work was why i switched to drawicon from markers, but that was like 9 years ago now ๐
I went away from markers in KotH completely, but if you can draw your wanted shape with markers, better use them instead, they're much faster than draw* commands, but limited in customisation.
Drawing the location with red rectangle and location made smaller so cutoff is more visible, works great with rotating GPS too
why?
BIS_fnc_MP in the current stable A3 version still uses publicVariableServer
Quick question - Can I use the BIS_fnc_traceBullets command on AI? I can get it to work for player, but not for AI.
Thanks man, I done it now, your the best.
{
_x switchLight "OFF";
} forEach (1 allObjects 0);
```even simplier version
Oh one more thing maybe you might know this
So the reason why I wanna shut off the lights is because I am making a horror zombies mod
Now I wanna add music, scary music that is on my desktop, how to I make it play in-game.
So I will past this in the init?
class CfgMusic
{
tracks[] = {};
class MyIntro
{
// display name
name = "My intro music";
// filename, volume, pitch
sound[] = { "\music\filename.ogg", db + 0, 1.0 };
};
class Ludwig9
{
name = "Ludwig Van Beethoven's Ninth Symphony";
sound[] = { "\music\ludwig9.ogg", db + 10, 1.0 };
};
};
No, read the beginning of the article
It works fine with AI
[unit] call BIS_fnc_traceBullets
I guess I need to also change the material somehow so alpha channel doesn't draw as black?
No, it is a model side thingy - you can't alter it

Ask and slap Dedmen kindly so he would make new shader
Wanted to recreate C&C Renegade stealth tank cloaking effect: https://www.youtube.com/watch?v=x6bDj5LhH7s
Renegade 2023 02 27 20 20 07 09
Looks pretty cool on characters with old VR material
Hm.. yep. In stable BIS_fnc_MP uses: publicvariableserver "BIS_fnc_MP_packet";
While in dev-branch: _params remoteExec [_functionName,_target,_isPersistent];
Nice ๐
{
_x switchLight "OFF";
} forEach (1 allObjects 0);
But there is a little distraction in comments on Biki page dedicated to BIS_fnc_MP
do you have a code for this this looks cool af
Its pretty complicated
Old VR material is easy though
Do setObjectMaterial with "a3\characters_f_bootcamp\data\vr_soldier_f.rvmat"
Ty very mutch for this Material looks cool af
holy cow I love it ๐
how do i convert a game_value type to something i can use in c++ after getting a return value from sqf using intercept?
right now i have some sqf that returns an array of 2d positions. now how do i get these positions out of the game_value that the __SQF macro returns?
question, when i add the "!alive "variable";" line to the set task state module to do a kill op unit mission can I put multiple variables in there like set task module to succeed, conditions " "!alive A1; !alive A2;" etc???
I want three different people to be killed under one task before its triggered complete
i don't know exactly how that module works but you should be able to connect them like this: (!alive A1) && (!alive A2);
hopefully that will fix it! a million thanks!
From scheduled scripts it should, I think newly created script should have top priority to run next frame (you could test this, have long running scheduled func logging every execution (sleep 0.00001 or smth), and then also log in newly spawned, newly spawned should log before old?)
From unscheduled, I don't know if unscheduled scripts run before or after scheduled.
std::transform is one way
Or just reserve a vector of vector2 and iterate manually over your game_value array and add them to the vector
You can convert a game value to array using to_array()
There is a helper function that we use to convert them tho
You can include it
gv.to_string() for example
or in that case I think (vector3)gv would work too
I think he means std::vector<vector2>
that's the end result i wanna have
"returns an array of 2d positions" oh 2d, well vector2 then ye
Then use one of those 3 methods
Ah no vector2 can't cast :harold:
so i can just cast the game value to vector2
nevermin
but a vector3 i could cast?
There will be some conversion function somewhere that does that for you
In that case cast to vector3 then to vector2 ๐
no I mean, can't cast from game value
as you need to convert to array, and then parse it into vector.
Mixed up with enfusion
Iirc we do have vector3 cast for game_value tho
Yeah there is __helpers::convert_to_vector
But it's not included via just #include <intercept.hpp>
Needs to be included manually iirc 
what do i need to include?
it's common_helpers.hpp
intercept::sqf::__helpers::__convert_to_vector<vector2>(return_data) so should this do everything i want?
Yes
nice
Undefined behaviour. 
wdym?
Spelling __helpers is illegal.
I didn't choose that name 
But it's for internal use, so it's ok-ish
Well it's undefined behaviour.
It means the game is frozen
@indigo snow fuckking lame >(
so it currently looks like this is returning me a bunch of [0,0] instead of my positions
show code
one second
nvm
__helpers::__convert_to_vector<vector3>(ret); this is the correct
nvm that is same as what you have ๐
std::vector<vector2> returnArray = intercept::sqf::__helpers::__convert_to_vector<vector2>(return_data);
auto_array arr = return_data.to_array();
std::vector<vector2> returnArray2 = {};
for (game_value p : arr) {
auto_array arr2 = p.to_array();
returnArray2.push_back(vector2(p[0], p[1]));
}
```
after this, returnArray contains 10 times (0,0) and returnArray2 contains the right values
Oki i was indded wrong before, game value has conversion operator to vector2 ๐
Well convert to vector seems to do basically the exact same
https://github.com/intercept/intercept/blob/0c2375b2e9fb32fa518da7d014477c7c8b6e4a2b/src/client/headers/client/sqf/common_helpers.hpp#L87
https://github.com/intercept/intercept/blob/cf6c17afb2e80a79db987966942b22234a29015f/src/client/intercept/shared/types.cpp#L646
BUT, it will fail if the arrays have more than 2 elements
so if your p has more than 2 elements, the convert_to_vector will return default (0,0) vectors
wait
auto_array arr = return_data.to_array();
also this code is bad, should be
auto_array& arr = return_data.to_array();
your code will copy the whole array on that assignment
your code would be more failsafe then, the helper is designed to implement SQF command wrappers and these usually return the proper things
i need to properly learn how pointers and such work
Hey there, if I use a std::cout in an extension and run it in client, will it show in rpt? If not, is there a way to open a console that arma is using? 
no, no
you can use OutputDebugString to show it inside your debugger's log
Can I have a debugger connected to the arma porcess? 
Or, the extension once it's running
yes
(99% of work I do is with g++ and gdb on linux, windows is new territory for me)
Is there a tutorial somewhere? 
Visual studio - Debug - Attach to Process
wonderful, will give it a go, thanks!
Wow, it actually works. Could have made my life way easier when I was creating it for linux long time ago 
im struggling to figure out something - once I put a display onto a texture, how can I later access with scripts so I can force an update?
I gave it an unique name in the procedural texture, but I dont think there are any scripting commands that allow me to reference this display by it
returns "no display"
The display is created the first time the texture is rendered
So you cannot immediately get it the same frame you set the texture
If you're using a custom display, you can also use a onLoad eventhandler on that
Im many many frames after creating it
๐ค
does it matter that it comes from description.ext ?
no
findDisplay, the one with string yes?
The wiki page is a bit unclear, the name thing doesn't work on non-texture I think (or does it? I could've done it don't remember)
Yeah I tried:
findDisplay 42069 which is the idd
findDisplay "RscDisplayCustomMap" which is the temporary class name
findDisplay "abc2" which is the temporary identifier specified in the texture
the last one would be the correct
hmm
they all return No Display
okay
I guess it really didn't like the name abc2
I restarted the mission with a new identifier called xdd and it works
Hi, i have a question ? Is it possible to detect which waypoints are completed ? Because the "waypoints _unit" command return every waypoints and completed waypoints aren't removed.
The wps before currentWaypoint would be completed.
ah ok thank you
The sure way is onLoad event handler. You have to create a hashmap to pass arguments to a display.
argumentsHashMap = createHashMap;
_obj setObjectTextures [0, "#(rgb,1024,512,1)ui('Texture_Laptop2x1','sometexturedisplay','ca')"];
argumentsHashMap set ["sometexturedisplay", ["anything","you","need"]];
then in onLoad do
params ["_display"];
private _my_name = displayUniqueName _display;
private _arguments = argumentsHashMap get _my_name; // ["anything","you","need"]
And do everything you need in that onLoad
Are we allowed to post GitHub links here? I want to self reply for anybody in the future searching for the same problem.
Sure
The BIS_fnc_MP function is scheduled for A3 1.54 to be changed to a proxy for the new system to provide backwards compability to missions still using BIS_fnc_MP.
It is indeed possible using the right display IDs. Use code below to find the display. Depending on the type (Briefing, Ingame, Zeus, TeamSwitch) may have to get crafty using spawn and sleep. See your RPT logs in C:\Users\YOU\AppData\Local\Arma 3
{
private _display = _x;
{
diag_log [_display, _x, ctrlType _x];
} forEach allControls _display;
} forEach allDisplays;
//https://community.bistudio.com/wiki/Arma_3:_IDD_List
//https://community.bistudio.com/wiki/Arma:_GUI_Configuration - 101 = main map
//https://github.com/Tek191/Teks-APP6-Markers Example of application
Much thanks again Sa-Matra, your reply did lead me down the right path.
When can an EH "HandleDamage" _instigator be "Error: No Vehicle"?
Right now when host kills client, the clients EH reproduces the behavior above.
When Client kills host, all is good.
This behavior is only seen when client player is in a vehicle
Problem fixed:
if (isNull _instigator) then {
_instigator = driver _source;
};
thanks
Arma is going to drive me insane, fr. I've spent 4 hours on trying to solve this problem and nothing worked so far.
So, let's say I have this in my missions description.ext:
class CfgSounds
{
sounds[] = {};
class ApcLostFirst
{
name = "ApcLostFirst";
sound[] = {"rs\ApcLostFirst.ogg", 300, 1};
titles[] = {0,""};
};
};```
I then call this:
```sqf
theBoss say3D [ "ApcLostFirst", 30, 1]
and it works just fine, the file rs\ApcLostFirst.ogg gets played as intended.
However. When I change my description.ext to this:
class CfgRadio
{
sounds[] = {};
class ApcLostFirst
{
name = "ApcLostFirst";
sound[] = {"rs\ApcLostFirst.ogg", db+0, 1};
title = "Oh no, it seems like we've lost one of the APCs! Try not to lose the second one.";
};
};```
(note that it is referring to literally the same .ogg file)
and try to make the AI say stuff using this:
```sqf
theBoss sideRadio "ApcLostFirst";
nothing happens.. just nothing, no error messages, no complaints, the dude just standing still without saying anything ๐ญ
I feel like I've tried everything, different .ogg settings, different mission files (created an empty mission just to test this), different naming conventions for classes/sound files, putting sounds in different folders, etc
so you said you tried using a number instead of db+0?
in your CfgSounds you've put 300 for volume (it's capped at 5 tho). well try that here too
welp, as it usually happens I found the solution 3 minutes after desperately posting for help.
I'm a dumbass and I forgot to give the player a radio
ah right ๐
Tbh I'm kinda disappointed how sideRadio worked. I was expecting the game to apply a radio filter for the sound file, as well as make the unit move it's lips
In vanilla campaign NPCs have this cool ability to speak directly when close (unfiltered) but when you move away they switch to radio (and "radio" filter gets applied to the sound)
My expected behavior for sideRadio was that when close the player would still hear the NPC directly even if player does not have a radio
there was another command that did this iirc
I think it was kb stuff
Yeah I've glanced on the whole Conversation system but I feel like that's an overkill for my purposes. I just want an AI unit to say a few sentences for brief/debrief, no dialog intended.
it's not that difficult tbh. and you can make a single bikb file and play pretty much anything with it
something like this: (radio.bikb)
class Sentences
{
class Radio
{
text = "%1%2%3%4%5%6%7%8%9%10";
speech[] = {"XMIT","%1","%2","%3","%4","%5","%6","%7","%8","%9","%10"};
class Arguments {};
};
class Say
{
text = "%1%2%3%4%5%6%7%8%9%10";
speech[] = {"%1","%2","%3","%4","%5","%6","%7","%8","%9","%10"};
class Arguments {};
};
};
class Arguments{};
class Special{};
startWithVocal[] = {hour};
startWithConsonant[] = {europe, university};
actually I think I use them with Words
not CfgSounds
nope I use them with sound paths
_tellArr = [_unit2, "Radio", "radio"];
{
_tellArr pushBack [str (1 + _forEachIndex), {}, _x#0 + " ", [_x#1]];
} forEach [
["Example word", "path\file.ogg"],
... // more stuff; up to 10 files are supported
];
_tellArr pushBack _isRadio;
_unit1 kbTell _tellArr;
@frozen seal ^
you also need to use kbAddTopic once for all receivers speakers:
player kbAddTopic ["Radio", "radio.bikb"];
AI kbAddTopic ["Radio", "radio.bikb"];
oh god this is dark magic.
Arma scripting is truly one of experiences of all time.
Gimme a sec to think this through.
does this work well in multiplayer? Can I use it to make an AI goon give us a briefing?
well according to biki it has global effect (local arg tho) so yes, you probably don't need to do much to make it MP compatible
this one is local arg and local effect so it needs remoteExec
Can I pass whole sentences instead of a single "Example Word"?
example word is just the "title" for the file.ogg sound
that's how I modified the code for my test, not working sadly ๐ฆ
_tellArr = [theBoss, "Radio", "radio"];
{
_tellArr pushBack [str (1 + _forEachIndex), {}, _x#0 + " ", [_x#1]];
} forEach [
["Oh no, it seems like we've lost one of the APCs! Try not to lose the second one.", "rs\ApcLostFirst.ogg"],
["God dammit, we've lost the second APC. Dang! Those would have been valuable assets.", "rs\ApcLostSecond1.ogg"],
["Uhm.. alright, try to make your way out of there. We'll get them another time.", "rs\ApcLostSecond2.ogg"]
];
player kbAddTopic ["Radio", "radio.bikb"];
theBoss kbAddTopic ["Radio", "radio.bikb"];
_tellArr pushBack true;
theBoss kbTell _tellArr;
oh
yep like that
wait my paths are wrong, brb
if you're sure they're correct, try getMissionPath "rs\ApcLostFirst.ogg" instead
some stuff in Arma need absolute paths
be sure to add radio.bikb to the mission folder too
yeah I did that, no luck so far though. Fixing the path did not help, the dude just stays silent
hmm
_tellArr = [theBoss, "Radio", "radio"];
{
_tellArr pushBack [str (1 + _forEachIndex), {}, _x#0 + " ", [_x#1]];
} forEach [
["AAA", "ApcLostFirst.ogg"],
["BBB", "ApcLostSecond1.ogg"],
["CCC", "ApcLostSecond2.ogg"]
];
_tellArr pushBack true;
player kbAddTopic ["Radio", "radio.bikb"];
theBoss kbAddTopic ["Radio", "radio.bikb"];
theBoss kbTell _tellArr;
that's my current version
did you try this?
and the mission folder
yes
oh wait I think the script might not be starting wtf
brb
Can I setDamage to player 1 from player 2's name as if p2 shot p1? (so p2 is accessible in handleDamage of p1)
yeah it does start, just not working T_T
I wish arma was more verbose when it does not like something
iirc there was a new syntax of set damage or something that had this
not even the subtitles?
also do both units have radio?
ok so by replacing
_tellArr pushBack true;
with
_tellArr pushBack false;
I'm able to get subtitles. No audio though.
try getMissionpath again
how to do an instant black screen?
is 1 frame delay ok?
tried various cutText, cutRsc, cutTitle with different timings
even with isNil {code}
i take all i can get
well you can use RscTitles
or just create a control on display 46 
_ctrl = findDisplay 46 ctrlCreate ["RscPicture", 1234];
_ctrl ctrlSetPosition [safeZoneX, safeZoneY, safeZoneW, safeZoneH];
_ctrl ctrlCommit 0;
_ctrl ctrlSetText "#(rgb,8,8,3)color(0,0,0,1)";
fixed a mistake
(it should be rgb not rgba)
RscTitles doesnt seem to have one yet. let me try the ctrlCreate
OK I think I figured it out! Here is the final code:
_tellArr = [player, "Radio", "radio"];
{
_tellArr pushBack [str (1 + _forEachIndex), {}, _x#0 + " ", [_x#1]];
} forEach [
["AAA", "\ApcLostFirst.ogg"],
["BBB", "\ApcLostSecond1.ogg"],
["CCC", "\ApcLostSecond2.ogg"]
];
_tellArr pushBack true;
player kbAddTopic ["Radio", "radio.bikb"];
theBoss kbAddTopic ["Radio", "radio.bikb"];
theBoss kbTell _tellArr;
My first mistake was that I set the speaker as the first value in _tellArr instead of the player.
The second mistake was that I did not have \ in front of the sound file name.
Thank you ๐
does it work now?
it does, at least in SP.
All sentences get crumpled together into a single subtitle text but I'll work this out
I mean the sound
I'll also need to check if it works in MP but I'll do that a bit later
yes
yeah like I said they're more like "words"
you can use kbTell 3 times instead
it should play them in sequence
also make sure you run kbAddTopic once per unit. iirc it gets buggy if you run it multiple times
so it should be in init.sqf or initPlayerLocal.sqf
thx man I appreciate it. Once I get to implement this in MP I'll do that
not bad. however at he mission end still need to combine with a cut effect as the debriefing kills the control and you no longer have black screen during debrief ๐
try findDisplay 0 instead 
I think I might be done for today, learning arma scripting is such a mindf*** that it should be taken in small dosages ๐
actually no it won't work
it's at the back
it seems BIS_fnc_playVideo is affected by scheduling or the video rendering itself/control handling - aka the video may start 0.5-1.5s late
any workaround to that then rewriting the function to work in unscheduled?
does not, won't
im trying to make a script that spawns a rocket, it flies to a target, and explodes.
This is what I managed to get:
Hint "Ready";
Sleep 1;
// Set the position of the building and the rocket source
Target_1 = missionNamespace getVariable ["Target_1", objNull];
Rocket_Source = missionNamespace getVariable ["Rocket_Source", objNull];
// Check that both the building and rocket source are valid objects
if (!isNull Target_1 && !isNull Rocket_Source) then {
// Spawn the rocket at the source
Rocket = "R_PG32V_F" createVehicle (getPos Rocket_Source);
// Set the velocity of the rocket
Rocket setVelocity [55, 25, 150];
// Fire the rocket towards the building
Rocket doTarget Target_1;
// Wait for the rocket to reach the building and explode
waitUntil {Rocket distance Target_1 < 2};
Rocket setDamage 1;
};
but it just spawns a rocket, it lies forward, and explodes. No real direction control. How many I solve this?
Hi, i made a little script that can move soldiers directly with animations so you can order what you want and the soldiers will go where you want and it's working fine but i have a problem. Sometimes when i order to all units in a group to go somewhere, when the units are arrived, some units are going back. See the following video to understand : https://www.youtube.com/watch?v=km951M82gDg
Is there a way to avoid this problem ? Because this AI is not going to a random position, i think it's the last position they had but actually i tried almost every commands to stop it but it's not working. I tried "doStop, moveTo, setDestination" and i'm not even able to know the position where the AI is going on. I tried "ExpectedDestination" and i thought it was that but it wasn't.
Is it possible to use kbWasSaid with this approach? I want to have something like this:
shaftoe kbTell [miles, "briefing", "shaftoe_briefing_H_1"];
waitUntil { shaftoe kbWasSaid [miles, "briefing", "shaftoe_briefing_H_1", 3]; };
but I struggle to understand what should I pass to kbWasSaid in our particular case
doTarget works on AI, not on rockets
you created the rocket
set it a vectorDir/vectorUp (or just a dir)
set it a velocity
let it fly
it's the "unstick" feature of vanilla AI (if it thinks it's stuck it jumps back to last position before being stuck)
you can't disable it
there are KB event handlers
oh ok but i have a question ? Because actually it was jumping back but now i put them in "Careless" before disabling the AI and it seems to work but actually as you can see it's not "Teleporting" but they are moving
do you think it's still the same thing ?
this worked for me so far:
_getTellArray = {
params ["_receiver", "_fileName", "_subtitle"];
_array = [_receiver, "Radio", "radio", ["1", {}, _subtitle, [_fileName]], true];
_array
};
_getWasSaidArray = {
params ["_receiver", "_waitLength"];
_array = [_receiver, "Radio", "radio", _waitLength];
_array
};
operator1 kbAddTopic ["Radio", "radio.bikb"];
theBoss kbAddTopic ["Radio", "radio.bikb"];
_tellSub = "Oh no, it seems like we've lost one of the APCs! Try not to lose the second one.";
_tellArr = [operator1, "\ApcLostFirst.ogg", _tellSub] call _getTellArray;
theBoss kbTell _tellArr;
_tellSub = "Yeah boss we lost that one... I'll try to make sure the second one is fine.";
_tellArr = [theBoss, "\ApcLostResponse.ogg", _tellSub] call _getTellArray;
operator1 kbTell _tellArr;
_waitTime = 10;
_waitArray = [theBoss, _waitTime] call _getWasSaidArray;
waitUntil { operator1 kbWasSaid _waitArray; };
sleep _waitTime;
hint "keep talking";
not concerned with MP yet though so probably will redo this
idk
ok and this feature is available for everyone or only the units in a group except the leader ? Because one time everyone was doing this except the leader
idk
then it's really sad to see that this system is impossible to change
i will ask my last question even if i probably already know the answer, Is it possible to get the last position of the unit ? I mean where the unit is going to ?
expectedDestination
ah ok but i tried with the unit you can see in the video and the point i got with "expectedDestination" was far from the real point
i tried for an other unit and it was the good position but for the unit in the video it wasn't
there is playerCountMultipleOf in https://community.bistudio.com/wiki/Description.ext#header that could, perhaps, eventually allow to help setting up people in the proper slots when joining
but nothing to prevent them from switching
this is why I say "perhaps"; I just re-re-added this setting after reading 2018 conversations, because this setting may still be used (only for unit assignment, at one point it was believed to be used as bandwith/maxplayer server definition)
the default value is 2 anyway, sooo
@velvet merlin
"MyLayer" cutText ["", "BLACK", 1e-6];
I don't even know what to ask for ๐ค
Changing rvmats with setObjectMaterial doesn't help, so I guess its some model face property that lets engine use texture's alpha channel
anyone familiar with the difference between say3D and playSound3D besides the local/global execution?
Anyone know if you can get the current map zoom value?
Thank you very much
Is there a way to get the volume of a player when he talks via voice channel? Or is this impossible?
https://community.bistudio.com/wiki/getPlayerVoNVolume
However this is not a direct getter for the volume of their microphone
If this doesn't fits into your usage, there's none
Hmm that unfortunately doesn't work for what I intended to do.
I wanted to create an progress bar which constantly displays how loud a player is speaking
I do not think there is a way, unfortunately
๐ข
Are EventHandlers always unscheduled no matter what?
Hi, I am trying to create a teleport script for the plyer. Map click teleports player to location. This is what I have so far but it does not work. Any advice?
yes, engine eventhandlers are (scripted may not)
_tpStart = openMap [true,false];
hintc "Left click on the map where you want to be teleported";
_plr = _this select 0;
["teleportClick", "onMapSingleClick",
{
private _pos = [];
mapPosition = []; // use global to get the variable from `onMapSingleClick`
_pos = mapPosition; // store it
hint "";
_this setPos _pos;
openmap [false,false];
["teleportClick", "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
},_plr] call BIS_fnc_addStackedEventHandler;
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
also
The following information is obsolete as of Arma 3 v1.58. Reason: Arma 3: Mission Event Handlers should be used instead.
https://community.bistudio.com/wiki/BIS_fnc_addStackedEventHandler
What if the object addEventHandler-function is executed within a spawned script?
addEventHandler doesn't execute the handler
First step, readable code
params ["_player"];
_tpStart = openMap [true,false];
hintC "Left click on the map where you want to be teleported";
["teleportClick", "onMapSingleClick",
{
params ["_player"];
private _pos = [];
mapPosition = []; // use global to get the variable from onMapSingleClick
_pos = mapPosition; // store it
hint "";
_player setPos _pos;
openMap [false,false];
["teleportClick", "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
},_player] call BIS_fnc_addStackedEventHandler;
no i mean when it's added
also sqf private _pos = []; mapPosition = []; // use global to get the variable from `onMapSingleClick` _pos = mapPosition; // store it doesn't really make much sense
addEventHandler doesn't execute code
This is written inside a spawned script:
private ["_group", "_isGroupEmpty"];
_group = _this select 0;
_isGroupEmpty = _this select 1;
_group setVariable ["_isGroupEmpty", true, true];
_group removeEventHandler [_thisEvent, _thisEventHandler];
Unit_Observer sideChat "EventHandler has been executed!";
}];```
Second step, remove nonsense and properly get parameters
params ["_player"];
_tpStart = openMap [true,false];
hintC "Left click on the map where you want to be teleported";
["teleportClick", "onMapSingleClick",
{
params ["_units", "_pos", "_alt", "_shift", "_player"];
hintSilent "";
_player setPos _pos;
openMap [false,false];
["teleportClick", "onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
}, _player] call BIS_fnc_addStackedEventHandler;
Third step, don't use obsolete/deprecated methods
params ["_player"];
openMap [true,false];
hintC "Left click on the map where you want to be teleported";
addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
_thisArgs params ["_player"];
hintSilent "";
_player setPos _pos;
openMap [false,false];
removeMissionEventHandler ["MapSingleClick", _thisEventHandler ]
}, _player];
Fourth step, comments
params ["_player"];
openMap [true,false]; // Force open the map
hintC "Left click on the map where you want to be teleported"; // Usage instructions
addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
_thisArgs params ["_player"];
hintSilent ""; // Hide the usage instruction if its still on screen
_player setPos _pos; // Teleport player
openMap [false,false]; // Close map
removeMissionEventHandler ["MapSingleClick", _thisEventHandler] // Remove handler so that next map click doesn't trigger teleport again
}, _player];
Yes again, addEventHandler doesn't execute the script, where that is done has no influence on how its executing
alright, just wondering why it has such big delay before running
Also what even is that question.
First you ask if unscheduled no matter what, I say yes.
Then you ask "but what if"
You already answered that question when you asked "no matter what"
It runs when the event happens
If it happens later, it runs later
that's exactly what i needed to know, thanks
as i said... i was just wondering about the delay, and i did not provide the information beforehand, could have been the case you needed that, anyway, thanks for help...
yeah, delay between actual click and event firing is very noticeable
I recommend always asking the question you want to ask.
Instead of thinking of a possible reason, and then asking a question about that possible reason that seems total nonsense to anyone who would know the answer to the real question you had in the first place
Thank you very much for your detailed explanation. This helps me a lot to learn. I am now thinking how I could make it work for the player + player's squad?
The only line you need to change is _player setPos _pos; // Teleport player
You have the player and the target position.
You can get all the units in the players group using the https://community.bistudio.com/wiki/units command
Then you can use https://community.bistudio.com/wiki/forEach to iterate through these units, and set each of the units position
params ["_grp"];
openMap [true,false]; // Force open the map
hintC "Left click on the map where you want to be teleported"; // Usage instructions
addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
_grp = [units player];
_thisArgs params ["_player"];
hintSilent ""; // Hide the usage instruction if its still on screen
_grp setPos _pos; // Teleport player
openMap [false,false]; // Close map
removeMissionEventHandler ["MapSingleClick", _thisEventHandler] // Remove handler so that next map click doesn't trigger teleport again
}] forEach units player;
I thought this could work but I guess I am doing something wrong
Yes, sir. Note to myself: There is no reason for Dedmen to think twice about anything. Any answer provided is ultimate, like the 10 commandments are. Or the Georgia Guidestones.
I gave you the steps you need
You have no forEach, so yes you're doing something wrong.
_grp = [units player];
this will result in essentially
_grp = [[player, otherPlayer, otherPlayer2, otherPlayer3]];
_grp setPos _pos;
you are passing an array to setPos
https://community.bistudio.com/wiki/setPos
Wiki page says setPos only takes object, it only takes a single object, you cannot pass multiple things at once
!quote 5
stop using 'setPos' for the love of god
Leopard20; Tuesday, 10 August 2021
Probably not very elegant but I made it work with this code:
params ["_player"];
openMap [true,false]; // Force open the map
hintC "Left click on the map where you want to be teleported"; // Usage instructions
addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
_thisArgs params ["_player"];
hintSilent ""; // Hide the usage instruction if its still on screen
player setPos _pos; // Teleport player
_resetPosition = getPos player;
{
_x setPos _resetPosition;
sleep 0.2;
}forEach units group player;
openMap [false,false]; // Close map
removeMissionEventHandler ["MapSingleClick", _thisEventHandler] // Remove handler so that next map click doesn't trigger teleport again
}, _player];
The sleep won't work
player setPos _pos; // Teleport player _resetPosition = getPos player;
This code doesn't make sense.
You set the players position to _pos, why would you get the position again? you just put the player at _pos, and getPos will return the players position, so you already know what _resetPosition will be.
You can get rid of that and just use _pos
units group player
You don't need the group command in there. If you read the units wiki page, it says it will take the unit itself
Sleep doesn't work, because eventhandlers are "unscheduled" that means the game freezes until the code has finished. For safety reasons the game blocks sleep as it would do essentially nothing but freeze your game.
Do you really want to have a pause between each teleportation? (I personally wouldn't, because for that time you also force the player initiating the teleportation to stay stuck on map screen)
Understood, thank you Dedmen. I will try to make the recommended changes. Your explanations helped me a lot!
Two other questions completed unrelated. What are the script commands to set the view into first person and switch to thermo view (2nd option of night vision) while using a uav drone?
Thank you
setCamUseTI is only for script-created virtual cameras and doesn't work on real vic/unit cams
I swear there was another one for use with real cams but I can't find it right now
I also wonder how to switch camera on a dater? It works with the player but not sure how to do it with a darter.
While being connected via UAV terminal
player has a keyboard, there are UI inputs for this
_darter switchCamera "INTERNAL" should do it
Or "GUNNER"
Possibly gunner _darter switchCamera ...
cutText ["", "BLACK OUT"];
sleep 1.5;
titleText ["Scouting the area. Launching recon drone.","PLAIN",1];
myUAV = createVehicle ["B_UAV_01_F", getPosWorld player, [], 0, "FLY"];
_grp = createVehicleCrew myUAV;
myUAV setUnitTrait ["audibleCoef", 0];
myUAV setUnitTrait ["camouflageCoef", 0];
{_x setCaptive true} forEach crew myUAV;
player connectTerminalToUAV myUAV;
player action ["Switchtouavgunner", getconnecteduav player];
myUAV addAction ["Destroy Drone!", {
player connectTerminalToUav objNull;
deleteVehicle getConnectedUAV player;
deleteVehicle myUAV;
player switchCamera "External";
},nil,1.5,false];
myUAV switchCamera "INTERNAL";
true setCamUseTI 0;
myUAV addAction ["Start Loiter!", {
_grp = createVehicleCrew myUAV;
_wp = _grp addwaypoint [getPosWorld player, -1];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterRadius 50;
},nil,1.5,false];
sleep 1.5;
cutText ["", "BLACK IN"];
Got it sort of working but somehow the mouse becomes unresponsive as soon as the cam switched into the darter.
My aim is to spawn the darter -> auto switch into turret position in first person view -> auto enable thermo view.
how do you change the light color of PortableHelipadLight_01_green_F for example? i tried setLightColor
the "green" might indicate that its green only
You can't through a script
Probably not. Most model/config lights are not controllable through script.
If you want to brighten it, you can create your own lightpoint in the same position
ok
another question, the PortableHelipadLight_01_red_F can be pushed around, is there anyway to prevent that?
like disable simulation or something
I mean yes, enableSimulation. But you could also attach it to something.
hmm
What about setMass
simulation is the way to go.
yea less work for the CPU
The only concern I have is whether turning off simulation will stop it flashing
Easy to test though
ah flashing? it will prevent that, I believe
oh thats not good
attachTo then, if the simulation of the object to which it is attached is not tooโฆ infrequent
that too stops the blinking
attachTo? try attaching it to the player?
that works ๐
so attach it to something that has a simulationโฆ or enjoy the blinking :p
Does anyone know whether setDamage (new syntax) triggers the HandleDamage EH?
It doesn't say in the wiki
closest thing is: it will be listed as _instigator parameter in the Killed event handler
please try and report so I can write it there
I'll make a test scenario
Although my word shouldn't be taken as a fact as I started writing SQF for the first time 2 weeks ago hehe
Hello, I have been trying to make a script that apon activation spawns an AI and then asks it to fire at a target.
This doesn't seem to work however, no matter how many times I try to correct it. Any ideas?
_grp3 doTarget "Target_1";
_grp3 doFire "Target_1";
What am I doing wrong here. Neither systemChat is getting written. The code is placed in a gamelogic module
instigatorUnit addAction ["Damage Victim (0.25)", {
_unitDamage = damage victimUnit;
victimUnit setDamage [_unitDamage + 0.25, true, instigatorUnit, instigatorUnit];
}];
victimUnit addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];
["Victim unit got hit by " + name _instigator]remoteExec["systemChat", 0]
}];
victimUnit addMPEventHandler ["MPKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
["Victim unit got killed by " + name _killer]remoteExec["systemChat", 0]
}];
(same without remoteExec)
|| ```sqf
instigatorUnit addAction ["Damage Victim (0.25)", {
_unitDamage = damage victimUnit;
victimUnit setDamage [_unitDamage + 0.25, true, instigatorUnit, instigatorUnit];
}];
victimUnit addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];
systemChat "Victim unit got hit by " + name _instigator;
}];
victimUnit addMPEventHandler ["MPKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
systemChat "Victim unit got killed by " + name _killer;
}];
addAction works fine
And the unit gets damaged
ah you're right
1 sec
I tested with this code and it "HandleDamage" EH is not getting called
instigatorUnit addAction ["Damage Victim (0.25)", {
_unitDamage = damage victimUnit;
victimUnit setDamage [_unitDamage + 0.25, true, instigatorUnit, instigatorUnit];
}];
victimUnit addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];
systemChat ("Victim unit got hit by " + name _instigator);
[("Victim unit got hit by " + name _instigator)] remoteExec ["systemChat", 0];
}];
victimUnit addMPEventHandler ["MPKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
systemChat ("Victim unit got killed by " + name _killer);
[("Victim unit got killed by " + name _killer)] remoteExec ["systemChat", 0];
}];
Killed event works fine
I will send you the mission file in DM in a minute
@winter rose
so we have the answer
Is your target variable name "Target_1", or just Target_1.
I bet you have Target_1,
So you need take quotes away from "Target_1"
When I do I get
For context I think I should mention the whole script, even if its just that part that seems to break.
Hint "Ready";
Sleep 1;
_grp1 = [getMarkerPos "Enemy_Spawn_1", east, ["OPTRE_Ins_ER_Insurgent_BR", "OPTRE_Ins_ER_Deserter_GL","OPTRE_Ins_ER_Farmer","OPTRE_Ins_ER_Hacker","OPTRE_Ins_ER_Militia_MG","OPTRE_Ins_ER_Guerilla_AR"],0] call BIS_fnc_spawnGroup;
_wpt1 = _grp1 addWaypoint [getMarkerPos "Hostile_Move_1",5];
_wpt1 setWaypointType "MOVE";
_wpt1 setWaypointBehaviour "COMBAT";
//second gorup
_grp2 = [getMarkerPos "Enemy_Spawn_2", east, ["OPTRE_Ins_ER_Insurgent_BR", "OPTRE_Ins_ER_Deserter_GL","OPTRE_Ins_ER_Farmer","OPTRE_Ins_ER_Hacker","OPTRE_Ins_ER_Militia_MG","OPTRE_Ins_ER_Guerilla_AR"],0] call BIS_fnc_spawnGroup;
_wpt1 = _grp2 addWaypoint [getMarkerPos "Hostile_Move_1",5];
_wpt1 setWaypointType "MOVE";
_wpt1 setWaypointBehaviour "COMBAT";
//third Group
_grp3 = [getMarkerPos "MG_Spawn_1", east, ["OPTRE_Ins_ER_Insurgent_BR"], 0] call BIS_fnc_spawnGroup;
_grp3 doTarget Target_1;
_grp3 doFire Target_1;
meaning line 25 should be
_grp3 doTarget Target_1;
The error tells you the problem: Type Group, expected Array,Object
The left argument for doTarget must be an Array or Object, you are passing it a Group which it does not support
So the shooter should be a object?
or im guessing it should be referencing a singular unit
cuz the target is a signpost
https://community.bistudio.com/wiki/doTarget
Syntax: unit doTarget target
Parameters: unit: Object or Array - a single unit or array of units
You are passing Group see Return value here. https://community.bistudio.com/wiki/BIS_fnc_spawnGroup And you need to pass Object or Array of Units.
alright
I havent been able how to figure out it making a single unit and just giving that a variable name in another way than a group with just a single member
so how would I do this in compression to the way I did now?
How would I write this in a way where it spawns a single unit and gives a name to it?
private _group = createGroup east;
private _unit = _group createUnit ["OPTRE_Ins_ER_Insurgent_BR",getMarkerPos "MG_Spawn_1",[],0,"CAN_COLLIDE"];
_unit doTarget target_1;
_unit doFire target_1;```
BIS_fnc_spawnGroup is designed to spawn an entire group, so it returns a reference to the group. If you want a single unit, just create...a single unit.
Note: you can also use units to return an array of all the units in the group, which is an acceptable argument for doTarget. That would work with your existing script.
okay new question
I have made it work by changing dofire with doSuppressiveFire
how may I now spawn a 2nd enemy who will do the same thing with a target named Target_2?
cuz I tried adding numbers at the end of the _unit and _group to difference the 2 but no ball
//Gunner 1
private _group1 = createGroup east;
private _unit1 = _group1 createUnit ["OPTRE_Ins_ER_Militia_MG",getMarkerPos "MG_Spawn_1",[],0,"CAN_COLLIDE"];
_unit1 doTarget target_1;
_unit1 doSuppressiveFire target_1;
//Gunner 2
private _group2 = createGroup east;
private _unit2 = _group2 createUnit ["OPTRE_Ins_ER_Militia_MG",getMarkerPos "MG_Spawn_2",[],0,"CAN_COLLIDE"];
_unit2 doTarget target_2;
_unit2 doSuppressiveFire target_2;```
the original unit does it like he should but the 2nd one is just idle
Did you remember to create a target_2 for him to shoot at?
Then I don't know. Once you've changed the variables appropriately, as you have, there's nothing in the code that makes it only work for the first unit. It should work fine.
I have the following problem:
I have a working kill/teamkill/assist system - "HandleDamage" EH is attached to each player unit (not his vehicle).
The "HandleDamage" EH is not triggered when the vehicle is hit and the player is not. This causes assists to not work when only the vehicle is damaged.
I need a way to "copy" damage ||(and lower it so much so it doesn't practically hurt the player)|| (or call the player "HandleDamage" EH) from the vehicle to the player so it associates the _instigator with the person who is shooting at the vehicle.
Current situation:
P1 and P2 are both flying jets.
P1 hits once P2 and damages his jet (no damage to P2 dealt).
P2's "HandleDamage" EH is not activated, because the damage is only dealt to the vehicle. I need it to activate for my other code to work
Perfect case:
P1 and P2 are both flying jets.
P1 hits once P2 and damages his jet (no damage to P2 dealt).
P2's "HandleDamage" EH is activated.
Q&A
"Why would you want to activate a player's "HandleDamage" EH when the JET is hit?"
- Because it currently adds the
_instigatorto P2'sassistersarray. When P2 crashes due to critical damage, allassistersshould get notified for "Kill assist".
Note: System currently works perfectly for players (infantry) on the ground.
hu, now I got it to work
after making some minor changes
and moving the target slightly
well whatever
If all these enemies are going to do is stand there and do suppression, you can probably reuse the same group instead of creating a new one (there is a limit on the number of groups that can exist, so it's good to save them where possible). Just remember to disable the units' pathing so they stay in their positions instead of trying to get in formation.
LDR_fnc_attachAssisters:
params ["_newEntity"];
_newEntity setVariable ["assisters", []];
["EH Handledamage ATTACHED to " + name _newEntity] remoteExec ["systemChat", 0];
_newEntity addEventHandler ["Handledamage",
{
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitindex", "_instigator", "_hitPoint"];
if (isNull _instigator) then {
_instigator = driver _source;
};
["#Killer is " + name _lastShooter] remoteExec ["systemChat", 0];
_unit setVariable ["lastShooter", _instigator, true];
(_unit getVariable "assisters") pushBackUnique _instigator;
_assisters = _unit getVariable "assisters";
_lastShooter = _unit getVariable "lastShooter";
["$ON HIT #Assists: " + str (_assisters apply {
name _x
}) + "#Killer is " + name _lastShooter] remoteExec ["systemChat", 0];
_damage
}];
_newEntity setVariable ["passedThatHandledamage", true, true];
Why not add handleDamage EH on the jets as well? You can still save the instigators to the pilot's records, using driver.
add HandleDamage EHs from "GetInMan" EH ๐ง
Thanks for the reply. Will think on that now
Anybody got some ideas on how to find objects placed in 3DEN, based on a keyword, and return all of them with matching keyword in any substring in their respective variablename-Strings to an object collection?
there is search fields. left and right
Of course, but I am not asking about the UI!
if you're placing them in 3den and need to use them in scripts later, i'd advise you to just save them to a layer https://community.bistudio.com/wiki/getMissionLayerEntities, or otherwise add them to an array already.
Yes... I want to add them to an array, doing that by hand works fine. Now only specific ones, and automatically by function, using the "find" command trying to "find" matches by their names from (allVariables missionNamespace) and do further processing does not.
is there a way to get your own owner id on the client without asking the server?
or whatever is ur extension
where u run the code?
hmm
can u get the vanilla flags working? try "flag_NATO.paa"
weird
(owner vehicle player)
maybe it doesnt support texture change
Try it in debug console too
owner player might work too
Texture commands sometimes don't work in init fields
it always returns 0 on the client at least according to the wiki
why do you need to "find" by the variable name string?
I am writing a module, nothing fancy. However, I want it to look up for any target objects of interest automatically instead of providing them by hand in the code with every new mission.
oh shit, that's right
Run the mission in editor then pause the game
yeah it's not that easy mate ;D
ah, and you're designating PoIs using sub strings in the variable name.
You could add all PoI objects to a layer, name it maxron_poi_objects, and then access those objects with private _pois = getMissionLayerEntities "maxron_poi_objects"
or use this setVariable ["maxron_isPoi", true]; and then use that to filter/search in script.
Yeah. I just tried to cut them and paste them into a new layer as you already said, didn't work, thanks for that advise but I really want to get them from the global space, which is, I guess, the missionNamespace ?! ๐
I mean the cut paste didn't work and I'm too lazy to create them all over again right now
don't need to cut/paste. make the layer, then in the left pane drag the objects into the layer.
but yeah, you gotta ask the server as of now
Does someone know how to correctly use setObjectModel correctly? BI got no docs about it.
i figured
There is a low priority serverPlayers command in development
setFlagTexture requires the full file path to the flag, not just the filename. For example, this setFlagTexture "\A3\Data_F\Flags\Flag_red_CO.paa";
The only time the name alone will work is if the flag texture is located in the top level of the mission folder. If it's somewhere else, like in a mod folder or somewhere in the base game files, you'll need to specify that.
I don't have CWR installed and I'm not going to install it to figure out where they keep their flag files, so that's up to you.
returns array with IDs, status, player objects of all players, in game/in lobby
probably because it doesn't exist ๐คทโโ๏ธ No mentions in google, no mentions in in-game autocomplete... i'm running full-text search on the unpacked game resources right now, but that's mostly for memes sake
That was as of some time ago though, it might have been scrapped since
_stringNames = (allVariables missionNamespace) select {(toLower "YourKeyword") in _x};
_actualReferences = [];
{
_actualReferences pushback (missionNamespace getVariable [_x,objNull]);
} forEach _stringNames;```
Well that is sad, I really thought such a command exists. Do you know one that replaces a model mid game by any way?
i'm pretty sure no way of replacing model exists at all
:(
ah but i'm also working with arma 2 oa so even so it wouldn't help me
Ah right, then yeah definitely
anyway, thanks
you can always create a super simple object and use specific models for them, its might be as close as you can get to replace objects midgame i guess
Works like a charm!!! Many thanks.
Any tips on how i could make commander using high command able to add a snippet of code to a waypoint if he wants?
Im trying to make tanks ram trough forest on demand and the ramming part works. But i dont know how i can make this happen on waypoints on drmand when needed in game
_actualReferences = _stringNames apply {missionNamespace getVariable [_x, objNull]}; to save couple of lines
And here is the function, where I replaced that "find" command logic with your logic, and how to call it, just in case somebody wants to use it:
// EXAMPLE: ArrayToSaveMatchesTo = [missionNamespace, "Your_Search_Keyword"] call XXX_fnc_getVariablesFromNamespaceByKeyword;
XXX_fnc_getVariablesFromNamespaceByKeyword = {
params ["_namespace", "_keyword"];
private ["_namespaceVariableNames", "_matches"];
_matches = [];
_namespaceVariableNames = (allVariables _namespace) select { (toLower _keyword) in _x };
{
_matches pushback (_namespace getVariable [_x, objNull]);
} forEach _namespaceVariableNames;
XXX_Output = _matches;
XXX_Output
};
(toLower _keyword) in (toLower _x) ๐
Is there a way to pause the following code and black out the screen for some time?
params ["_player"];
openMap [true,false]; // Force open the map
hintC "Left click on the map where you want to be teleported"; // Usage instructions
addMissionEventHandler ["MapSingleClick", {
params ["_units", "_pos", "_alt", "_shift"];
_thisArgs params ["_player"];
hintSilent ""; // Hide the usage instruction if its still on screen
player setPos _pos; // Teleport player
_resetPosition = getPos player;
{
_x setPos _resetPosition;
}forEach units group player;
openMap [false,false]; // Close map
removeMissionEventHandler ["MapSingleClick", _thisEventHandler] // Remove handler so that next map click doesn't trigger teleport again
}, _player];
sleep does not work with a eventhandler
to run a scheduled code from inside unscheduled you may use spawn ๐คทโโ๏ธ But don't forget to pass needed local variables to it, as it's a totally separate script/thread/call it whatever you want
so something like sqf params ["_player"]; openMap [true,false]; // Force open the map hintC "Left click on the map where you want to be teleported"; // Usage instructions addMissionEventHandler ["MapSingleClick", { params ["_units", "_pos", "_alt", "_shift"]; _thisArgs params ["_player"]; hintSilent ""; // Hide the usage instruction if its still on screen titleCut ["", "BLACK OUT", 1]; [_player, _pos, _thisEventHandler] spawn { params ["_player", "_pos", "_thisEventHandler"]; player setPos _pos; // Teleport player _resetPosition = getPos player; { _x setPos _resetPosition; } forEach units group player; sleep 5; titleCut ["", "BLACK IN", 1]; openMap [false,false]; // Close map removeMissionEventHandler ["MapSingleClick", _thisEventHandler] // Remove handler so that next map click doesn't trigger teleport again }; }, _player]; ๐คทโโ๏ธ
Thanks a lot. I'll give it a try and report back.
toLower _x isn't required, allVariables already returns in lowercase
Brilliant. Thanks a lot for your help!
look above, disregard me, save some CPU cycles
Oh, didn't see that, will try right now ๐
i mean. Nothing really to try, you original code was faster and equally working
lol, already happening
Yeah that toLower _x actually isn't really necessary, could have thought of that myself
I have a respawn vehicle with 1 seat which immediately gets emptied as soon as somebody gets in.
My problem is that when 2 people sanctimoniously try to spawn in, one of them spawns outside.
How can I fix this problem? For example, is there a way to implement a queue for people respawning on the vehicle?
You can do what you like in onPlayerRespawn?
A trigger with this fixed the issue:
null = [thisList] spawn {
params ["_thisList"];
{
_player = _x;
_jet = nearestObject [_x, "Plane"];
waitUntil {{alive _x} count crew _jet == 0};
_player moveInDriver _jet;
} forEach _thisList;
};
New question.
Why does this code spawn 2 jets when the client gets in the vehicle? It spawns only 1 jet when the host gets in. (2 players are on the server - host and client)
// IN _respawnTemplateJet INIT FIELD
if (isServer) then {
_respawnTemplateJet addEventHandler ["Getin", {
params ["_respawnTemplateJet", "", "_playerUnit"];
moveOut _playerUnit;
private _jet = createvehicle[(typeOf(_respawnTemplateJet)), getmarkerPos "marker1", [], 100, "FLY"];
}
}
My guess is that it has something to do with the local keyword or with isServer or hasInterface
But I can't figure it out
Or put in another way - How can I find out which unit is running the code ? (Server, client_x, etc.)
On host respawn:
Jet spawned!
On client respawn:
Jet spawned!
Jet spawned!
(format ["Jet spawned on machine %1", clientOwner]) remoteExec ["diag_log", 2]
I tested with 1 host and 2 clients and the spawned jets still are two. So it's something to do with client and server
Hmm nothing gets displayed in the chat but the code runs fine
diag_log logs to RPT
what does this mean
I'm not sure what that is
Just follow the links from diag_log
Oh i just realized you're not using system chat
I understand now
I'll read about diag log
This didn't work. They popped back up without any delay
I think I need to try this with somebody later because right now on my machine it's returning the same IDs
Thanks for the help for now
did i mention that there are like 3 different kinds of popup targets all those months ago? Thanks for the ping, btw, keke
ah. So the one with the scoreboard; has those settings when you pace in Zeus, but don't work at all when its called in script, using the example you provided.
yeah, something like that. One kind is described on wiki, one kind should be kinda described by whatever i've written then. There may be one (or more) different to both of those. Sorry, don't remember and too drunk to re-check ๐
It's all good. I may have found a way, from an old mission which is where the want/inspiration comes from
Target init: nul = [this] execvm "scripts\800\targets.sqf";
targets.sqf
_target = _this select 0;
_target addEventHandler ["Hit",{
_this spawn {
_target = _this select 0;
waitUntil {(_target animationPhase "terc") > 0.1};
_target animate ["terc",0];
};
}];```
yay question: after a map UI control has been resized, map animations such as "please center the map on this position" give incorrect results, they don't seem to know that the map's center isn't the same anymore
any way to correct that?
@bold comet, I tried some time ago, but not found solution...
/* Note on blueprint: How to cycle over a collection by using recursion:
Step 1: Pass your collection as argument to a script. Name the parameter _collection.
Step 2: Create a variable named _currentIndex and set its value equal to 0, place it in the function's parentscope, the script scope.
Step 3: Call the function in your script, after defining it. Design the signature in a way that you pass the _currentIndex from parentscope.
Step 4: Execute your business logic, after that, implement following calculation:
_currentIndex = (_currentIndex + 1) % (count _collection);
This increments the index exactly from start to finish, then again to start, and so on, forever or until terminated.
Step 5: Call the function inside the function: Recursion or "Calling-Yourself", of course by the exact same signature. */
I discarded a today's concrete implementation because I am too dumb to maintain an approach like this in the SQF ecosystem the proper way, however, I think recursion has an exceptional beauty because actual trees in actual forests also don't use forEach-loops and shit to develop their branches and leafs and such, but that's completely out of term here, anyway, I didn't want this to get dumped down into some dark corner of my comments forever, so I hope it turns out to be useful to whom ever might read this to get one or more ideas from on how to deal with this in SQF.
no worries :) let's hope someone ran into the issue and found a workaround
Well... There is a few alt language which compile to sqf
It's not really a "machine" ID. Even if you use loopback, the clients each have a different clientOwner value.
If they all say "2" then it's somehow running twice on the server.
host, client and additional all say 2
at least one should say one
But I am running this locally
I will test it tomorrow with a friend it might change
Maybe I might've done something wrong hmm
Try just running clientOwner as local in the debug console from the client.
Will do tomorrow, thank you!
I'm trying to enhance my groups flashlight mod (which makes the vanilla flashlight brighter and longer-reaching) so that it can be toggled between narrow and wide modes. But I cannot seem to figure out how to add a mode toggle upon pressing Ctrl+L.
Here is my original working code with just the original narrow beam:
https://sqfbin.com/akiqolasomomekozijiq
Can someone tell me what I should do to this in order to toggle the flaremaxdistance and outerangle between the current value and a new value?
Not sure if this is the right channel or if config makers is the right channel
are there any widely accepted SQF mutex implementations? http://pastebin.com/nauJrfXy here's one i'm using. it assumes the statement at line 6 to be atomic. so far it's seemed to work in all my tests
ehhh ... is that rly a recursive waitUntil call?!
or am im missing something now?
ohhh ye
my fault
hell i should get to bed ...
recursive waitUntil... BRILLIANT
waitUntil call
please be precise if you try to do what i usualy do
or you wont be successful
btw. that thingy can be made faster and more atomic by just using the defines without the rest functions ...
still a mutex in arma is ... well it simply does not makes fun
waste of performance for ArmA
you never got real race conditions anyway ..
so?
code better and dont make race conditions happen
there's just some cases where it's unavoidable
How can I play a radio message like "ammo low" using a unit's config voice and the current behaviour tone?
you know what they say about premature optimization though and it's not like i'm locking huge sections of code anyway
you are right
better use some weirdo construct which is not needed in any case
i mean
feel free to show me (@all) any piece of code where you NEED a mutex in arma
If it's config based you'll have to swap the accessory itself, afaik, they don't handle modes
especially because using a mutex has nothing to do with optimization
not sure if there's a more native approach, but I've used a similar method to this in previous missions. Never explored the use of detecting the behaviour. But it'd be easy enough I guess
https://forums.bohemia.net/forums/topic/178184-playsound3d-and-vanilla-sound-list/
Is there a list of all vanilla sound effects? I know, the names can be found out with triggers and searching the mission.sqm. But I need the full path and file name to be able to play it with playsound3d. These work: playSound3D [A3\Sounds_F\sfx\alarm_independent.wss, player]; playSound3D [A3\Sou...
yeah it has to do with safety, and i'd rather be safe than save 0.1 milliseconds here and there
anyone know the bone name for a tanks barrel?
Is it possible to display text/hit marker on a plane MFD/HUD with a script
Hey, so it's been a bit but I was finally able to put the jammer into a mission and I ran into a problem
Go ahead, let's see if we can figure it out ๐
So, it works perfectly, but when my players destroyed the jammer, it didn't un-jam their radios
So they were stuck on jammed radios for the whole op
Computers are kind of "dumb" in a sense that you need to tell them everything explicitly. The issue here lies in that the while condition stops from being evaluated when a jammer gets destroyed, and there's no code after it to unjam the radios (because it's inside the while loop that is not being run anymore)
You can do it like that, yeah. Or the a bit cheap/easy but probably decent enough way:
// yourFunction.sqf (a separate .sqf file)
YourFunctionName = {
params ["_jammer"];
while {alive _jammer} do {
_unitInJammerArea = nearestObjects [_jammer, ["Man"], 200];
_allUnits = allPlayers - entities "HeadlessClient_F";
_notInJammerArea = _allUnits - _unitInJammerArea;
if !(count _notInJammerArea isEqualTo 0) then {
{
_x setVariable ["tf_receivingDistanceMultiplicator", 1];
_x setVariable ["tf_sendingDistanceMultiplicator", 1];
} foreach _notInJammerArea;
};
if !(count _unitInJammerArea isEqualTo 0) then {
{
_x setVariable ["tf_receivingDistanceMultiplicator", 0];
_x setVariable ["tf_sendingDistanceMultiplicator", 0];
} foreach _unitInJammerArea;
};
sleep 5;
};
{
_x setVariable ["tf_receivingDistanceMultiplicator", 1];
_x setVariable ["tf_sendingDistanceMultiplicator", 1];
} foreach _unitInJammerArea;
};
``` This way the radios get unjammed because the code I added in the end gets executed when a jammer gets destroyed (as the code isn't "stuck" at executing the `while` loop anymore). (Oops, fixed a copy-paste error)
Strange
You'd think that "while" would just mean that it stops when it's not alive anymore
But I guess it changes a value that needs to be switched back
That's what it does, but you have to state explicitly that you want to unjam the radios after it
While works while codition is true when its not true anymore it stops and exits the {} of the code.
if you are using CBA you could do something like this
params ["_jammer"];
_allplayers = allPlayers - entities "HeadlessClient_F";
if (!alive _jammer) exitWith {
{
_x setVariable ["tf_receivingDistanceMultiplicator", 1];
_x setVariable ["tf_sendingDistanceMultiplicator", 1];
} foreach _allplayers;
};
_unitInJammerArea = _allplayers inAreaArray [getposatl _jammer,200,200,0,false];
_notInJammerArea = _allplayers-_unitInJammerArea;
_notInJammerArea = _allUnits - _unitInJammerArea;
if (_notInJammerArea isNotEqualTo []) then {
{
_x setVariable ["tf_receivingDistanceMultiplicator", 1];
_x setVariable ["tf_sendingDistanceMultiplicator", 1];
} foreach _notInJammerArea;
};
if (_unitInJammerArea isNotEqualTo []) then {
{
_x setVariable ["tf_receivingDistanceMultiplicator", 0];
_x setVariable ["tf_sendingDistanceMultiplicator", 0];
} foreach _unitInJammerArea;
};
[TAG_fnc_jammmerFunction, [_jammer], 5] call CBA_fnc_waitAndExecute;
// slower
!(count _unitInJammerArea isEqualTo 0)
// faster
(_unitInJammerArea isnotequalto [])
So, I think I have an extraordinarily interesting problem to solve: How to implement lightweight/"kind of" interfaces in SQF?
Background story: There are various kinds of scripted items in my gamemode. Because of both clean code and architecture principles and also to avoid extra manual work with duplicate code, I'd like to give them an array of simulated "interfaces" that they implement or at least inherit the base definitions from the code. Due to paradigm of SQF it's a non-trivial issue.
Issue 1: Those interfaces have cross-dependencies, so they need to be initialized in order.
Issue 2: It's quite easy to introduce deadlocks where interface A requires interface B and vice versa.
Issue 3: In case of (multiple) inheritance, the issue of "diamond of death" (see: https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem)
So I've come up with some preliminary logic to solve these issues:
- At mission init, compile and run a function that resolves and checks for the dependencies and gives a fatal error if there are deadlocks (probably achievable with some dedicated detection algorithm (maybe?) or as cheap implementation, some watchdog style thingy) and saves the results into global variable
- Define an array of interfaces that the item implements in it's specific script.
- When the item script gets executed during runtime, retrieve the dependencies from the results of step 1
- Execute the scripts in order that the dependencies retrieved from global variable require/state.
Can anyone spot any issues with this approach? Because there probably are those (and many of them most likely!)
_allplayers = allplayers;
_unitinjammerarea = _allplayers inareaarray [getposatl _jammer,200,200,0,false];
_notinjammerarea = allplayers - _allplayers;```
Is there a simple way to copy an array without making a reference
How would this work vs the other code?
_myCopy = +_myArr;```