Хочу кик за афк.
1 час чел афкашит его кикает с причиной АФК админ ULX
Мне нужен код.
Как сделать часы
Какие часы?
Часы ulx походу
local CONFIG = {
AFK_LIMIT = 900, -- 15 минут в секундах
CHECK_INTERVAL = 5, -- Проверка каждые 5 секунд
KICK_MESSAGE = "Вы были кикнуты за простой более чем на 15 минут."
}
local pairs, ipairs = pairs, ipairs
local os_time = os.time
local player_GetAll = player.GetAll
local timer_Create = timer.Create
local hook_Add = hook.Add
local playerLastActive = setmetatable({}, {__mode = "k"})
local adminCache = setmetatable({}, {__mode = "k"})
local function isAdmin(ply)
local cached = adminCache[ply]
if cached == nil then
cached = ply:IsAdmin() or ply:IsSuperAdmin()
adminCache[ply] = cached
end
return cached
end
local function updateActivity(ply)
playerLastActive[ply] = os_time()
end
hook_Add("KeyPress", "UpdatePlayerActivity", updateActivity)
hook_Add("PlayerInitialSpawn", "InitializePlayerActivity", updateActivity)
timer_Create("CheckPlayerAFKStatus", CONFIG.CHECK_INTERVAL, 0, function()
local currentTime = os_time()
for _, ply in ipairs(player_GetAll()) do
if not isAdmin(ply) then
local lastActive = playerLastActive[ply]
if lastActive and (currentTime - lastActive > CONFIG.AFK_LIMIT) then
ply:Kick(CONFIG.KICK_MESSAGE)
end
end
end
end)
hook_Add("PlayerDisconnected", "CleanupPlayerActivity", function(ply)
playerLastActive[ply] = nil
adminCache[ply] = nil
end)