Jump to content
Sign in to follow this  
holo89

[Script] Simple script to put user created markers (MP) in world

Recommended Posts

I saw KillzoneKid's blog on the drawIcon3D and it inspired me for something I was thinking for since months.

It is a script that you can add to your MP Mission (could work in SP probably), that will put the marker's text of user created markers during a game on the 3D world while playing.

Let say you want to put an LZ marker, the LZ text will be seen by the pilot (and everyone) without having to check the map.

I know, for those RP players, it's not an option, but I like gadget like this in my mission.

Here is the code:

UserMarkers.sqf

// Users Markers transformed to 3D Icons Markers
aUserMarkers = [];  // array of arrays composed of [[[position1],"Text to show1"],[[position2],"Text to show2"], ...] 
                   // example when two Users Markers are found [[[34.022,45.019,0],"LZ Safe"],[[39.543,22.827,0],"Pick me Up!"]]
userMarkersUp = true; //a variable to toggle it on / off with a radio Alpha trigger for example or based of a minimum frame rate returned by diag_fps

//the background loop that look for new Users Markers and add it to the array aUserMarkers
[] spawn {
   private ["_userMarkerNaming","_tmpUserMarker"];
   _userMarkerNaming = "_USER_DEFINED #"; // for example "_USER_DEFINED #2/0"
   while {true} do {
       sleep 15; // Markers update interval in seconds
       aUserMarkers = [];

       {
           if ([_userMarkerNaming, _x, true] call BIS_fnc_inString) then {

               _tmpUserMarker = [getMarkerPos _x, MarkerText _x];
               aUserMarkers = aUserMarkers + [_tmpUserMarker];
           };
       } foreach allMapMarkers;
   };
};

// Code to be executed on each frame since drawIcon3D stay for few miliseconds, 
// it has to be executed every frame to stay displayed steady. That is what Draw3D mEH is for, thanks Xeno
_idx = addMissionEventHandler ["Draw3D",  {
   if (userMarkersUp) then {
       {
           drawIcon3D [
               "",
               [1,1,1,0.5],
               _x select 0,
               0,
               0,
               0,
               _x select 1,
               0,
               0.03,
               "PuristaMedium"
           ];
       } foreach aUserMarkers;
   };
}];

You need to put this in your init.sqf :

_null = [] execVM "UserMarkers.sqf";

... preferably somewhere a dedicated server is not executing the code.

Also this is the trigger I use for now in the mission to toggle the markers on / off in case some people don't like it.

mission.sqm trigger example

	class Item4
	{
		position[]={1375.9983,-40.02404,5773.5405};
		activationBy="BRAVO";
		repeating=1;
		interruptable=1;
		age="UNKNOWN";
		text="User Markers Toggle";
		expActiv="if (userMarkersUp) then {userMarkersUp = false} else {userMarkersUp = true};";
		class Effects
		{
		};
	};

Hope this could help someone else...

TODO: Matching the color the user gave to the marker, for now it is always white (1,1,1) with a 0.5 alpha.

PS: This is my first script "released", I need your feedback, like if I done something wrong... I want to know.

Edited by holo89
Adding the trigger

Share this post


Link to post
Share on other sites

Just implemented this into one of my missions -

All my team members love it.

GREAT WORK!

Thannks for sharing

Oh and just to let you know we use it on a dedi and hosted it works perfectly and is JIP compatible

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  

×