Simple AFK Timer

Hello there! I’m new to lua pretty much. I wanted to start making more helpful tools for gmod.
My last tool wasn’t too well received, probably because it was poorly thought out.
I made sure not to make that same mistake again. I wanted to make something useful that would help servers get rid of idle players taking up their precious slots.
So I present to you: AFK Timer. A simple tool that checks if a player is AFK every 10 minutes (This will be changeable in the future.). If the player doesn’t hit the okay button, it kicks them.
Here are some screenshots of the tool.

http://i.imgur.com/78eL2d8.jpg[/t]

New design:
[t]http://i.imgur.com/xxBYZqu.jpg

I know it isnt much but I plan on adding on to this as my abilities with lua get better I will be adding new customization options to this.
Features
45 Minute AFK Timer.
Okayish Design
Admin Immunity to afk check

ConVars:
sv_afktime - The time it takes in minutes for the Checker to show up. The default is 45 minutes.
sv_kicktime - The time it takes in seconds for the player to be kicked. Don’t set this lower than the afk timer or the addon will not work.
sv_kickmessage - The message that shows up when a player is kicked for being afk.

Plans:
[del]Better Design[/del]
Color chooser for the menu and text built into an admin menu for the tool
Admin menu for the tool
[del]ConVars so you can set the amount of time on the timer and the kick text.[/del]

I uploaded this to the workshop here
You can also download the full addon here.

I want to improve this simple addon as much as I can while I learn lua, so please give me some feedback.
I also know that tools such as ULX have an afk kicker, I wanted one that required the user to click a button to continue.

Not a bad idea I suppose. But, IMO you should detect if they move at all within 10 minutes instead of making them verify they’re there. I could see the notice thing getting a bit annoying on build servers among other things.

Someone could make a thing to make their player move every couple seconds thus making the afk timer useless. Clicking it makes it prove they are actively there. I also plan on making a configurable timer so build servers can set it for every 30 minutes if they want.

a player can make a five second script to get around ANY anti-afk script

there is no good reason to make players click a box when they were not even detected to be afk in the first place

there is no good reason to make players click a box at all

sorry, this just isn’t very useful

[lua]
local plyafk = {}
local seconds = 60*10
timer.Create(“SimpleAfkChecker”,5,0,function()
for k, v in pairs(player.GetAll()) do
plyafk[v] = plyafk[v] || {}
local oldangs = plyafk[v][2] || v:EyeAngles()
plyafk[v][2] = v:EyeAngles()
if plyafk[v][2] == oldangs then
if CurTime() - plyafk[v][1] >= seconds then v:Kick(“AFK”) end
else
plyafk[v][1] = CurTime()
end
end
end)
[/lua]

this script, in lua/autorun/server, will kick players who don’t move their mouse for ten minutes, without bothering them any

you could add some networking stuff to warn the player with some onscreen text with a kick countdown timer

Thanks for the feedback, as I said on steam I will be adding this as an option. I want to make a highly customizable afk checker with a variety of options. I will start by making it less intrusive so it’s not annoying to the player, then I will move on to add in more options such as the one you suggested.
Edit:
Here is the current size and position of the AFK timer. I will be touching up the VGUI a bit to make it more pleasing to the eyes.

Nice! I’m testing on my server

I would wait. I’m adding some new features that will make it better.

Fixed up the design a little.

I’m also just going to make it check every 45 minutes by default. There is no point checking every 10 minutes.

New update is now published. Check the OP for links.

you can add immunity to admin?

github.com mirror ?

It’s already added. :slight_smile: If a player is admin they will not get the AFK menu.

ULX function with groups?

adminvip, moderador, vip, etc etc… ?

I havent tested it with ULX. Let me test it out.

It’s still saying I’m immune to the AFK checker when I have ULX installed.
I will try to make it so you can add groups for immunity.

I would go with bitches suggestion of using their eye angles, but only use the pitch (looking up down) because you can’t modify the pitch using concmds. All other afk-detectable properties such as position and angle yaw can be bypassed by running +forward +right before going afk (you will run a circle until you do -forward -right).

I enjoy my way better. After thinking about it the way I do it isnt that bad. I will be changing it so the mouse doesn’t appear suddenly. I will also be making it so you have to press a key for it to appear. Thanks for the suggestion though!

your way only comes down to “because i prefer being inconvenienced”

It’s only an inconvenience if the admin setting up the timer makes it that way. I’ve made it highly changeable so they can make the AFK Timer set for hours if they wanted to. The kick timer can be set just as long as well. I still think view angles are too easy to bot.
Thank you for your feedback, bitches. I’ve taken it into consideration and don’t want to do that. I prefer it this way personally.
Sorry.

Alright. I made the final design (Hopefully)

This will be updated on workshop and the other link soon-ish. I also made it so it doesn’t unlock your cursor when the menu shows up. You press B to do it at anytime now.
I also added some ConVars:
sv_afktime - The time it takes in minutes for the Checker to show up. The default is 45 minutes.
sv_kicktime - The time it takes in seconds for the player to be kicked. Don’t set this lower than the afk timer or the addon will not work.
sv_kickmessage - The message that shows up when a player is kicked for being afk.

the cursor is not working. vcmod, atm, tab, etc …
Please remove the lock slider (B)

Works fine on my end.

Send me an IP to your server so I can see what you are talking about.

and you can not use the default system darkrp? with f3?

It should work fine with that. Let me test it.

Tested with DarkRP, works fine.