Jump to content
Sign in to follow this  
Alo Keen

MP map friendly player markers

Recommended Posts

Either there is a very easy way to do this and I've missed it, or I just couldn't find it on its own... but anyway:

A script to display friendly units on the map, nothing fancy. Requires units in the editor to be named. Will deal with it if needed.

I'd appreciate feedback on performance, or anything else you might think of.

Optional name tags on players in the field sounds like an idea someone's going to have - yeah, thought of that but didn't want/need it. Could squeeze it in as an option, I guess.


if(!isDedicated) then {
   waitUntil {!isNull player && isPlayer player};
   private["_unit", "_unitList", "_mySide", "_unitName", "_aMarker", "_aMarker"];
   player addMPEventHandler ["MPRespawn", { [_this select 0] spawn pinMarkerF;}];
   pinMarkerF = {
       _unit = (_this select 0);
       _unitList = allUnits;
       _mySide = side _unit;
       {
           if((side _x) == _mySide) then {
               _unitName = name _x;
               _aMarker = vehicleVarName _x;
               _aMarker = createMarkerLocal [_aMarker,[0,0]];
               _aMarker setMarkerShapeLocal "ICON";
               _aMarker setMarkerTypeLocal "mil_dot";
               _aMarker setMarkerTextLocal _unitName;
               _aMarker setMarkerSizeLocal [1,1];
               _aMarker setmarkerDirLocal (getdir _x);
               _aMarker setMarkerPosLocal (getPos _x);
               _aMarker setMarkerTextLocal _unitName;
               _aMarker setMarkerColorLocal "ColorGreen";
           };
       } foreach _unitList;

       while {alive _unit} do {
           {
           _aMarker = vehicleVarName _x;
           _aMarker setMarkerDirLocal (getDir _x);
           _aMarker setMarkerPosLocal (getPos _x);
           } foreach _unitList;
               sleep 0.2; 
       };
       _myVarName = vehicleVarName _unit;
       _myVarName setMarkerColorLocal "ColorBlack";
       sleep 3;
       deleteMarkerLocal _myVarName;
   };
   [player] spawn pinMarkerF;
};if(!isDedicated) then {
   waitUntil {!isNull player && isPlayer player};
   private["_unit", "_unitList", "_mySide", "_unitName", "_aMarker", "_aMarker"];
   player addMPEventHandler ["MPRespawn", { [_this select 0] spawn pinMarkerF;}];
   pinMarkerF = {
       _unit = (_this select 0);
       _unitList = allUnits;
       _mySide = side _unit;
       {
           if((side _x) == _mySide) then {
               _unitName = name _x;
               _aMarker = vehicleVarName _x;
               _aMarker = createMarkerLocal [_aMarker,[0,0]];
               _aMarker setMarkerShapeLocal "ICON";
               _aMarker setMarkerTypeLocal "mil_dot";
               _aMarker setMarkerTextLocal _unitName;
               _aMarker setMarkerSizeLocal [1,1];
               _aMarker setmarkerDirLocal (getdir _x);
               _aMarker setMarkerPosLocal (getPos _x);
               _aMarker setMarkerTextLocal _unitName;
               _aMarker setMarkerColorLocal "ColorGreen";
           };
       } foreach _unitList;

       while {alive _unit} do {
           {
           _aMarker = vehicleVarName _x;
           _aMarker setMarkerDirLocal (getDir _x);
           _aMarker setMarkerPosLocal (getPos _x);
           } foreach _unitList;
               sleep 0.2; 
       };
       _myVarName = vehicleVarName _unit;
       _myVarName setMarkerColorLocal "ColorBlack";
       sleep 3;
       deleteMarkerLocal _myVarName;
   };
   [player] spawn pinMarkerF;
};

Include this line in your init.sqf, the script does the server check. Or feel free to mess around, this is what I was working with :)

[] execVM "marker.sqf";

Edited by Ceh
Layout and clarity

Share this post


Link to post
Share on other sites

NP, if anyone uses this I'd appreciate feedback on performance, and if any experienced coders bump into this, I'm open to suggestions on best practices etc.

Is there benefit from formally releasing this in the other topic, does it warrant a release and all that....?

I saw a tutorial that should allow the same functionality through use of modules in the editor, but couldn't find mentioned module in A3. Will look in A2. Perhaps an old tut, or I was too tired....

Share this post


Link to post
Share on other sites

Request: in my Team vs. team mission I want markers to follow specified units. blufor cant se opfor markers, and opfor can't see blufor markers. I don't want to use colored text like your screenshot, but a simple Infantry marker

Share this post


Link to post
Share on other sites
Request: in my Team vs. team mission I want markers to follow specified units. blufor cant se opfor markers, and opfor can't see blufor markers. I don't want to use colored text like your screenshot, but a simple Infantry marker

OK, I understand blufor/opfor not seeing each other, I have solved that in a version of script we are using in some missions, but can you be a bit more clear on "specified units" or was it with regard to BLUFOR/OPFOR seeing each other?

Also, which kind of marker would you like? An arrow (useful for showing direction of player) or...?

Share this post


Link to post
Share on other sites

I don't know if you are still maintaining the script but here is a suggestion:

Your script is showing also AI. Could you build-in a possibility to show only the players?

Share this post


Link to post
Share on other sites

Heh, never thought of them - we weren't using AI :D Will look into it, gotta find an updated version somewhere...

EDIT: got a file from one of my folders - haven't tested it to see if it's the working version, got some work to do ATM. If it doesn't drop a note here I'll try to look into it ASAP.

if(!isDedicated) then {
   waitUntil {!isNull player && isPlayer player};
   private["_unitList", "_mySide", "_unitName", "_aMarker", "_dMarker", "_killedMarker"];
   player addMPEventHandler ["MPRespawn", { [_this select 0] spawn nc_pinMarkerF;}];
   player addMPEventHandler ["MPKilled", {[_this select 0] spawn nc_playerKilledF}];

   nc_playerKilledF = {
       private["_unit"];
       _unit = (_this select 0);
       _killedMarker = vehicleVarName _unit;
       _killedMarker setMarkerAlphaLocal 0.5;
       _killedMarker setMarkerColorLocal "ColorBlack";
       sleep 3;
       deleteMarkerLocal _killedMarker;

   };

   nc_pinMarkerF = {
       private["_unit"];
       _unit = (_this select 0);
       _unitList = allUnits;


       _mySide = side _unit;
       {
           if(isPlayer _x) then {
               if((side _x) == _mySide) then {
                   if (getMarkerColor _aMarker == "") then {
                       _unitName = name _x;
                       _aMarker = vehicleVarName _x;
                       _aMarker = createMarkerLocal [_aMarker,[0,0]];
                       _aMarker setMarkerShapeLocal "ICON";
                       _aMarker setMarkerTypeLocal "mil_arrow2";
                       _aMarker setMarkerTextLocal _unitName;
                       _aMarker setMarkerSizeLocal [0.5,0.75];
                       _aMarker setmarkerDirLocal (getdir _x);
                       _aMarker setMarkerPosLocal (getPos _x);
                       _aMarker setMarkerTextLocal _unitName;
                       _aMarker setMarkerColorLocal "ColorGreen";
                       _aMarker setMarkerAlphaLocal 0.5;
                   };
               };
           };
       } foreach _unitList;

       while {alive _unit} do {
           _unitList = allUnits;
           if (cameraView == "External") then {
               _unit switchCamera "Internal";
           };


           {
               if(isPlayer _x) then {
                   _aMarker = vehicleVarName _x;
                   _unitName = name _x;

                   if((side _x) == _mySide) then {
                       if (getMarkerColor _aMarker == "") then {
                           _aMarker = createMarkerLocal [_aMarker,[0,0]];
                           _aMarker setMarkerShapeLocal "ICON";
                           _aMarker setMarkerTypeLocal "mil_arrow2";
                           _aMarker setMarkerSizeLocal [0.5,0.75];
                           _aMarker setMarkerColorLocal "ColorGreen";
                           _aMarker setMarkerAlphaLocal 0.5;
                       };
                   };
                   _aMarker setMarkerTextLocal _unitName;                
                   _aMarker setMarkerDirLocal (getDir _x);
                   _aMarker setMarkerPosLocal (getPos _x);
               };
           } foreach _unitList;
           sleep 0.3; 
       };

   };
   [player] spawn nc_pinMarkerF;


};

Edited by Ceh

Share this post


Link to post
Share on other sites

Hey id like to see all the opponents on a mod im making, is there a script to make the other team visible on my map? i want team A to see team B and team B NOT to be able to see team A. id also like this to be from the start of the mission regardless of visible sight or contact.

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
Sign in to follow this  

×