Routing buckets: split game state

Originally published at: https://cookbook.fivem.net/2020/11/27/routing-buckets-split-game-state/

Server versions from pipeline ID 3245 and above have added a ‘routing bucket’ functionality, which is similar in concept to the ‘dimension’ or ‘virtual world’ functionality seen in prior non-Rockstar ■■■■■■■■■■■ implementations. For those unaware or lazy to search, one can assign a player or entity to a routing bucket, and they will only…

18 Likes

Any reason why bucket ID is limited to 63 only? Would you consider changing that in the future?

1 Like

World grid allocation currently isn’t dynamic, this might be changed somewhen.

1 Like

Perhaps increasing kNumRoutingBuckets to higher number than 64 (like 256/512) would fit needs of everyone, at least for now - let’s take as an example a 1024 slot server that is a simple deathmatch 2v2 server. With 1024 players, 2 players per dimension giving us 512 dimensions.
Of course if an extra 112MB (if I calculated properly) of memory to allocate won’t be an overkill.

2 Likes

It’s actually closer to 400mb of overhead

2 Likes

Does this mean that events like the explosions and such will have a function extensions to handle the bucket it’s happening in or will it know in which bucket you are and only trigger it in there ?

1 Like

Anyway to use more than 63 dimensions

I don’t understand how routing buckets work, however, in SA-MP we had “Virtual Worlds”, and they were unlimited (or better, limited to the max int32 value).
This allowed scripters to define constant offsets, and then add variable parts like player or house ids to them.
The following is an example of how I would use routing buckets if they were unlimited:

readonly int BUCKET_OFFSET_CHAR_CREATOR = 10000;
readonly int BUCKET_OFFSET_HOUSES = 20000;

// when sending a player to character creator/selector
void SendToCharacterCreator(Player player)
{
    player.TriggerEvent("goToCharacterCreator");
    SetPlayerRoutingBucket(player.Handle, BUCKET_OFFSET_CHAR_CREATOR + int.Parse(player.Handle));
}

// when entering a house
void EnterHouse(Player player, House house)
{
    player.TriggerEvent("enterHouse", house.Id);
    SetPlayerRoutingBucket(player.Handle, BUCKET_OFFSET_HOUSES + house.Id);
}

They are, however, since a while now, minus the memory used for world grid allocation per used ID.

How much memory and id’s are we talking about?

What’s the default dimension ID?
If I never used it before, and I make a new dimension (like house interior, or garage interior) how can I send the player back to the “normal” dimension? 0 ID is the default?

Set it back to 0

2 Likes

What is World grid allocation?

Is there a way to have a bucket where i can see all other plays but they cant see me?

This is not how Buckets work. Buckets are like instance, if you are in a bucket and other player are in an other one, you can see them and they can’t see you.
What you are looking is an invisible thing where you are invisible to other player, but you can still see them. Buckets will not help in that case

Is this still the case? Limited to 63? Or is it now higher?

There isn’t any limit anymore. Why do people keep finding these old posts from before?

4 Likes

Google. Although I figured this was the case as the documentation didn’t mention a limit anymore, thank you for confirming!

4 Likes

How can I create blips and interactions for individual buckets. bucket 0 all blips with input to bucket 1 and in bucket 1 other blips with output to bucket 0

nice bro.

1 Like