#arma3_scripting

1 messages ยท Page 53 of 1

warped oak
#

Been looking for satchel config but have not yet found one, maybe I should try to look the vanilla one with eliteness or so

sullen sigil
#

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

tender fossil
#

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];

winter rose
#

(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)

meager granite
#

@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

tender fossil
sullen sigil
#

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

proven charm
#

setVelocityModelSpace / setVelocity ?

sullen sigil
#

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

proven charm
#

so what are you trying to achieve?

south swan
#

๐Ÿฟ

sullen sigil
#

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

south swan
#

just convert everything to model space of one of the objects ๐Ÿคทโ€โ™‚๏ธ

proven charm
#

well it sure is over my head XD

sullen sigil
#

Like I said it's deceptively complex lol

south swan
#
_velocity1modelspace2 = obj2 worldToModel (getPosWorld obj2 vectorAdd velocity obj 1);
_total1relativeto2 = _velocity1modelspace2 vectorAdd velocityModelSpace obj2;
```or something like that
#

and _velocityAfterTP = obj3 modelToWorld _total1relativeto2;

sullen sigil
#

I'm now confused why is position calculations involved for this

south swan
#

to calculate velocity of object1 in modelspace of object 2 ๐Ÿคทโ€โ™‚๏ธ

#

as worldToModel takes world coordinates as its input ๐Ÿคทโ€โ™‚๏ธ

sullen sigil
#

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

meager granite
#

Run this each time you change vehicle

south swan
#

jolly quadratic spline fun notlikemeow

#

also, vectorAdd was most likely an error and vectorSub was actually needed there notlikemeow

#

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 notlikemeow

sullen sigil
#

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"

south swan
#

aww, for cat's sake, i suck at reading and "quadratic spline" was proposed as a thing user/coder can implement themselves notlikemeowcry

#

and setVelocityTransformation itself is claimed to be dumb linear interpolation

sullen sigil
#

its linear? was under the impression it was quadratic thonk

south swan
#

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

sullen sigil
#

well that throws a spanner in my hopes for making the cube curve between points
guess its turning before moving because fuck that

south swan
#

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

sullen sigil
#

oh so two transforms at the same time?

south swan
#

three

sullen sigil
#

ah -- either way it doesn't solve my issue at the moment either ๐Ÿ˜…

south swan
#

kek

sullen sigil
#

why couldnt einstein have written in sqf

sharp arch
#

dumb question, but does anyone know a script that make a vehicles engine invincible to damage?
and only the engine?

south swan
#

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
๐Ÿคทโ€โ™‚๏ธ

sullen sigil
#

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

tender fossil
# meager granite ```sqf { if(isNil{_x getVariable "my_draw_eh"}) then { _x setVariabl...

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!"
granite sky
#

@sharp arch Can be done with a handleDamage EH, although it has to be the last one attached to override the output damage.

fleet sand
south swan
#

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).

granite sky
#

@fleet sand Not sure, might be too slow to prevent knock-on effects.

south swan
#

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) blobdoggoshruggoogly

granite sky
#

Like RHS vehicles will explode if you hit the engine twice.

sullen sigil
#

what would that return? modelspace velocity of obj1 relative to obj2 as stationary observer?

south swan
#

relative velocity of obj1 in modelspace of obj2 if i haven't derped anywhere

sullen sigil
#

and then how would I end up applying that to obj1?

