AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   Basic AFK Manager (https://forums.alliedmods.net/showthread.php?t=74531)

Liam 07-20-2008 15:03

Basic AFK Manager
 
3 Attachment(s)
This plugin has been designed to handle AFK players. It checks each player every 10 seconds to see if they are still in the same place, and if so, will kick them after a specified amount of time.

This has been tested on TF2 and CSS.

Changelog
1.0
- Initial Release
1.1
- Fixed a bug where it wasn't clearing out the AFK times.
1.2
- Adjusted the code to check the clients eye position to verify AFK so that Snipers / Campers don't get kicked for not moving.
1.3
- Added a new cVar, sm_minplayerskick, to specify the minimum amount of players to have before kicking.
- Renamed sm_minplayers to sm_minplayersmove, to specify the minimum amount of players to have before moving them to spec.
- Suggestion: delete the old afk_manager.cfg so that it can generate a new one with the updated fields.
1.4
- Corrected the bad cVar bug that was spamming the log files.
- Corrected the version info for when the plugin is loaded.
1.5
- Corrected the issue with the AFK Manager not kicking players from spec.
1.6
- Corrected issue with players not on a team or class in TF2 not getting kicked.
- Corrected issue with picking a team not resetting the AFK timer.
- Corrected issue with it not kicking players from spec correctly.
1.7
- Rewrote the handlers that checked the players view. It was not updating on the fly, so if the player ever moved from spawn, they would not be counted as AFK.
- Corrected a bug in the code that prevented players from getting kicked.
- Corrected a bug in the code that made the plugin ignore players and not bots. (Yes, I had a ! in the wrong place :P)
- NOTE: Unload Sourcemod when you reload this, or reboot your server. I removed some of the event hooks and we need to make sure they're cleared.
1.8
- Added a check in to deal with dead players.
1.9
- Fixed the glitch that prevented spectating players from getting kicked.
2.0
- Added in PrintToChat messages to notify the in-game players when someone was moved/kicked.
2.1
- Moved the Log and Kick messages above KickClient( ) to get rid of errors.
2.2
- Added in debug messages which can be enabled by setting _DEBUG to 1.
- Moved the check for MinPlayers, which shouldn't make any difference.
- Added a timer to delay the start of AFK checking so players have time to join the game.
2.3
- Corrected issues with the plugin kicking admins.
- Corrected issues with the plugin not paying attention to the MinPlayerCount restrictions.
2.4
- Corrected an issue where players joined a team from spec and got moved back because the AFK Timer wasn't reset.
2.5
- Fixed a bug where dead players would get moved to spec if they were floating in one place and didn't move for the afk timelimit.
2.6
- Added support for Synergy.
- Corrected a bug in the 'same place' eye check.
2.7
- Corrected an issue with TF2 Arena moving players into 'Waiting to Play' instead of 'Spectate'.
- Corrected a bug where if a player moved in the last few seconds before a kick it would not register their movement and kick them anyway.
2.8
- fixed hook event issue with CSS

cVars:
- sm_afkenable - Enable or Disable the AFK manager
- sm_minplayersmove - Minimum number of players needed before AFK players are moved to spec.
- sm_minplayerskick - Minimum number of players needed before AFK players are kicked from spec.
- sm_adminsimmune - Are admins immune to being kicked for AFK? (Note: They'll still get moved to spec)
- sm_movespec - Move AFK players to spec before kicking them.
- sm_timetomove - Amount of time to wait before moving an AFK player.
- sm_timetokick - Amount of time to wait before kicking an AFK player.

Please let me know if you experience any issues or problems. The cfg file should be in cfg\sourcemod\afk_manager.cfg.

PStar 07-20-2008 15:19

Re: AFK Manager
 
Hmm doesn't it put a heavy load on a big server? If every player is chechked in 10 sec? I think it would be enough to check for 20 sec or 30 sec.
Anyway nice to have an old plugin reworked to get it working.

Kigen 07-20-2008 15:21

Re: AFK Manager
 
Quote:

Originally Posted by PStar (Post 655663)
Hmm doesn't it put a heavy load on a big server? If every player is chechked in 10 sec? I think it would be enough to check for 20 sec or 30 sec.
Anyway nice to have an old plugin reworked to get it working.

Not really.

Now if it was in a callback like OnGameFrame() then it would be a heavy load on the server.

Liam 07-20-2008 15:27

Re: AFK Manager
 
I didn't notice any CPU difference running this every 10 seconds. Your only talking about 20-30 iterations of a loop, which is done in less than one second.

Greyscale 07-20-2008 15:40

Re: AFK Manager
 
Quote:

Originally Posted by Liam (Post 655671)
I didn't notice any CPU difference running this every 10 seconds. Your only talking about 20-30 iterations of a loop, which is done in less than one second.

More like 0.0001 seconds :P

DontWannaName 07-20-2008 15:47

Re: AFK Manager
 
When you say amount of time to kick is it in minutes, seconds, or miliseconds lol. nvm, didnt know it created its own cfg.

bl4nk 07-20-2008 18:16

Re: AFK Manager
 
How does it handle players who were bumped by teamates in TF2?

Jokerz99 07-20-2008 18:35

Re: AFK Manager
 
Quote:

Originally Posted by DontWannaName (Post 655688)
When you say amount of time to kick is it in minutes, seconds, or miliseconds lol. nvm, didnt know it created its own cfg.


seconds

Kigen 07-20-2008 19:08

Re: AFK Manager
 
Quote:

Originally Posted by bl4nk (Post 655778)
How does it handle players who were bumped by teamates in TF2?

Well, since its checking the player's eye position it'll probably see them as moving. I played with eye positions when I recreated Death Match in a SourceMod plugin (making it so you could get newer guns when you went back to your spawn point).

Liam 07-20-2008 19:38

Re: AFK Manager
 
It doesn't check their eyeposition, it checks their physical location.

Kigen 07-20-2008 20:12

Re: AFK Manager
 
My bad. Meh. :p Same basic result tho. Its based on the players position in the game.

DJ Tsunami 07-20-2008 21:10

Re: AFK Manager
 
Is it? Snipers/engineers can be standing still on the same spot for 5 minutes, and if they're not moving their eyes it means they're AFK, if they are, they're just turtling :P

Liam 07-20-2008 21:15

Re: AFK Manager
 
well, maybe I'll modify it. :P

Liam 07-22-2008 10:19

Re: AFK Manager
 
Plugin updated. See the OP for changes.

DontWannaName 07-22-2008 15:28

Re: AFK Manager
 
Way to support campers Liam! lol j/k...

edward.81 07-22-2008 15:40

Re: AFK Manager
 
Thx for this plugin.
1.1 hare working very well in my server. now i try this new version.
But i have made a little change in the code for logging plugin action.

Code:

HandleAFKClient(client)
{
    new Float:f_SpecTime = GetConVarFloat(g_Cvar_TimeToMove) / 10.0;
    new Float:f_KickTime = GetConVarFloat(g_Cvar_TimeToKick) / 10.0;

    if(GetConVarInt(g_Cvar_MoveSpec) == 1
        && g_TimeAFK[client] < f_KickTime
        && g_TimeAFK[client] > f_SpecTime)
    {
        new f_Team = GetClientTeam(client);

        if(f_Team > 1){
            ChangeClientTeam(client, 1); // 1 == spec on TF2 and CSS
            LogAction(client, -1, "%L moved to spectator. (%i Players)", client, GetClientCount());
            return;
        }
    }

    if(((GetConVarInt(g_Cvar_MoveSpec) == 0
        && g_TimeAFK[client] >= f_SpecTime)
        || g_TimeAFK[client] >= f_KickTime)
        && !IsAdmin(client))
    {
        LogAction(client, -1, "%L kick for AFK. (%i Players)", client, GetClientCount());
        KickClient(client, "You were AFK for too long.");
    }
}


Liam 07-22-2008 17:17

Re: AFK Manager
 
Okay? Thanks for telling me. :)

dann 07-23-2008 03:54

Re: Basic AFK Manager
 
if "sm_minplayers" isnt reached will it still move players to spectate?

edward.81 07-23-2008 06:46

Re: Basic AFK Manager
 
No, working fine until now. But we have to test the new feature added in 1.2

Quimbo 07-23-2008 08:07

Re: Basic AFK Manager
 
In the AFK manager plugin I wrote for my server I check players angles instead of position.

It works perfect even for bumps.

Liam 07-23-2008 08:31

Re: Basic AFK Manager
 
I changed it to check where they're looking.

on sm_minplayers, the answer is! *checks* no - when someone requested I write this, they didn't want it to do anything if minplayers wasn't met.

However, if you want it to, post a feature request. :)

