May 25, 2020, 11:27 am

Author Topic: [Add Rule] AFK Demotion Time  (Read 4066 times)

Offline Ravenz

  • ByB Fanatic
  • ****
  • Posts: 584
  • Have cognition before ignition
    • View Profile
[Add Rule] AFK Demotion Time
« on: January 13, 2013, 02:42 am »
Type: Add

Info: No rules on demoting AFK players.

Reason for suggestion: Players sometimes get demoted for being AFK for 1 minute. Not fair.

Suggestion as to what should be added specifically in the MOTD (What the MOTD should say):

Any player that is AFK or puts their job at "AFK" must return within 5 minutes and continue roleplaying, otherwise they are up to be demoted. Players can track their AFK time with !thetime or a stopwatch. Demoting a player for being AFK under 5 minutes will be an invalid demote. Admins cannot kick players for being AFK.

Pros: I can take a wee-wee without getting demoted. It gives a defined AFK time and allows players a couple minutes to go AFK and tend to real life issues, for 5 minutes.

Cons: Admins will have to enforce this as an invalid demote if someone gets demoted under 5 minutes. Although this can be easily figured out through logs (Dark RP and ULX), in-game enforcement could be difficult.

Server specific: Global

Other info: This will set a general synopsis of how AFK players should be handled.

Offline cckane

  • ByB Fanatic
  • ****
  • Posts: 462
  • Swiggity Swooty
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #1 on: January 13, 2013, 02:55 am »
Or a timer could be put up that demotes a player if they're idle while a job that has a limit for 5 minutes.

That way we wouldn't have idiots going "I thought it had been 5 minutes" when they were just hungry for the thief class and it had only been 45 seconds.

Offline Ravenz

  • ByB Fanatic
  • ****
  • Posts: 584
  • Have cognition before ignition
    • View Profile
Re: Re: [Add Rule] AFK Demotion Time
« Reply #2 on: January 13, 2013, 03:07 am »
Or a timer could be put up that demotes a player if they're idle while a job that has a limit for 5 minutes.

That way we wouldn't have idiots going "I thought it had been 5 minutes" when they were just hungry for the thief class and it had only been 45 seconds.

That would work, but what if players go AFK without marking themselves as AFK? Maybe if we could integrate the TTT AFK timer into Dark RP.

Offline Vito DeLuca

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 538
  • 4M > Yours
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #3 on: January 13, 2013, 03:15 am »
I don't think that there is really that big of an issue with demoting for AFK, but if a time limit were put into place that wouldn't really bother me. Although, how would someone enforce if somebody's been AFK for a specific amount of time? And once someone makes an invalid demote that person loses their job/ability to get that job back for a period of time.


Offline cckane

  • ByB Fanatic
  • ****
  • Posts: 462
  • Swiggity Swooty
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #4 on: January 13, 2013, 03:20 am »
That would work, but what if players go AFK without marking themselves as AFK? Maybe if we could integrate the TTT AFK timer into Dark RP.

They won't need to mark themselves as afk, the timer will just mercilessly demote those who don't move for 5 minutes.

Offline Mathium

  • Supporter
  • ByB Champion
  • *
  • Posts: 2499
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #5 on: January 13, 2013, 03:41 am »
I use this on my server.

After 5 Minutes, automatically puts [Afk] in front of their name & brings up a message on their screen that reads "If you don't move within <countdown timer>, you will be kicked" and after another 5 minutes they are kicked. It can easily be changed to demote, but its works rather nicely.

Code: [Select]
AddCSLuaFile("autorun/anti_afk.lua")

local afk_mark = CreateConVar( "afk_mark", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick = CreateConVar( "afk_kick", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick_admins = CreateConVar( "afk_kick_admins", "0", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )

local function TimeString( seconds )
local days = math.floor(seconds/(60*60*24))
seconds = seconds - days*24*60*60
local hours = math.floor(seconds/(60*60))
seconds = seconds - hours*60*60
local minutes = math.floor(seconds/60)
seconds = seconds - minutes*60
seconds = math.floor(seconds)

local s = ""

if days > 0 then
s = s..days.." day"
if days != 1 then
s = s.."s"
end
if (hours > 0 and minutes > 0) or (hours > 0 and seconds > 0) or (minutes > 0 and seconds > 0) then
s = s..", "
elseif hours > 0 or minutes > 0 or seconds > 0 then
s = s.." and "
end
end
if hours > 0 then
s = s..hours.." hour"
if hours != 1 then
s = s.."s"
end
if minutes > 0 and seconds > 0 then
s = s..", "
elseif minutes > 0 or seconds > 0 then
s = s.." and "
end
end
if minutes > 0 then
s = s..minutes.." minute"
if minutes != 1 then
s = s.."s"
end
if seconds > 0 then
s = s.." and "
end
end
if seconds > 0 then
s = s..seconds.." second"
if seconds != 1 then
s = s.."s"
end
end

return s
end

local afk_mark = CreateConVar( "afk_mark", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick = CreateConVar( "afk_kick", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick_admins = CreateConVar( "afk_kick_admins", "0", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )

if SERVER then
local function SetAFK(ply, time)
if time == (ply.AFK_Time or 0) then return end

ply.AFK_Time = time
umsg.Start("AFK")
umsg.Entity(ply)
umsg.Float(time)
umsg.End()
end

local function SetActivity(ply)
ply.LastActivity = CurTime()
SetAFK(ply, 0)
end

hook.Add("PlayerInitialSpawn", "Anti-AFK - Player Join", SetActivity)
hook.Add("PlayerSay", "Anti-AFK - Player Chat", SetActivity)
hook.Add("KeyPress", "Anti-AFK - Player Key Press", SetActivity)
hook.Add("KeyRelease", "Anti-AFK - Player Key Release", SetActivity)

hook.Add("Tick", "Anti-AFK Tick", function()
local cur_time = CurTime()
for _,ply in pairs(player.GetAll()) do
local angles = ply:EyeAngles()
if ply.LastAngles != angles then
ply.LastAngles = angles
if angles.p != 0 then
SetActivity(ply)
end
end

if afk_mark:GetInt() > 0  then
if ply.LastActivity + afk_mark:GetInt() <= cur_time then
if afk_kick:GetInt() > 0 and ply.LastActivity + afk_mark:GetInt() + afk_kick:GetInt() <= cur_time and (not ply:IsAdmin() or afk_kick_admins:GetBool()) then
ply:Kick( "AFK for "..TimeString(afk_kick:GetInt()) )
elseif not tobool(ply.AFK_Time) then
SetAFK(ply, ply.LastActivity)
end
elseif tobool(ply.AFK_Time) then
SetAFK(ply, 0)
end
end
end
end)
end

if CLIENT then

usermessage.Hook("AFK", function(um)
local ply = um:ReadEntity()
local time = um:ReadFloat()
ply.AFK_Time = time
end)

local meta = FindMetaTable("Player")
local oldName = meta.Name

local function Name(ply)
if tobool(ply.AFK_Time) then
return "[AFK]"..oldName(ply)
else
return oldName(ply)
end
end

meta.Name = Name
meta.GetName = Name
meta.Nick = Name

local padding = 15
local spacing = 10

hook.Add("HUDPaint", "Anti-AFK - Kick Countdown", function()
if afk_mark:GetInt() <= 0 then return end
if not tobool(LocalPlayer().AFK_Time) then return end
if (afk_kick:GetInt() <= 0) or (LocalPlayer():IsAdmin() and not afk_kick_admins:GetBool()) then return end

local txt1 = "You are marked as AFK!"
local w1, h1 = surface.GetTextSize( txt1 )

local txt2 = "If you don't move within "..TimeString( LocalPlayer().AFK_Time + afk_mark:GetInt() + afk_kick:GetInt() - CurTime() )..", you will be kicked!"
local w2, h2 = surface.GetTextSize( txt2 )

local boxw = math.Max(w1, w2) + padding*2
local boxh = h1 + spacing + h2 + padding*2

draw.RoundedBox( 6, (ScrW()-boxw)/2, (ScrH()-boxh)/2, boxw, boxh, Color( 20, 20, 20, 180 ) )
draw.SimpleText( txt1, "ScoreboardText", ScrW()/2, ScrH()/2 - spacing/2 - h1, Color(255,0,0,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
draw.SimpleText( txt2, "ScoreboardText", ScrW()/2, ScrH()/2 + spacing/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
end)
end

Offline Vito DeLuca

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 538
  • 4M > Yours
    • View Profile
Re: Re: [Add Rule] AFK Demotion Time
« Reply #6 on: January 13, 2013, 03:56 am »
I use this on my server.

After 5 Minutes, automatically puts [Afk] in front of their name & brings up a message on their screen that reads "If you don't move within <countdown timer>, you will be kicked" and after another 5 minutes they are kicked. It can easily be changed to demote, but its works rather nicely.

Code: [Select]
AddCSLuaFile("autorun/anti_afk.lua")

local afk_mark = CreateConVar( "afk_mark", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick = CreateConVar( "afk_kick", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick_admins = CreateConVar( "afk_kick_admins", "0", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )

local function TimeString( seconds )
local days = math.floor(seconds/(60*60*24))
seconds = seconds - days*24*60*60
local hours = math.floor(seconds/(60*60))
seconds = seconds - hours*60*60
local minutes = math.floor(seconds/60)
seconds = seconds - minutes*60
seconds = math.floor(seconds)

local s = ""

if days > 0 then
s = s..days.." day"
if days != 1 then
s = s.."s"
end
if (hours > 0 and minutes > 0) or (hours > 0 and seconds > 0) or (minutes > 0 and seconds > 0) then
s = s..", "
elseif hours > 0 or minutes > 0 or seconds > 0 then
s = s.." and "
end
end
if hours > 0 then
s = s..hours.." hour"
if hours != 1 then
s = s.."s"
end
if minutes > 0 and seconds > 0 then
s = s..", "
elseif minutes > 0 or seconds > 0 then
s = s.." and "
end
end
if minutes > 0 then
s = s..minutes.." minute"
if minutes != 1 then
s = s.."s"
end
if seconds > 0 then
s = s.." and "
end
end
if seconds > 0 then
s = s..seconds.." second"
if seconds != 1 then
s = s.."s"
end
end

return s
end

local afk_mark = CreateConVar( "afk_mark", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick = CreateConVar( "afk_kick", "300", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )
local afk_kick_admins = CreateConVar( "afk_kick_admins", "0", { FCVAR_REPLICATED, FCVAR_ARCHIVE, FCVAR_NOTIFY } )

if SERVER then
local function SetAFK(ply, time)
if time == (ply.AFK_Time or 0) then return end

ply.AFK_Time = time
umsg.Start("AFK")
umsg.Entity(ply)
umsg.Float(time)
umsg.End()
end

local function SetActivity(ply)
ply.LastActivity = CurTime()
SetAFK(ply, 0)
end

hook.Add("PlayerInitialSpawn", "Anti-AFK - Player Join", SetActivity)
hook.Add("PlayerSay", "Anti-AFK - Player Chat", SetActivity)
hook.Add("KeyPress", "Anti-AFK - Player Key Press", SetActivity)
hook.Add("KeyRelease", "Anti-AFK - Player Key Release", SetActivity)

hook.Add("Tick", "Anti-AFK Tick", function()
local cur_time = CurTime()
for _,ply in pairs(player.GetAll()) do
local angles = ply:EyeAngles()
if ply.LastAngles != angles then
ply.LastAngles = angles
if angles.p != 0 then
SetActivity(ply)
end
end

if afk_mark:GetInt() > 0  then
if ply.LastActivity + afk_mark:GetInt() <= cur_time then
if afk_kick:GetInt() > 0 and ply.LastActivity + afk_mark:GetInt() + afk_kick:GetInt() <= cur_time and (not ply:IsAdmin() or afk_kick_admins:GetBool()) then
ply:Kick( "AFK for "..TimeString(afk_kick:GetInt()) )
elseif not tobool(ply.AFK_Time) then
SetAFK(ply, ply.LastActivity)
end
elseif tobool(ply.AFK_Time) then
SetAFK(ply, 0)
end
end
end
end)
end

if CLIENT then

usermessage.Hook("AFK", function(um)
local ply = um:ReadEntity()
local time = um:ReadFloat()
ply.AFK_Time = time
end)

local meta = FindMetaTable("Player")
local oldName = meta.Name

local function Name(ply)
if tobool(ply.AFK_Time) then
return "[AFK]"..oldName(ply)
else
return oldName(ply)
end
end

meta.Name = Name
meta.GetName = Name
meta.Nick = Name

local padding = 15
local spacing = 10

hook.Add("HUDPaint", "Anti-AFK - Kick Countdown", function()
if afk_mark:GetInt() <= 0 then return end
if not tobool(LocalPlayer().AFK_Time) then return end
if (afk_kick:GetInt() <= 0) or (LocalPlayer():IsAdmin() and not afk_kick_admins:GetBool()) then return end

local txt1 = "You are marked as AFK!"
local w1, h1 = surface.GetTextSize( txt1 )

local txt2 = "If you don't move within "..TimeString( LocalPlayer().AFK_Time + afk_mark:GetInt() + afk_kick:GetInt() - CurTime() )..", you will be kicked!"
local w2, h2 = surface.GetTextSize( txt2 )

local boxw = math.Max(w1, w2) + padding*2
local boxh = h1 + spacing + h2 + padding*2

draw.RoundedBox( 6, (ScrW()-boxw)/2, (ScrH()-boxh)/2, boxw, boxh, Color( 20, 20, 20, 180 ) )
draw.SimpleText( txt1, "ScoreboardText", ScrW()/2, ScrH()/2 - spacing/2 - h1, Color(255,0,0,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
draw.SimpleText( txt2, "ScoreboardText", ScrW()/2, ScrH()/2 + spacing/2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
end)
end
I like this idea a lot.
+ Support

Offline xiValve

  • Global Admin
  • ByB Novice
  • *
  • Posts: 169
  • The Guy Who Cant Drive on GMOD
    • View Profile
    • Youtube Channel
Re: [Add Rule] AFK Demotion Time
« Reply #7 on: January 13, 2013, 09:31 am »
+Support
But change it from 5min to something higher, because you could be gone for 5minutes doing something such as making a report thread or E2ing :)
Your signature is too big, aim for around 200px in height (in total) for all images please.img1 | img2

Offline Barkly1

  • ByB Fanatic
  • ****
  • Posts: 308
  • I am who I choose to be.
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #8 on: January 13, 2013, 10:02 am »
GOD DAM SUPPORT. This is such a crazy insane idea, I love it, it helps alot that you cant imagine. I cant believe ravenz brought this idea up. Man, good job.

Offline Moosaphine

  • Root of all Evil
  • ByB Champion
  • *
  • Posts: 3145
  • I am amazing xo
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #9 on: January 13, 2013, 12:15 pm »
Nothing worse than players smeging that they have been demoted
Jamie : Oli we are so having a LAN party soon
... wait, Oli can you get up stairs?
*Facepalm*


Offline Awesomesauce

  • ByB Champion
  • *****
  • Posts: 1049
  • Goodbye Banana. I already miss you :(
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #10 on: January 27, 2013, 03:10 pm »
There are loopholes though. IIRC in Gmod 12 you could go around that by putting +left and go because it registers as doing something.

Offline Vito DeLuca

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 538
  • 4M > Yours
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #11 on: January 27, 2013, 05:21 pm »
There are loopholes though. IIRC in Gmod 12 you could go around that by putting +left and go because it registers as doing something.
Yeah, but I don't think a majority of people would know how to do that. And it's better than not having anything at all with people complaining about jobs not being available while it's known that someone in that class is/has been away for longer than five/ten minutes. I don't think that this idea should just be thrown away because of a small loophole that most people wouldn't know about.

Offline Tschudy

  • Super Admin
  • ByB Champion
  • *
  • Posts: 1385
  • Tuh-Shoo-Dee
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #12 on: January 29, 2013, 01:59 am »
lets just implement this as a kick then.  Theres no reason that any job should be standng in one spot doing literally nothing for ten minutes.  At that point, all the person is doing is taking up a server slot.  Quite simple, after 10 minutes, the person is automatically kicked from the server.
DO NOT send me a friend request unless you are a super or above.  I'm done folks!


Offline Awesomesauce

  • ByB Champion
  • *****
  • Posts: 1049
  • Goodbye Banana. I already miss you :(
    • View Profile
Re: [Add Rule] AFK Demotion Time
« Reply #13 on: February 01, 2013, 10:43 pm »
lets just implement this as a kick then.  Theres no reason that any job should be standng in one spot doing literally nothing for ten minutes.  At that point, all the person is doing is taking up a server slot.  Quite simple, after 10 minutes, the person is automatically kicked from the server.
There are loopholes though. IIRC in Gmod 12 you could go around that by putting +left and go because it registers as doing something.

Offline Vito DeLuca

  • Supporter
  • ByB Fanatic
  • *
  • Posts: 538
  • 4M > Yours
    • View Profile
Re: Re: [Add Rule] AFK Demotion Time
« Reply #14 on: February 01, 2013, 11:43 pm »
Yeah, but I don't think a majority of people would know how to do that. And it's better than not having anything at all with people complaining about jobs not being available while it's known that someone in that class is/has been away for longer than five/ten minutes.
What I said applies to the same way of what you just quoted. Just because a small percentage of players would be able to get around it, doesn't mean it shouldn't be implemented at all. That's just like we shouldn't ban high capacity magazines because if people really wanted them they would find a way to get them anyway.