Author Topic: AAFK V_3.1 : Anti-AFK system for Garry's Mod  (Read 125989 times)

0 Members and 4 Guests are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
AAFK V_3.1 : Anti-AFK system for Garry's Mod
« on: January 13, 2013, 11:09:20 PM »
Anti-AFK Version 3.1

Description:
This script monitors a players movements and actions on a server to attempt to determine if they are AFK. If they are found to be AFK it will tag them as such (client-side graphical).
Optionally (enabled by default) you can have the script kick players who have been afk for a certain number of minutes.

Installation Instructions:
Unzip the ULX_AFK folder into your addons folder.
Check the ConVars below and change them from a server console to your liking.

Console Variables:
ulx_afk_flagminutes - ( Default: 8 ) - How long in minutes a player needs to have not performed an action on the server to be flagged as afk
ulx_afk_kickminutes - ( Default: 10 ) - How long in minutes a player needs to be afk before they are kicked if kicking is enabled (see below)
ulx_afk_ignoreadmins - ( Default: 0 ) - Should the script ignore admins? 1-Yes, 0-No
ulx_afk_kickonafk - ( Default: 1 ) - Should the script kick at all? 1-Yes, 0-No : If this is set to 0 then AFKs will only be shown and players will not be kicked.
ulx_afk_kickonlywhenfull - ( Default: 0 ) - If this is enabled, players will only be kicked from the server for being AFK if the server is full. 1-Yes, 0-No

ChangeLog:

V3.1
+Fixed the verbage of the log messages to make more sense.

V3.0
+Recoded from scratch
+garrysmod13 release


As always... Questions/Comments are welcome!
« Last Edit: January 14, 2013, 03:14:18 PM by MrPresident »

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: AAFK V_3.0 : Anti-AFK system for Garry's Mod
« Reply #1 on: January 14, 2013, 03:30:08 AM »
Very awesome. :D
Experiencing God's grace one day at a time.

Offline Wully616

  • Jr. Member
  • **
  • Posts: 64
  • Karma: 10
    • WullysGamers
Re: AAFK V_3.0 : Anti-AFK system for Garry's Mod
« Reply #2 on: January 14, 2013, 04:57:19 AM »
You sir, are a legend and have won my Internets! Thanks for this  ;D
[/url]

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: AAFK V_3.0 : Anti-AFK system for Garry's Mod
« Reply #3 on: January 14, 2013, 06:20:33 AM »
You are just too awesome. My admins and I were just discussing this the other day, and couldn't find one that worked. You rock, so many socks.

Offline TweaK

  • Jr. Member
  • **
  • Posts: 80
  • Karma: 14
    • Garry's Mod Engineers
Re: AAFK V_3.0 : Anti-AFK system for Garry's Mod
« Reply #4 on: January 14, 2013, 07:25:51 AM »
Sweeeet. Throwing this on my servers now :D

edit: it works, but it prints twice... "You is now AFK!"

wat
« Last Edit: January 14, 2013, 07:50:54 AM by TweaK »


Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: AAFK V_3.0 : Anti-AFK system for Garry's Mod
« Reply #5 on: January 14, 2013, 08:15:25 AM »
@Mr. P, choose verbs wisely when using fancy logging. :)

I suggest "<Name> went AFK" which works with "You went AFK" and "Bob went AFK".
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: AAFK V_3.0 : Anti-AFK system for Garry's Mod
« Reply #6 on: January 14, 2013, 03:10:04 PM »
Yes.. the verb.. I caught it right away but I thought it was comical and I figured it would only affect the person who was going afk.. (but I'll change it)

Also, it prints twice because the first is the FancyLog. Which will only display if you have logecho on. The second is the notification I added to show to all connected players when a player goes in and out of afk. If you want to disable the second one, look in the code for anywhere you see ulib.tsayColor and comment it out.

V3.1
------
+Fixed the verbage to make more sense.

Download in the original post.
« Last Edit: January 14, 2013, 03:14:56 PM by MrPresident »

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #7 on: January 14, 2013, 10:57:33 PM »
I've run into only one issue with this. TTT has an auto spectate option, if that activates after you go into afk, the afk resets. Is it possible to make it so if TTT puts you into spectate that counts as you going afk, then it skips to step two for waiting to be kicked? Or at least could you point me in the direction on how to implement this on my own, since you guys try to keep ulx independent from game modes.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #8 on: January 14, 2013, 11:28:55 PM »
Find out how to tell if the player is in the spectate option for TTT. Once you have that.. You'll need to modify the 3 functions that check if the player has done something to break the afk.

All 3 functions have the same code, i just had them separated for debugging purposes, I might merge them in the future. For now just change the code to this: (this is pseudo-code.. you'll have to actually figure out what the TTT spectate code is)


Code: [Select]
function ulx.AFKExit_Chat( pl )
if pl.afk == false then return end
if pl:IsTTTSpectator() then return end

if not IsValid( pl ) then return end
if not pl:IsConnected() then return end
ulx.ResetAFKStatus( pl )
end
hook.Add("PlayerSay", "AFKExit_Chat", ulx.AFKExit_Chat)


On a totally unrelated note... I just noticed I hit over 1000 posts.. woo!

Offline SuperAero_

  • Newbie
  • *
  • Posts: 13
  • Karma: 1
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #9 on: January 15, 2013, 12:34:44 AM »

On a totally unrelated note... I just noticed I hit over 1000 posts.. woo!

Grats :P

Offline Eccid

  • Full Member
  • ***
  • Posts: 115
  • Karma: 11
  • Hey, come on... We just met...
    • Terror Abound! Steam Group
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #10 on: January 15, 2013, 01:41:34 AM »
So this is what I have (on all three functions) gonna test it soon and tell you how it goes.

Code: [Select]
function ulx.AFKExit_Chat( pl )
if pl.afk == false then return end
if pl:IsSpec() then return end

if not IsValid( pl ) then return end
if not pl:IsConnected() then return end
ulx.ResetAFKStatus( pl )
print("1")

end

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #11 on: January 15, 2013, 05:03:50 AM »
Well, you can get rid of the print line at the end of the functions. Those were debug lines that I forgot to remove.

Offline Bizzclaw

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • Frostburnt Foundation
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #12 on: March 07, 2013, 12:41:36 PM »
Does it detect if people are working on a PAC3 outfit?
http://steamcommunity.com/sharedfiles/filedetails/?id=104691717
Don't want people to be kicked when making a custom model, especially because they wouldn't have a chance to save and if they have been working that long on an outfit, they may rage quit, and that's just no fun. 

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #13 on: March 07, 2013, 02:33:03 PM »
Does it detect if people are working on a PAC3 outfit?
I've not looked at code, but, most likely, no.
I'm betting once he gets back on his (coding) feet after his surgery, he could probably investigate ways to monitor in-game menu actions or key presses, without being specific to just PAC.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bizzclaw

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • Frostburnt Foundation
Re: AAFK V_3.1 : Anti-AFK system for Garry's Mod
« Reply #14 on: March 08, 2013, 12:59:33 AM »
I was thinking that perhaps 60 or 30 seconds before they are autokicked, it opens a derma panel over evrything else that says "You are about to be kicked for being AFK! If you're there, hit this button." And the player can simply click the button and the timer resets, otherwise they get kicked would be a bit annoying, but it would be easy, and heck I could probably do that if I looked in to it a bit.