Advertisement
electrux

GPS System samp by Electrux

Jan 4th, 2013
3,793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.83 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3. #include <dini>
  4. #include <zcmd>
  5. #include <dfile>
  6.  
  7. #define MAX_GPS_LOCATIONS 100
  8. #define MAX_GPS_NAME_STRING 100
  9.  
  10. #define GPS_DIALOG 5900
  11.  
  12. #define COLOR_GREY 0xAFAFAFAA
  13. #define COLOR_GREEN 0x33AA33AA
  14. #define COLOR_RED 0xAA3333AA
  15. #define COLOR_YELLOW 0xFFFF00AA
  16. #define COLOR_WHITE 0xFFFFFFAA
  17. #define COLOR_BLUE 0x0000BBAA
  18. #define COLOR_LIGHTBLUE 0x33CCFFAA
  19. #define COLOR_ORANGE 0xFF9900AA
  20. #define COLOR_RED 0xAA3333AA
  21. #define COLOR_LIME 0x10F441AA
  22. #define COLOR_MAGENTA 0xFF00FFFF
  23. #define COLOR_NAVY 0x000080AA
  24. #define COLOR_AQUA 0xF0F8FFAA
  25. #define COLOR_CRIMSON 0xDC143CAA
  26. #define COLOR_FLBLUE 0x6495EDAA
  27. #define COLOR_BISQUE 0xFFE4C4AA
  28. #define COLOR_BLACK 0x000000AA
  29. #define COLOR_CHARTREUSE 0x7FFF00AA
  30. #define COLOR_BROWN 0XA52A2AAA
  31. #define COLOR_CORAL 0xFF7F50AA
  32. #define COLOR_GOLD 0xB8860BAA
  33. #define COLOR_GREENYELLOW 0xADFF2FAA
  34. #define COLOR_INDIGO 0x4B00B0AA
  35. #define COLOR_IVORY 0xFFFF82AA
  36. #define COLOR_LAWNGREEN 0x7CFC00AA
  37. #define COLOR_SEAGREEN 0x20B2AAAA
  38. #define COLOR_LIMEGREEN 0x32CD32AA //<--- Dark lime
  39. #define COLOR_MIDNIGHTBLUE 0X191970AA
  40. #define COLOR_MAROON 0x800000AA
  41. #define COLOR_OLIVE 0x808000AA
  42. #define COLOR_ORANGERED 0xFF4500AA
  43. #define COLOR_PINK 0xFFC0CBAA // - Light pink
  44. #define COLOR_SPRINGGREEN 0x00FF7FAA
  45. #define COLOR_TOMATO 0xFF6347AA // - Tomato >:/ sounds wrong lol... well... :P
  46. #define COLOR_YELLOWGREEN 0x9ACD32AA //- like military green
  47. #define COLOR_MEDIUMAQUA 0x83BFBFAA
  48. #define COLOR_MEDIUMMAGENTA 0x8B008BAA // dark magenta ^^
  49. #define COLOR_GREY 0xAFAFAFAA
  50.  
  51. new gpspos[MAX_PLAYERS][MAX_GPS_LOCATIONS][MAX_GPS_NAME_STRING];
  52. new indexgps[MAX_PLAYERS];
  53.  
  54. public OnFilterScriptInit()
  55. {
  56.     print("\n--------------------------------------");
  57.     print(" Loaded GPS FilterScript by ELECTRUX!!");
  58.     print("--------------------------------------\n");
  59.     return 1;
  60. }
  61.  
  62. public OnFilterScriptExit()
  63. {
  64.     for(new i=0; i<=MAX_PLAYERS; i++)
  65.     {
  66.         indexgps[i] = -1;
  67.         for(new j=0; j<=MAX_GPS_LOCATIONS; j++)
  68.         {
  69.             for(new k=0; k<=MAX_GPS_NAME_STRING; k++)
  70.                 gpspos[i][j][k] = -1;
  71.         }
  72.     }
  73.     return 1;
  74. }
  75.  
  76.  
  77.  
  78. public OnPlayerConnect(playerid)
  79. {
  80.     new pname[50],folder[100];
  81.     GetPlayerName(playerid,pname,sizeof(pname));
  82.     format(folder,sizeof(folder),"/gps/%s",pname);
  83.     if(!dfile_DirectoryExists(folder))
  84.     {
  85.         dfile_CreateDirectory(folder);
  86.     }
  87.     return 1;
  88. }
  89.  
  90. public OnPlayerDisconnect(playerid, reason)
  91. {
  92.     indexgps[playerid] = -1;
  93.     for(new i=0; i<=MAX_GPS_LOCATIONS; i++)
  94.     {
  95.         for(new j=0; j<=MAX_GPS_NAME_STRING; j++)
  96.             gpspos[playerid][i][j] = -1;
  97.     }
  98.     return 1;
  99. }
  100.  
  101. CMD:newgpspos(playerid,params[])
  102. {
  103.     new placename[50],pname[50],file[100],Float:x,Float:y,Float:z;
  104.     indexgps[playerid] = GetPlayerGPSFileCount(playerid);
  105.     if(sscanf(params,"s",placename)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /newgpspos [PLACE NAME]");
  106.     GetPlayerName(playerid,pname,sizeof(pname));
  107.     GetPlayerPos(playerid,x,y,z);
  108.     format(file,sizeof(file),"/gps/%s/%d.gps",pname,indexgps[playerid]);
  109.     dini_Create(file);
  110.     dini_Set(file,"Name",placename);
  111.     dini_FloatSet(file,"PosX",x);
  112.     dini_FloatSet(file,"PosY",y);
  113.     dini_FloatSet(file,"PosZ",z);
  114.     SendClientMessage(playerid,COLOR_GREEN,"Place added to your GPS. Use /gps to see.");
  115.     return 1;
  116. }
  117.  
  118. CMD:gps(playerid,params[])
  119. {
  120.     new pname[50],mstring[2000],str1[256],str2[260],file[100];
  121.     GetPlayerName(playerid,pname,sizeof(pname));
  122.     for(new i=0; i<=MAX_GPS_LOCATIONS; i++)
  123.     {
  124.         format(file,sizeof(file),"/gps/%s/%d.gps",pname,i);
  125.         if(dini_Exists(file))
  126.         {
  127.             str1 = dini_Get(file,"Name");
  128.             format(str2,sizeof(str2),"%s\n",str1);
  129.             strcat(mstring,str2);
  130.         }
  131.     }
  132.     ShowPlayerDialog(playerid,GPS_DIALOG,DIALOG_STYLE_LIST,"GPS Locations",mstring,"OK","Cancel");
  133.     return 1;
  134. }
  135.  
  136. public OnPlayerEnterCheckpoint(playerid)
  137. {
  138.     DisablePlayerCheckpoint(playerid);
  139.     return 1;
  140. }
  141. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  142. {
  143.     if(dialogid == GPS_DIALOG)
  144.     {
  145.         if(response == 1)
  146.         {
  147.             new pname[50],file[200],Float:px,Float:py,Float:pz,send[100];
  148.             GetPlayerName(playerid,pname,sizeof(pname));
  149.             format(file,sizeof(file),"/gps/%s/%d.gps",pname,listitem);
  150.             px = dini_Float(file,"PosX");
  151.             py = dini_Float(file,"PosY");
  152.             pz = dini_Float(file,"PosZ");
  153.             SetPlayerCheckpoint(playerid,px,py,pz,3.0);
  154.             format(send,sizeof(send),"Checkpoint made at %.2f %.2f %.2f",px,py,pz);
  155.             SendClientMessage(playerid,COLOR_GREEN,send);
  156.             return 1;
  157.         }
  158.         else
  159.         {
  160.             SendClientMessage(playerid,COLOR_RED,"You cancelled!");
  161.             return 1;
  162.         }
  163.     }
  164.     return 0;
  165. }
  166.  
  167. stock GetPlayerGPSFileCount(playerid)
  168. {
  169.     new file[100],pname[50];
  170.     GetPlayerName(playerid,pname,sizeof(pname));
  171.     for(new i=0; i<=MAX_GPS_LOCATIONS; i++)
  172.     {
  173.         format(file,sizeof(file),"/gps/%s/%d.gps",pname,i);
  174.         if(!dini_Exists(file))
  175.         {
  176.             return i;
  177.         }
  178.     }
  179.     return 1;
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement