Playtime Tracker

Playtime Tracker 1.0.0

Sign in to download
Provides an API to track player playtime and AFK time for other plugins
Works With
This plugin tracks how long players are active or AFK and makes that data available to other plugins. It's perfect for building reward systems, rank leaderboards, or AFK kickers.







Features

  • Tracks total playtime and AFK time for each player individually.
  • Fully exposed API for other plugins to fetch player time data.
  • Customizable AFK detection using movement and idle timeout settings.
  • Provides commands for checking and resetting player time data.
  • Leaderboard showing top players with the most active playtime.
  • Optional player exclusion list to prevent tracking certain SteamIDs.
  • Data resets automatically on new map saves.
  • Clean and formatted time output (e.g. 02h:45m:12s).

Permissions

  • playtimetracker.use - Required to use the /playtime command and view your stats or leaderboard entries.

Commands

  • /playtime - Displays your total tracked playtime and AFK time.
  • /playtime top - Shows the top players on the server ranked by total playtime, up to the configured max entries.
  • playtime <nameOrId> - Console-only command that displays a player's tracked time and AFK time. Can be used from server console or by an admin.
  • playtime reset <nameOrId> - Console-only command to remove all stored time data for the given player ID or partial name.

Configuration

JSON:
{
  "Version": "1.0.0",
  "Update Interval Seconds": 60,
  "Enable Afk Tracking": true,
  "Idle Timeout Seconds": 300,
  "Data Autosave Interval Seconds": 300,
  "Reset Data On New Save": false,
  "Top Leaderboard Entries": 10,
  "Do Not Track Players": []
}
  • Update Interval Seconds - How often (in seconds) the plugin updates player time, including both playtime and AFK tracking.
  • Enable Afk Tracking - Enables detection of whether a player is idle (AFK) based on their movement.
  • Idle Timeout Seconds - How long (in seconds) a player must remain unmoving before being marked as AFK.
  • Data Autosave Interval Seconds - How often (in seconds) the plugin saves all tracked data to disk to prevent data loss.
  • Reset Data On New Save - If true, all saved playtime data will be deleted automatically on map wipe.
  • Top Leaderboard Entries - The maximum number of players to include in the /playtime top leaderboard command.
  • Do Not Track Players - List of specific player Steam64 IDs that should be excluded from tracking entirely.

Stored Data

JSON:
{
  "Players": {
    "76561198000000000": {
      "Name": "PlayerOne",
      "Playtime Seconds": 4580.5,
      "Afk Seconds": 900.0
    },
    "76561198000000001": {
      "Name": "PlayerTwo",
      "Playtime Seconds": 1220.0,
      "Afk Seconds": 300.0
    }
  }
}
  • Players- Dictionary where the key is a player's Steam64 ID, and the value is their individual data:
    • Name - The player's current display name, saved at time of tracking.
    • Playtime Seconds - Total number of seconds the player has been tracked as active (not AFK).
    • Afk Seconds - Total number of seconds the player has been considered idle/AFK.

Localization

JSON:
{
  "Info.SelfTime": "Playtime: {0} (AFK {1})",
  "Info.ResetSuccess": "Reset stats for {0}.",
  "Help.General": "Type /playtime top to see the leaders.",
  "Usage.Console.General": "Usage: playtime <nameOrId> | playtime reset <nameOrId>",
  "Usage.Console.Reset": "Usage: playtime reset <nameOrId>",
  "Leaderboard.Header": "Top playtimes:",
  "Leaderboard.Entry": "{0}. {1} – {2}",
  "Error.NoPermission": "You do not have permission to use this command.",
  "Error.PlayerNotFound": "Player '{0}' not found.",
  "Error.NoDataStored": "No data stored for that player.",
  "Error.NoDataForPlayer": "No data for that player.",
  "Error.UnknownSubCommand": "Unknown sub-command."
}

Developer API

C#:
double API_GetPlaytimeSeconds(ulong playerId)
Returns the total active playtime in seconds for the specified player.
  • playerId - Steam64 ID of the player.
  • Returns the playtime in seconds as a double.
C#:
double API_GetAfkSeconds(ulong playerId)
Returns the total AFK time in seconds for the specified player.
  • playerId - Steam64 ID of the player.
  • Returns the AFK time in seconds as a double.
C#:
string API_GetFormattedPlaytime(ulong playerId)
Returns the player's playtime formatted as HHh:MMm:SSs.
  • playerId - Steam64 ID of the player.
  • Returns a formatted string.
C#:
List<Dictionary<string, object>> API_GetTopPlaytimes(int count = 10)
Returns a list of top players sorted by total playtime.
  • count - The maximum number of players to include (default is 10).
  • Returns a list of dictionaries with PlayerId and PlaytimeSeconds.

Developer Hooks

C#:
void OnPlaytimeUpdate(BasePlayer player, Dictionary<string, object> data)
Called every time a player's playtime or AFK time is updated.
  • player - The player whose stats were updated.
  • data- Dictionary containing:
    • PlaytimeSeconds - Total active time.
    • AfkSeconds - Total AFK time.
    • IsCurrentlyAfk - Whether the player is AFK during this update.
Author
VisEntities
Downloads
3
First release
Last update

Ratings

0.00 star(s) 0 reviews

Also by VisEntities

Back
Top
Chat commands start with a /, while console commands can be entered directly in the F1 console or server console. Use find <keyword> in console to search for available commands related to the plugin. Parameters in < > are required, while [ ] are optional.
This plugin uses Oxide's permission system. Grant or revoke permissions using oxide.grant and oxide.revoke. You can assign them to individual players or groups using their Steam id or group name.
Settings are stored in the config file found under the config/ directory. You can edit this file manually, then reload the plugin to apply your changes.
Persistent data is saved in the data/ directory. This includes things like saved settings, usage stats, or player progress depending on the plugin. Deleting a data file will reset stored progress or customizations.
Language files are located in the lang/ folder. To translate messages, copy the en.json file into your target language folder (e.g. fr, de) and edit the values. Reload the plugin after changes to apply new messages.
This section lists public methods exposed by the plugin for use in other plugins. You can call these via the CallHook method. Ensure the plugin is loaded before calling its API to avoid null reference errors.
These are custom hooks that other plugins can listen for. Simply define a method with the same name and expected parameters in your plugin to handle the event. Hooks are triggered at key moments and are useful for extending or reacting to plugin behavior.
These hooks are injected into the game's code using Harmony. They let the plugin run code at key points in the game's internal logic. You can return values to block or modify behavior. Use with caution — these are powerful and can affect core mechanics.
Cart