Jump to content
Sign in to follow this  
bangabob

Marker Localisation System

Recommended Posts

Marker Localisation System (MLS)



By BangaBob



Description

Easily localise markers according to players - side, group, faction and name. Fully MP compatible.

Instructions

Add this code into the init.sqf

null = [] execVM "H8_LocMkr_OpenMe.sqf";

Open "H8_LocMkr_OpenMe.sqf" and place your initial markers inside.

Arguments

0 = [["ARG1"],[ARG2],ARG3] spawn H8_addMarker;

ARG1 - Marker Name (String) | Paste the name of the marker you wish to localise. Can be ordered as a list for multiple markers.

ARG2 - (SIDE, GROUPNAME, UNITNAME, FACTION) | Define who can see the marker. Can be ordered as a list for multiple conditions.

  • SIDES = WEST, EAST, INDEPENDENT, CIVILIAN
  • FACTIONS = "BLU_F","BLU_G_F","OPF_F","OPF_G_F","IND_F","IND_G_F","CIV_F"

ARG3 - Marker Alpha (Integer) | Define the alpha of the marker. 0 = Invisible. 1 = Max Alpha. (Default 1).

Examples

Localise "mkr_3" to ONLY west units

0 = [["mkr_3"],[WEST]] spawn H8_addMarker;  

Localise "mkr_1" and "mkr_2" to ONLY independent units

0 = [["mkr_1","mkr_2"],[iNDEPENDENT]] spawn H8_addMarker; 

Localise "mkr_4" to "BLU_F" faction and the unit named PLAYER1

0 = [["mkr_4"],["BLU_F", PLAYER1]] spawn H8_addMarker;	 

Localise "mkr_5" and "mkr_6" to groups, group1 & group2 and set the alpha to 0.7

0 = [["mkr_5","mkr_6"],[group1,group2],0.7] spawn H8_addMarker; 

Functions

Update Marker Alpha

0 = [["MKR_1"],0.3] spawn H8_updateAlpha;

Remove Marker

0 = ["MKR_2"] spawn H8_removeMkr;

Get local Marker

_localMkr = ["mkr"] call H8_getLocalMkr;

Get all markers

_addedMarkers = H8_markerArray (Returns array of all markers);

waitUntil INIT complete

waitUntil {!isNil ("H8_initComplete")};

Download

here v1.0

ArmaHolic Link



OR

Take a look inside the script below!

H8_LocMkr_OpenMe.sqf

H8_Localinit = {
/* Marker Localisation Script by BangaBob (H8erMaker) v1.0
Description
Easily localise markers according to players - side, group, faction and name.

Instructions 
Add this code into the init.sqf 
	 null = [] execVM "H8_LocMkr_OpenMe.sqf";

Arguments
0 = [["ARG1"],[ARG2],ARG3] spawn H8_addMarker;

ARG1 - Marker Name (String) | Paste the name of the marker you wish to localise. Can be ordered as a list for multiple markers.

ARG2 - (SIDE, GROUPNAME, UNITNAME, FACTION) | Define who can see the marker. Can be ordered as a list for multiple conditions.
	SIDES 		= WEST, EAST, INDEPENDENT, CIVILIAN
	FACTIONS 	= "BLU_F","BLU_G_F","OPF_F","OPF_G_F","IND_F","IND_G_F","CIV_F"

ARG3 - Marker Alpha (Integer) | Define the alpha of the marker. 0 = Invisible. 1 = Max Alpha. (Default 1).

Examples
0 = [["mkr_3"],[WEST]] spawn H8_addMarker;  				// Localise "mkr_3" to ONLY west units
0 = [["mkr_1","mkr_2"],[iNDEPENDENT]] spawn H8_addMarker;	// Localise "mkr_1" and "mkr_2" to ONLY independent units
0 = [["mkr_4"],["BLU_F", PLAYER1]] spawn H8_addMarker;		// Localise "mkr_4" to "BLU_F" faction and the unit named PLAYER1
0 = [["mkr_5","mkr_6"],[group1,group2],0.7] spawn H8_addMarker;	// Localise "mkr_5" and "mkr_6" to groups, group1 & group2 and set the alpha to 0.7

Functions
Update Marker Alpha
	0 = [["MKR_1"],0.3] spawn H8_updateAlpha;

Remove Marker
	0 = ["MKR_2"] spawn H8_removeMkr;

Get local Marker
	_localMkr = [] call H8_getLocalMkr;

Get all markers
	_addedMarkers = H8_markerArray (Returns array of all markers);

waitUntil INIT complete
	waitUntil {!isNil ("H8_initComplete")};


					CALL YOUR MARKERS BELOW!
*/



//	DO NOT EDIT BELOW	//
};
#define FACTIONARRAY 	["BLU_F","BLU_G_F","OPF_F","OPF_G_F","IND_F","IND_G_F","CIV_F"]
#define LOCALPREFIX		"h8"

