Jump to content
Sign in to follow this  
mr_shadow

[CODE] markers

Recommended Posts

Hello, can someone please help me?

The help is about changing the code, so it will create a marker on the map BUT only for player(so it wont display all the players on the map like "local")

I have tryed change _x to player but it will stick on the map without moving.

The other things is that if the player have varriable "gps" now, it will display all postions of all player on the map.

I want it to display only your current posistion of one player but in as global marker.

// Markers.sqf

while {true} do
{
   {
       deleteMarkerLocal _x;

   } foreach Markers;



Markers = [];
   if (side player == civilian) then {
        if((player getVariable "gps") == 1) then{
       { 
           if (side _x == civilian) then
           {

               _marker = createMarkerLocal[name _x, getpos _x];
               _marker setMarkerTypeLocal "o_unknown";
               _marker setMarkerColorLocal "coloryellow";
               _text = format ["%1: %2",_x,(name _x)];
               _marker setMarkerTextLocal _text;
               Markers = Markers + [_marker];
           };

       } foreach playableUnits;
   };
    };
   sleep 2;
}

Edited by mr_shadow

Share this post


Link to post
Share on other sites

I've found the easiest way to create player markers is to first set up the marker with the attributes you want, then setPos to the object/player you want to show, rather than deleting and re-creating it.

EDIT: I wrote some code a while back on the forum for another guy asking almost the same thing, if you look a bit it shouldn't be too hard to find

Share this post


Link to post
Share on other sites

Its not the things im looking for, the target is with this varrible and making it visibale only for player< but globally on a map. So u will see everyone who is using it right now.

Share this post


Link to post
Share on other sites

Let me get this straight, because I still don't seem to understand.

You want to create local markers representing every player using the GPS at that moment I'm looking at my map? What do you mean by "globally on the map" then?

Or do you mean, everyone looking at his map shall see who else has his GPS open right now?

Share this post


Link to post
Share on other sites

The person in a mission can buy a phone.

This "phone" have a gps function which is being executed from init.sqf

Theoritically when the player press to turn it on - its creating your marker on a map(createMarkerglobal, cus the local will make it only for player side).

So basically even the player from the pther team will see your marker on a map when you started useing this script.

The key, itself. makes only this:

gps.sqf

if((player getVariable "gps") == 0) then
		{
		player setVariable["gps",1,true];
		player globalChat format["GPS is now ON"];
}else{
if((player getVariable "gps") == 1) then
		{
		player setVariable["gps",0,true];
		player globalChat format["GPS is now OFF"];
};}

and the marker script is cheking for this varriable.

However, for now it works like, even if u do have this phone and the another player not, it will create a marker with his position.

Hope I'm clear to understand now.

Share this post


Link to post
Share on other sites

So basically, phone is turned on, the GPS is "initialized", and the player see's his position, and only his position on the GPS, but even if another player had a GPS, they won't be able to see eachother's positions?

But your issue now is that it creates a marker on the player's position no matter if he is possesion of the phone or not? Sorry but your wording of it is kind of confusing.

Edited by JShock

Share this post


Link to post
Share on other sites

Idea is - if the another player have gps they will see each other.

But now if the another dont have it - the first one will see him on th map.

But your issue now is that it creates a marker on the player's position no matter if he is possesion of the phone or not?

So basically yes.

Edited by mr_shadow

Share this post


Link to post
Share on other sites

You've got nothing checking if the other character has that phone variable.

correction:

           if ((side _x == civilian)&&(_x getVariable ["gps",0] == 1)) then
           {

               _marker = createMarkerLocal[name _x, getpos _x];
               _marker setMarkerTypeLocal "o_unknown";
               _marker setMarkerColorLocal "coloryellow";
               _text = format ["%1: %2",_x,(name _x)];
               _marker setMarkerTextLocal _text;
               Markers pushBack _marker;
           };

Also, don't use: Array = Array + [element];,

use: Array pushBack element;

It's faster.

Share this post


Link to post
Share on other sites

// Markers.sqf

while {true} do
{
   {
       deleteMarkerLocal _x;

   } foreach Markers;



   Markers = [];
   if (side player == civilian) then {
        if((player getVariable "gps") == 1) then{
       { 
         if ((side _x == civilian)&&(_x getVariable ["gps",0] == 1)) then
           {

               _marker = createMarkerLocal[name _x, getpos _x];
               _marker setMarkerTypeLocal "o_unknown";
               _marker setMarkerColorLocal "coloryellow";
               _text = format ["%1: %2",_x,(name _x)];
               _marker setMarkerTextLocal _text;
               Markers pushBack _marker;
           };

       } foreach playableUnits;
   };
    };
   sleep 2;
} ; 

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  

×