Advertisement
Guest User

Untitled

a guest
Feb 12th, 2012
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #define MAX_CONNECT_IN_ROW 3
  2. #define MAX_REJOIN_TIME 4000
  3.  
  4. enum IPConnectData
  5. {
  6. ip[25],
  7. lastConnectTime,
  8. connectTimes
  9. }
  10. new Connects[MAX_PLAYERS][IPConnectData];
  11.  
  12. public OnPlayerConnect(playerid)
  13. {
  14. new pIP[25];
  15. new bool:ipFound = false;
  16. GetPlayerIp(playerid, pIP, 25);
  17. for (new i; i < MAX_PLAYERS; i++)
  18. {
  19. if(!strcmp(Connects[i][ip], pIP, false))
  20. {
  21. if (GetTickCount() - Connects[i][lastConnectTime] < MAX_REJOIN_TIME)
  22. {
  23. Connects[i][lastConnectTime] = GetTickCount();
  24. Connects[i][connectTimes]++;
  25. if (Connects[i][connectTimes] > MAX_CONNECT_IN_ROW)
  26. {
  27. new str[100];
  28. format(str, 100, "banip %s", pIP);
  29. SendRconCommand(str);
  30. Kick(playerid);
  31. return 1;
  32. }
  33. }
  34. else
  35. {
  36. Connects[i][lastConnectTime] = GetTickCount();
  37. Connects[i][connectTimes] = 1;
  38. }
  39. ipFound = true;
  40. break;
  41. }
  42. }
  43. if (!ipFound)
  44. {
  45. for (new i; i < MAX_PLAYERS; i++)
  46. {
  47. if (GetTickCount() - Connects[i][lastConnectTime] > MAX_REJOIN_TIME)
  48. {
  49. format(Connects[i][ip], 25, "%s", pIP);
  50. Connects[i][lastConnectTime] = GetTickCount();
  51. Connects[i][connectTimes] = 1;
  52. break;
  53. }
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement