How to use Routing Buckets for instanced content
Routing buckets are OneSync's built-in instance system. They let you create separate "worlds" where only players in the same bucket can see each other. This is how apartment interiors, heist lobbies, and instanced missions work. This lesson builds a simple apartment entry system using routing buckets.
Build it
Create the resource
resources/qu_buckets_demo/
fxmanifest.lua
server.lua
fx_version 'cerulean'
game 'gta5'
server_script 'server.lua'
Enter an apartment (assign bucket)
-- Map of apartment ID → bucket ID
local apartmentBuckets = {}
RegisterNetEvent('qu_buckets:enterApartment', function(apartmentId)
local src = source
-- Create or reuse a bucket for this apartment
if not apartmentBuckets[apartmentId] then
-- Bucket IDs should be above 100 to avoid conflicts
apartmentBuckets[apartmentId] = 100 + apartmentId
end
local bucket = apartmentBuckets[apartmentId]
SetPlayerRoutingBucket(src, bucket)
print(('Player %s entered apartment %s (bucket %s)'):format(src, apartmentId, bucket))
end)