How do i make this code to not check on admins?
AFK_TIME = 900
AFK_WARN_TIME = 600
--------------------------------------------------
hook.Add("PlayerInitialSpawn", "MakeAFKVar", function(ply)
ply.NextAFK = CurTime() + AFK_TIME
end)
hook.Add("Think", "HandleAFKPlayers", function()
for _, ply in pairs (player.GetAll()) do
if ( ply:IsConnected() and ply:IsFullyAuthenticated() ) then
if (!ply.NextAFK) then
ply.NextAFK = CurTime() + AFK_TIME
end
local afktime = ply.NextAFK
if (CurTime() >= afktime - AFK_WARN_TIME) and (!ply.Warning) then
ply:ChatPrint("Warning: You will be kicked soon if you are inactive.")
ply.Warning = true
elseif (CurTime() >= afktime) and (ply.Warning) then
ply.Warning = nil
ply.NextAFK = nil
ply:Kick("Kicked for being AFK for 15 minutes.\n")
end
end
end
end)
hook.Add("KeyPress", "PlayerMoved", function(ply, key)
ply.NextAFK = CurTime() + AFK_TIME
ply.Warning = false
end)
I made it right?
--------------------------------------------------
AFK_TIME = 900
AFK_WARN_TIME = 600
--------------------------------------------------
hook.Add("PlayerInitialSpawn", "MakeAFKVar", function(ply)
ply.NextAFK = CurTime() + AFK_TIME
end)
hook.Add("Think", "HandleAFKPlayers", function()
for _, ply in pairs (player.GetAll()) do
if ( ply:IsAdmin() ) then end
if ( ply:IsConnected() and ply:IsFullyAuthenticated() ) then
if (!ply.NextAFK) then
ply.NextAFK = CurTime() + AFK_TIME
end
local afktime = ply.NextAFK
if (CurTime() >= afktime - AFK_WARN_TIME) and (!ply.Warning) then
ply:ChatPrint("Warning: You will be kicked soon if you are inactive.")
ply.Warning = true
elseif (CurTime() >= afktime) and (ply.Warning) then
ply.Warning = nil
ply.NextAFK = nil
ply:Kick("Kicked for being AFK for 15 minutes.\n")
end
end
end
end)
hook.Add("KeyPress", "PlayerMoved", function(ply, key)
ply.NextAFK = CurTime() + AFK_TIME
ply.Warning = false
end)
It didn't work
AFK_TIME = 900
AFK_WARN_TIME = 600
hook.Add("PlayerInitialSpawn", "MakeAFKVar", function(ply)
if ply:IsAdmin() then return end
ply.NextAFK = CurTime() + AFK_TIME
end)
hook.Add("Think", "HandleAFKPlayers", function()
for _, ply in pairs(player.GetAll()) do
if ply:IsAdmin() then return end
if ( ply:IsConnected() and ply:IsFullyAuthenticated() ) then
if (!ply.NextAFK) then
ply.NextAFK = CurTime() + AFK_TIME
end
local afktime = ply.NextAFK
if (CurTime() >= afktime - AFK_WARN_TIME) and (!ply.Warning) then
ply:ChatPrint("Warning: You will be kicked soon if you are inactive.")
ply.Warning = true
elseif (CurTime() >= afktime) and (ply.Warning) then
ply.Warning = nil
ply.NextAFK = nil
ply:Kick("Kicked for being AFK for 15 minutes.\n")
end
end
end
end)
hook.Add("KeyPress", "PlayerMoved", function(ply, key)
if ply:IsAdmin() then return end
ply.NextAFK = CurTime() + AFK_TIME
ply.Warning = false
end)
Can I ask you about your admin system?
I use ULX and FAdmin
Sorry, you need to Log In to post a reply to this thread.