Advertisement
Guest User

Ignite AFK

a guest
Nov 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. --------------------------------------------------
  2. AFK_TIME = 60
  3.  
  4. AFK_WARN_TIME = 20
  5. --------------------------------------------------
  6.  
  7. hook.Add("PlayerInitialSpawn", "MakeAFKVar", function(ply)
  8.     ply.NextAFK = CurTime() + AFK_TIME
  9. end)
  10.  
  11. hook.Add("Think", "HandleAFKPlayers", function()
  12.     for _, ply in pairs (player.GetAll()) do
  13.         if ( ply:IsConnected() and ply:IsFullyAuthenticated() ) then
  14.             if ( IsValid(ply) && ply:IsPlayer() ) then
  15.                 if ply:Team() == 2 then
  16.                     if (!ply.NextAFK) then
  17.                         ply.NextAFK = CurTime() + AFK_TIME
  18.                     end
  19.        
  20.                     local afktime = ply.NextAFK
  21.                     if (CurTime() >= afktime - AFK_WARN_TIME) and (!ply.Warning) then
  22.                         ply:ChatPrint("Attention: Ne restez pas immobile vous risquez de prendre feu :) .")
  23.                
  24.                         ply.Warning = true
  25.                     elseif (CurTime() >= afktime) and (ply.Warning) then
  26.                         ply.Warning = nil
  27.                         ply.NextAFK = nil
  28.                         ply:ChatPrint("Vous êtes immobile depuis 1 minute.\n")
  29.                         ply:Ignite(30)
  30.                         on_fire = 1
  31.                     end
  32.                 end
  33.             end
  34.         end
  35.     end
  36. end)
  37.  
  38. hook.Add("KeyPress", "PlayerMoved", function(ply, key)
  39.     if on_fire == 1   then
  40.         ply:Extinguish()
  41.         on_fire = 0
  42.     end
  43.     ply.NextAFK = CurTime() + AFK_TIME
  44.     ply.Warning = false
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement