Sleepless Grid
Last updated on
A spatial grid other resources use to load and unload nearby world content. Players stream the cell they are standing in, plus a buffer around it.
Features
- Cells built from world X and Y. The default cell is 100 meters
- Streaming of the current cell and the surrounding buffer
- Speed hysteresis that shrinks streaming to the current cell while the player is moving fast
- Routing buckets so occupancy and streaming stay inside the bucket the player is in
- Optional bucket names when
sleepless_routingis running
Dependencies
- ox_lib (required)
- sleepless_routing (optional, for bucket names)
A framework bridge loads for Qbox, QBCore, ox_core, or ESX. Qbox is preferred when more than one is started, then QBCore, ox_core, and ESX.
Installation
Download the Resource
Download a release from GitHub.
Add to Server
Place the sleepless_grid folder in your server's resources directory. Keep the folder name so exports.sleepless_grid resolves.
Configure Your Server
Add the following to your server.cfg, before resources that subscribe to cells:
ensure ox_lib
ensure sleepless_gridQuick Start
exports.sleepless_grid:RegisterCellHandler(function(cellId, bucket)
lib.print.info('entered', cellId, bucket)
end, function(cellId, bucket)
lib.print.info('left', cellId, bucket)
end)On the server, the same export receives the player id first.
local players = exports.sleepless_grid:getPlayersFromCell(coords)
exports.sleepless_grid:triggerClientEventForCell(coords, 'myresource:client:cellUpdated', payload)getPlayersFromCell lists players standing in the cell. getSubscribersFromCell lists players streaming it. Pass a bucket id, or a sleepless_routing bucket name, when the cell is not in the global world.
