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:
Code:
using System; using System.Collections.Generic; using System.Text; using System.Timers; using Addon; namespace PingWarn { public class PingPlugin : CPlugin { int maxPing = 200; int maxWarnings = 3; int maxGraceSeconds = 10; Dictionary<string, int> warnDictionary = new Dictionary<string, int>(); Dictionary<string, DateTime> graceDictionary = new Dictionary<string, DateTime>(); public override void OnServerLoad() { maxPing = int.Parse(CheckSetting("MaxPing", "200")); maxWarnings = int.Parse(CheckSetting("MaxWarnings", "3")); maxGraceSeconds = int.Parse(CheckSetting("MaxGraceSeconds", "10")); Timer timerRefresh = new Timer(); timerRefresh.Interval = int.Parse(CheckSetting("Interval", "20")) * 1000; timerRefresh.Elapsed += new ElapsedEventHandler(timerRefresh_Elapsed); timerRefresh.Start(); } public override ChatType OnSay(string Message, ServerClient Client) { if (Message.StartsWith("!setmaxping") && IsAdmin(Client.XUID)) { string[] command = Message.Split(' '); int desiredMaxPing; if (command.Length > 1 && int.TryParse(command[1], out desiredMaxPing)) { maxPing = desiredMaxPing; SetServerCFG("PingPlugin", "MaxPing", maxPing.ToString()); } else TellClient(Client.ClientNum, "^2[PingPlugin] ^7Unable to set max ping value!", true); return ChatType.ChatNone; } return ChatType.ChatContinue; } List<string> GetCommandsAllowedInGroup(string groupname) { List<string> group = new List<string>(); string group_string = GetServerCFG("Permission", groupname + "_commands", " "); if (group_string != " ") foreach (string cmd in group_string.Split(',')) group.Add(cmd); return group; } List<string> GetUsersInGroup(string groupname) { List<string> group = new List<string>(); string group_string = GetServerCFG("Permission", groupname + "_xuids", " "); if (group_string != " ") foreach (string xuid in group_string.Split(',')) group.Add(xuid); return group; } bool IsAdmin(string XUID) { List<string> XUIDList = new List<string>(); foreach (string usergroup in GetServerCFG("Permission", "Usergroups", "").Split(',')) if (GetCommandsAllowedInGroup(usergroup).Contains("!setmaxping") || GetCommandsAllowedInGroup(usergroup).Contains("*ALL*")) XUIDList.AddRange(GetUsersInGroup(usergroup)); return XUIDList.Contains(XUID); } public override void OnPlayerConnect(ServerClient Client) { if (!graceDictionary.ContainsKey(Client.XUID)) graceDictionary.Add(Client.XUID, DateTime.Now); else graceDictionary[Client.XUID] = DateTime.Now; } string CheckSetting(string key, string value) { if (string.IsNullOrEmpty(GetServerCFG("PingPlugin", key, ""))) { SetServerCFG("PingPlugin", key, value); return value; } return GetServerCFG("PingPlugin", key, ""); } void timerRefresh_Elapsed(object sender, ElapsedEventArgs e) { foreach(ServerClient sc in GetClients()) { if (!graceDictionary.ContainsKey(sc.XUID)) continue; if (graceDictionary[sc.XUID].Subtract(DateTime.Now).TotalSeconds * -1 > maxGraceSeconds && sc.Ping >= maxPing) { if(!warnDictionary.ContainsKey(sc.XUID)) warnDictionary.Add(sc.XUID, 1); else warnDictionary[sc.XUID]++; if (warnDictionary[sc.XUID] == maxWarnings) { KickClient(sc); warnDictionary[sc.XUID] = 0; } else WarnClient(sc); } } } void KickClient(ServerClient sc) { ServerCommand("kickclient " + sc.ClientNum + " \"You have been kicked for having excessive ping!\""); ServerSay("^2" + sc.Name + " ^7has been kicked for having excessive ping!", true); } void WarnClient(ServerClient sc) { iPrintLn("^1WARNING: ^7Your ping is too high! Maximum allowed is " + maxPing + "ms. (" + warnDictionary[sc.XUID] + "/" + maxWarnings + ")", sc); ServerSay("^1WARNING: ^2" + sc.Name + "^7's ping is too high, maximum allowed is " + maxPing + "ms! (" + warnDictionary[sc.XUID] + "/" + maxWarnings + ")", true); } } }

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


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

A casual conversation between barata and I about Nukem.

#2
Good to see you creating plugins as well.
Mine was a piece of crap Tongue

#3
nice.

#4
Geez, just finished having our own one working and you post this.
Good work.

#5
+rep

#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

#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!

#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,


#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)

#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.



Possibly Related Threads…
Thread Author Replies Views Last Post
Rainbow [Release] Plugin ReservedSlot v1.3 frst_ 1 5,060 11-08-2018, 19:17
Last Post: frst_
Tongue [Release] MW3 Shop plugin Dude 56 52,006 03-25-2018, 05:18
Last Post: [email protected]
  [Release] Permission plugin Pozzuh 202 166,699 05-01-2017, 15:41
Last Post: W4R||The Hyper
  [Release] FIXED SPEED PLUGIN hillbilly 2 5,725 06-02-2016, 20:23
Last Post: clacki
  [Release] Bots Plugin For Users Casper 22 40,223 08-22-2015, 17:45
Last Post: SnapBacks
  [Release] God Plugin v5.0 [Ingame Rcon Tool] OzonE 464 341,558 06-27-2015, 15:38
Last Post: bluedot
  [Release] Anti Hardscope Plugin 8q4s8 26 28,011 06-20-2015, 22:44
Last Post: urj88419
  [Release] ProMod Plugin zxz0O0 875 774,505 03-25-2015, 22:02
Last Post: kris
  [Release] [Discontinued] Speed Plugin Pozzuh 164 124,198 10-06-2014, 12:56
Last Post: Nekochan
  [help]how create a ping plugin clacki 3 5,172 09-13-2014, 01:23
Last Post: clacki

Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2026 Melroy van den Berg.