south swan
#
_newVelocity = (obj3 modelToWorld _thatGoddamnThing) vectorSub getPosWorld obj3;
obj1 setVelocity _newVelocity;```
sullen sigil
#

ok i will try that thank you lmfao

#

I assume you mean vectorDiff instead of vectorSub too right

south swan
#

yeah, totally

meager granite
#

Also use ctrlAddEventHandler, ctrlSetEventHandler overwrites everything is outdated

sullen sigil
#

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
south swan
#

so what looks wrong?

sullen sigil
#

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

south swan
#

i'd say here private _shipVel = (_shipLastPos vectorDiff _shipPos) vectorMultiply 1/diag_deltaTime;, kek

sullen sigil
#

What's up with it?

south swan
#

as velocity is usually described as "(new position - old position) / time" and you seem to have it reversed

sullen sigil
#

oh of course

#

i'll try swap

#

omg

#

let me just test the other way around but i think that is it

gloomy aspen
#

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 ๐Ÿ™‚

sullen sigil
#

disabling of blood or damage?

gloomy aspen
#

blood specifically, still want them to take damage as usual

sullen sigil
#

you using ACE medical?

gloomy aspen
#

Yeah mate

#

Sorry I should probably clarify, I mean the visual presence of blood not the blood system

sullen sigil
#

I tried doing this a while ago and couldn't find an easy way to do it without destroying performance

gloomy aspen
#

Cheers mate! Will ask there ๐Ÿ™‚

sullen sigil
#

my thing is solved thank you artemoz the genius

drowsy geyser
#
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?

slow isle
#

this is what I get:

south swan
#

You seem to have CfgFunction as the root of your hpp

slow isle
#

I understand now, thanks!

south swan
#

Making the resulting description.ext have class CfgFunctions { class CfgFunctions { class LDR...

slow isle
#

Ill try to fix it now

fleet sand
drowsy geyser
#

yes, but making the light follow the bone rotation is not accurate if the player goes into crouch or prone position

fleet sand
# drowsy geyser yes, but making the light follow the bone rotation is not accurate if the player...

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,
    "",
    ""
];
slow isle
#

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)

granite sky
#

Looks like you're adding the HandleDamage EH on the server?

slow isle
#

and to who

#

the player or the vehicle

granite sky
#

When a player gets in a vehicle as driver/pilot, the vehicle switches locality to their machine.

slow isle
#

Oh I see.

#

Alright I'll work on that

#

Thanks

slow isle
winter rose
#

IF ISSERVER

slow isle
#

which I believe is server+clients

winter rose
#

where did you do so?

winter rose
#

that image is not the final code, right?

slow isle
#

No

winter rose
#

ok ok

slow isle
#

I'll send the final code now to remove confusion

granite sky
#

I don't get why the server is creating another jet in the init field for a jet.

slow isle
#
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];
        
    }];
};
slow isle
granite sky
#

madness

#

I dunno, should work.

slow isle
#

Yep, that's why I'm crying constantly about locality

south swan
#

And all that inside the event handler? Radical

slow isle
#

Should I send it?

granite sky
#

uh :P

slow isle
#

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];
    }];
};
granite sky
#

Does that missile nerf function definitely exist on clients?

slow isle
#

Yes, it is in CfgFunctions

granite sky
#

client and server can have different CfgFunctions :P

slow isle
#

how

granite sky
#

Although if it's a mission it should be fine.

slow isle
#

It's a mission

#

this is the file system

granite sky
#

You get no systemChats on clients from the nerf function either?

slow isle
#

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

granite sky
#

I'd definitely keep the systemchat...

slow isle
#

I'll add one now

#

remote 0 or not?

granite sky
#

Trouble is that subsequent handledamage event handlers will block the return-override functionality.

slow isle
#

I don't understand what that means

granite sky
#

never mind. If the systemchat isn't firing then it doesn't matter.

slow isle
#

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

tender fossil
#

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

slow isle
slender olive
#

Hey guys, how can I make these things true in a PVP mission:

  1. Sectors that are captured faster if you have a certain item in your inventory
  2. 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
slow isle
#

Important question: can client run remoteExec[..., 0] ?

#

or remoteExec at all?

granite sky
#

yes.

slow isle
#

is there something that can't run remoteExec

granite sky
#

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.

slow isle
#

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

granite sky
#

Isn't that the point? GetIn is a global EH, so you only want to install it on the server.

slow isle
#

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

granite sky
#

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.

tender fossil
#

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 notlikemeow

#

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

slow isle
#

I can reach the code

tender fossil
# tender fossil I'm hesitating to call it a bug because this is wildly unfamiliar area to me for...

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?

slow isle
#

How can I pass parameters to:

{...} remoteExec ["call", 0];
#

I want this: [...] call {...} in remoteExec without using a function

winter rose
#

[argLeft, argRight]

tender fossil
#

Does it use some commands that work on actual map only? I tried to google about ctrlMapScale and such but didn't find anything

slow isle
little raptor
#

yes

chrome hinge
#

Is it possible to hide trees from AI pathfinding?

#

Id like ai tanks to ram trees but they are very reluctant to do it

little raptor
#

also set their behavior to combat

little raptor
#

also this is for Arma 3 right?

tender fossil
tender fossil
chrome hinge
modern meteor
#

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?

little raptor
little raptor
modern meteor
#

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)];

tender fossil
# little raptor did you try logging _toDraw after `select`?

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;

modern meteor
#

My objective is to enableAI when a shot is fired nearby the squad

#

As I disable AI during a certain move command

little raptor
tender fossil
little raptor
#

or the problem is _lookingAt

little raptor
little raptor
tender fossil
# little raptor dunno. log them 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

little raptor
#
{
    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

little raptor
modern meteor
#

oh wow. more complex than i thought

#

i'll give it a shot. Thank you!

little raptor
tender fossil
#

!

little raptor
#

@tender fossil :

_worldSize = worldSize;
_scale = ctrlMapScale _mapCtrl;
_dist = _scale*_worldSize/8192*250;

that's how I measure distance with scale in my mod

modern meteor
#

Not sure what this means

tender fossil
# tender fossil !

I increased the sqf _x distance _lookingAT <= (_scale * 10000) with ```sqf
_x distance _lookingAT <= (_scale * 100000)

little raptor
#

like I said your scale is arbitrary

#

I think you should read it from the config

little raptor
jagged mica
#

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

tender fossil
#

It broke the map routing too. Arma...

modern meteor
little raptor
#

enemy only

tender fossil
#

And the script seems to need something between 10000 and 100000 to work properly. Absolutely no idea why ๐Ÿ˜„

modern meteor
little raptor
#

if dist, your code is wrong

tender fossil
#

Ah, well I was wondering. Where's the error?

little raptor
#

there are 2 properties iirc

#

minScale and maxScale

little raptor
modern meteor
#

Thank you. Regarding the distance, can I use any number here? I guess this is the radius within the shots needs to be fired?

tender fossil
#

I.e. how do I retrieve them ๐Ÿ˜›

little raptor
modern meteor
#

Thanks Leopard

little raptor
# modern meteor 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]);
little raptor
#

it's in control config

#

not world

tender fossil
tender fossil
#

Yeah ๐Ÿ˜„

little raptor
# tender fossil 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

tender fossil
little raptor
#

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

tender fossil
#

Yes, I'm figuring out how to do that ๐Ÿ˜›

digital hollow
tender fossil
#

I managed to print the main config file but didn't find anything interesting there

little raptor
#

how do you even fetch its map ctrl?

tender fossil
little raptor
#

you know the IDD. you find a display whose IDD=133

#

then you just look at its controls

tender fossil
tender fossil
# little raptor well that's the way to get its config then

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)

little raptor
tender fossil
little raptor
#

like I said: do a config search for all disps with IDD=133

#

then find the controls

#

CA_MiniMap is the GPS map

tender fossil
little raptor
#

get a config dump then search via a text editor

tender fossil
#

Trying to figure it out though

little raptor
little raptor
#

use ctrl+F meowsweats

little raptor
# tender fossil

also I already showed you where it is. you don't need to search

#

configFile >> "RscMiniMap" >> "controlsBackground" >> "MiniMap" >> "Controls" >> "CA_MiniMap"

tender fossil
#

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"

little raptor
#

well the question is is that even what you want tho? ๐Ÿ˜›

tender fossil
tender fossil
little raptor
slow isle
#

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

little raptor
#

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 
}
tender fossil
little raptor
#

it's wrong

slow isle
#

does this make sense

little raptor
#

idk what you mean

#

the damage you turn in handleDamage is the final damage iirc

#

not the added damage

slow isle
#

Oooh

little raptor
#

so you should return _unit getHitIndex _hitindex if you want no damage

slow isle
#

if I want to lower the damage by twice what do I do

#

_damage / 2 ?

little raptor
#

also check if hitIndex is negative or not

slow isle
#

or _unit getHitIndex _hitindex + (_damage/2)

little raptor
#

_damage is the FINAL damage

slow isle
#

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
}
midnight niche
#

Still hung up on this if anyone has any suggestions ๐Ÿค”

tender fossil
# little raptor it's wrong

