Advertisement
Guest User

Untitled

a guest
May 12th, 2022
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. // Topo do script
  2. #define MAX_COUNTRY_NAME 64
  3.  
  4. public OnPlayerConnect(playerid) {
  5. if(strcmp("127.0.0.1", GetPlayerIPEx(playerid), true) != 0) {
  6. format(STRX, 128, "ip-api.com/json/%s", GetPlayerIPEx(playerid));
  7. HTTP(playerid, HTTP_GET, STRX, "", "HTTP_Connect");
  8. return 1;
  9. }
  10.  
  11. forward HTTP_Connect(playerid, response_codec, data[]);
  12. public HTTP_Connect(playerid, response_codec, data[]) {
  13. if(response_codec != 200) {
  14. SetPVarString(playerid, "Pais", "Desconhecido"), SetPVarString(playerid, "Estado", "Desconhecido"), SetPVarString(playerid, "Cidade", "Desconhecida");
  15. return 1;
  16. }
  17.  
  18. new string[128], pos;
  19. if(strfind(data, "Reserved", true) == -1 && strlen(data) >= 15) {
  20. if((pos = strfind(data, "\"country\":")) != -1)
  21. {
  22. pos += 11;
  23. strmid(string, data, pos, strfind(data, "\"", true, pos));
  24. SetPVarString(playerid, "Pais", string);
  25. }
  26. if((pos = strfind(data, "\"regionName\":")) != -1)
  27. {
  28. pos += 14;
  29. strmid(string, data, pos, strfind(data, "\"", true, pos));
  30. SetPVarString(playerid, "Estado", string);
  31. }
  32. if((pos = strfind(data, "\"city\":")) != -1)
  33. {
  34. pos += 8;
  35. strmid(string, data, pos, strfind(data, "\"", true, pos));
  36. SetPVarString(playerid, "Cidade", string);
  37. }
  38. }
  39.  
  40. GetPVarString(playerid, "Pais", string, MAX_COUNTRY_NAME);
  41. if(strfind(string, "Brazil", true) == -1 && strfind(string, "Portugal", true) == -1 && strfind(string, "France", true) == -1 && strfind(string, "Desconhecido", true) == -1)
  42. {
  43. SendClientMessage(playerid, 0xFF0000AA, "A entrada de seu IP não é permitida.");
  44. Kick(playerid);
  45. }
  46. return 0;
  47. }
  48.  
  49. stock GetPlayerCountry(playerid)
  50. {
  51. new string[MAX_COUNTRY_NAME];
  52. GetPVarString(playerid, "Pais", string, MAX_COUNTRY_NAME);
  53. return string;
  54. }
  55.  
  56. stock GetPlayerRegion(playerid)
  57. {
  58. new string[MAX_COUNTRY_NAME];
  59. GetPVarString(playerid, "Estado", string, MAX_COUNTRY_NAME);
  60. return string;
  61. }
  62. stock GetPlayerCountry(playerid)
  63. {
  64. new string[MAX_COUNTRY_NAME];
  65. GetPVarString(playerid, "Pais", string, MAX_COUNTRY_NAME);
  66. return string;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement