Skip to content

Ayrton09/afkmanager

Repository files navigation

AFK Manager

Detection Rules

  • Players on a playable team are considered active only when their view angles change.
  • Spawn AFK tracking starts on player spawn, team change when the player becomes alive on T/CT, and round freeze end for alive T/CT players.
  • View angle checks use a small tolerance to avoid false positives from tiny jitter.
  • Dead players are ignored and their AFK timer is reset while they wait to respawn.
  • Players with no selected team are tracked separately by time spent in the no-team/team-selection state. They are not treated as spectators and are not exempted by ignore_spectators.
  • Spectators are ignored by default with ignore_spectators. This does not ignore players who are still in team selection.

Performance

  • The plugin checks players on check_interval_seconds; it does not run AFK detection every server tick.
  • The default interval is 5 seconds. For very full public servers, 5-10 seconds is a good practical range.
  • The periodic check reuses internal collections and caches admin immunity flags to avoid avoidable allocations during normal operation.
  • Language files are loaded only on plugin load/config reload, not during every player check.
  • Logging is disabled by default. If log_actions is enabled, only real actions such as move/kick attempts are logged; repeated warnings are not logged.

Language

The plugin uses the language configured in CounterStrikeSharp ServerLanguage.

Example: if CounterStrikeSharp is configured with ServerLanguage set to es, AFK Manager uses Lang/es.json.

Language files live in:

AfkManager/Lang/

Included files:

  • de.json
  • es.json
  • en.json
  • fr.json
  • pt.json
  • ru.json
  • zh.json

Warnings and kick reasons are loaded from the language file. Warnings are chat-only.

Action Flow

All thresholds are seconds. Set a threshold to 0 to disable that stage.

For team players:

  1. spawn_warning_time_seconds: how many seconds before the spawn move action countdown warnings start.
  2. spawn_move_to_spectator_time_seconds: moves a player to spectator if they spawned and never moved their view.
  3. After the player has moved their view once, warning_time_seconds controls how many seconds before the normal move/kick action countdown warnings start.
  4. move_to_spectator_time_seconds: moves the player to spectator once.
  5. kick_time_seconds: kicks the player once with the language file's kick_reason. If the plugin already moved the player to spectator, the kick timer can still finish without sending spectator warning spam. Default is 0, disabled.

For players who have not chosen a team:

  1. no_team_move_to_spectator_time_seconds: moves them to spectator if they do not choose a team. Default is 10.
  2. no_team_kick_time_seconds: kicks them with no_team_kick_reason. If no_team_move_to_spectator_time_seconds moved them first, the kick timer can still finish. Default is 0, disabled.

Countdown warning steps are controlled by repeat_warning_interval_seconds. Example: if spawn_move_to_spectator_time_seconds is 15, spawn_warning_time_seconds is 10, and repeat_warning_interval_seconds is 5, the player is warned at 10 seconds remaining and 5 seconds remaining. If a warning time is higher than the action time, it is capped internally to the action time.

Project Structure

afkmanager/
  AfkManager.csproj
  AfkManagerPlugin.cs
  Config/
    AfkManagerConfig.cs
  Core/
    AfkService.cs
    PlayerAfkState.cs
  Localization/
    AfkLanguage.cs
    AfkLanguageManager.cs
  Lang/
    de.json
    es.json
    en.json
    fr.json
    pt.json
    ru.json
    zh.json
  Samples/
    afkmanager.example.json
  README.md

Install

  1. Create a plugin folder on the server:
game/csgo/addons/counterstrikesharp/plugins/afkmanager/
  1. Copy the release output files into that folder.
  2. Start the server once so CounterStrikeSharp can generate the config, or copy Samples/afkmanager.example.json into the plugin config location used by your CounterStrikeSharp install.
  3. Adjust thresholds in CounterStrikeSharp's generated plugin config and reload the plugin or run css_afk_reload.

The active config is normally generated by CounterStrikeSharp under:

game/csgo/addons/counterstrikesharp/configs/plugins/afkmanager/afkmanager.json

Commands

  • css_afk_reload: reload config. Requires @css/config.
  • css_afk_config: print active runtime config values. Requires @css/config.
  • css_afk_enabled: print runtime enabled state. Requires @css/config.
  • css_afk_enabled <0|1>: disable or enable AFK Manager until config reload/map/plugin reload. Requires @css/config.
  • css_afk_status: print status for all players. Requires @css/generic.
  • css_afk_status <name|#userid>: print status for matching players.
  • css_afk_reset: reset your AFK timer. Requires @css/generic.
  • css_afk_reset <name|#userid>: reset a target timer.

Notes

  • No team balancing logic is included.
  • Bot, spectator, and admin immunity behavior are configurable.
  • State is cleared on map end, map start, disconnect, plugin unload, and reconnect identity changes.

About

CounterStrikeSharp AFK manager for CS2

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages