Before I add all the bells and whistles I was wondering if this was a terrible or expensive way to do this. Also do these timers get removed on PlayerDissconnect?
hook.Add("PlayerInitialSpawn", "StartAFK_Timer", function(ply) timer.Create("AFK_Timer: " ..ply:Nick(), 15, 0, function() ply:Kill() ply:SetTeam(TEAM_SPECTATOR) end) end) function ResetAFK_Status (ply, key) timer.Adjust("AFK_Timer: " ..ply:Nick(), 15, 0, function() ply:Kill() ply:SetTeam(TEAM_SPECTATOR) end) end hook.Add( "KeyPress", "Reset AFK Timer", ResetAFK_Status )
I’ve seen some methods use ply:GetPos or ply:GetAngles, those methods seem flawed considering if they die or the round restarts they are not flagged as AFK anymore.
[editline]7th June 2014[/editline]
Would adding to a counter in the think hook then resetting the counter in the KeyPress hook be a more efficient?