Skip to content

playcurrent/shards

Repository files navigation

Shards are a set of country groups that either roughly match up to where Roblox's server infrastructure is located or help to group up countries that, whilst may connect to a certain server region, don't geographically exist there (for instance, African countries tend to connect to Europe). This package helps faciliate the use of shards in games by providing a thin API wrapper around the shard data and giving a mechanism to automatically fetch updated shard lists.

When you get a shard for a player, you can feed that into a matchmaking system to pair them up with players in the same general region, meaning that players get better ping and experience. This is ideal for competitive or ping-dependent games, but is also just good generally for a smoother experience for everyone. This also means that you will (in the best conditions) create reserved servers in the best region for all of the players on a match.

In the spirit of eating our own dog food, this library is used in Basketball: Zero for ranked matchmaking, and has been working extremely well, improving latency issues and matching people with others in their own regions.

Documentation

local Shards = require(...)

-- load the latest shard data from the default source, you should ideally do this once but
-- you can do it as many times as you like
--
-- NOTE: if this does fail, it will use the version of the data built in to your version of
-- the library instead
Shards.loadRemoteShardData()

-- if you want to load data from a custom source, you can do that too:
Shards.loadRemoteShardData("https://example.org/shards.json")

local shardId = Shards.getShardForPlayer(game.Players.lewisakura)
-- if you have a specific country code already (ex. trying to get the server's shard ID
-- instead), you can do that too:
Shards.getShardForCountry("US")

-- the shardId is a numerical ID representing the shard, so to get a display name, you can
-- use getShardName:
print(shardId) -- 1
print(Shards.getShardName(shardId)) -- North America

Installation

Wally Package

Shards = "playcurrent/[email protected]"

RBXM Module

Pop over to the releases!

FAQ

Why a package?

The biggest benefit is that the shard data can be updated remotely, so if an unexpected country code shows up or if Roblox releases new server regions, we can quickly update games to start using the new entries without needing to release a game update. Plus, it provides a small little API for people to use to make it easier.

Why do shards have numerical IDs?

A lot of matchmaking systems actually have quite a hard time with strings. For instance, Amazon's GameLift FlexMatch (funnily enough, what we use at BB:Z) really does not play nice with string equality in expansion rules, so a numerical ID is provided as an alternative.

Logo modified from Crystal Shard, under CC-BY-SA-4.0 by Chanut is Industries

About

Put Roblox players into defined regions to optimize matchmaking latency.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Languages