Skip to main content
Clients read the shared flags out of GlobalState, which the server publishes and the game replicates. There is no round trip and no request — the value is already on the machine — so client reads are synchronous and safe inside a tick.
Only shared flags are published. Reading a server flag from a client is exactly like reading one that does not exist: it returns the fallback.
A joining player holds the values before your resource runs a line, because the state bag arrives with the connection rather than being requested.

Exports

Checks whether a boolean flag is on.
Parameters
  • key: string — The flag’s key
  • fallback: boolean — Returned when the flag is not a readable boolean flag (optional, false by default)
Returns
  • enabled: boolean — Whether the flag is on
A missing flag, one holding a non-boolean value, or one the server does not share with clients all return the fallback.
Reads a flag’s value, whatever its type.
Parameters
  • key: string — The flag’s key
  • fallback: any — Returned when the flag is missing, or before the server has published any (optional)
Returns
  • value: any — The flag’s value, or the fallback
Reads every flag this client holds, keyed by flag key.
Returns
  • values: table — The flag values, keyed by flag key. Empty before the server has published any.
Whether the server has published any values yet.
Returns
  • ready: boolean
Reads before this is true fall back, so this is what to check when you would rather show nothing than show a fallback.

Reading the state bag directly

The exports are a thin wrapper that handles the empty case. Nothing stops you reading the bag yourself:
Reading the bag directly skips the subscription signal. The server stops refreshing the flags when no client says it is reading them, so a resource that only reads GlobalState may sit on values that stop being refreshed. Either go through the exports, or set flags.polling.enabled to true in the configuration.
The key is flags.global_state_key from your configuration — nocloud_flags by default.

Reacting to changes

There is no client event. Watch the state bag directly:
The bag is only rewritten when what players can see has actually changed, so a server-only flag being edited never costs your handler a wake-up.

What leaves the client

Almost nothing. Reading tells the server that this client reads flags, so it keeps them current, and five minutes without a read tells it you have stopped.
Those two signals carry no data and only fire at the edges — not per read. Every read is a local lookup and nothing more, so reading a flag inside a tick sends nothing over the network.
A client announcing itself is rate limited to 5 times per minute per player, so the signal cannot be used to spam the server.

Lua Library

For a cleaner API, include the client Lua library in your fxmanifest.lua:
Usage
The library ships full LuaLS annotations, so Cloud.flags autocompletes with parameter and return types in any editor with the Lua Language Server.