Jokerz99 07-23-2008 09:23

Re: Basic AFK Manager
 
if they want it to work at all time all they have to do it set the min player to 1.

Dominator 07-23-2008 17:15

Re: Basic AFK Manager
 
Plugin works pretty good, but it seems to still kick players that are still playing. Also is there a setting to have it kick an afker, just put him into spectate like the other cvar?

Also when a player gets kicked he can't rejoin...

Mosalar 07-25-2008 10:03

Re: Basic AFK Manager
 
I'm a bit confused by the sm_minplayers setting. I want it to always move afk's to spec, but only kick the afk's when the server has x amount of players. Is this possible now? Or would it be a feature request?

Liam 07-25-2008 10:19

Re: Basic AFK Manager
 
Plugin updated. See the OP for details.

Mosalar 07-25-2008 11:00

Re: Basic AFK Manager
 
<3

[Arnold] 07-26-2008 06:47

Re: Basic AFK Manager
 
Quote:

public Plugin:myinfo =
{
name = "AFK Manager",
author = "Liam",
description = "Handles AFK Players",
version = "1.0",
url = "http://www.wcugaming.org"
};
Shouldn't that be 1.3 also?

Liam 07-26-2008 10:55

Re: Basic AFK Manager
 
Quote:

Originally Posted by [Arnold] (Post 659000)
Shouldn't that be 1.3 also?

Yeah, I need to change it to VERSION.

sofwmrebiteme 07-27-2008 16:06

Re: Basic AFK Manager
 
got a question in relation to AFK. If I wanted to take a player from a playing status and kick him to spectate immediately from console what command could i use?

DJ Tsunami 07-27-2008 16:15

Re: Basic AFK Manager
 
That has nothing to do with this plugin, but you can get the TeamSwitch or SM Super Commands plugin and use sm_teamswitch_spec or sm_spec respectively.

Labyrinthine 07-27-2008 22:16

Re: Basic AFK Manager
 
Switched over from an older AFK Manager plugin today.

My error log is being inundated by

Code:

L 07/27/2008 - 14:00:07: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 07/27/2008 - 14:00:07: [SM] Debug mode is not enabled for "afkmgr.smx"

Just barely checked/noticed it, so I'll post the debug later if you need it.

I'm running CSS. Let me know if you need more info.

Liam 07-27-2008 23:52

Re: Basic AFK Manager
 
Please post the debug output.

Liam 07-28-2008 10:11

Re: Basic AFK Manager
 
Plugin updated. See the OP for details.

Labyrinthine 07-28-2008 10:38

Re: Basic AFK Manager
 
Code:

L 07/28/2008 - 00:59:54: [SM] Native "GetConVarInt" reported: Invalid convar handle 0 (error 4)
L 07/28/2008 - 00:59:54: [SM] Displaying call stack trace for plugin "afkmgr.smx":
L 07/28/2008 - 00:59:54: [SM]  [0]  Line 346, C:\Documents and Settings\Labyrinthine\Desktop\sourcemod-1.0.3\addons\sourcemod\scripting\include\float.inc::operator>=(_:,Float:)()
L 07/28/2008 - 00:59:54: [SM]  [1]  Line 162, afkmgr.sp::HandleAFKClient()
L 07/28/2008 - 00:59:54: [SM]  [2]  Line 124, afkmgr.sp::Timer_CheckPlayers()

There's the debug. I have no clue why it's making a nice reference to my desktop when it's from the gameserver. O.o

Thanks for the quick response.

Liam 07-28-2008 11:26

Re: Basic AFK Manager
 
Either way, the issue is fixed. I had a typo in the convar registration.

Labyrinthine 07-28-2008 11:57

Re: Basic AFK Manager
 
Awesomesauce.

Thanks a bunch

rocketteem 07-28-2008 22:34

Re: Basic AFK Manager
 
Question:

TF2's built in AFK kicker has an issue where if someone manually changes to spectator, it won't detect, and will never kick them.

Does this have the same issue? Will it kick those who manually joined Spectator? If not, that would be a good feature...

Also, I have auto team join on which requires the user to pick a class, but randomly joins them to a team. Meaning, if they are AFK when they join the server, they join a team, but stay dead with no class chosen, TF2 also does not pick this up. Will yours?

Thanks in advance
--Welder

Liam 07-28-2008 23:00

Re: Basic AFK Manager
 
It treats spectators differently than in-game clients.

If they are in spec, they get x time and then they get a boot.

dann 07-29-2008 06:07

Re: Basic AFK Manager
 
this wasn't working at all when I had it installed. I had to switch back to my old one. I've posted my config below.

Code:

// This file was auto-generated by SourceMod (v1.0.3)
// ConVars for plugin "afkmgr.smx"
 
// Admins immune to being kicked? [0 = FALSE, 1 = TRUE]
// -
// Default: "0"
sm_adminsimmune "0"
// Is the AFK manager enabled or disabled? [0 = FALSE, 1 = TRUE]
// -
// Default: "1"
sm_afkenable "1"
// Minimum amount of connected clients needed to kick AFK clients.
// -
// Default: "23"
sm_minplayerskick "23"
// Minimum amount of connected clients needed to move AFK clients to spec.
// -
// Default: "1"
sm_minplayersmove "1"
// Move AFK clients to spec before kicking them? [0 = FALSE, 1 = TRUE]
// -
// Default: "1"
sm_movespec "1"
// Time in seconds before kicking an AFK player.
// -
// Default: "300.0"
sm_timetokick "300.0"
// Time in seconds before moving an AFK player.
// -
// Default: "90.0"
sm_timetomove "90.0"


Liam 07-29-2008 13:18

Re: Basic AFK Manager
 
Is it moving people to spec?


All times are GMT -4. The time now is 07:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.