Other Information

File Structure

Understanding the file structure helps with customization and troubleshooting:

LuaBeans-afk/

├── config.lua                    # Main configuration file (NOT escrowed)
├── fxmanifest.lua                # FiveM resource manifest
├── README.md                     # This file

├── client/
│   ├── client.lua                # Main client-side logic (escrowed)
│   └── editable.lua              # Developer editable client file (NOT escrowed)

└── server/
    ├── server.lua                # Main server-side logic (escrowed)
    └── editable.lua              # Developer editable server file (NOT escrowed)

File Descriptions

config.lua

  • Purpose: Main configuration file

  • Escrowed: No (fully editable)

  • Contains: All configuration options, messages, timers, whitelist

  • When to Edit: Always edit this file for configuration changes

fxmanifest.lua

  • Purpose: FiveM resource manifest

  • Escrowed: No (but rarely needs editing)

  • Contains: Resource metadata, script loading order, escrow configuration

  • When to Edit: Only if you need to modify resource structure

client/client.lua

  • Purpose: Main client-side AFK detection logic

  • Escrowed: Yes (protected, cannot be edited)

  • Contains: AFK detection, movement tracking, warning system, whitelist checks

  • When to Edit: Never (use client/editable.lua for customizations)

client/editable.lua

  • Purpose: Developer customization file for client-side code

  • Escrowed: No (fully editable)

  • Contains: Example code and placeholders for custom functionality

  • When to Edit: When you need to add custom client-side logic or override functions

server/server.lua

  • Purpose: Main server-side kick handling

  • Escrowed: Yes (protected, cannot be edited)

  • Contains: Kick event handlers, player management

  • When to Edit: Never (use server/editable.lua for customizations)

server/editable.lua

  • Purpose: Developer customization file for server-side code

  • Escrowed: No (fully editable)

  • Contains: Example code and placeholders for custom functionality

  • When to Edit: When you need to add custom server-side logic or override functions

Technical Details

Detection Algorithm

The AFK detection uses a multi-stage approach:

  1. Movement Check: Runs every second

    • Calculates distance between current and last known position

    • Threshold: 0.5 game units (configurable in code, not config)

    • Resets timer if movement detected

  2. Input Check: Continuous monitoring

    • Monitors WASD keys (Controls 32, 33, 34, 35)

    • Checks vehicle speed if player is in vehicle

    • Monitors camera rotation

  3. Timer Management: Updates every second

    • Increments timeSinceLastMovement by 1000ms each second

    • Compares against configured thresholds

    • Triggers warnings and kicks at appropriate times

Performance Considerations

  • CPU Usage: Minimal - checks run every 1-5 seconds depending on active detection methods

  • Memory Usage: Low - stores minimal data per player (coordinates, timer)

  • Network Usage: Minimal - only sends events when warnings/kicks occur

  • Server Load: Very low - most processing happens client-side

Detection Sensitivity

The system is designed to avoid false positives:

  • Movement Threshold: 0.5 units prevents minor position adjustments from resetting timer

  • Vehicle Speed Threshold: 0.1 units/second accounts for stopped vehicles

  • Camera Detection: Accounts for players looking around without moving

Thread Management

  • Main Detection Thread: Runs continuously, checks every 1 second

  • Debug Thread: Only active when Config.Debug = true, logs every 30 seconds

  • Event Handlers: Register once on resource start, remain active

Client-Server Communication

Events Used:

  • luaBeans:afk:kick - Client to server, requests player kick

  • Standard FiveM chat events for notifications

No Unnecessary Network Traffic: The resource only communicates when necessary (warnings/kicks), minimizing network overhead.

Last updated