Jump to content
Rawshark

Marking player position on death in the map

Recommended Posts

So for a multiplayer session, I want to create a script that will mark the position of any friendly BLUFOR player should they go unconscious/awaiting revive...and upon a successful revive have that maker be deleted. It's not a PvP mission so the marker should only be visible to players on the same side.

This is what I've come up with so far but I haven't been able to test it atm. Can someone point out if there is any glaring errors with it or know a better code I could implement:

_player = _x; _mrk = format ["%1",_player];

_mrk setMarkerTextLocal format ["%1 Injured",name _player]; _mrk setMarkerColorLocal "ColorRed";

I am not certain a) what BIS_func I have to call for checking player state as there only seems to be a 'BIS fnc paramReviveUnconsciousStateMode' option to check before dropping the marker

b) I am not sure how to then remove said "injured" marker if the revive is complete. Could I get away with:

While (true) do { injured marker code; }

else

{deleteMarkerLocal _x} forEach _markers;

Any help would be appreciated as I am not the best at this. thanks.

Share this post


Link to post
Share on other sites
0 = [] spawn {
  while {true} do {
    _allUnits = allUnits select { isNil {_x getVariable "Raw_incap"}};
    {
       _x spawn {
        params ["_unit"];
        _unit setVariable ["Raw_incap",true];
        _unit addEventHandler ["AnimChanged", {
            params ["_unit", "_anim"];
            if (lifeState _unit == "incapacitated" and side group _unit == playerSide) then {
               _mrk = createMarkerLocal [str (_unit), getposATL _unit];
               _mrk setMarkerTypeLocal "mineFieldAP";
               _mrk setMarkerSizeLocal [0.7,0.7];
               _mrk setMarkerColorLocal ([playerSide,  true] call BIS_fnc_sideColor);
            } else {
              deleteMarkerLocal str (_unit);
            };
        }];
      };
    } forEach _allUnits;
    sleep 2;
  }
};

in init.sqf  or initPlayerLocal.sqf

 

  • Like 4

Share this post


Link to post
Share on other sites
35 minutes ago, GEORGE FLOROS GR said:

 

Pierre , if it is "createMarkerLocal" then the other players will not see the markers right ?

https://community.bistudio.com/wiki/createMarkerLocal

https://community.bistudio.com/wiki/createMarker

 

I believe it's by design George, the code makes each client manage it's own set of local markers. It's a good way to keep network traffic low since each update needs to be broadcast otherwise.

I am a bit confused as to why the "setMarkerXXX" aren't using the local variant though since AFAIK they would make the local marker go global. @pierremgi Can you clarify?

Share this post


Link to post
Share on other sites
8 hours ago, GEORGE FLOROS GR said:

 

Pierre , if it is "createMarkerLocal" then the other players will not see the markers right ?

https://community.bistudio.com/wiki/createMarkerLocal

https://community.bistudio.com/wiki/createMarker

Yep

 

Oups! I copied/pasted a createMarker code from one of my script and forgot to adapt it . For course, you must use local commands everywhere. Yes, creating a maker local and adding some global features will transform it in global version one... And deleteMarkerLocal will work only on the local PC, leaving the marker everywhere else.

 

Corrected above! sorry.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×