Update: You shouldn’t use this! This was something I wrote years ago which relies on the client to dictate whether the should be kicked (which is bad on all levels!)
Hi!
After a few players informed me that they were being kicked as soon as their ping hit over the set limit I decided to quickly write a strike based ping kicking system.
The config is self explanatory:
Config = {
limit = 200, -- Strike a player after going over this ping
maxStrikes = 5, -- Amount of strikes it takes to be kicked
checkInterval = 2000, -- (ms) Every two seconds
}
Feel free to improve on this and contribute to the GitHub repository below.
Hi, thank you for this release man, anyway. i have a problem with the script.
When a player reach the ping limit (300ms in my server), he get kicked, but some others players get kicked too… Last time, 6 people got kicked, but only one got 300+ ms.
Could you please tell me if there is something to do? Thank you.
Latest release now fixes this, currently it gets their final ping when they are kicked, this could be lower than what they were originally kicked for as obviously ping changes every ms, the client now send their last ping when kicking.
I just made this script to be entirely server sided for vrp for anyone interested:
local userPing = {}
local pingStrike = {}
local maxPing = 300
local maxStrikes = 10
Citizen.CreateThread(function()
while true do
local users = vRP.getUsers({})
if users ~= nil then
for k, v in pairs(users) do
local user_id = vRP.getUserId({v})
userPing[user_id] = GetPlayerPing(v)
if userPing[user_id] >= maxPing then
if pingStrike[user_id] == nil then
pingStrike[user_id] = 1
else
pingStrike[user_id] = pingStrike[user_id] + 1
end
if pingStrike[user_id] >= maxStrikes then
DropPlayer(v, "You have been kicked due to your high ping! (" ..userPing[user_id].. "ms/" ..maxPing.."ms limit)")
pingStrike[user_id] = 0
end
end
end
end
Citizen.Wait(2000)
end
end)