Statebags Documentation

This page provides an overview of the statebags used in Nexure Racing System. Statebags are a convenient way to manage player and entity states in a shared and synchronized manner across the server and clients in FiveM. Below are the currently implemented player statebags in the Nexure Racing System.


Player Statebags

inRace

  • Description: Indicates whether a player is currently participating in a race.
  • Type: boolean
  • Possible Values:
    • true: The player is in an active race.
    • false: The player is not in a race.
  • Default Value: false
  • Usage:
    • This statebag is automatically updated by the Nexure Racing System during race events.
    • Use it to check if the player is in a race, e.g., to modify the UI or restrict certain actions.
-- Example
local inRace = LocalPlayer.state.inRace
if inRace then
    print("Player is currently in a race.")
else
    print("Player is not in a race.")
end

raceId

  • Description: Represents the unique identifier of the race the player is currently participating in.
  • Type: number
  • Possible Values:
    • A positive integer representing the race ID if the player is in a race.
    • nil if the player is not in a race.
  • Default Value: nil
  • Usage:
    • This statebag is updated by the Nexure Racing System when the player joins or leaves a race.
    • Use it to retrieve the playerโ€™s current race ID and apply race-specific logic.
-- Example
local raceId = LocalPlayer.state.raceId
if raceId then
    print(("Player is in race with ID: %d"):format(raceId))
else
    print("Player is not in a race.")
end

Notes

  • These statebags are synchronized across all clients, ensuring consistent data for all players.
  • Modifications to these statebags are managed internally by the Nexure Racing System. Avoid directly changing these values to ensure system stability.