Champa

Multiplayer queue system for matchmaking

Recommended Posts

I'm building an mp game that needs to have some sort of a queue system (eg League of Legends, CSGO, Dota2...)

So my question is how to implement such ?

I mean the core concept (I'm not looking for done code, even though some code would be welcome)

EDIT:

I have created a lobby system where you can invite players and if they accept their id is put into the lobby array and the lobby id is returned to them on client side. So the problem now is when the lobby creator hits the start queue button... How to find other lobbies that combine 8 players (2 teams of 4) but leaves the premade players in the same team

Share this post


Link to post
Share on other sites

Hey, good to see some future multiplaying :P

You can create your lobbies as an array of length 2 : lobby[0] is team 1, lobby[1] is team 2 (4 players in each array).

// list of lobbies
var lobbies = [];

// new lobby
var lobby = [];
lobby[0] = [];
lobby[1] = [];
lobbies.push(lobby);

// When a player comes, put it in the correct team
lobby[0].push(id);  // team 1
or lobby[1].push(id);  // team 2

// When you're ready, search for another lobby to complete
// iterate over lobbies and look free space in team 1 and 2
for(var i=0; i<lobbies.length; i++) {
  var lobby = lobbies[i];
  // 
  if(myLobby[0].length <= (4 - lobby[0].length)
    && myLobby[1].length <= (4 - lobby[1].length) ) {
    // Match found !
    // mix your arrays here to make only one
    // and search again with this new array if there is free space
  }
}

It's my first though about it, good luck with that :)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.