Advertisement
Guest User

Dinamican gps sistem

a guest
Dec 15th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.67 KB | None | 0 0
  1. ////////////////////////////////////////////////////////
  2. #include  < a_samp >
  3. #include  < sscanf2 >
  4. #include  < zcmd >
  5. #include  < YSI\y_ini >
  6. ////////////////////////////////////////////////////////
  7. #define blue                                                                                                      "{00C0FF}"
  8. #define gray                                                                                                  "{C0C0C0}"
  9. ////////////////////////////////////////////////////////
  10. #define SCM                                                                                                SendClientMessage
  11. #define SPD                                                                                                 ShowPlayerDialog
  12. ////////////////////////////////////////////////////////
  13. #define GPS_FILE                                                                                "GPS/%d.ini"
  14. #define MAX_GPS_LOCATION                                                                                  30
  15. #define DIALOG_LOCATION_NAME                                                                                        4059
  16. #define MAX_NAME_LOCATION                                                                                                        128
  17. #define DIALOG_GPS                                                          5069
  18. #define DIALOG_GPS_ADMIN                                                    5070
  19. ////////////////////////////////////////////////////////
  20. new GPSON[MAX_PLAYERS];
  21. ////////////////////////////////////////////////////////
  22. enum GPS {
  23.     gpsName[MAX_NAME_LOCATION],
  24.     Float:gpsX,
  25.     Float:gpsY,
  26.     Float:gpsZ }
  27. new gpsInfo[MAX_GPS_LOCATION][GPS];
  28. ////////////////////////////////////////////////////////
  29. public OnFilterScriptInit() {
  30.         for(new i = 0; i < sizeof(gpsInfo); i++)
  31.     {
  32.         new kFile[50];
  33.         format(kFile, sizeof(kFile), GPS_FILE, i);
  34.         if(fexist(kFile))
  35.         {
  36.                         INI_ParseFile(kFile, "LoadGPS", .bExtra = true, .extra = i);
  37.                 }
  38.         }
  39.         return (1); }
  40. ////////////////////////////////////////////////////////
  41. public OnPlayerConnect(playerid) {
  42.         GPSON[playerid] = 0;
  43.         return (1); }
  44. ////////////////////////////////////////////////////////
  45. public OnFilterScriptExit() {
  46.     for(new a = 0; a < sizeof(gpsInfo); a++) { SaveGPS(a); }
  47.         return (1); }
  48. ////////////////////////////////////////////////////////
  49. CMD:kreirajgpslokaciju(playerid, params[]) {
  50.         if(!IsPlayerAdmin(playerid)) return SCM(playerid,-1,"Morate biti rcon administrator za koristenje ove komande!");
  51.     new id = NextGPS();
  52.     if(id >= MAX_GPS_LOCATION) return SCM(playerid,-1, "Nemozete preci maximalan broj gps lokacija!");
  53.     SPD(playerid,DIALOG_LOCATION_NAME,DIALOG_STYLE_INPUT,"Kreiranje GPS lokacije","Upisi naziv lokacije","Dalje","Odustani");
  54.         SetPVarInt(playerid, "CREATE_LOCATION_ID",id); SetPVarInt(playerid, "CREATE_LOCATION",1);
  55.         return (1); }
  56. ////////////////////////////////////////////////////////
  57. CMD:gps(playerid,params[]) {
  58.     new string[1024],string2[256],gpsfile[256];
  59.         for(new i=0;i<MAX_GPS_LOCATION;i++) {
  60.                 format(gpsfile,sizeof(gpsfile), "GPS/%i.ini",i);
  61.                 if(fexist(gpsfile)) {
  62.                                         if(i==0) {
  63.                                         format(string2, sizeof(string2), ""blue"(%d) "gray"Lokacija: %s",i,gpsInfo[i][gpsName]);
  64.                                         strcat(string, string2); }
  65.                                                 else {
  66.                                 format(string2, sizeof(string2), "\n"blue"(%d) "gray"Lokacija: %s",i,gpsInfo[i][gpsName]);
  67.                                 strcat(string, string2); } }
  68.                                         else break; }
  69.         SPD(playerid, DIALOG_GPS, DIALOG_STYLE_LIST, ""gray"GPS - Sistem", string, "Odaberi", "Odustani");
  70.         return (1); }
  71. ////////////////////////////////////////////////////////
  72. CMD:gpsoff(playerid, params[]) {
  73.         if(GPSON[playerid] == 0) return SCM(playerid,-1,""gray"Vas gps je iskljucen od prije!");
  74.         DisablePlayerCheckpoint(playerid); GPSON[playerid] = 0;
  75.         SCM(playerid,-1,""blue"* "gray"GPS uspesno iskljucen!");
  76.         return (1); }
  77. ////////////////////////////////////////////////////////
  78. public OnPlayerEnterCheckpoint(playerid) {
  79.     if(GPSON[playerid] == 1) return DisablePlayerCheckpoint(playerid), GPSON[playerid] = 0, SCM(playerid,-1,""blue"*"gray" Stigli ste na odrediste!");
  80.     return (1); }
  81. ////////////////////////////////////////////////////////
  82. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  83.         if(dialogid == DIALOG_LOCATION_NAME) {
  84.                 new Float: X,Float: Y,Float: Z, ime[MAX_NAME_LOCATION], id = GetPVarInt(playerid, "KREIRA_LOKACIJU_ID");
  85.                 if(sscanf(inputtext, "s[128]", ime)) return SPD(playerid,DIALOG_LOCATION_NAME,DIALOG_STYLE_INPUT,"Kreiranje GPS lokacije","Upisi naziv lokacije","Dalje","Odustani");
  86.                 GetPlayerPos(playerid, X, Y, Z);
  87.             gpsInfo[id][gpsX] = X; gpsInfo[id][gpsY] = Y; gpsInfo[id][gpsZ] = Z;
  88.                 SetString(gpsInfo[id][gpsName], ime); SetPVarInt(playerid, "CREATE_LOCATION",0);
  89.                 SaveGPS(id); }
  90.         if(dialogid == DIALOG_GPS) {
  91.                 if(!response) return (1);
  92.                 for(new i=0;i<MAX_GPS_LOCATION;i++) {
  93.                                 if(GPSON[playerid] == 1) { SCM(playerid,-1,""gray"Vas GPS je vec aktiviran, morate ga iskljuciti (/gpsoff)"); return(1); }
  94.                                 if(GPSON[playerid] == 0) {
  95.                                         if(!IsPlayerAdmin(playerid)) {
  96.                                                 SetPlayerCheckpoint(playerid, gpsInfo[i][gpsX],gpsInfo[i][gpsY],gpsInfo[i][gpsZ], 3.0), GPSON[playerid] = 1;
  97.                                                 new string[128];
  98.                                                 format(string, sizeof(string), ""blue"* "gray"Uspesno ste postavili gps na lokaciju "blue"(%s)",gpsInfo[i][gpsName]); SCM(playerid, -1, string); }
  99.                                         else if(IsPlayerAdmin(playerid)) {
  100.                                                 SPD(playerid,DIALOG_GPS_ADMIN,DIALOG_STYLE_MSGBOX, ""blue"GPS - Admin",""gray"Vi ste rcon-administrator te se mozete portat preko GPS sistema\nOdaberite da li zelite portanje ili oznacivanje markerom","Teleport","Marker"); } } } }
  101.         if(dialogid == DIALOG_GPS_ADMIN) {
  102.             if(!response) {
  103.                 for(new i=0;i<MAX_GPS_LOCATION;i++) {
  104.                 SetPlayerCheckpoint(playerid, gpsInfo[i][gpsX],gpsInfo[i][gpsY],gpsInfo[i][gpsZ], 3.0), GPSON[playerid] = 1;
  105.                         new string[128];
  106.                         format(string, sizeof(string), ""blue"* "gray"Uspesno ste postavili gps na lokaciju "blue"(%s)",gpsInfo[i][gpsName]); SCM(playerid, -1, string);
  107.                 return (1); } }
  108.             if(response) {
  109.                 for(new i=0;i<MAX_GPS_LOCATION;i++) {
  110.                         SetPlayerPos(playerid, gpsInfo[i][gpsX],gpsInfo[i][gpsY],gpsInfo[i][gpsZ]);
  111.                         new string[128];
  112.                         format(string, sizeof(string), ""blue"* "gray"Uspesno ste se teleportali do lokacije "blue"(%s)",gpsInfo[i][gpsName]); SCM(playerid, -1, string);
  113.                 return (1); } } }
  114.         return (1); }
  115. ////////////////////////////////////////////////////////
  116. forward LoadGPS(gpsid,  name[], value[]);
  117. public LoadGPS(gpsid, name[], value[]) {
  118.         INI_String("Naziv",gpsInfo[gpsid][gpsName], 128);
  119.         INI_Float("X",gpsInfo[gpsid][gpsX]);
  120.     INI_Float("Y",gpsInfo[gpsid][gpsY]);
  121.     INI_Float("Z",gpsInfo[gpsid][gpsZ]);
  122.         return (1); }
  123. ////////////////////////////////////////////////////////
  124. stock SaveGPS(gpsid) {
  125.         new kFile[80];
  126.     format(kFile, sizeof(kFile), GPS_FILE, gpsid);
  127.         new INI:File = INI_Open(kFile);
  128.         INI_WriteString(File,"Naziv",gpsInfo[gpsid][gpsName]);
  129.     INI_WriteFloat(File,"X",gpsInfo[gpsid][gpsX]);
  130.     INI_WriteFloat(File,"Y",gpsInfo[gpsid][gpsY]);
  131.     INI_WriteFloat(File,"Z",gpsInfo[gpsid][gpsZ]);
  132.         INI_Close(File);
  133.         return (1); }
  134. ////////////////////////////////////////////////////////
  135. stock SetString(obj[], string[]) return strmid(obj, string, 0, strlen(string), 255);
  136. ////////////////////////////////////////////////////////
  137. stock NextGPS() {
  138.     new gpssystem[64];
  139.         for(new f = 0; f<= MAX_GPS_LOCATION; f++)
  140.         {
  141.                 format(gpssystem, sizeof(gpssystem), "GPS/%i.ini", f);
  142.         if(!fexist(gpssystem)) return f;
  143.     }
  144.         return (1); }
  145. ////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement