countrycheck.pwn 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. new bool:cCheck = false;
  2. CMD:togcountrycheck(playerid, params[])
  3. {
  4. if(PlayerInfo[playerid][pAdmin] < 1337) return 0;
  5. if(cCheck)
  6. cCheck = false, SendClientMessageEx(playerid, -1, "Disabled");
  7. else
  8. cCheck = true, SendClientMessageEx(playerid, -1, "Enabled");
  9. return 1;
  10. }
  11. CountryCheck(playerid)
  12. {
  13. if(cCheck == false) return 1;
  14. new ccGetUrl[68];
  15. format(ccGetUrl, sizeof(ccGetUrl), "jamie.ng-gaming.net/geocheck.php?ip=%s&id=%d", PlayerInfo[playerid][pIP], PlayerInfo[playerid][pId]);
  16. HTTP(playerid, HTTP_GET, ccGetUrl, "", "CountryCheckResponse");
  17. return 1;
  18. }
  19. forward CountryCheckResponse(playerid, response_code, data[]);
  20. public CountryCheckResponse(playerid, response_code, data[]) {
  21. szMiscArray[0] = 0;
  22. if(response_code == 200) {
  23. new resCodeIndex = strfind(data, "GEORESULT:")+10;
  24. new resCode = strval(data[resCodeIndex]);
  25. if(data[resCodeIndex] != '4' && data[resCodeIndex] != '0' && data[resCodeIndex] != '1' && data[resCodeIndex] != '2' && data[resCodeIndex] != '3')
  26. {
  27. resCode = '1';
  28. }
  29. /* Rescode response values:
  30. 0 = Response error
  31. 1 = Country code match / Allow login
  32. 2 = Data submit error, IP/ID was missing or IP was invalid.
  33. 3 = Country code mismatch, disallow login.
  34. */
  35. switch(resCode) {
  36. case 0: {
  37. printf("GEOCHECK WARNING: Response error, returned %d (%s)", resCode, data[resCodeIndex]);
  38. }
  39. case 1: {
  40. // Allow login
  41. }
  42. case 2: {
  43. print("GEOCHECK WARNING: Invalid ID or IP input");
  44. }
  45. case 3: {
  46. format(szMiscArray, sizeof(szMiscArray), "{AA3333}AdmWarning{FFFF00}: %s (IP:%s) has failed their countrycode check and was auto-kicked.", GetPlayerNameEx(playerid), PlayerInfo[playerid][pIP]);
  47. ABroadCast(COLOR_YELLOW, szMiscArray, 2);
  48. format(szMiscArray, sizeof(szMiscArray), "WARNING: %s(%d) (IP:%s) has failed their countrycode check and was auto-kicked.", GetPlayerNameEx(playerid), GetPVarInt(playerid, "pSQLID"), PlayerInfo[playerid][pIP]);
  49. Log("logs/geocheck.log", szMiscArray);
  50. SendClientMessage(playerid, COLOR_RED, "Your account is not set to log in from your current country. Make an Admin Request @ http://ng-gaming.net/forums");
  51. SetTimerEx("KickEx", 5000, 0, "i", playerid);
  52. }
  53. case 4: {
  54. format(szMiscArray, sizeof(szMiscArray), "{AA3333}AdmWarning{FFFF00}: %s (IP:%s) has attempted to log in while locked by the Geosecurity system, and was auto-kicked.", GetPlayerNameEx(playerid), PlayerInfo[playerid][pIP]);
  55. ABroadCast(COLOR_YELLOW, szMiscArray, 2);
  56. format(szMiscArray, sizeof(szMiscArray), "WARNING: %s(%d) (IP:%s) has attempted to log in while locked by the Geosecurity system.", GetPlayerNameEx(playerid), GetPVarInt(playerid, "pSQLID"), PlayerInfo[playerid][pIP]);
  57. Log("logs/geocheck.log", szMiscArray);
  58. SendClientMessage(playerid, COLOR_RED, "Your account is locked due to numerous logins from incorrect countries. Make an Admin Request @ http://ng-gaming.net/forums");
  59. SetTimerEx("KickEx", 5000, 0, "i", playerid);
  60. }
  61. default: {
  62. printf("GEOCHECK: Unknown code returned, returned %d", resCode);
  63. }
  64. }
  65. }
  66. return 1;
  67. }