Advertisement
Guest User

Example for MapMark.inc

a guest
Sep 11th, 2011
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.65 KB | None | 0 0
  1. #include <a_samp>
  2. #include <mapmark>
  3.  
  4. new Float:GPSx[MAX_PLAYERS];
  5. new Float:GPSy[MAX_PLAYERS];
  6. new bool:GPSon[MAX_PLAYERS];
  7.  
  8. public OnPlayerCommandText(playerid, cmdtext[])
  9. {
  10.     if (strcmp("/map", cmdtext, true) == 0)
  11.     {
  12.         SendClientMessage(playerid,0x00FF00FF,"Mark a position on the map to transmit it to the server!");
  13.        
  14.         SetPlayerMarkingMap(playerid,1);
  15.        
  16.         return 1;
  17.     }
  18.    
  19.     if (strcmp("/gps", cmdtext, true) == 0)
  20.     {
  21.         SendClientMessage(playerid,0x00FF00FF,"Mark a position on the map to transmit it to the server!");
  22.  
  23.         SetPlayerMarkingMap(playerid,2);
  24.  
  25.         return 1;
  26.     }
  27.     return 0;
  28. }
  29. public OnPlayerMarkMap(playerid, MarkID, Float:X, Float:Y, Float:Z)
  30. {
  31.     if(MarkID == 1)
  32.     {
  33.         SendClientMessage(playerid,0xFF0000FF,"MapIcon successfully set.");
  34.         SetPlayerMapIcon(playerid,1,X,Y,Z,32,0,MAPICON_GLOBAL);
  35.     }
  36.     if(MarkID == 2)
  37.     {
  38.         GPSx[playerid] = X;
  39.         GPSy[playerid] = Y;
  40.         GPSon[playerid] = true;
  41.         SetTimerEx("GPSTimer",3000,0,"d",playerid);
  42.     }
  43. }
  44.  
  45. forward GPSTimer(playerid);
  46. public GPSTimer(playerid)
  47. {
  48.     if(!GPSon[playerid]) return 0;
  49.    
  50.     new Float: Distance;
  51.     new Float:X, Float:Y, Float:Z;
  52.    
  53.     GetPlayerPos(playerid,X,Y,Z);
  54.     if(IsPlayerInAnyVehicle(playerid)) GetVehiclePos(GetPlayerVehicleID(playerid),X,Y,Z);
  55.    
  56.     Distance = GDBP(X,Y,Z,GPSx[playerid],GPSy[playerid],Z);
  57.    
  58.     if(Distance > 10.0)
  59.     {
  60.         new str[128];
  61.  
  62.         format(str,sizeof(str),"~r~-GPS-~n~~g~Distance: %.2f",Distance);
  63.         GameTextForPlayer(playerid,str,1000,4);
  64.         SetTimerEx("GPSTimer",500,0,"d",playerid);
  65.     }
  66.     else
  67.     {
  68.         GameTextForPlayer(playerid,"~r~-GPS-~n~~g~Destination reached.",4000,4);
  69.         GPSon[playerid] = false;
  70.     }
  71.     return 1;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement