I ported this over from 2003 and made some changes.
It does work sometimes as I see the message being logged, but more than not the players with high pings are not being kicked.
Can anyone see anything wrong with this code?
It does work sometimes as I see the message being logged, but more than not the players with high pings are not being kicked.
Can anyone see anything wrong with this code?
Code:
// ===================================================================== // MutLimitByPing - Kicks players from a server if they do not meet the ping requirements // Created by OzForces Internet (http://www.ozforces.com/) // ===================================================================== class LimitPing extends Mutator config; var int Violations[64]; var string ClanName[5]; var config string ClanName0; var config string ClanName1; var config string ClanName2; var config string ClanName3; var config string ClanName4; var config int MaximumPing; var config int MaxViolations; var config int WarningLevel; var config float CheckInterval; var config string ClientWarning; function PreBeginPlay() { Super.PreBeginPlay(); saveconfig(); } event PostBeginPlay() { ClanName[0] = ClanName0; ClanName[1] = ClanName1; ClanName[2] = ClanName2; ClanName[3] = ClanName3; ClanName[4] = ClanName4; SetTimer(CheckInterval,true); Super.PostBeginPlay(); } function Timer() { local Controller P, NextP; local int i, found, dokick, PlayerID; local string checkclan, playername; P = Level.ControllerList; if (P != None) { do { NextP = P.NextController; if (PlayerController(P) != None && P.PlayerReplicationInfo != None && P.bIsPlayer && NetConnection(PlayerController(P).Player) != None) { dokick = 0; for (i = 0;i < 5; i++) { checkclan = Caps(ClanName[i]); // don't kick these clans if (checkclan != "") { playername = Caps(P.PlayerReplicationInfo.PlayerName); found = InStr(playername, checkclan); if (found != -1) dokick = 1; } } if ( P.PlayerReplicationInfo.Ping > MaximumPing && dokick == 0) { PlayerID = P.PlayerReplicationInfo.PlayerID; Violations[PlayerID]++; if ((P.IsA('PlayerController')) && (Violations[PlayerID] > MaxViolations)) { Log("-->LimitPing Kicking = " $P.PlayerReplicationInfo.PlayerName); Log("-->LimitPing Kicking = " $PlayerController(P).GetPlayerNetworkAddress()); Level.Game.AccessControl.KickPlayer(PlayerController(P)); } else if (Violations[PlayerID] > WarningLevel) PlayerController(P).ClientMessage(ClientWarning); } } P = NextP; } until (P == None); } } static function FillPlayInfo(PlayInfo PlayInfo) { Super.FillPlayInfo(PlayInfo); PlayInfo.AddSetting("LimitPing", "ClanName0", "Clan to Exclude", 0,1, "Text", "10",, True,True); PlayInfo.AddSetting("LimitPing", "ClanName1", "Clan to Exclude", 0,1, "Text", "10",, True,True); PlayInfo.AddSetting("LimitPing", "ClanName2", "Clan to Exclude", 0,1, "Text", "10",, True,True); PlayInfo.AddSetting("LimitPing", "ClanName3", "Clan to Exclude", 0,1, "Text", "10",, True,True); PlayInfo.AddSetting("LimitPing", "ClanName4", "Clan to Exclude", 0,1, "Text", "10",, True,True); PlayInfo.AddSetting("LimitPing", "MaximumPing", "Maximum Ping", 0,1, "Text", "10;1:300",, True,True); PlayInfo.AddSetting("LimitPing", "MaxViolations", "Max Violations", 0,1, "Text", "3;1:5"); PlayInfo.AddSetting("LimitPing", "WarningLevel", "Warning Violations", 0,1, "Text", "3;1:5"); PlayInfo.AddSetting("LimitPing", "CheckInterval", "Check Interval", 0,1, "Text", "10;30:300"); PlayInfo.AddSetting("LimitPing", "ClientWarning", "Client Warning", 0,1, "Text", "90",, True,True); } static event string GetDescriptionText(string PropName) { switch (PropName) { case "ClanName0": return "Clan to Exclude from being kicked:"; case "ClanName1": return "Clan to Exclude from being kicked"; case "ClanName2": return "Clan to Exclude from being kicked"; case "ClanName3": return "Clan to Exclude from being kicked"; case "ClanName4": return "Clan to Exclude from being kicked"; case "MaximumPing": return "Maximum ping allowed before being kicked"; case "MaxViolations": return "Ping Violations before being kicked"; case "WarningLevel": return "How Many warnings (should be one less or equal to Max Violations)"; case "CheckInterval": return "How Often to check in seconds"; case "ClientWarning": return "Warning Message to Client"; } return Super.GetDescriptionText(PropName); } defaultproperties { ClanName0="(Clan)" ClanName1="" ClanName2="" ClanName3="" ClanName4="" MaximumPing=200 MaxViolations=4 WarningLevel=3 CheckInterval=60.000000 ClientWarning="Your ping is too high, you will be kicked" GroupName="LimitPing" FriendlyName="LimitPing" Description="Will kick any players with a ping higher than a set level" }
Comment