Skip to main content
TRACK B·PRODUCTION ENGINEERING·Verified June 2026 · Lua 5.4 · ox_lib 3.x
Learning with an AI assistant?
Copies this lesson plus 2026 ground rules (no lua54 'yes', Cfx.re Portal, correct callback signatures) as a ready-to-paste mentor prompt.

OneSync fundamentals and entity ownership

A routing bucket is a separate world on the same server. Assign a player or entity to a bucket and they only see players and entities in that same bucket. Use them for sessions and game modes, not for interiors. This lesson builds a small instance and proves the partition with two players.

You'll learn
What OneSync gives you, what a routing bucket actually is, SetPlayerRoutingBucket, SetRoutingBucketPopulationEnabled, SetRoutingBucketEntityLockdownMode, server entity ownership, and how to key a reusable bucket by a stable id
Time
~26 minutes
Outcome
You build a 4-player heist instance that is invisible to other players on the server, and you prove the invisibility with two test players
BEFORE YOU START

Build it

Make the resource folder

The server has one folder for this lesson.

Inside your server's resources folder, create this folder:

code
resources/qu_network_onesync

Create the files

Every file named in the manifest exists.

Create this exact file layout:

code
resources/qu_network_onesync/
fxmanifest.lua
server.lua

Write fxmanifest.lua

FiveM knows which files to load.

Open fxmanifest.lua and paste this:

code
fx_version 'cerulean'
game 'gta5'

server_script 'server.lua'

Older tutorials add a lua54 'yes' line here. As of June 2025 that setting is deprecated and ignored: Lua 5.4 is the only Lua runtime now, so you leave it out.

Write the lesson code

A real instance manager that partitions players exists.

Open server.lua and paste this:

code
-- Move yourself into a heist instance (its own routing bucket).
RegisterCommand('heist', function(src)
local bucket = 10

-- 1. Make this bucket a clean, locked-down instance.
SetRoutingBucketPopulationEnabled(bucket, false)
SetRoutingBucketEntityLockdownMode(bucket, 'strict')

-- 2. Move the player into it. They now share a world only with
--    other players in bucket 10.
SetPlayerRoutingBucket(src, bucket)

print(('[qu_network_onesync] moved %s (id %s) into heist bucket %d'):format(GetPlayerName(src), src, bucket))
end, false)

-- Send yourself back to the shared world (bucket 0).
RegisterCommand('leaveheist', function(src)
SetPlayerRoutingBucket(src, 0)
print(('[qu_network_onesync] returned %s (id %s) to bucket 0'):format(GetPlayerName(src), src))
end, false)

-- Read which bucket a player is currently in.
RegisterCommand('mybucket', function(src)
print(('[qu_network_onesync] %s is in bucket %d'):format(GetPlayerName(src), GetPlayerRoutingBucket(src)))
end, false)

Start and test it

The expected proof appears in the txAdmin Live Console.

Open server.cfg and add this line:

code
ensure qu_network_onesync

Save server.cfg. Then type this into the server console (the txAdmin Live Console, or the black FXServer console window if you run it directly), not PowerShell and not the in-game chat:

code
restart qu_network_onesync

Join the server. In the in-game chat (press T) type /heist, press Enter, then /mybucket. (In the F8 console you would type the same commands without the leading slash.) The printed lines appear in the server console, not on your screen:

Alex and id 3 are illustrative: you will see your own in-game name and the server id you were assigned on join. The lines that must match exactly are the [qu_network_onesync] prefix and bucket 10.

Prove the invisibility

Two players confirm a routing bucket really partitions the world.

A bucket number printing is not proof of anything. The whole point of this feature is that players in different buckets cannot see each other. So test that directly.

Get two players on the server (a friend, or a second FiveM client on another machine). Have both stand next to each other so you can see each other's character. Then on player one only, run:

code
/heist

Player one is now in bucket 10. Player two is still in bucket 0. Watch what happens: player one's character vanishes from player two's screen, and player two vanishes from player one's. You are standing on identical coordinates and you cannot see each other. Run /leaveheist on player one and you reappear to each other instantly. That disappearance is the routing bucket doing its only job.

SERVER
weather = rain
CLIENT 1
weather = rain
CLIENT 2
weather = rain
CLIENT 3
weather = rain
OneSync makes the server the owner of shared state. It sets the value once and replicates it to each client in turn; clients never set it directly.

Keep reading the full lesson

Sign in to start, then unlock every step of this lesson and the full FiveM School with a membership.

Still ahead in this lesson
  • How it works
  • If something went wrong
  • What you can do now
  • Try it yourself

The remainder of OneSync fundamentals and entity ownership is available to FiveM School members.