RoyaleWindRoyaleWind

Bucket

Server-side API for inspecting and managing whole buckets.

rw_buckets Server API — Bucket Functions

Server-side API for inspecting and managing buckets as a whole, rather than one player or entity at a time. Buckets are created automatically the first time a key is used (setPlayerBucket / setEntityBucket) and garbage-collected automatically once the last player or entity leaves — you never create or destroy them directly.


exports.rw_buckets:getBucketContents(key)

Returns everyone and everything currently assigned to a bucket.

local contents = exports.rw_buckets:getBucketContents('mission_alpha')
for playerId in pairs(contents.players) do
    print('player', playerId)
end
for entityId in pairs(contents.entities) do
    print('entity', entityId)
end
  • key: string — The bucket key.
  • Returns: table{ players: table<number, boolean>, entities: table<number, boolean>, key: string }.

players and entities are sets, not arrays — keys are IDs, values are always true. Iterate with pairs, not ipairs. If the bucket doesn't exist (empty, or never used), this still returns an empty table with the same shape rather than nil, so no nil-check is needed.


exports.rw_buckets:getActiveBucketKeys()

Lists every currently active bucket.

local buckets = exports.rw_buckets:getActiveBucketKeys()
for _, bucket in pairs(buckets) do
    print(bucket.id, bucket.key)
end
  • Returns: table<number, {id: number, key: string}> — one entry per bucket that currently has at least one player or entity in it. Empty buckets are cleaned up automatically and won't appear here.

exports.rw_buckets:killBucket(key)

Removes every player and entity from a bucket — sending them back to bucket 0 — and deletes the bucket.

exports.rw_buckets:killBucket('mission_alpha')
  • key: string — The bucket key.

Irreversible: everyone and everything in the bucket is moved back to bucket 0 immediately, with no record kept of the previous grouping. This export does not return a value.

On this page