Advertisement
Guest User

SOFTIC BABOO

a guest
Apr 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. SOFTIC OTACCCCC
  2. public OnPlayerConnect(playerid)
  3. {
  4. new IP[30], str[300], pName[MAX_PLAYER_NAME];
  5. GetPlayerName(playerid, pName, sizeof(pName));
  6. GetPlayerIp(playerid, IP, sizeof(IP));
  7. if(!strcmp(IP, "127.0.0.1"))
  8. {
  9. format(str, 230, "%s {FAFAFA}Has joined the server. {1FC7FF}Country: {FAFAFA}localhost", pName);
  10. SendClientMessageToAll(GetPlayerColor(playerid), str);
  11. }
  12. else
  13. {
  14. format(str, sizeof(str),"api.ipinfodb.com/v3/ip-country/?key="APIKEY"&ip=%s", IP);
  15. HTTP(playerid, HTTP_GET, str, "", "GetPlayerCountry");
  16. }
  17. return 1;
  18. }
  19. forward GetPlayerCountry(index, response_code, data[]);
  20. public GetPlayerCountry(index, response_code, data[])
  21. {
  22. new buffer[358];
  23. if(response_code == 200)
  24. {
  25. new str[230], city[3], country[20], pName[MAX_PLAYER_NAME];
  26. GetPlayerName(index, pName, sizeof(pName));
  27. format(buffer, sizeof(buffer), "%s", data);
  28. strmid(str, buffer, 4, strlen(buffer)); // Cutting the 'OK' response...
  29. strmid(city, str, strfind(str, ";", true) + 1, strfind(str, ";", true) + 3); // Getting City
  30. strmid(country, str, strfind(str, ";", true) + 4, strlen(buffer)); // Getting Country
  31. //printf("city: %s, country: %s", city, country);
  32. format(str, 230, "%s {FAFAFA}Has joined the server. {1FC7FF}Country: {FAFAFA}%s %s", pName, country, city);
  33. SendClientMessageToAll(GetPlayerColor(index), str);
  34. }
  35. else
  36. {
  37. new str[300], pName[MAX_PLAYER_NAME];
  38. GetPlayerName(index, pName, sizeof(pName));
  39. #if defined ALWAYS_RESPONSE
  40. new IP[30];
  41. GetPlayerIp(index, IP, sizeof(IP));
  42. format(str, sizeof(str),"api.ipinfodb.com/v3/ip-country/?key="APIKEY"&ip=%s", IP);
  43. HTTP(index, HTTP_GET, str, "", "GetPlayerCountry");
  44. #else // Normal message, without country
  45. format(str, 120, "%s {FAFAFA}Has joined the server.", pName);
  46. SendClientMessageToAll(GetPlayerColor(index), str);
  47. #endif
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement