Page cover

Statebags

This page will assist you in understanding statebags within FiveM, as well as addressing any errors you may encounter during their use.


What is a statebag?

A Statebag is a server-side data structure in FiveM used to manage and synchronize state-related information for players or server entities. It allows developers to store and update session-specific data—such as inventory, vehicle status, or player progression—without requiring constant communication between the server and client.

Although Statebags are stored on the server, their contents can be accessed and modified by both the server and the client, as long as proper synchronization is maintained. This makes them a powerful tool for efficiently managing dynamic gameplay data across networked sessions.


Statebag errors

By default, Statebags in FiveM are subject to rate limits. This means if too many updates are sent in a short period, the server may throttle or reject them—potentially causing unexpected behaviour or performance issues.

When these rate limits are exceeded, the server may:

  • Reject the updates, leading to inconsistent game state or errors.

  • In severe cases, kick the player from the server.

To maintain stable performance and avoid disruptions, it's important to understand these limits and implement proper throttling or debounce mechanisms in your scripts.

What can we do about these errors?

To address issues caused by Statebag rate limiting, you can adjust the server’s rate limit settings to allow more frequent updates. This ensures that Statebag changes have enough headroom to be processed without being rejected or throttled.

Add the following lines to your server.cfg file:

set rateLimiter_stateBag_rate 2000
set rateLimiter_stateBag_burst 3000
  • rateLimiter_stateBag_rate defines how many updates per second are allowed.

  • rateLimiter_stateBag_burst sets how many updates can be sent in a short burst before throttling begins.

Last updated