State Bags

Player state used by Possible Territories.

Important

The resource folder on your server must be named exactly possible-territories.

Territories uses one player/entity state bag to tell other scripts which zone someone is in.

possible_territories_info

Set on the player's ped when they enter a territory zone. Cleared (set to nil) when they leave.

Resource sets this server-side with replication on, so clients can read it as well.

Shape

Lua
{    name = "LSIA",      -- territory / zone name    owner = "ballas",   -- owning gang, or nil    gangColor = 7       -- blip color for the owner}

Read on the server

Lua
local ped = GetPlayerPed(playerId)local info = Entity(ped).state.possible_territories_info
if info and info.name then    print(info.name, info.owner)end

This is what GetPlayerTerritory uses under the hood.

Read on the client

Lua
local info = Entity(PlayerPedId()).state.possible_territories_info-- or, for the local player:-- local info = LocalPlayer.state.possible_territories_info
if info then    -- player is inside info.nameend

Notes

  • Only updated when the player actually enters / exits an ox_lib zone. Standing still outside a zone keeps it nil.
  • Do not write this bag yourself unless you know what you are doing — the territories resource owns it.
  • Ownership changes while someone is already inside a zone may not refresh until they re-enter. Prefer exports for authoritative territory data when you need owner/influence.
JDB-NET Logo
Partner Service

Self-hosted unlimited logs with managed Grafana

JDB-NET provides a self-hosted solution with unlimited logs, a fully managed Grafana instance, and unlimited users. Perfect for FiveM servers that need comprehensive logging and monitoring.

Check out JDB-NET