• 6 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Release] Ping Warn Plugin v1.1
#1
This is like BadPing plugin by @JariZ however this one is tested and working.

Settings: (sv_config.ini)
MaxPing - The maximum ping allowed on the server. (default value is 200)
MaxWarnings - The maximum amount of warnings allowed before the player is kicked. (default value is 3)
Interval - How often (in seconds) to check every player's ping. (default value is 20)
MaxGraceSeconds - The maximum of seconds to ignore a player's ping after they've joined the game. (default value is 10).

Commands:
!setmaxping <value> - Sets the maximum ping allowed.
- You can add more commands using the source, I'm busy with other stuffs at the moment.

In order to use the text commands, you will Pozzuh's Permission Plugin and have to add !setmaxping to the allowed commands list. Alternatively, you can copy and paste this into your config if you don't want to use the permission plugin:
Code:
[Permission]
//You can add more user groups here
Usergroups=Admin
//Add admin xuids here (Use the status command in console to obtain XUIDs)
Admin_xuids=xuid1,xuid2,xuid3
//Admins can use all commands (Do not change!).
Admin_commands=*ALL*

Source:
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Timers;
  5. using Addon;
  6.  
  7. namespace PingWarn
  8. {
  9. public class PingPlugin : CPlugin
  10. {
  11. int maxPing = 200;
  12. int maxWarnings = 3;
  13. int maxGraceSeconds = 10;
  14.  
  15. Dictionary<string, int> warnDictionary = new Dictionary<string, int>();
  16. Dictionary<string, DateTime> graceDictionary = new Dictionary<string, DateTime>();
  17.  
  18. public override void OnServerLoad()
  19. {
  20. maxPing = int.Parse(CheckSetting("MaxPing", "200"));
  21. maxWarnings = int.Parse(CheckSetting("MaxWarnings", "3"));
  22. maxGraceSeconds = int.Parse(CheckSetting("MaxGraceSeconds", "10"));
  23.  
  24. Timer timerRefresh = new Timer();
  25. timerRefresh.Interval = int.Parse(CheckSetting("Interval", "20")) * 1000;
  26. timerRefresh.Elapsed += new ElapsedEventHandler(timerRefresh_Elapsed);
  27. timerRefresh.Start();
  28. }
  29.  
  30. public override ChatType OnSay(string Message, ServerClient Client)
  31. {
  32. if (Message.StartsWith("!setmaxping") && IsAdmin(Client.XUID))
  33. {
  34. string[] command = Message.Split(' ');
  35. int desiredMaxPing;
  36.  
  37. if (command.Length > 1 && int.TryParse(command[1], out desiredMaxPing))
  38. {
  39. maxPing = desiredMaxPing;
  40. SetServerCFG("PingPlugin", "MaxPing", maxPing.ToString());
  41. }
  42. else
  43. TellClient(Client.ClientNum, "^2[PingPlugin] ^7Unable to set max ping value!", true);
  44.  
  45. return ChatType.ChatNone;
  46. }
  47.  
  48. return ChatType.ChatContinue;
  49. }
  50.  
  51. List<string> GetCommandsAllowedInGroup(string groupname)
  52. {
  53. List<string> group = new List<string>();
  54.  
  55. string group_string = GetServerCFG("Permission", groupname + "_commands", " ");
  56.  
  57. if (group_string != " ")
  58. foreach (string cmd in group_string.Split(','))
  59. group.Add(cmd);
  60.  
  61. return group;
  62. }
  63.  
  64. List<string> GetUsersInGroup(string groupname)
  65. {
  66. List<string> group = new List<string>();
  67.  
  68. string group_string = GetServerCFG("Permission", groupname + "_xuids", " ");
  69.  
  70. if (group_string != " ")
  71. foreach (string xuid in group_string.Split(','))
  72. group.Add(xuid);
  73.  
  74. return group;
  75. }
  76.  
  77. bool IsAdmin(string XUID)
  78. {
  79. List<string> XUIDList = new List<string>();
  80. foreach (string usergroup in GetServerCFG("Permission", "Usergroups", "").Split(','))
  81. if (GetCommandsAllowedInGroup(usergroup).Contains("!setmaxping") || GetCommandsAllowedInGroup(usergroup).Contains("*ALL*"))
  82. XUIDList.AddRange(GetUsersInGroup(usergroup));
  83.  
  84. return XUIDList.Contains(XUID);
  85. }
  86.  
  87. public override void OnPlayerConnect(ServerClient Client)
  88. {
  89. if (!graceDictionary.ContainsKey(Client.XUID))
  90. graceDictionary.Add(Client.XUID, DateTime.Now);
  91. else
  92. graceDictionary[Client.XUID] = DateTime.Now;
  93. }
  94.  
  95. string CheckSetting(string key, string value)
  96. {
  97. if (string.IsNullOrEmpty(GetServerCFG("PingPlugin", key, "")))
  98. {
  99. SetServerCFG("PingPlugin", key, value);
  100. return value;
  101. }
  102.  
  103. return GetServerCFG("PingPlugin", key, "");
  104. }
  105.  
  106. void timerRefresh_Elapsed(object sender, ElapsedEventArgs e)
  107. {
  108. foreach(ServerClient sc in GetClients())
  109. {
  110. if (!graceDictionary.ContainsKey(sc.XUID))
  111. continue;
  112.  
  113. if (graceDictionary[sc.XUID].Subtract(DateTime.Now).TotalSeconds * -1 > maxGraceSeconds && sc.Ping >= maxPing)
  114. {
  115. if(!warnDictionary.ContainsKey(sc.XUID))
  116. warnDictionary.Add(sc.XUID, 1);
  117. else
  118. warnDictionary[sc.XUID]++;
  119.  
  120. if (warnDictionary[sc.XUID] == maxWarnings)
  121. {
  122. KickClient(sc);
  123. warnDictionary[sc.XUID] = 0;
  124. }
  125. else
  126. WarnClient(sc);
  127. }
  128. }
  129. }
  130.  
  131. void KickClient(ServerClient sc)
  132. {
  133. ServerCommand("kickclient " + sc.ClientNum + " \"You have been kicked for having excessive ping!\"");
  134. ServerSay("^2" + sc.Name + " ^7has been kicked for having excessive ping!", true);
  135. }
  136.  
  137. void WarnClient(ServerClient sc)
  138. {
  139. iPrintLn("^1WARNING: ^7Your ping is too high! Maximum allowed is " + maxPing + "ms. (" + warnDictionary[sc.XUID] + "/" + maxWarnings + ")", sc);
  140. ServerSay("^1WARNING: ^2" + sc.Name + "^7's ping is too high, maximum allowed is " + maxPing + "ms! (" + warnDictionary[sc.XUID] + "/" + maxWarnings + ")", true);
  141. }
  142. }
  143. }


Credits:
@JariZ - Base/concept of plugin.
@Pozzuh - Permission plugin.


Attached Files
.zip   PingWarn-v1.1.zip (Size: 3.83 KB / Downloads: 776)
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply
#2
Good to see you creating plugins as well.
Mine was a piece of crap Tongue
  Reply
#3
nice.
  Reply
#4
Geez, just finished having our own one working and you post this.
Good work.
  Reply
#5
+rep
  Reply
#6
I keep getting message like this whenever there are empty slots on my server,
and this plugin try to warn "players" even if no one is connected to server.
can these message be removed or deactivated ex: you type "!hideinfo 1" then no more in-game info will be shown
thanks.

Client 0 is not active
Client 11 is not active
Client 10 is not active
Client 9 is not active
Client 8 is not active
Client 7 is not active
Client 6 is not active
Client 5 is not active
Client 4 is not active
Client 3 is not active
Client 2 is not active
Client 1 is not active
  Reply
#7
hello this plugin working perfectly parabens, I'm with a doubt, as I have these phrases trasuzir ""^7has been kicked for having excessive ping! "^1WARNING : 7Your ping is too high! Maximum allowed is "!" [/b]"^1WARNING:^7's ping is too high, maximum allowed is
"" "plugin that sends the server alerting players ping to translate to the language of my parents? has some potential ?, is esplicar I'm kinda noob ............. sorry for my english! thank you!
  Reply
#8
This is a wonderful plugin thanks.

Is there a way to allow the server Admin to control how high or low the ping setting is instead of having it set (and not adjustable) at 200?

Please allow a more wider range of max ping settings controlled by server admin.

Also the warnings seem to be a little off. It will say that someone has a high ping when they are joining but when they join there ping is fine.

Is there anyway for it not to say that when folks are joining?

Thanks,

  Reply
#9
help with sv config? did I set this up right?

Settings: (sv_config.ini)
MaxPing - 350 The maximum ping allowed on the server. (default value is 200)
MaxWarnings - The maximum amount of warnings allowed before the player is kicked. (default value is 3)
Interval - 25 How often (in seconds) to check every player's ping. (default value is 20)
  Reply
#10
(03-11-2012, 14:12)Kiyone6400 Wrote: I keep getting message like this whenever there are empty slots on my server,
and this plugin try to warn "players" even if no one is connected to server.
can these message be removed or deactivated ex: you type "!hideinfo 1" then no more in-game info will be shown
thanks.

Client 0 is not active
Client 11 is not active
Client 10 is not active
Client 9 is not active
Client 8 is not active
Client 7 is not active
Client 6 is not active
Client 5 is not active
Client 4 is not active
Client 3 is not active
Client 2 is not active
Client 1 is not active

I'm not sure why that's happening, must be something to do with GetClients().

dthem_2000 Wrote:Also the warnings seem to be a little off. It will say that someone has a high ping when they are joining but when they join there ping is fine.

Yeah, I'm not sure about that, it's a bug with the game. You could add a 'grace period' which ignores the checking for the player for 10 seconds after joining.

dthem_2000 Wrote:Please allow a more wider range of max ping settings controlled by server admin.

Like what?
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 3,871 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 4,328 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 38,038 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 5,230 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 4,581 10-19-2013, 06:59
Last Post: iRoNinja
  [Release] Yurio Map Plugin Yurio 101 57,241 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 17,271 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 2,515 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 30,191 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
  Search Plugin Fluid Killcam N3xT_974 1 2,831 09-10-2013, 20:27
Last Post: Nekochan

Forum Jump:


Users browsing this thread: 1 Guest(s)