Advertisement
Guest User

Anti-Ping by Jankingston

a guest
Oct 18th, 2013
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.92 KB | None | 0 0
  1. // Anti Ping
  2.  
  3. #include <a_samp>
  4.  
  5. #define MAX_SECONDS 10
  6. #define MAX_PING 666
  7.  
  8. new Sekundy[200];
  9.  
  10. public OnFilterScriptInit() {
  11. SetTimer("SprawdzPing", 1000, true);
  12. return 1;
  13. }
  14.  
  15. public OnPlayerConnect(playerid) {
  16. Sekundy[playerid] = 0;
  17. return 1;
  18. }
  19.  
  20. forward SprawdzPing();
  21. public SprawdzPing() {
  22. new IloscOsob, Ping, s[256], name[50];
  23. for(new p = 0; p < GetMaxPlayers(); p++) {
  24. if(IsPlayerConnected(p)==1) {
  25. IloscOsob++;
  26. Ping += GetPlayerPing(p);
  27. }
  28. }
  29. Ping /= IloscOsob;
  30. for(new p = 0; p < GetMaxPlayers(); p++) {
  31. if(IsPlayerConnected(p)==1) {
  32. if(GetPlayerPing(p) >= Ping + MAX_PING) {
  33. Sekundy[p]++;
  34. if(Sekundy[p] == MAX_SECONDS) {
  35. GetPlayerName(p, name, sizeof name);
  36. format(s, sizeof s, "%s (ID: %d) is kicked. Reason: a lot of ping.", name, p);
  37. SendClientMessageToAll(0xAA3333AA, s);
  38. Kick(p);
  39. }
  40. }
  41. else if(GetPlayerPing(p) < Ping + MAX_PING) {
  42. if(Sekundy[p] != 0) {
  43. Sekundy[p]--;
  44. }
  45. }
  46. }
  47. }
  48. return 1;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement