Guest User

MoroJr

a guest
Mar 23rd, 2009
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. // Author: K_POLAND
  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. {
  12.     SetTimer("SprawdzPing", 1000, true);
  13.     return 1;
  14. }
  15.  
  16. public OnPlayerConnect(playerid)
  17. {
  18.     Sekundy[playerid] = 0;
  19.     return 1;
  20. }
  21.  
  22. forward SprawdzPing();
  23. public SprawdzPing()
  24. {
  25.     new IloscOsob, Ping, s[256], name[50];
  26.     for(new p = 0; p < GetMaxPlayers(); p++)
  27.     {
  28.         if(IsPlayerConnected(p)==1)
  29.         {
  30.             IloscOsob++;
  31.             Ping += GetPlayerPing(p);
  32.         }
  33.     }
  34.     Ping /= IloscOsob;
  35.     for(new p = 0; p < GetMaxPlayers(); p++)
  36.     {
  37.         if(IsPlayerConnected(p)==1)
  38.         {
  39.             if(GetPlayerPing(p) >= Ping + MAX_PING)
  40.             {
  41.                 Sekundy[p]++;
  42.             }
  43.             if(Sekundy[p] == MAX_SECONDS)
  44.             {
  45.                 GetPlayerName(p, name, sizeof name);
  46.                 format(s, sizeof s, "%s (ID: %d) is kicked. Reason: a lot of ping.", name, p);
  47.                 SendClientMessageToAll(0xAA3333AA, s);
  48.                 Kick(p);
  49.             }
  50.         }
  51.         else if(GetPlayerPing(p) < Ping + MAX_PING)
  52.         {
  53.             if(Sekundy[p] != 0)
  54.             {
  55.                 Sekundy[p]--;
  56.             }
  57.         }
  58.     }
  59.     return 1;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment