Jump to content
Freddywall

Map markers script

Recommended Posts

Hello, i got script which shows player markers on map, but it show only players in group. How to make it show all players on your side?

 

waitUntil {!isNull (finddisplay 12)}; ((findDisplay 12)

displayCtrl 51) ctrlAddEventHandler [

"Draw",

{

params ["_ctrl"];

{

_ctrl drawIcon [

getText (configFile >> "CfgVehicles" >> typeOf

_x >> "icon"),

[side _x] call BIS_fnc_sideColor,

_x,

32,

32,

getDir _x,

name _x,

true

]

} forEach (units (group player));

}

];

Share this post


Link to post
Share on other sites
waitUntil {!isNull (finddisplay 12)}; 
((findDisplay 12)displayCtrl 51) ctrlAddEventHandler ["Draw",{
	params ["_ctrl"];
	private _list = [];
	{
		if ((side _x) isEqualTo (side player)) then {
			_list pushBackUnique _x;
		}
	} forEach allPlayers;

	{

		_ctrl drawIcon [

			getText (configFile >> "CfgVehicles" >> typeOf _x >> "icon"), [side _x] call BIS_fnc_sideColor, _x,	32, 32, getDir _x, name _x, true

		];

	} forEach _list;

}];

//// 

May not be the most efficient way but i believe it works.

Share this post


Link to post
Share on other sites

this is the most efficient way that i can think of as it shouldnt affect game play performance what so ever when you dont have the map open.

when the player opens the map it will call a function that gets all players that are on the same side as the player that opened the map, it will loop through them and create markers for each of those players and store them in an array (each element holds the marker and the unit the marker is for). then it does a continuous loop that only runs while the player has the map open that iterates through the array and sets the markers position to the positions of each unit continually so you will see any movement they make on their map marker. if a player on your side dies while the map is open, it will delete their marker from the map and remove their element from the array. since players will probably be respawning, then it will *refresh* itself every 5 seconds so any player that dies gets removed from the map markers, any player that respawns (comes back into play) will be reshown on the map within 5-10 seconds. once the map is closed then it removes all of the markers. all the markers are created locally for the client who has their map open so throw this in initPlayerLocal.sqf

AddMissionEventHandler["Map",
{
	Params ["_MapIsOpened", "_MapIsForced"];
	
	if (_MapIsOpened) then
	{
		ShowAllOnMap = true;
		_nil = []Spawn {Call BUF_ShowUnitsOnMap;};
	} else
	{
		ShowAllOnMap = false;
	};
}];

BUF_GetPlayerSideMarkers =
{
	_MySide = side player;
	_Units = (allUnits select {isPlayer _x && alive _x && side _x isEqualTo _MySide});
	_Markers = [];
	
	{
		_UnitName = name _x;
		_Marker = createMarkerLocal [_UnitName, _x];
		_Marker setMarkerType "hd_dot";
		_Marker setMarkerColor ([_MySide, true] call BIS_fnc_sideColor);
		_Marker setmarkerText _UnitName;
		_Data = [_Marker, _x];
		_Markers pushBack _Data;
	} forEach _Units;
	_Markers
};

BUF_ShowUnitsOnMap =
{
	_Markers = call BUF_GetPlayerSideMarkers;
	
	_StartTime = time;
	while {ShowAllOnMap} do
	{
		_ControlIndex = 0;
		{
			_x params ["_Marker", "_Unit"];
			if (alive _Unit) then
			{
				_Marker setMarkerPosLocal _Unit;
			} else
			{
				deleteMarkerLocal _Marker;
				_Markers deleteAt _ControlIndex;
				_ControlIndex = _ControlIndex - 1;
			};
			_ControlIndex = _ControlIndex + 1;
		} forEach _Markers;
		if (_StartTime > time + 5) then
		{
			_Markers = call BUF_GetPlayerSideMarkers;
		};
	};
	{
		_x params ["_Marker", "_Unit"];
		DeleteMarkerLocal _Marker;
	} forEach _Markers;
};

 

Share this post


Link to post
Share on other sites
4 hours ago, gokitty1199 said:

this is the most efficient way that i can think of

What's wrong with the OPs original event? If the map is not open then the map ctrl does not draw.

 

11 hours ago, Freddywall said:

How to make it show all players on your side?

All players? or all units? on their side.

waitUntil{ !isNull findDisplay 12 };
findDisplay 12 displayCtrl 51 ctrlAddEventHandler[ "Draw", {
	params ["_map"];
	
	//All alive PLAYERS
	_units = allPlayers select{ alive _x && side _x isEqualTo side group player };
	//All alive UNITS
	//_units = allUnits select{ side _x isEqualTo side group player };
	
	{
		_map drawIcon [
			getText (configFile >> "CfgVehicles" >> typeOf _x >> "icon"),
			[side _x] call BIS_fnc_sideColor,
			_x,
			32,
			32,
			getDir _x,
			name _x,
			true
		]
	} forEach _units;
}]; 

Pretty much what @bumyplum showed you other than I have cleaned up the selection of units.

  • Like 1

Share this post


Link to post
Share on other sites

Hello I made a very easy marker script for playable units. It will follow the unit around the map and when the unit is killed or unconscious the marker will indicate the current location of the unit. I am curious to know what others think of this approach. Every unit can have a unique marker from the game selection from the editor. This was made for a open mission using MCC and Zeus. The mission has 105 playable units.  105the bird company.

 

#In game moveable unit markers
 *add codelines to MISSION.INIT.SQF
 *map markers placed on the map from editor. Most give Variable names to markers and the unit it will represent.

 


//Map markers for Playable units********** this code in Mission init. sqf

 

[] spawn {while {not isnull Bird_Company_Cap} do {"Bird_Company_Capmk"setmarkerpos getpos Bird_Company_Cap; sleep 0.5;};};
[] spawn {while {not isnull Bird_Company_Off2} do {"Bird_Company_Off2mk"setmarkerpos getpos Bird_Company_Off2; sleep 0.5;};};
[] spawn {while {not isnull Bird_Company_Off3} do {"Bird_Company_Off3mk"setmarkerpos getpos Bird_Company_Off3; sleep 0.5;};};
[] spawn {while {not isnull Bird_Company_Off4} do {"Bird_Company_Off4mk"setmarkerpos getpos Bird_Company_Off4; sleep 0.5;};};

 

[] spawn {while {not isnull Raven_SL} do {"Raven_SLmk" setmarkerpos getpos Raven_SL; sleep 0.5;};};
[] spawn {while {not isnull Raven_GL} do {"Raven_GLmk" setmarkerpos getpos Raven_GL; sleep 0.5;};};
[] spawn {while {not isnull Raven_MM} do {"Raven_MMmk" setmarkerpos getpos Raven_MM; sleep 0.5;};};
[] spawn {while {not isnull Raven_MG} do {"Raven_MGmk" setmarkerpos getpos Raven_MG; sleep 0.5;};};
[] spawn {while {not isnull Raven_RAT} do {"Raven_RATmk" setmarkerpos getpos Raven_RAT; sleep 0.5;};};
[] spawn {while {not isnull Raven_RS} do {"Raven_RSmk" setmarkerpos getpos Raven_RS; sleep 0.5;};};
[] spawn {while {not isnull Raven_ES} do {"Raven_ESmk" setmarkerpos getpos Raven_ES; sleep 0.5;};};
[] spawn {while {not isnull Raven_AT} do {"Raven_ATmk" setmarkerpos getpos Raven_AT; sleep 0.5;};};
[] spawn {while {not isnull Raven_AA} do {"Raven_AAmk" setmarkerpos getpos Raven_AA; sleep 0.5;};};
[] spawn {while {not isnull Raven_RO} do {"Raven_ROmk" setmarkerpos getpos Raven_RO; sleep 0.5;};};
[] spawn {while {not isnull Raven_MED} do {"Raven_MEDmk" setmarkerpos getpos Raven_MED; sleep 0.5;};};
[] spawn {while {not isnull Raven_AMED} do {"Raven_AMEDmk" setmarkerpos getpos Raven_AMED; sleep 0.5;};};

 

[] spawn {while {not isnull Falcon_SL} do {"Falcon_SLmk" setmarkerpos getpos Falcon_SL; sleep 0.5;};};
[] spawn {while {not isnull Falcon_GL} do {"Falcon_GLmk" setmarkerpos getpos Falcon_GL; sleep 0.5;};};
[] spawn {while {not isnull Falcon_MM} do {"Falcon_MMmk" setmarkerpos getpos Falcon_MM; sleep 0.5;};};
[] spawn {while {not isnull Falcon_MG} do {"Falcon_MGmk" setmarkerpos getpos Falcon_MG; sleep 0.5;};};
[] spawn {while {not isnull Falcon_RAT} do {"Falcon_RATmk" setmarkerpos getpos Falcon_RAT; sleep 0.5;};};
[] spawn {while {not isnull Falcon_RS} do {"Falcon_RSmk" setmarkerpos getpos Falcon_RS; sleep 0.5;};};
[] spawn {while {not isnull Falcon_ES} do {"Falcon_ESmk" setmarkerpos getpos Falcon_ES; sleep 0.5;};};
[] spawn {while {not isnull Falcon_AT} do {"Falcon_ATmk" setmarkerpos getpos Falcon_AT; sleep 0.5;};};
[] spawn {while {not isnull Falcon_AA} do {"Falcon_AAmk" setmarkerpos getpos Falcon_AA; sleep 0.5;};};
[] spawn {while {not isnull Falcon_RO} do {"Falcon_ROmk" setmarkerpos getpos Falcon_RO; sleep 0.5;};};
[] spawn {while {not isnull Falcon_MED} do {"Falcon_MEDmk" setmarkerpos getpos Falcon_MED; sleep 0.5;};};
[] spawn {while {not isnull Falcon_AMED} do {"Falcon_AMEDmk" setmarkerpos getpos Falcon_AMED; sleep 0.5;};};

 

[] spawn {while {not isnull Hawk_LPar} do {"Hawk_LParmk" setmarkerpos getpos Hawk_LPar; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par2} do {"Hawk_par2mk" setmarkerpos getpos Hawk_Par2; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par3} do {"Hawk_par3mk" setmarkerpos getpos Hawk_Par3; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par4} do {"Hawk_par4mk" setmarkerpos getpos Hawk_Par4; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par5} do {"Hawk_par5mk" setmarkerpos getpos Hawk_Par5; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par6} do {"Hawk_par6mk" setmarkerpos getpos Hawk_Par6; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par7} do {"Hawk_par7mk" setmarkerpos getpos Hawk_Par7; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par8} do {"Hawk_par8mk" setmarkerpos getpos Hawk_Par8; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par9} do {"Hawk_par9mk" setmarkerpos getpos Hawk_Par9; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par10} do {"Hawk_par10mk" setmarkerpos getpos Hawk_Par10; sleep 0.5;};};
[] spawn {while {not isnull Hawk_Par11} do {"Hawk_par11mk" setmarkerpos getpos Hawk_Par11; sleep 0.5;};};
[] spawn {while {not isnull Hawk_AMed} do {"Hawk_AMedmk" setmarkerpos getpos Hawk_AMed; sleep 0.5;};};

 

 

 

Works great for me is it the most efficient way I don't know but I don't see any real lag due to it.

 

 

Share this post


Link to post
Share on other sites
8 hours ago, Larrow said:

What's wrong with the OPs original event? If the map is not open then the map ctrl does not draw.

 

nothing wrong, ive always preferred event handlers to trigger things if all possible (hence "the most efficient way i can think of"). what would be the better way?

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

×