Guest User

Pacino`s dynaminc GPS

a guest
Jun 15th, 2011
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.44 KB | None | 0 0
  1. /*
  2.  
  3. URADIO:
  4.     Irfan Pacino | Irfan Šarić
  5.     14.6.2011
  6. */
  7. #define FILTERSCRIPT
  8.  
  9. #include <a_samp>
  10. #include <zcmd>
  11. #include <sscanf2>
  12. #include <dini>
  13.  
  14.  
  15. //===================Define - skraceno==============
  16. #define SCM SendClientMessage
  17. #define SPD ShowPlayerDialog
  18. #define ISPA IsPlayerAdmin
  19.  
  20. //=============Boje=========
  21.  
  22. //===OSNOVNE===
  23. #define WHITE   0xFFFFFFFF
  24. #define RED     0xFF0000FF
  25. #define BLUE    0x0000FFFF
  26. #define YELLOW  0xFFFF00FF
  27. #define GREEN   0x00FF00FF
  28. #define PINK    0xFF9FF2FF
  29. #define BLACK   0x000000FF
  30. #define ORANGE  0xFF8900FF
  31. #define BROWN       0x9E5125FF
  32. //------------------------------Dialog ID----------------------
  33. #define ADMINGPS 1
  34. #define GPSNOVALOK 2
  35. #define GPSDELETE 3
  36. #define GPSIME 4
  37. #define GPSSIZE 5
  38. #define GPSKRAJ 6
  39. #define GPS 7
  40.  
  41. #define MAX_GPS_DOZVOLJEN 10
  42. enum GPSData
  43. {
  44.     Ime[255],
  45.     Float:X,
  46.     Float:Y,
  47.     Float:Z,
  48.     Float:cpVelicina,
  49. };
  50. new gps[MAX_GPS_DOZVOLJEN][GPSData];
  51. new StvoreniGPS = 0;
  52.  
  53.  
  54. public OnFilterScriptInit()
  55. {
  56.     print("\n--------------------------------------");
  57.     print(" Pacino`s GPS System loaded");
  58.     print("--------------------------------------\n");
  59.     LoadGPS();
  60.     return 1;
  61. }
  62. public OnFilterScriptExit()
  63. {
  64.     print("\n----------------------------------");
  65.     print(" Pacino`s GPS System unloaded");
  66.     print("----------------------------------\n");
  67.     return 1;
  68. }
  69.  
  70. public OnPlayerConnect(playerid)
  71. {
  72.     return 1;
  73. }
  74.  
  75. public OnPlayerDisconnect(playerid, reason)
  76. {
  77.     return 1;
  78. }
  79.  
  80. public OnPlayerSpawn(playerid)
  81. {
  82.     return 1;
  83. }
  84.  
  85. public OnPlayerDeath(playerid, killerid, reason)
  86. {
  87.     return 1;
  88. }
  89.  
  90. public OnVehicleSpawn(vehicleid)
  91. {
  92.     return 1;
  93. }
  94.  
  95. public OnVehicleDeath(vehicleid, killerid)
  96. {
  97.     return 1;
  98. }
  99.  
  100. public OnPlayerText(playerid, text[])
  101. {
  102.     return 1;
  103. }
  104. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  105. {
  106.     return 1;
  107. }
  108.  
  109. public OnPlayerExitVehicle(playerid, vehicleid)
  110. {
  111.     return 1;
  112. }
  113.  
  114. public OnPlayerStateChange(playerid, newstate, oldstate)
  115. {
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerEnterCheckpoint(playerid)
  120. {
  121.     return 1;
  122. }
  123.  
  124. public OnPlayerLeaveCheckpoint(playerid)
  125. {
  126.     return 1;
  127. }
  128.  
  129. public OnPlayerEnterRaceCheckpoint(playerid)
  130. {
  131.     return 1;
  132. }
  133.  
  134. public OnPlayerLeaveRaceCheckpoint(playerid)
  135. {
  136.     return 1;
  137. }
  138.  
  139. public OnRconCommand(cmd[])
  140. {
  141.     return 1;
  142. }
  143.  
  144. public OnPlayerRequestSpawn(playerid)
  145. {
  146.     return 1;
  147. }
  148.  
  149. public OnObjectMoved(objectid)
  150. {
  151.     return 1;
  152. }
  153.  
  154. public OnPlayerObjectMoved(playerid, objectid)
  155. {
  156.     return 1;
  157. }
  158.  
  159. public OnPlayerPickUpPickup(playerid, pickupid)
  160. {
  161.     return 1;
  162. }
  163.  
  164. public OnVehicleMod(playerid, vehicleid, componentid)
  165. {
  166.     return 1;
  167. }
  168.  
  169. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  170. {
  171.     return 1;
  172. }
  173.  
  174. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  175. {
  176.     return 1;
  177. }
  178.  
  179. public OnPlayerSelectedMenuRow(playerid, row)
  180. {
  181.     return 1;
  182. }
  183.  
  184. public OnPlayerExitedMenu(playerid)
  185. {
  186.     return 1;
  187. }
  188.  
  189. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  190. {
  191.     return 1;
  192. }
  193.  
  194. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  195. {
  196.     return 1;
  197. }
  198.  
  199. public OnRconLoginAttempt(ip[], password[], success)
  200. {
  201.     return 1;
  202. }
  203.  
  204. public OnPlayerUpdate(playerid)
  205. {
  206.     return 1;
  207. }
  208.  
  209. public OnPlayerStreamIn(playerid, forplayerid)
  210. {
  211.     return 1;
  212. }
  213.  
  214. public OnPlayerStreamOut(playerid, forplayerid)
  215. {
  216.     return 1;
  217. }
  218.  
  219. public OnVehicleStreamIn(vehicleid, forplayerid)
  220. {
  221.     return 1;
  222. }
  223.  
  224. public OnVehicleStreamOut(vehicleid, forplayerid)
  225. {
  226.     return 1;
  227. }
  228.  
  229. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  230. {
  231.     switch(dialogid)
  232.     {
  233.         case ADMINGPS:
  234.         {
  235.             if(!response) return 1;
  236.            
  237.             switch(listitem)
  238.             {
  239.                 case 0:
  240.                 {
  241.                     if(StvoreniGPS < MAX_GPS_DOZVOLJEN)
  242.                     {
  243.                         SPD(playerid, GPSNOVALOK, DIALOG_STYLE_LIST,"Nova GPS pozicija", "Ime\nPozicija\nCP Velicina\nKraj", "Odaberi", "Nazad");
  244.                     }
  245.                     else return SCM(playerid, RED, "Prvo izbrisi neku lokaciju, jer si dostigao limit!");
  246.                 }
  247.                 case 1:
  248.                 {
  249.                     if(StvoreniGPS != 0)
  250.                     {
  251.                         SPD(playerid, GPSDELETE, DIALOG_STYLE_INPUT, "Brisanje lokacije", "Unesi ID lokacije koju zelis da obrises!", "Ok", "Nazad");
  252.                     }
  253.                     else return SCM(playerid, RED, "Nema niti jedna GPS lokacija!");
  254.                 }
  255.             }
  256.         }
  257.         case GPSNOVALOK:
  258.         {
  259.             if(response)
  260.             {
  261.                 switch(listitem)
  262.                 {
  263.                     case 0: SPD(playerid, GPSIME, DIALOG_STYLE_INPUT, "Ime lokacije", "Unesi ime lokacije koju trenutno pravis!", "Ok", "Nazad");
  264.                     case 1: SCM(playerid, GREEN, "Koristi /savegps da sacuvas poziciju GPS-a na zeljenoj poziciji!");
  265.                     case 2: SPD(playerid, GPSSIZE, DIALOG_STYLE_INPUT, "Velicina CP-a", "Unesi velicinu CP-a u rasponu od 1 do 10\n(Mozes koristiti i racinalne brojeve sa tackom)", "Ok", "Nazad");
  266.                     case 3: SPD(playerid, GPSKRAJ, DIALOG_STYLE_MSGBOX, "Kraj?", "Da li si zavrsio dodavanje nove lokacije?", "Da", "Ne");
  267.                 }
  268.             }
  269.         }
  270.         case GPSDELETE:
  271.         {
  272.             if(response)
  273.             {
  274.                 new id, string[128];
  275.                 if(!sscanf(inputtext, "i", id))
  276.                 {
  277.                     format(string, 128, "GPS/GPS_%d.ini", id);
  278.                     if(fexist(string))
  279.                     {
  280.                         format(string, sizeof(string), "Obrisao si GPS lokaciju sa ID-em %d | Ime: %s", id, gps[id][Ime]);
  281.                         SCM(playerid, ORANGE, string);
  282.                     }
  283.                     else return SCM(playerid, RED, "Ta lokacija ne postoji!");
  284.                 }
  285.             }
  286.             else return SPD(playerid, ADMINGPS, DIALOG_STYLE_LIST, "Admin GPS panel", "Nova lokacija\nIzbrisi lokaciju", "Odaberi", "Nazad");
  287.         }
  288.         case GPSIME:
  289.         {
  290.             if(response)
  291.             {
  292.                 new ime[64], string[128];
  293.                 new ide = StvoreniGPS + 1;
  294.                 if(!sscanf(inputtext, "s[64]", ime))
  295.                 {
  296.                     format(string, sizeof(string), "Postavio si ime lokacije na %s", ime);
  297.                     SCM(playerid, BLUE, string);
  298.                     strmid(gps[ide][Ime], ime, 0, strlen(ime), 255);
  299.                 }
  300.             }
  301.             else return SPD(playerid, GPSNOVALOK, DIALOG_STYLE_LIST,"Nova GPS pozicija", "Ime\nPozicija\nCP Velicina\nKraj", "Odaberi", "Nazad");
  302.         }
  303.         case GPSSIZE:
  304.         {
  305.             if(response)
  306.             {
  307.                 new string[128], ide = StvoreniGPS + 1;
  308.                 new Float:velicina;
  309.                 if(!sscanf(inputtext, "f", velicina))
  310.                 {
  311.                     gps[ide][cpVelicina] = velicina;
  312.                     format(string, sizeof(string), "Postavio si velicinu CP-a na %f", velicina);
  313.                     SCM(playerid, BLUE, string);
  314.                 }
  315.             }
  316.             else return SPD(playerid, GPSNOVALOK, DIALOG_STYLE_LIST,"Nova GPS pozicija", "Ime\nPozicija\nCP Velicina\nKraj", "Odaberi", "Nazad");
  317.         }
  318.         case GPSKRAJ:
  319.         {
  320.             if(response)
  321.             {
  322.                 new string[128];
  323.                 new g = StvoreniGPS + 1;
  324.                 format(string, sizeof(string), "GPS/GPS_%d.ini", g);
  325.                 dini_Create(string);
  326.                 dini_Set(string, "Ime", gps[g][Ime]);
  327.                 dini_FloatSet(string, "X", gps[g][X]);
  328.                 dini_FloatSet(string, "Y", gps[g][Y]);
  329.                 dini_FloatSet(string, "Z", gps[g][Z]);
  330.                 dini_FloatSet(string, "CPVelicina", gps[g][cpVelicina]);
  331.                
  332.                
  333.             }
  334.             else return SPD(playerid, GPSNOVALOK, DIALOG_STYLE_LIST,"Nova GPS pozicija", "Ime\nPozicija\nCP Velicina\nKraj", "Odaberi", "Nazad");
  335.         }
  336.         case GPS:
  337.         {
  338.             if(response)
  339.             {
  340.                 new string[128];
  341.                 switch(listitem)
  342.                 {
  343.                     case 0:
  344.                     {
  345.                         new g = 1;
  346.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  347.                         SCM(playerid, RED, string);
  348.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  349.                     }
  350.                     case 1:
  351.                     {
  352.                         new g = 2;
  353.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  354.                         SCM(playerid, RED, string);
  355.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  356.                     }
  357.                     case 2:
  358.                     {
  359.                         new g = 3;
  360.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  361.                         SCM(playerid, RED, string);
  362.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  363.                     }
  364.                     case 3:
  365.                     {
  366.                         new g = 4;
  367.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  368.                         SCM(playerid, RED, string);
  369.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  370.                     }
  371.                     case 4:
  372.                     {
  373.                         new g = 5;
  374.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  375.                         SCM(playerid, RED, string);
  376.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  377.                     }
  378.                     case 5:
  379.                     {
  380.                         new g = 6;
  381.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  382.                         SCM(playerid, RED, string);
  383.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  384.                     }
  385.                     case 6:
  386.                     {
  387.                         new g = 7;
  388.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  389.                         SCM(playerid, RED, string);
  390.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  391.                     }
  392.                     case 7:
  393.                     {
  394.                         new g = 8;
  395.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  396.                         SCM(playerid, RED, string);
  397.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  398.                     }
  399.                     case 8:
  400.                     {
  401.                         new g = 9;
  402.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  403.                         SCM(playerid, RED, string);
  404.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  405.                     }
  406.                     case 9:
  407.                     {
  408.                         new g = 10;
  409.                         format(string, sizeof(string), "Postavio si lokaciju na %s", gps[g][Ime]);
  410.                         SCM(playerid, RED, string);
  411.                         SetPlayerCheckpoint(playerid, gps[g][X], gps[g][Y], gps[g][Z], gps[g][cpVelicina]);
  412.                     }
  413.                 }
  414.             }
  415.         }
  416.         default: return SCM(playerid, RED, "[GRESKA] Nepostojeci dialog id!");
  417.     }
  418.     return 1;
  419. }
  420.  
  421. stock SaveGPS( g )
  422. {
  423.     new dat[128];
  424.     format(dat, sizeof(dat), "GPS/GPS_%d.ini", g);
  425.     if(fexist(dat))
  426.     {
  427.         dini_Set(dat, "Ime", gps[g][Ime]);
  428.         dini_FloatSet(dat, "X", gps[g][X]);
  429.         dini_FloatSet(dat, "Y", gps[g][Y]);
  430.         dini_FloatSet(dat, "Z", gps[g][Z]);
  431.         dini_FloatSet(dat, "CPVelicina", gps[g][cpVelicina]);
  432.     }
  433.     else printf("GPS %d ne postoji!", g);
  434.     return 1;
  435. }
  436.    
  437. stock LoadGPS()
  438. {
  439.     new string[128];
  440.     for(new i = 0; i < MAX_GPS_DOZVOLJEN; i++)
  441.     {
  442.         format(string, sizeof(string), "GPS/GPS_%d.ini", i);
  443.         if(fexist(string))
  444.         {
  445.             gps[i][Ime] = dini_Get(string, "Ime");
  446.             gps[i][X] = dini_Float(string, "X");
  447.             gps[i][Y] = dini_Float(string, "Y");
  448.             gps[i][Z] = dini_Float(string, "Z");
  449.             gps[i][cpVelicina] = dini_Float(string, "CPVelicina");
  450.             printf("GPS lokacija %s[ID: %i] ucitana!", gps[i][Ime], i);
  451.             StvoreniGPS++;
  452.         }
  453.     }
  454.     return 1;
  455. }
  456.            
  457. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  458. {
  459.     return 1;
  460. }
  461. //----------------------------------------------------------------------------[ZCMD]-----------------------------------------------------
  462. CMD:gpshelp(playerid, params[])
  463. {
  464.     #pragma unused params
  465.     new string[256];
  466.     format(string, sizeof(string), "");
  467.     strcat(string, "Pacino`s GPS sistem - Komande");
  468.     strcat(string, "/admingps | /agps | /gps | /gpsoff");
  469.     SPD(playerid, GPS, DIALOG_STYLE_MSGBOX, "Pomoc - GPS sistem", string, "Ok", "");
  470.     return 1;
  471. }
  472. CMD:admingps(playerid, params[])
  473. {
  474.     if(ISPA(playerid))
  475.     {
  476.         SPD(playerid, ADMINGPS, DIALOG_STYLE_LIST, "Admin GPS panel", "Nova lokacija\nIzbrisi lokaciju", "Odaberi", "Nazad");
  477.     }
  478.     else return SCM(playerid, RED, "Nisi ovlasten!");
  479.     return 1;
  480. }
  481. CMD:gps(playerid, params[])
  482. {
  483.     new string[256];format(string, sizeof(string), "");new c = 1;
  484.     new stringe[128];
  485.     for(new i = 1; i < MAX_GPS_DOZVOLJEN+1; i++)
  486.     {
  487.         format(stringe, sizeof(stringe), "GPS/GPS_%d.ini", i);
  488.         if(fexist(stringe))
  489.             {
  490.                 new a[12];
  491.                 valstr(a, i);
  492.                 strcat(string, a);
  493.                 strcat(string, " | ");
  494.                 strcat(string, "{0080C0}");
  495.                 strcat(string, gps[i][Ime]);
  496.                 strcat(string, "\n");
  497.                 c++;
  498.             }
  499.         else if(!fexist(stringe))
  500.             {
  501.                 new a[12];
  502.                 valstr(a, c);
  503.                 strcat(string, a);
  504.                 strcat(string, " | ");
  505.                 strcat(string, "{FF2626}Nema");
  506.                 strcat(string, "\n");
  507.                 c++;
  508.             }
  509.     }
  510.     SPD(playerid, GPS, DIALOG_STYLE_LIST, "Odaberi lokaciju!", string, "Ok", "Ponisti");
  511.     return 1;
  512. }
  513. CMD:savegps(playerid, params[])
  514. {
  515.     if(ISPA(playerid))
  516.     {
  517.         new Float:p[3];
  518.         GetPlayerPos(playerid, p[0], p[1], p[2]);
  519.         new g = StvoreniGPS + 1;
  520.         gps[g][X] = p[0];
  521.         gps[g][Y] = p[1];
  522.         gps[g][Z] = p[2];
  523.         SCM(playerid, RED, "Lokacija postavljena!");
  524.     }
  525.     return 1;
  526. }
  527. CMD:gpsoff(playerid, params[])
  528. {
  529.     DisablePlayerCheckpoint(playerid);
  530.     SCM(playerid, ORANGE, "GPS iskljucen!");
  531.     return 1;
  532. }
  533. COMMAND:agps(playerid, params[])
  534. {
  535.   return cmd_admingps(playerid, params);
  536. }
Advertisement
Add Comment
Please, Sign In to add comment