ItsMods

Full Version: BadPing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
A bad ping kicker, if you don't want lagging players, install this.

WARNING: Not tested. Don't freak out when it doesn't work, just tell me and i'll fix it ASAP

Settings (not required, just when you want to change the settings do this: )
In addon\\sv_config.ini add
Code:
[BADPING]
max=500
seconds=20
max is the max ping a user is able to have
seconds is the amount of seconds the plugin waits before checking if someone has a to high ping

Credits
- @JariZ


CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Diagnostics;
  6. using Addon;
  7. using System.Timers;
  8. using System.Collections;
  9.  
  10. namespace BadPing
  11. {
  12. public class BadPing : CPlugin
  13. {
  14. Timer timer = new Timer();
  15. public override void OnServerLoad()
  16. {
  17. ServerPrint("BadPing by JariZ loaded.");
  18.  
  19. maxping = Convert.ToInt32(GetServerCFG("BADPING", "max", "500"));
  20. timer.Interval = Convert.ToInt32(GetServerCFG("BADPING", "seconds", "20"))*100; //20 secs
  21. timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
  22. timer.Start();
  23. }
  24. int maxping = 0;
  25. Hashtable warnings = new Hashtable();
  26. void timer_Elapsed(object sender, ElapsedEventArgs e)
  27. {
  28. List<ServerClient> list = GetClients();
  29. foreach (ServerClient client in list)
  30. {
  31. if (client.Ping > maxping)
  32. {
  33. object nyancat = null;
  34. try
  35. {
  36. nyancat = warnings[client.XUID];
  37. }
  38. catch { }
  39. if (nyancat == null)
  40. {
  41. doWarn(client, 1);
  42. warnings.Add(client.XUID, 1);
  43. }
  44. else
  45. {
  46. doWarn(client, (int)warnings[client.XUID]);
  47. int curr = (int)warnings[client.XUID];
  48. warnings[client.XUID] = curr + 1;
  49. if(curr == 3) ByeBye(client);
  50. warnings[client.XUID] = 0; //reset warns
  51. }
  52. }
  53. }
  54. }
  55.  
  56. void doWarn(ServerClient player, int warn)
  57. {
  58. iPrintLnBold("^2BadPing: ^3WARNING (" + warn + "/3 ^1Your ping is to high (max " + maxping + ")", player);
  59. ServerSay("^2BadPing: ^3WARNING (" + warn + "/3 ^1" + player.Name + "'s ping is to high (max " + maxping + ")", true);
  60. }
  61.  
  62. void ByeBye(ServerClient player)
  63. {
  64. ServerCommand("clientkick " + player.ClientNum);
  65. ServerSay("^2BadPing: ^3" + player.Name + " ^1got kicked because of their high ping", true);
  66. }
  67. }
  68. }


Download
Code:
timer.Interval = Convert.ToInt32(GetServerCFG("BADPING", "seconds", "20"))*100;
should be
timer.Interval = Convert.ToInt32(GetServerCFG("BADPING", "seconds", "20"))*1000;
Which version of addon this plugin?
The plug-in version works, but does not delete 1.168 player with great ping the server, but warns him that he had big. Ping Wouldn't need to players with a ping Server 200-1000, or arms, threw from the players. analogue set sv_maxping "200".
never understood why would you kick players with bad ping
(01-04-2012, 11:20)OrangePL Wrote: [ -> ]never understood why would you kick players with bad ping

cause it sucks when you play against a lagging opponent
get used to it like me Troll
Maybe you should check if the high ping is just a lag spike or a stable high ping. Just an example: if the server loses connection to the internet for 1 second it would kick all players because of the high ping. So you could do:

Check 1: has the player high ping?- if yes continue
wait 5 seconds
Check 2: has the player still a high ping? - if yes kick
nvm sorry :p
Um, read the code before saying 'IT WILL KICK EVERYONE OMG'.
It runs every 20 secs and will give 3 warnings to people with high ping, after 3 warnings, it will kick
@Pozzuh no need to be sorry, it actually was a mistake, it should be 1000
Flood on the screen.
Does not work.
[Image: y4mFo.png]
Pages: 1 2