LUA 187
V1+ Ping Kick 1.0 By xdedeone on 26th February 2019 07:16:43 PM
  1.  
  2. warned = {} -- don't touch this
  3.  
  4. max_ping = 800 --How high the ping of the player should be before you kick them.
  5. pingkick_timeout = 5 --After this many minutes any player warned of high ping will be forgotten.
  6.  
  7. warn_players = true -- Will warn everyone in the server if someone is getting kicked for high ping.
  8.  
  9. function GetRequiredVersion()
  10.         return 10058
  11. end
  12.  
  13. function OnScriptLoad(process)
  14.         registertimer(600000, "remindTimer")
  15.         registertimer(18000, "pingkickTimer")
  16.         registertimer(pingkick_timeout * 60000, "pingTimeout")
  17. end
  18.  
  19. function OnScriptUnload()
  20. end
  21.  
  22. function OnNewGame(map)
  23. end
  24.  
  25. function OnGameEnd(mode)
  26. end
  27.  
  28. function OnServerChat(player, chattype, message)
  29.         return 1
  30. end
  31.  
  32. function OnServerCommand(player, command)
  33.  
  34.         t = {}
  35.         local count = gettokencount(command, " ")
  36.         local response = 1
  37.  
  38.         for i=1,count do
  39.                 local word = gettoken(command, " ", i - 1)
  40.                 word = string.lower(word:gsub('"', ""))
  41.                 table.insert(t, word)
  42.         end
  43.  
  44.         if t[1] == "ping_kick" or t[1] == "pingkick" or t[1] == "sv_pingkick" or t[1] == "sv_setpingmax" then
  45.                 response = 0
  46.                 if count == 2 then
  47.                         max_ping = tonumber(t[2])
  48.                         hprintf("Max Ping set to " .. t[2])
  49.                 else
  50.                         hprintf("Invalid Syntax: sv_pingkick [maxping]")
  51.                 end
  52.         end
  53.         return response
  54. end
  55.  
  56. function OnTeamDecision(cur_team)
  57.         return dest_team
  58. end
  59.  
  60. function OnPlayerJoin(player, team)
  61. end
  62.  
  63. function OnPlayerLeave(player, team)
  64. end
  65.  
  66. function OnPlayerKill(killer, victim, mode)
  67. end
  68.  
  69. function OnKillMultiplier(player, multiplier)
  70. end
  71.  
  72. function OnPlayerSpawn(player, m_objectId)
  73. end
  74.  
  75. function OnPlayerSpawnEnd(player, m_objectId)
  76.  
  77. end
  78.  
  79. function OnTeamChange(relevant, player, team, dest_team)
  80.         return 1
  81. end
  82.  
  83. function OnClientUpdate(player, m_objectId)
  84.  
  85. end
  86.  
  87. function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
  88.         return 1
  89. end
  90.  
  91. function OnWeaponReload(player, weapon)
  92.         return 1
  93. end
  94.  
  95. function OnVehicleEntry(relevant, player, vehicleId, vehicle_tag, seat)
  96.         return 1
  97. end
  98.  
  99. function OnVehicleEject(player, forceEject)
  100.         return 1
  101. end
  102.  
  103. function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
  104. end
  105.  
  106. function OnWeaponAssignment(player, object, count, tag)
  107. end
  108.  
  109. function OnObjectCreation(m_objectId, player_owner, tag)
  110. end
  111.  
  112. function remindTimer(id, count)
  113.         say("This server is equipped with Ping Kick")
  114.         say("If your ping is over " .. max_ping .. " then you will be kicked!")
  115.         return 1
  116. end
  117.  
  118. function pingTimeout(id, count)
  119.         for i = 0,15 do
  120.                 if getplayer(i) ~= nil then
  121.                         warned[gethash(i)] = nil
  122.                 end
  123.         end
  124. end
  125.  
  126. function pingkickTimer(id, count)
  127.         for i = 0,15 do
  128.                 local m_player = getplayer(i)
  129.                 if m_player ~= nil then
  130.                         local player_ping = readword(m_player, 0xDC)
  131.                         if player_ping > max_ping then
  132.                                 if warned[gethash(i)] ~= nil then
  133.                                         svcmd("sv_kick " .. resolveplayer(i))
  134.                                         say(getname(i) .. " was kicked for: Ping over " .. max_ping)
  135.                                 else
  136.                                         warned[gethash(i)] = true
  137.                                         say("WARNING! " .. getname(i) .. " will be kicked for: Ping over " .. max_ping)
  138.                                 end
  139.                         end
  140.                 end
  141.         end
  142.         return 1
  143. end

HaloNet.Net is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.