Advertisement
GeoSoares

Sistema de GPS básico

Mar 5th, 2022
898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.01 KB | None | 0 0
  1.  
  2.  
  3. #include <a_samp>
  4.  
  5. #define     AGENCIADELS 1310.1472,-1369.6836,13.5656
  6. #define     HOSPITALDELS    1184.3213,-1323.0328,13.1424
  7. #define     PRAIADELS   322.7799,-1809.6986,4.4727
  8.  
  9. #define     MensagemGps "[GPS] Siga o checkpoint vermelho em seu mapa para chegar ao seu destino!"
  10. #define     MensagemGpsErro "[GPS] Você precisa desativar seu destino atual primeiro!"
  11. #define     MensagemGpsDesativado "[GPS] Você desligou o GPS!"
  12. #define     MensagemGpsChegou "[GPS] Você chegou ao seu destino!"
  13. #define     MensagemSemDestino  "[GPS]Você não selecionou este destino!"
  14.  
  15. #define D_GPS   10000
  16.  
  17. new StringGps[128];
  18.  
  19. new GpsLigado[MAX_PLAYERS];
  20.  
  21. public OnGameModeInit()
  22. {
  23.  
  24.     return 1;
  25. }
  26.  
  27. public OnGameModeExit()
  28. {
  29.     for(new i = 0; i < MAX_PLAYERS; i++)
  30.     {
  31.         if(IsPlayerConnected(i))
  32.         {
  33.              if(GpsLigado[i] == 1)
  34.             {
  35.                 DisablePlayerCheckpoint(i);
  36.                 GpsLigado[i] = 0;
  37.             }
  38.         }
  39.     }
  40.     return 1;
  41. }
  42.  
  43. public OnPlayerDisconnect(playerid, reason)
  44. {
  45.     for(new i = 0; i < MAX_PLAYERS; i++)
  46.     {
  47.         if(IsPlayerConnected(i))
  48.         {
  49.              if(GpsLigado[i] == 1)
  50.             {
  51.                 DisablePlayerCheckpoint(i);
  52.                 GpsLigado[i] = 0;
  53.             }
  54.         }
  55.     }
  56.     return 1;
  57. }
  58.  
  59.  
  60.  
  61. public OnPlayerCommandText(playerid, cmdtext[])
  62. {
  63.     if (strcmp("/gps", cmdtext, true, 10) == 0)
  64.     {
  65.         format(StringGps, sizeof(StringGps), "{FFFFFF}Praia de LS\nHospital de LS\nAgencia de Ls\nDesligar GPS");
  66.         ShowPlayerDialog(playerid, D_GPS, DIALOG_STYLE_LIST, "{0080FF}GPS", StringGps, "Selecionar", "Cancelar");
  67.         return 1;
  68.     }
  69.     return 0;
  70. }
  71.  
  72. public OnPlayerEnterCheckpoint(playerid)
  73. {
  74.     if(GpsLigado[playerid] == 1)
  75.     {
  76.         DisablePlayerCheckpoint(playerid);
  77.         SendClientMessage(playerid, -1, MensagemGpsChegou);
  78.         GpsLigado[playerid] = 0;
  79.         PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
  80.     }
  81.     else
  82.     {
  83.         SendClientMessage(playerid, -1, MensagemSemDestino);
  84.     }
  85.     return 1;
  86. }
  87.  
  88. public OnPlayerLeaveCheckpoint(playerid)
  89. {
  90.     return 1;
  91. }
  92.  
  93. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  94. {
  95.     if(dialogid == D_GPS)
  96.     {
  97.         if(response)
  98.         {
  99.             if(listitem == 0)
  100.             {
  101.                 if(GpsLigado[playerid] == 0)
  102.                 {
  103.                     SetPlayerCheckpoint(playerid, PRAIADELS, 1.0);
  104.                     GpsLigado[playerid] = 1;
  105.                     SendClientMessage(playerid, 0x46A3FFFF, MensagemGps);
  106.                 }
  107.                 /*else if(IsPlayerAdmin(playerid)) coloque a variável de admin da sua gm aqui
  108.                 {
  109.                     SetPlayerPos(playerid, PRAIADELS);
  110.                     SendClientMessage(playerid, 0x46A3FFFF, MensagemGps);
  111.                 }*/
  112.                 else
  113.                 {
  114.                     SendClientMessage(playerid, -1, MensagemGpsErro);
  115.                 }
  116.             }
  117.             if(listitem == 1)
  118.             {
  119.                 if(GpsLigado[playerid] == 0)
  120.                 {
  121.                     SetPlayerCheckpoint(playerid, HOSPITALDELS, 1.0);
  122.                     GpsLigado[playerid] = 1;
  123.                     SendClientMessage(playerid, 0x46A3FFFF, MensagemGps);
  124.                 }
  125.                 /*else if(IsPlayerAdmin(playerid)) coloque a variável de admin da sua gm aqui
  126.                 {
  127.                     SetPlayerPos(playerid, HOSPITALDELS);
  128.                     SendClientMessage(playerid, 0x46A3FFFF, MensagemGps);
  129.                 }*/
  130.                 else
  131.                 {
  132.                     SendClientMessage(playerid, -1, MensagemGpsErro);
  133.                 }
  134.             }
  135.             if(listitem == 2)
  136.             {
  137.                 if(GpsLigado[playerid] == 0)
  138.                 {
  139.                     SetPlayerCheckpoint(playerid, AGENCIADELS, 1.0);
  140.                     GpsLigado[playerid] = 1;
  141.                     SendClientMessage(playerid, 0x46A3FFFF, MensagemGps);
  142.                 }
  143.                 /*else if(IsPlayerAdmin(playerid)) coloque a variável de admin da sua gm aqui
  144.                 {
  145.                     SetPlayerPos(playerid, AGENCIADELS);
  146.                     SendClientMessage(playerid, 0x46A3FFFF, MensagemGps);
  147.                 }*/
  148.                 else
  149.                 {
  150.                     SendClientMessage(playerid, -1, MensagemGpsErro);
  151.                 }
  152.             }
  153.             if(listitem == 3)
  154.             {
  155.                 GpsLigado[playerid] = 0;
  156.                 DisablePlayerCheckpoint(playerid);
  157.                 SendClientMessage(playerid, -1, MensagemGpsDesativado);
  158.             }
  159.         }
  160.     }
  161.     return 1;
  162. }
  163.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement