Client
Client-side exports for the rw_buckets routing system.
rw_buckets API
Client-side exports for moving the local player — and, optionally, the vehicle they're driving — into a routing bucket. Every setter here is a thin wrapper around a server callback; the value returned by getBucket() is kept in sync automatically via the rw_buckets:onBucketUpdate event, so you never need to poll the server for it.
Client Exports
exports.rw_buckets:getBucket()
Returns the current bucket key the player is assigned to.
local bucketKey = exports.rw_buckets:getBucket()
print(bucketKey)- Returns:
string|0|nil— the bucket key if assigned,0if the player has been removed from a bucket at some point this session, ornilif no bucket event has fired yet (e.g. right after the resource starts).
0 is truthy in Lua. A plain if bucketKey then check will not detect "not in any bucket" once a removal has happened — check bucketKey and bucketKey ~= 0 instead.
exports.rw_buckets:setMe(bucketKey)
Assign the local player to a routing bucket.
local success = exports.rw_buckets:setMe('mission_alpha')- bucketKey:
string— The bucket identifier. - Returns:
boolean—trueif the server accepted the change.
exports.rw_buckets:remMe()
Remove the local player from any current bucket assignment.
exports.rw_buckets:remMe()This export does not return a value, even though the server confirms success internally — don't rely on its return for control flow.
exports.rw_buckets:setVeh(vehicle, bucketKey)
Assign a vehicle to a routing bucket.
local veh = GetVehiclePedIsIn(cache.ped, false)
local success = exports.rw_buckets:setVeh(veh, 'mission_alpha')- vehicle:
number— Local vehicle entity ID (not network ID). - bucketKey:
string— The bucket identifier. - Returns:
boolean—falseifvehicledoesn't exist, isn't actually a vehicle, or the server rejects the change.
exports.rw_buckets:remVeh(vehicle)
Remove a vehicle from its current bucket.
local veh = GetVehiclePedIsIn(cache.ped, false)
exports.rw_buckets:remVeh(veh)- vehicle:
number— Local vehicle entity ID. - Returns:
boolean—falseifvehicledoesn't exist or isn't actually a vehicle.
exports.rw_buckets:setMeAndVeh(bucketKey)
Assign both the player and their current vehicle to a routing bucket in one call.
exports.rw_buckets:setMeAndVeh('mission_alpha')- bucketKey:
string— The bucket identifier. - Returns:
boolean—trueonly if both the vehicle and the player were moved successfully.
Requires the player to currently be the driver (cache.seat == -1) of an existing vehicle. The vehicle is moved first; if assigning the player then fails, the vehicle bucket is automatically rolled back so the two never end up split across buckets. The player is re-warped into their seat afterwards to guard against desync from the switch.
exports.rw_buckets:remMeAndVeh()
Remove both the player and their current vehicle from any bucket assignment.
exports.rw_buckets:remMeAndVeh()- Returns:
boolean—trueonly if both the vehicle and the player were removed successfully.
Requires the player to currently be the driver of an existing vehicle, same as setMeAndVeh.
Events
rw_buckets:onBucketUpdate
RegisterNetEvent('rw_buckets:onBucketUpdate', function(bucketKey)
print('My bucket is now:', bucketKey)
end)Fired locally whenever the player's bucket changes, including when it's changed remotely by an admin command. Listen for this instead of polling getBucket() if you need to react to bucket changes — for example, toggling custom UI.
- bucketKey:
string|0— the new bucket key, or0if the player was just removed from their bucket.