Any closer? ๐Ÿ˜„ ```sqf
private _dist = _worldSize * (_configMiniMapSizeMax / _configMiniMapSizeMin) / _scale;
// ...
_toDraw = _toDraw select {
_x distance2D _lookingAT <= (_dist)
};

little raptor
#
_oldDmg = if (_hitIndex < 0) then {damage _unit} else {_unit getHitIndex _hitIndex};
_deltaDmg = _damage - _oldDmg;
_oldDmg + _deltaDmg / 4;
little raptor
little raptor
slow isle
#

The 0 case?

little raptor
#

return 0

slow isle
#

ah

little raptor
#

I've made it return 1/4 damage tho

require 2-4 missiles to disable jet (nerf missile damage)

slow isle
#

I'll try to understand it brb

little raptor
#

I'm sure _dist is ridiculously large now

tender fossil
#

Well, more than 10000 at least

little raptor
#

I meant log it

little raptor
#

it makes no sense

tender fossil
#

It doesn't work if it's 10000

slow isle
#

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)

little raptor
#

don't confuse the 2

little raptor
#

try it

slow isle
#

Works perfectly as of now

#

again, thank you very much

tender fossil
# little raptor again I'm talking about dist. not scale
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 ๐Ÿ˜„

little raptor
#

you're essentially not filtering anything at all

tender fossil
little raptor
#

_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

tender fossil
#
// 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]
frozen seal
#

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?

little raptor
midnight niche
# little raptor how do you hide it?

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

little raptor
#

the "#ACTION" menu is created dynamically.

#

you can't show it by scripts

frozen seal
#

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

midnight niche
# little raptor the "#ACTION" menu is created dynamically.

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 ๐Ÿ˜†

meager granite
#

@tender fossil What are you trying to do anyways?

#

With the _configMiniMapSizeMin stuff

meager granite
#

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

tender fossil
#

Yeah, I can imagine Draw being very expensive

meager granite
#

So you can draw shaped lines

tender fossil
#

That's nice!

meager granite
#

Only through markers though, no draw*

tender fossil
#

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

meager granite
#

Check animationList for animations in vehicle's class, then check them with animationPhase

tender fossil
pulsar bluff
#

i guess this is like resizing the location to fit the shown map area on screen

meager granite
#

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

pulsar bluff
#

on mobile, is there any command for map similar to โ€œworldtoscreenโ€ which returns [] for pos off screen

meager granite
#

When assigning "Draw" event handler, also create a location for each map control, koth_map_location, also default aim

pulsar bluff
#

nm think you just answered that lol

#

yep

meager granite
#

_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

pulsar bluff
#

does it make sense for you to only eval the array every n frames and cache the result

meager granite
#

Which array?

pulsar bluff
#

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

meager granite
#

Maybe, but i wouldn't, so load is even

pulsar bluff
#

fair

meager granite
#

From my experience the most of the load with map drawing is feeding arma draw* command arrays

pulsar bluff
#

i think your work was why i switched to drawicon from markers, but that was like 9 years ago now ๐Ÿ˜‚

meager granite
#

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.

meager granite
#

Drawing the location with red rectangle and location made smaller so cutoff is more visible, works great with rotating GPS too

jade abyss
#

why?

indigo snow
#

BIS_fnc_MP in the current stable A3 version still uses publicVariableServer

quasi zenith
#

Quick question - Can I use the BIS_fnc_traceBullets command on AI? I can get it to work for player, but not for AI.

tough abyss
#

Thanks man, I done it now, your the best.

meager granite
tough abyss
#

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.

tough abyss
# meager granite https://community.bistudio.com/wiki/Description.ext#CfgMusic

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 };
};

};

meager granite
#

No, read the beginning of the article

meager granite
#

[unit] call BIS_fnc_traceBullets

meager granite
#

I guess I need to also change the material somehow so alpha channel doesn't draw as black?

warm hedge
#

No, it is a model side thingy - you can't alter it

meager granite
warm hedge
#

Ask and slap Dedmen kindly so he would make new shader

meager granite
meager granite
#

Looks pretty cool on characters with old VR material

torn hemlock
#

Hm.. yep. In stable BIS_fnc_MP uses: publicvariableserver "BIS_fnc_MP_packet";
While in dev-branch: _params remoteExec [_functionName,_target,_isPersistent];

warm hedge
#

Nice ๐Ÿ™‚

tough abyss
#

{
_x switchLight "OFF";
} forEach (1 allObjects 0);

torn hemlock
#

But there is a little distraction in comments on Biki page dedicated to BIS_fnc_MP

fleet sand
meager granite
#

Old VR material is easy though

#

Do setObjectMaterial with "a3\characters_f_bootcamp\data\vr_soldier_f.rvmat"

fleet sand
winter rose
quiet gazelle
#

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?

minor narwhal
#

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

quiet gazelle
#

i don't know exactly how that module works but you should be able to connect them like this: (!alive A1) && (!alive A2);

minor narwhal
#

hopefully that will fix it! a million thanks!

still forum
#

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.

little raptor
#

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

still forum
little raptor
#

I think he means std::vector<vector2>

quiet gazelle
still forum
#

"returns an array of 2d positions" oh 2d, well vector2 then ye

little raptor
#

Then use one of those 3 methods

still forum
#

Ah no vector2 can't cast :harold:

quiet gazelle
#

so i can just cast the game value to vector2

#

nevermin

#

but a vector3 i could cast?

still forum
#

There will be some conversion function somewhere that does that for you

little raptor
still forum
#

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

little raptor
#

Iirc we do have vector3 cast for game_value tho

little raptor
#

But it's not included via just #include <intercept.hpp>

#

Needs to be included manually iirc notlikemeow

quiet gazelle
#

what do i need to include?

little raptor
#

idk it's called helpers.hpp or something

#

Iirc it's under client headers

quiet gazelle
#

it's common_helpers.hpp

#

intercept::sqf::__helpers::__convert_to_vector<vector2>(return_data) so should this do everything i want?

little raptor
#

Yes

quiet gazelle
#

nice

pliant stream
little raptor
#

wdym?

pliant stream
#

Spelling __helpers is illegal.

little raptor
#

I didn't choose that name blobdoggoshruggoogly
But it's for internal use, so it's ok-ish

pliant stream
#

Well it's undefined behaviour.

little raptor
#

Why? It's just a name

#

And last I checked no compiler uses __helpers or anything blobdoggoshruggoogly

pliant stream
still forum
#

It means the game is frozen

nocturne bluff
#

@indigo snow fuckking lame >(

quiet gazelle
still forum
#

show code

quiet gazelle
#

one second

still forum
#

nvm

#

__helpers::__convert_to_vector<vector3>(ret); this is the correct

#

nvm that is same as what you have ๐Ÿ˜„

quiet gazelle
#
    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

still forum
#

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

quiet gazelle
#

wait

still forum
#

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

quiet gazelle
#

maybe i did indeed mess up and have more than 2 values in there

#

yes i did

still forum
#

your code would be more failsafe then, the helper is designed to implement SQF command wrappers and these usually return the proper things

quiet gazelle
leaden ibex
#

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? monkaHmm

still forum
leaden ibex
#

Can I have a debugger connected to the arma porcess? monkaHmm

#

Or, the extension once it's running

quiet gazelle
#

yes

leaden ibex
#

(99% of work I do is with g++ and gdb on linux, windows is new territory for me)

leaden ibex
still forum
#

Visual studio - Debug - Attach to Process

leaden ibex
#

wonderful, will give it a go, thanks!

leaden ibex
#

Wow, it actually works. Could have made my life way easier when I was creating it for linux long time ago dogeKek

jagged mica
#

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

warm hedge
jagged mica
still forum
#

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

jagged mica
#

Im many many frames after creating it

still forum
#

๐Ÿค”

jagged mica
#

does it matter that it comes from description.ext ?

still forum
#

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)

jagged mica
#

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

still forum
#

the last one would be the correct

jagged mica
#

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

faint oasis
#

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.

digital hollow
faint oasis
meager granite
#
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

slender badge
#

Are we allowed to post GitHub links here? I want to self reply for anybody in the future searching for the same problem.

still forum
#

Sure

native hemlock
#

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.

slender badge
#

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.

slow isle
#

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

frozen seal
#

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

little raptor
#

in your CfgSounds you've put 300 for volume (it's capped at 5 tho). well try that here too

frozen seal
little raptor
#

ah right ๐Ÿ˜…

frozen seal
#

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

little raptor
#

I think it was kb stuff

frozen seal
little raptor
#

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"];
frozen seal
#

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?

little raptor
#

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

little raptor
frozen seal
little raptor
#

example word is just the "title" for the file.ogg sound

frozen seal
# little raptor ```sqf _tellArr = [_unit2, "Radio", "radio"]; { _tellArr pushBack [str (1 + ...

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

little raptor
#

yep like that

frozen seal
#

wait my paths are wrong, brb

little raptor
#

if you're sure they're correct, try getMissionPath "rs\ApcLostFirst.ogg" instead

#

some stuff in Arma need absolute paths

little raptor
frozen seal
#

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

frozen seal
#

and the mission folder

frozen seal
#

oh wait I think the script might not be starting wtf

#

brb

slow isle
#

Can I setDamage to player 1 from player 2's name as if p2 shot p1? (so p2 is accessible in handleDamage of p1)

frozen seal
little raptor
little raptor
#

also do both units have radio?

slow isle
#

object setDamage [damage, useEffects, killer, instigator]

#

thanks!

frozen seal
velvet merlin
#

how to do an instant black screen?

little raptor
#

is 1 frame delay ok?

velvet merlin
#

tried various cutText, cutRsc, cutTitle with different timings

#

even with isNil {code}

velvet merlin
little raptor
#

well you can use RscTitles

#

or just create a control on display 46 meowsweats

#
_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 meowsweats (it should be rgb not rgba)

velvet merlin
#

RscTitles doesnt seem to have one yet. let me try the ctrlCreate

frozen seal
# little raptor try getMissionpath again

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 ๐Ÿ™‚

little raptor
#

does it work now?

frozen seal
#

All sentences get crumpled together into a single subtitle text but I'll work this out

little raptor
#

I mean the sound

frozen seal
#

I'll also need to check if it works in MP but I'll do that a bit later

frozen seal
little raptor
#

you can use kbTell 3 times instead

#

it should play them in sequence

little raptor
#

so it should be in init.sqf or initPlayerLocal.sqf

frozen seal
#

thx man I appreciate it. Once I get to implement this in MP I'll do that

velvet merlin
frozen seal
#

I think I might be done for today, learning arma scripting is such a mindf*** that it should be taken in small dosages ๐Ÿ˜…

little raptor
#

it's at the back

velvet merlin
#

well

#

one bad thing about using 46

#

it persists if you do "restart" mission

little raptor
#

yeah. well you can just use RscTitles

#

it works best for this case

velvet merlin
#

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?

winter rose
#

does not, won't

stray flame
#

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?

faint oasis
#

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.

frozen seal
winter rose
little raptor
#

you can't disable it

faint oasis
#

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 ?

frozen seal
# little raptor there are KB event handlers

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

faint oasis
# little raptor 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

little raptor
#

idk

faint oasis
#

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 ?

little raptor
#

expectedDestination

faint oasis
#

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

winter rose
#

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

meager granite
#

@velvet merlin

"MyLayer" cutText ["", "BLACK", 1e-6];
meager granite
#

Changing rvmats with setObjectMaterial doesn't help, so I guess its some model face property that lets engine use texture's alpha channel

rich frost
#

anyone familiar with the difference between say3D and playSound3D besides the local/global execution?

dusk gust
#

Anyone know if you can get the current map zoom value?

dusk gust
#

Thank you very much

drowsy geyser
#

Is there a way to get the volume of a player when he talks via voice channel? Or is this impossible?

warm hedge
#

If this doesn't fits into your usage, there's none

drowsy geyser
#

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

warm hedge
#

I do not think there is a way, unfortunately

drowsy geyser
#

๐Ÿ˜ข

lethal dew
#

Are EventHandlers always unscheduled no matter what?

modern meteor
#

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?

still forum
modern meteor
#
_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;
still forum
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
โ†“

// your code here
hint "good!";
south swan
lethal dew
still forum
#

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;
lethal dew
#

no i mean when it's added

south swan
#

also sqf private _pos = []; mapPosition = []; // use global to get the variable from `onMapSingleClick` _pos = mapPosition; // store it doesn't really make much sense

still forum
lethal dew
#

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!";
    }];```
still forum
#

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];
still forum
lethal dew
still forum
#

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"

still forum
lethal dew
lethal dew
south swan
#

yeah, delay between actual click and event firing is very noticeable

still forum
#

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

modern meteor
still forum
modern meteor
#
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

lethal dew
still forum
winter rose
#

!quote 5

lyric schoonerBOT
modern meteor
# still forum I gave you the steps you need You have no forEach, so yes you're doing something...

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];
still forum
#

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)

modern meteor
#

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?

modern meteor
#

Thank you

hallow mortar
#

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

modern meteor
#

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

pulsar bluff
#

player has a keyboard, there are UI inputs for this

hallow mortar
#

Or "GUNNER"

#

Possibly gunner _darter switchCamera ...

modern meteor
#
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.

proven charm
#

how do you change the light color of PortableHelipadLight_01_green_F for example? i tried setLightColor

pulsar bluff
#

the "green" might indicate that its green only

warm hedge
#

You can't through a script

proven charm
#

ok

#

is even setLightBrightness supposed to work?

hallow mortar
#

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

proven charm
#

ok

#

another question, the PortableHelipadLight_01_red_F can be pushed around, is there anyway to prevent that?

#

like disable simulation or something

hallow mortar
#

I mean yes, enableSimulation. But you could also attach it to something.

proven charm
#

hmm

drowsy geyser
#

What about setMass

winter rose
#

simulation is the way to go.

proven charm
#

yea less work for the CPU

hallow mortar
#

The only concern I have is whether turning off simulation will stop it flashing

#

Easy to test though

winter rose
#

ah flashing? it will prevent that, I believe

proven charm
#

oh thats not good

winter rose
#

attachTo then, if the simulation of the object to which it is attached is not tooโ€ฆ infrequent

proven charm
#

that too stops the blinking

winter rose
#

attachTo? try attaching it to the player?

proven charm
winter rose
#

so attach it to something that has a simulationโ€ฆ or enjoy the blinking :p

slow isle
#

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

winter rose
slow isle
#

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

stray flame
#

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";
slow isle
# winter rose please try and report so I can write it there

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

winter rose
#

systemChat ("a" + "b") otherwise it will only show "a"

#

or throw an error

slow isle
#

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

winter rose
#

so we have the answer

stable dune
stray flame
#

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;

hallow mortar
#

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

stray flame
#

So the shooter should be a object?

#

or im guessing it should be referencing a singular unit

#

cuz the target is a signpost

hallow mortar
fleet sand
stray flame
#

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?

hallow mortar
#
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.

stray flame
#

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

hallow mortar
#

Did you remember to create a target_2 for him to shoot at?

stray flame
#

yep

#

checked that the variable name is a match too

hallow mortar
#

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.

slow isle
#

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 _instigator to P2's assisters array. When P2 crashes due to critical damage, all assisters should get notified for "Kill assist".

Note: System currently works perfectly for players (infantry) on the ground.

stray flame
#

hu, now I got it to work

#

after making some minor changes

#

and moving the target slightly

#

well whatever

hallow mortar
#

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.

slow isle
# slow isle I have the following **problem**: I have a working kill/teamkill/assist system...

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];
hallow mortar
#

Why not add handleDamage EH on the jets as well? You can still save the instigators to the pilot's records, using driver.

south swan
#

add HandleDamage EHs from "GetInMan" EH ๐Ÿง 

slow isle
lethal dew
#

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?

proven charm
lethal dew
#

Of course, but I am not asking about the UI!

digital hollow
lethal dew
#

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.

proven charm
#

the right code is?

#

try adding ".paa"

pliant stream
#

is there a way to get your own owner id on the client without asking the server?

proven charm
#

or whatever is ur extension

#

where u run the code?

#

hmm

#

can u get the vanilla flags working? try "flag_NATO.paa"

#

weird

lone glade
#

(owner vehicle player)

proven charm
#

maybe it doesnt support texture change

little raptor
#

Try it in debug console too

lone glade
#

owner player might work too

little raptor
#

Texture commands sometimes don't work in init fields

pliant stream
#

it always returns 0 on the client at least according to the wiki

digital hollow
lethal dew
lone glade
#

oh shit, that's right

little raptor
#

Run the mission in editor then pause the game

pliant stream
#

yeah it's not that easy mate ;D

digital hollow
tranquil nymph
#

There isn't

#

Well, netIDs are almost enough to get it

lethal dew
#

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

digital hollow
#

don't need to cut/paste. make the layer, then in the left pane drag the objects into the layer.

tranquil nymph
#

but yeah, you gotta ask the server as of now

wicked sparrow
#

Does someone know how to correctly use setObjectModel correctly? BI got no docs about it.

pliant stream
#

i figured

tranquil nymph
#

There is a low priority serverPlayers command in development

hallow mortar
#

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.

tranquil nymph
#

returns array with IDs, status, player objects of all players, in game/in lobby

south swan
tranquil nymph
#

That was as of some time ago though, it might have been scrapped since

hallow mortar
wicked sparrow
south swan
#

i'm pretty sure no way of replacing model exists at all

wicked sparrow
#

:(

pliant stream
#

ah but i'm also working with arma 2 oa so even so it wouldn't help me

tranquil nymph
#

Ah right, then yeah definitely

pliant stream
#

anyway, thanks

kindred zephyr
#

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

lethal dew
chrome hinge
#

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

south swan
#

_actualReferences = _stringNames apply {missionNamespace getVariable [_x, objNull]}; to save couple of lines

lethal dew
# hallow mortar ```sqf _stringNames = (allVariables missionNamespace) select {(toLower "YourKeyw...

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
};
south swan
#

(toLower _keyword) in (toLower _x) ๐Ÿ˜‰

modern meteor
#

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

south swan
#

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]; ๐Ÿคทโ€โ™‚๏ธ

modern meteor
#

Thanks a lot. I'll give it a try and report back.

hallow mortar
modern meteor
south swan
lethal dew
south swan
#

i mean. Nothing really to try, you original code was faster and equally working

lethal dew
#

lol, already happening

#

Yeah that toLower _x actually isn't really necessary, could have thought of that myself

slow isle
#

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?

granite sky
#

You can do what you like in onPlayerRespawn?

slow isle
#

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!
granite sky
#

(format ["Jet spawned on machine %1", clientOwner]) remoteExec ["diag_log", 2]

slow isle
#

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

slow isle
granite sky
#

diag_log logs to RPT

slow isle
#

what does this mean

granite sky
#

You can do the same thing with systemChat but it sucks.

#

blinks

slow isle
#

I'm not sure what that is

granite sky
#

Just follow the links from diag_log

slow isle
#

Oh i just realized you're not using system chat

#

I understand now

#

I'll read about diag log

frank mango
#

This didn't work. They popped back up without any delay

slow isle
#

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

south swan
frank mango
#

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.

south swan
#

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 ๐Ÿ˜›

frank mango
#

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];
    };
}];```
bold comet
#

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?

frank cedar
#

@bold comet, I tried some time ago, but not found solution...

lethal dew
#
/*    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.

bold comet
#

no worries :) let's hope someone ran into the issue and found a workaround

queen cargo
#

Well... There is a few alt language which compile to sqf

granite sky
#

If they all say "2" then it's somehow running twice on the server.

slow isle
#

at least one should say one

#

But I am running this locally

#

I will test it tomorrow with a friend it might change

granite sky
#

Nah, client that's not localhost is never 2.

#

Nothing would work otherwise :P

slow isle
#

Maybe I might've done something wrong hmm

granite sky
#

Try just running clientOwner as local in the debug console from the client.

slow isle
#

Will do tomorrow, thank you!

ruby bronze
#

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

pliant stream
#

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

queen cargo
#

ehhh ... is that rly a recursive waitUntil call?!

#

or am im missing something now?

#

ohhh ye
my fault

#

hell i should get to bed ...

pliant stream
#

recursive waitUntil... BRILLIANT

queen cargo
#

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 ..

pliant stream
#

yeah i guess not using any concurrency protection is more !FUN!

#

but i'm scared :<

queen cargo
#

so?
code better and dont make race conditions happen

pliant stream
#

there's just some cases where it's unavoidable

queen cargo
#

its always avoidable

#

at least in arma

#

for other langs (eg. C/C++) i would agree

digital hollow
#

How can I play a radio message like "ammo low" using a unit's config voice and the current behaviour tone?

pliant stream
#

you know what they say about premature optimization though and it's not like i'm locking huge sections of code anyway

queen cargo
#

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

midnight niche
queen cargo
#

especially because using a mutex has nothing to do with optimization

midnight niche
# digital hollow How can I play a radio message like "ammo low" using a unit's config voice and t...

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/

pliant stream
#

yeah it has to do with safety, and i'd rather be safe than save 0.1 milliseconds here and there

wary needle
#

anyone know the bone name for a tanks barrel?

slow isle
#

Is it possible to display text/hit marker on a plane MFD/HUD with a script

crystal lagoon
#

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

tender fossil
crystal lagoon
#

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

tender fossil
crystal lagoon
#

ugh

#

Maybe an eventhandler to reset the radio range?

tender fossil
# crystal lagoon Maybe an eventhandler to reset the radio range?

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)
crystal lagoon
#

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

tender fossil
fleet sand
stable dune
#

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;
pulsar bluff
#
// slower
!(count _unitInJammerArea isEqualTo 0)
// faster
(_unitInJammerArea isnotequalto [])
tender fossil
#

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:

  1. 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
  2. Define an array of interfaces that the item implements in it's specific script.
  3. When the item script gets executed during runtime, retrieve the dependencies from the results of step 1
  4. 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!)

pulsar bluff
cold rampart
#

Is there a simple way to copy an array without making a reference

crystal lagoon
pliant stream
#
_myCopy = +_myArr;```