H8_addMarker = {
 if (isServer) then {
  private ["_preAlpha"];
_mkrArray =		(_this select 0);
_condArray =	[_this, 1, []] call BIS_fnc_param;
_alpha =		[_this, 2, -1] call BIS_fnc_param;

		{
	_mkr = _x;
	{
_cond=_x;
if (_alpha != -1) then {

_preAlpha = _alpha;

		}else{
	_preAlpha = markerAlpha _mkr;
	 if (_preAlpha == 0) then {
		_preAlpha = 0.5;
			};
};

H8_markerArray set [count H8_markerArray,_mkr];

_mkrProperties = [_x,_mkr,_preAlpha];
H8_markerProperties set [count H8_markerProperties,_mkrProperties];	


	if (!isDedicated) then {
0 = [_mkrProperties] spawn H8_fnc_Localise;
					};//RUN IN EDITOR

		}forEach _condArray;
	_mkr setMarkerAlpha 0;
			}forEach _mkrArray;
publicVariable "H8_markerArray"; // SEND TO ALL CLIENTS
publicVariable "H8_markerProperties"; // SEND TO ALL CLIENTS
 };
};



H8_checkCond = {
// Credit SHUKO for this code
   _cond = _this select 0;

     switch (typename _cond) do {
       case (typename grpNull): { (player in (units _cond)) };
       case (typename objNull): { player == _cond };
       case (typename WEST):    { (side player == _cond) };
       case (typename true):    { _cond };
       case (typename ""): {
         if (_cond in FACTIONARRAY) then {
           (faction player == _cond)
         };
       };
       default { false };
     };
 };



H8_removeMkr = {
 private ["_index","_tempProperties"];
  _mkrsToUpdate =	_this;

	{
_mkrToUpdate = _x;
_indexs = [_mkrToUpdate] call H8_findIndex;

		{
	_index = _x;

	H8_markerProperties set [_index, "delete_me"];
	H8_markerProperties = H8_markerProperties - ["delete_me"];;
		}foreach _indexs;

0 = [[_mkrToUpdate],"H8_deleteLocalMkr",true] call BIS_fnc_MP;
	}forEach _mkrsToUpdate;


publicVariable "H8_markerProperties";
 };



H8_deleteLocalMkr = {
_mkr = 		(_this select 0);
_localMkr = format ["%2%1",_mkr,LOCALPREFIX];

deleteMarkerLocal _localMkr;
}; 



H8_updateAlpha = {
  _mkrsToUpdate =	(_this select 0);
  _alphatoUpdate =	(_this select 1);

	{
_mkrToUpdate = _x;
_indexs = [_mkrToUpdate] call H8_findIndex;

		{
_index = _x;
_tempProperties = H8_markerProperties select _index;
_tempProperties = [(_tempProperties select 0),(_tempProperties select 1),_alphatoUpdate];

	H8_markerProperties set [_index,_tempProperties];

	if (!isDedicated) then {0 = [_tempProperties] spawn H8_fnc_Localise;};//RUN IN EDITOR
		}foreach _indexs;
	}foreach _mkrsToUpdate;

publicVariable "H8_markerProperties";
 };



H8_findIndex = {
private ["_index","_return"];
_mkrToUpdate =	(_this select 0);

_index =	0;
_return = 	[];


	{
_mkr = (_x select 1);

if (_mkrToUpdate == _mkr) then {
_return set [count _return,_index]
			};

_index = _index + 1;
	}forEach H8_markerProperties;

_return // RETURN INDEXS FOR MARKERS
};



// LOCAL SCRIPTS
H8_getLocalMkr = {
 _mkr	=	(_this select 0);
 _localMkr = 	format ["%2%1",_mkr,LOCALPREFIX];

 _localMkr //RETURN
};



H8_fnc_Localise = {
_markerProperties = (_this select 0);
_cond =	(_markerProperties select 0);

_return = [_cond] call H8_checkCond;

if (_return) then {
	_mkr =		(_markerProperties select 1);
	_preAlpha =	(_markerProperties select 2);

	0 = [_mkr,_preAlpha] call H8_fnc_createMkr;
	};	
};



H8_fnc_createMkr = {
if (!isDedicated) then {

 _mkr =		(_this select 0);
 _preAlpha =	(_this select 1);

_localMkr = 	format ["%2%1",_mkr,LOCALPREFIX];

if (getMarkerColor _localMkr == "") then {
_localMkr = createMarkerLocal [_localMkr,(getMarkerPos _mkr)];
	};

	_localMkr setMarkerAlphaLocal 	_preAlpha;
	_localMkr setMarkerPosLocal		(markerPos _mkr);
	_localMkr setMarkerColorLocal 	(markerColor _mkr);
	_localMkr setMarkerDirLocal 	(markerDir _mkr);
	_localMkr setMarkerShapeLocal 	(markerShape _mkr);
	_localMkr setMarkerSizeLocal 	(getMarkerSize _mkr);
	_localMkr setMarkerTextLocal 	(markerText _mkr);
	_localMkr setMarkerTypeLocal 	(markerType _mkr);
	_localMkr setMarkerBrushLocal 	(markerBrush _mkr);
};
};


// RUN FOR SERVER
if isServer then {
if (isNil ("H8_markerProperties")) then {
	H8_markerProperties = [];
	publicVariable "H8_markerProperties";};
if (isNil ("H8_markerArray")) then {
	H8_markerArray = [];
	publicVariable "H8_markerArray";};

0 = [] spawn H8_Localinit;
};



// RUN FOR JIP PLAYERS
if (!isServer && (player != player)) then { waitUntil {player == player}; waitUntil {time > 15};};


if (!isNil ("H8_markerProperties")) then {
		{
_mkrProperties = _x;
0 = [_mkrProperties] spawn H8_fnc_Localise;
		}forEach H8_markerProperties;
	};

"H8_markerProperties" addPublicVariableEventHandler {
		{
_mkrProperties = _x;
   0 = [_mkrProperties] spawn H8_fnc_Localise;
		}foreach H8_markerProperties;
};

H8_initComplete = TRUE;

Edited by BangaBob
  • Like 1

Share this post


Link to post
Share on other sites

Very nice, I'm sure lot's of multiplayer mission makers will find this useful.

Share this post


Link to post
Share on other sites

Very clever,

I knew it was possible to draw markers in multiplayer local to which chat channel you're in, but your additional options make this a gem.

would it be possible to use drawIcon and a draw eventhandler on the map instead of markers?

No idea about localization, so I'm curious.

Cheers

Share this post


Link to post
Share on other sites
Very nice, I'm sure lot's of multiplayer mission makers will find this useful.

Yes thank you for this.. saves some annoying headaches :)

Share this post


Link to post
Share on other sites
Very clever,

I knew it was possible to draw markers in multiplayer local to which chat channel you're in, but your additional options make this a gem.

would it be possible to use drawIcon and a draw eventhandler on the map instead of markers?

No idea about localization, so I'm curious.

Cheers

In theory yes. Anything that is local to the player could be done in a similar method.

I think that the drawIcon is local to the player. So take the barebones of this script and adapt it for drawIcon instead of markers if you like.

---------- Post added at 19:20 ---------- Previous post was at 19:19 ----------

Yes thank you for this.. saves some annoying headaches :)

You're welcome. I was surprised that there aren't any other scripts that do this already.

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites
Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Awesome. Thanks!

Share this post


Link to post
Share on other sites

hey,

I want to use the follow car script to follow around 30 cillivians for only the indepentent player to see.

how would i execute that locally on a dedicated server for the independent player? and would I need to

make that same script 30 times (one for each civ) to get it working?

please let me know if that makes sense ;)

awesome script, perfect for my mission.

Share this post


Link to post
Share on other sites
hey,

I want to use the follow car script to follow around 30 cillivians for only the indepentent player to see.

how would i execute that locally on a dedicated server for the independent player? and would I need to

make that same script 30 times (one for each civ) to get it working?

please let me know if that makes sense ;)

awesome script, perfect for my mission.

Each marker is local to the player. Therefore to move/change the marker the script has to be run on the players machine.(Not dedicated).

Something like this ran from the init.sqf (After MLS has initiated)

MoveMarker.sqf


_civs = []; //INSERT CIVILIANS HERE
while {true} do {
 {
_localMkr = [(format ["%1mkr",_x])] call H8_getLocalMkr; //MARKER NAME INSERTED HERE
_localMkr setMarkerPos _x;
 }forEach _civs;
sleep 1;//DELAY FOR UPDATING THE MARKER
};

This is a rough concept. It will need adapting depending on how you are generating the markers.

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  

×