zapi-matchmaking
v1.1.0
Published
A simple matchmaking module for Javascript.
Downloads
29
Maintainers
Readme
zapi-matchmaking
A super simple and light matchmaker module that matches by rank. This module is from Zarran API.
How to use
- Call the "startMatchMaker" function with these 2 values: Whether rank is enabled for matchmaking, and if so the rank quota to be matched together.
- Use the "startMatch" call with your user IDs afterwards.
Here's an example on how to use this:
import mm from "matchmaking"
const serverArray = [sv1, sv2, sv3]
mm.startMatchMaker(serverArray, 1, 50) // Rank matching enabled, anyone within 50 rank of another user will be matched with them
const user1 = await mm.startMatch(UUID1, "100") // Doesn't return anything until someone else enters the queue with a close enough rank or after ~21 seconds, after which it returns "002-0001". It sends a promise if the call worked.
const user2 = await mm.startMatch(UUID2, "120") // Returns sv1 for this call and the other since they both have a close enough rank to be matched.
Alternatively, if you don't want to use ranking, do this instead:
import mm from "matchmaking"
const serverArray = [sv1, sv2, sv3]
mm.startMatchMaker(serverArray, 0) // Rank matching disabled
const user1 = await mm.startMatch(UUID1) // Same as before, just without the rank check
const user2 = await mm.startMatch(UUID2) // Returns sv1 for this call and the other one since there is someone in the queue
Errors
"002-0001"
Nobody found in the queue.
"002-0002"
You have not started the match maker yet! Go do that.
"002-0003"
i forgor how to use the function right :skull: In all seriousness, please put in the right values for the function or you get this.
"002-0004"
Someone tried to run the placeholder test in package.json >:/