Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ### Ping Kick Script v3 ###]]--
- --[[ ### by H® Shaft ###]]--
- --[[ ### for Phasor v2 ###]]--
- --[[ ### other thanks below ###]]--
- -- updated 2/17/2014 to change old code, and to change from players hash to players ip, added remove timers at game end, added game_started
- -- Added Spanish warnings.
- max_ping = 500 -- Max Ping: edit as needed
- pingkick_timeout = 2 -- After this many minutes any player warned of high ping will be forgotten, or kicked if still too high. - edit as needed
- --don't edit:
- pingwarned = {}
- game_started = false
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- end
- function OnNewGame(map)
- game_started = true
- pingwarned = {}
- pingtimer = registertimer(180000, "pingkickTimer") -- check all players pings every 180000ms = 3 minutes
- pingtimeouter = registertimer(pingkick_timeout * 60000, "pingTimeout")
- end
- function pingTimeout(id, count) --re-evaluate warn or kick
- for i = 0,15 do
- if getplayer(i) then
- pingwarned[getip(i)] = nil
- end
- end
- end
- function pingkickTimer(id, count)
- for i = 0,15 do
- local m_player = getplayer(i)
- if m_player then
- local player_ping = readword(m_player, 0xDC)
- local ping = player_ping
- local maxping = max_ping
- if player_ping > max_ping and game_started then
- if pingwarned[getip(i)] and not isadmin(i) then
- say(getname(i) .. " was kicked for having a ping over " .. maxping .. "ms.")
- svcmd("sv_kick " .. resolveplayer(i))
- log_msg(1, getname(i) .. " was kicked for high ping: " .. ping)
- log_msg(3, getname(i) .. " was kicked for high ping: " .. ping)
- else
- warn_ping = registertimer(1000, "pingwarn")
- end
- end
- end
- end
- return true
- end
- function OnPlayerLeave(player)
- pingwarned[getip(player)] = nil
- end
- function pingwarn(id, count) --warns player they will be kicked, tells them their ping
- if count == 1 then
- for i = 0,15 do
- local m_player = getplayer(i)
- if m_player then
- local player_ping = readword(m_player, 0xDC)
- local timeout = pingkick_timeout
- local ping = player_ping
- local maxping = max_ping
- if player_ping > max_ping and game_started then
- if pingwarned[getip(i)] == nil then
- pingwarned[getip(i)] = true
- privatesay(i, "WARNING: Your Ping: " .. ping .. "ms. You will be kicked if your ping is over " .. maxping .. "ms.")
- privatesay(i, "You have " .. timeout .. " minute(s) to solve it before being kicked.")
- privatesay(i, "Usted tiene 2 minuto(s) para resolver este PING antes de ser expulsado.")
- sendconsoletext(i, "YOUR PING IS TOO HIGH! " .. ping .. "ms. TU PING ES DEMASIADO ALTA: " .. ping .. "ms.")
- end
- end
- end
- end
- end
- return true
- end
- function OnGameEnd(stage)
- if stage == 1 then
- game_started = false
- if warn_ping then
- removetimer(warn_ping)
- warn_ping = nil
- end
- if pingtimer then
- removetimer(pingtimer)
- pingtimer = nil
- end
- if pingtimeouter then
- removetimer(pingtimeouter)
- pingtimeouter = nil
- end
- end
- end
- -- 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
- -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
- -- Visit http://halorace.org/forum/index.php?topic=514.0 or
- -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment