Skip to content

AFK Kick

Person8880 edited this page Mar 26, 2021 · 20 revisions

Overview

This plugin will kick out players that remain AFK for more than the set amount of time.

Immunity

If you wish to provide immunity to certain players, then give them access to the sh_afk command. This is not a console command, but if a user has permission to it they are immune to being warned and kicked.

Also, you can instead assign sh_afk_partial, which will make a player immune to being kicked, but not immune to being warned.

Configuration

The default config file should look something like this:

{
    "KickTimeInMinutes": 15,
    "MinPlayers": 10,
    "MovementDelaySeconds": 0,
    "Delay": 1,
    "SampleIntervalInSeconds": 0.25,
    "OnlyCheckOnStarted": false,
    "IgnoreSpectators": false,
    "KickOnConnect": false,
    "KickTimeIsAFKThreshold": 0.25,
    "MarkPlayersAFK": true,
    "WarnMinPlayers": 5,
    "Warn": true,
    "WarnTimeInMinutes": 5,
    "WarnActions": {
        "NoImmunity": [ "NOTIFY", "MOVE_TO_READY_ROOM" ],
        "PartialImmunity": [ "NOTIFY", "MOVE_TO_SPECTATE" ]
    },
    "Leniency": {
        "NoImmunity": "STRICT",
        "PartialImmunity": "STRICT"
    },
    "PlayerCountRules": [],
    "__Version": "1.10"
}

The file should be called "AFKKick.json" and should be placed in the directory defined as your plugin config directory (default is config://shine/plugins).

There are a few options available to tune the plugin to your liking.

Option Description
KickTimeInMinutes Controls how long (in minutes) a player has to be AFK before being kicked out.
MinPlayers Controls how many players should be present in the server before starting to kick AFK players. When using KickOnConnect, values less than the number of player slots will be ignored.
MovementDelaySeconds Sets the number of seconds after a player is warned before any move actions are applied to them.
Delay Controls how long (in minutes) after a player joins the plugin should wait before starting to check them.
SampleIntervalInSeconds Controls how frequent movement should be sampled. Lower values will potentially be more costly to server performance with higher player counts, but result in more accurate tracking.
OnlyCheckOnStarted Controls whether to check only when a game is in progress, or all the time.
IgnoreSpectators Sets whether to exclude spectators from AFK checks.
KickOnConnect When true, players who are AFK past the kick time will not be kicked until the number of players is greater equal the larger of MinPlayers and the number of player slots, and a new player tries to join.
KickTimeIsAFKThreshold When a player has been AFK for KickTime * KickTimeIsAFKThreshold, they will be marked as AFK on the scoreboard.
MarkPlayersAFK Sets whether to mark players as AFK on the scoreboard or not.
PlayerCountRules An array of rules to set any of WarnTimeInMinutes, KickTimeInMinutes or MarkPlayersAFK based on the current player count.
WarnMinPlayers Controls how many players should be present in the server before starting to warn, but not kick, players.
Warn Controls whether players should be warned about being kicked.
WarnTimeInMinutes Controls how long (in minutes) a player has to be AFK before being warned.
WarnActions Controls the actions to take when a player is warned.

Those under NoImmunity apply to players with no access to sh_afk or sh_afk_partial. Those under PartialImmunity apply to those with access to sh_afk_partial only.

The available actions are:
  • NOTIFY - plays a sound and flashes the taskbar
  • MOVE_TO_READY_ROOM - moves the player to the ready room (cannot be used with MOVE_TO_SPECTATE)
  • MOVE_TO_SPECTATE - moves the player to spectate (cannot be used with MOVE_TO_READY_ROOM)
Leniency Controls how the plugin resets a player's AFK time. As with WarnActions, this is configurable based on immunity. The options are:
  • STRICT - AFK time is only reduced by activity, not reset.
  • LENIENT_FOR_SPECTATORS - spectators will reset their AFK time with activity, but strict mode is still applied to non-spectators.
  • LENIENT - AFK time is reset by activity for all players.

Player Count Rules

Some configuration options can be configured based on player count. The PlayerCountRules field should contain an array of rules with a MaxPlayers and optionally MinPlayers bound at which the rule's configuration options are applied. For example:

"PlayerCountRules": [
    {
        "MaxPlayers": 10,
        "WarnTimeInMinutes": 1,
        "KickTimeInMinutes": 5,
        "MarkPlayersAFK": false
    }
]

This rule would set the warn time to 1 minute, the kick time to 5 minutes and disable marking players as AFK when the number of players on the server is less than or equal to 10. For all other player counts, the default values specified in the top-level configuration are used.

Commands

Command Chat Command Arguments Description
sh_afk_status N/A (player) Prints a summary of the AFK state of the given player or all players to the console. This includes the last move time and last seen action, accrued AFK time, whether the player is considered frozen, whether the player has been seen to move at all etc.
Clone this wiki locally