Usage

Commands, auto-AFK flow, the /tafk dialog, and state-bag integration.

Everyday

How AFK triggers

tAFK watches for input every tick. Three paths fire the cinematic camera:

TriggerGated byNotes
AutotimeoutSeconds of no input (default 30s)Must be in a vehicle; system must be enabled (per-player KVP)Detector fades to black, then opens the first sequence
Manual/afk commandMust be in a vehicleSame fade → cinematic flow, skips the idle timer
Manual/tafk menu → Enter AFK ModeSame as /afkCloses the dialog first, then triggers

All three trigger on one code path. What counts as input:

  • Position delta > 0.05 units
  • Heading delta > 0.5°
  • Gameplay cam rotation delta > 0.001 rad (very sensitive — any mouse movement exits)
  • Any of 12 monitored controls (movement, look, aim, attack, sprint, jump, crouch)

Commands

CommandAccessEffect
/afkAnyoneToggle AFK cinematic on/off (fastest path)
/tafkAnyoneOpen the settings dialog — player overrides, admin panels if ACE
/tafkeditAdmin (tlib.admin)Open the free-cam keyframe editor (must be in a vehicle)

/tafk vs /afk

/afk is the single-press toggle. /tafk opens the dialog where players set persistent preferences — they're different surfaces for different needs.


The /tafk dialog

Player section (always visible)

  • Enter AFK Mode / Exit AFK Mode — live toggle, disabled when the system is off for this player
  • AFK System — persistent master switch. Stored as tafk:playerDisabled KVP. When off, even /afk and the detector are silenced for this player
  • Play Music During AFK — two-state checkbox. On/off; overrides the server default for this player
  • Music Volume — 0–100 (%) slider, step 1. Stored as 0.0–1.0 after division by 100
  • Hide HUD While AFK — if on, DisplayRadar(false) and DisplayHud(false) fire on AFK start, reversed on exit. Backed by the hideHudInAFK setting
  • My Sequence Preferences — sub-dialog listing every loaded sequence with a checkbox. Uncheck to opt this player out of that sequence. Server-disabled sequences are read-only
  • Reset My Settings — clears all KVP for this player, falls back to server defaults

Admin section (requires tlib.admin)

Two buttons, both open sub-dialogs or the editor:

  • Server Defaults — idle timeout (seconds), min/max sequence duration (seconds), beat anchor (ms), and server-wide fallback values for music / volume / hide-HUD. Players with their own override still win; these are just the defaults for players who haven't chosen.
  • Open Sequence Editor — launches the free-cam editor overlay. Shown only when the admin is in a vehicle; otherwise the button is disabled with the label Get in a vehicle to open the editor. All sequence management — list, enable/disable, create, edit, delete — happens inside the editor overlay. There's no separate "Manage Sequences" sub-dialog. See Editor guide.

All changes apply live — sliders and checkboxes push to server or KVP on every change. No save button.

Music is auto-discovered

There's no music-track management UI. Drop .ogg / .mp3 / .wav files into tAFK/audio/ and restart the resource. Filenames matching bg1.ogg, track2.ogg, afk3.ogg, music4.ogg, or cinematic5.wav (1–99) are picked up automatically; any other filename works too if you list it in audio/manifest.txt. See Configuration → Music tracks.


Exit conditions

Once AFK, the detector exits the cinematic immediately when any of these become true:

  • Any input from the input list above
  • Player exits the vehicle
  • Vehicle entity no longer exists (despawn, destroy)
  • IsCutsceneActive() or IsPlayerSwitchInProgress() returns true

Fade-out during entry is also cancellable — hit any key mid-fade and the whole thing aborts cleanly without ever rendering the cinematic camera.


State bag integration

Every AFK enter/exit sets a replicated state bag on the local player:

LocalPlayer.state:set('afk', true, true)   -- on enter
LocalPlayer.state:set('afk', false, true)  -- on exit (also set to false at resource start)

Other scripts read this without any handshake:

-- Server-side
local isAfk = Player(playerId).state.afk   -- true | false | nil

-- Client-side, from another resource
local peer = GetPlayerFromServerId(targetId)
local isAfk = Player(peer).state.afk

Use-cases

  • Radio scripts can mute transmit for AFK players
  • Scoreboard / F8 overlays can mark AFK names
  • Dispatch panels can filter busy units
  • Economy scripts can pause paycheque timers

None of this requires integration with tAFK beyond the state bag read.


The tafk:stateChanged event

For same-client listeners that need to know the moment state changes (e.g., muting a different NUI, pausing a minigame), a local event fires in parallel with the state-bag write:

AddEventHandler('tafk:stateChanged', function(isAfk)
  if isAfk then
    -- entering AFK — freeze your own HUD, pause timers
  else
    -- leaving AFK — unfreeze
  end
end)

The event is client-local only. For cross-player awareness use the state bag.


Exports

See the API Reference for full signatures. Quick summary:

exports['tAFK']:IsAFK()                -- this client, right now
exports['tAFK']:IsAFKEnabled()         -- session switch (/tafk master toggle)
exports['tAFK']:StartAFK()             -- manual enter (still needs vehicle)
exports['tAFK']:StopAFK()              -- exit now
exports['tAFK']:ToggleAFK()
exports['tAFK']:SetAFKEnabled(bool)

Disabling temporarily

If you need to suppress tAFK during a specific scene (a race, a cutscene, a minigame in your own resource), call:

exports['tAFK']:SetAFKEnabled(false)
-- ... your scene ...
exports['tAFK']:SetAFKEnabled(true)

SetAFKEnabled(false) also stops an in-progress cinematic immediately. The setting is session-only — it doesn't persist to KVP unless you also write tafk:playerDisabled.

On this page

Need help?

Ask on Discord