--[[ ### Ping Kick Script v3 ###]]-- --[[ ### by Wizard ###]]-- --[[ ### for Phasor v2 ###]]-- --[[ ### other thanks below ###]]-- --This script measures time in seconds, and 'ping updates' --Ping updates are when the player gets a new ping (or has his ping 'updated') on the F1 menu, which usually happens every 3 seconds. max_ping = 365 -- Max Ping: edit as needed max_players_before_kick = 12 -- start pingkicking when the server has this many players. omg_ping = 700 -- unless their ping is at this many ms. pingkick_timeout = 45 -- After this many seconds any player warned of high ping will be forgotten. - edit as needed pingupdate_fix_time = 4 -- A player must have a ping lower than the max_ping/omg_ping for this many ping updates to be forgiven. pingupdate_warn_time = 4 -- A player must have a ping higher than the max_ping/omg_ping for this many ping updates to trigger a warning. --don't edit: pingwarned = {} -- Table of players who have been warned for high ping playerRemoved = {} currentplayers = 0 in_grace = {} warncount = {} gracecount = {} function GetRequiredVersion() return 200 end function OnScriptLoad(process, game, persistent) end function OnNewGame(map) pingwarned = {} pingtimer = registertimer(3000, "pingkickTimer") -- check all players pings every second end function pingkickTimer(id, count) for i = 0,15 do if not playerRemoved[i] then local m_player = getplayer(i) if m_player then local player_ping = readword(m_player + 0xDC) local pingcheck = highPingCheck(player_ping) --Check if player has been warned. if not pingwarned[i] then --Check if we should start the warn counter if pingcheck then if not warncount[i] then warncount[i] = 0 end warncount[i] = warncount[i] + 1 if warncount[i] == pingupdate_warn_time then pingwarned[i] = true privatesay(i, string.format("WARNING: Your Ping: %s ms. You will be kicked if your ping is over %s ms.", player_ping, pingcheck)) local time, units = timeUnit(pingkick_timeout) privatesay(i, string.format("You have %s %s to solve it before being kicked.", time, units)) end else warncount[i] = 0 end else --need some way to determine if player failed to meet grace time. if in_grace[i] == "nope" then if pingcheck then say(getname(i) .. " was kicked for having a ping over " .. pingcheck .. "ms.") else say(getname(i) .. " was kicked for having a ping over " .. max_ping .. "ms.") end svcmd("sv_kick " .. resolveplayer(i)) playerRemoved[i] = true in_grace[i] = nil --if not nil then person has pingkick_timeout to lower their ping. elseif in_grace[i] then if not pingcheck then if not gracecount[i] then gracecount[i] = 0 end gracecount[i] = gracecount[i] + 1 if gracecount[i] >= pingupdate_fix_time then removetimer(in_grace[i]) in_grace[i] = nil pingwarned[i] = nil end else gracecount[i] = 0 end elseif not in_grace[i] then in_grace[i] = registertimer(pingkick_timeout * 1000, "pingTimeout", i) end end end end end return true end function timeUnit(seconds) local minutes = seconds / 60 if minutes == math.floor(minutes) then --really hate programs that never change to singular... if minutes == 1 then return minutes, "minute" end return minutes, "minutes" end --really hate programs that never change to singular... if minutes == 1 then return seconds, "second" end return minutes, "seconds" end --without this function if statements would be too long function highPingCheck(ping) if ping > max_ping and currentplayers >= max_players_before_kick then return max_ping elseif ping >= omg_ping then return omg_ping end return false end function pingTimeout(id, count, player) --re-evaluate warn or kick pingwarned[player] = nil in_grace[player] = "nope" return false end function OnPlayerJoin(player) currentplayers = currentplayers + 1 end function OnPlayerLeave(player) pingwarned[player] = nil playerRemoved[player] = nil currentplayers = currentplayers - 1 end -- Thanks to H® Shaft for the original script. -- Also thanks to H® BugZ, Oxide, Elite Prime, Nugget & many others for their contributions to Phasor and the Halo Community -- 365 is high limit for UK connecting to US server, 333 is too low and will kick even though UK player is not warping nor having packet loss (lag) -- for regional ping limits (client to host) that is stable such as Chicago to New York a good high is 250 which means UK players would get warned/kicked quickly