Sign In Register

How can we help you today?

Start a new topic

MMO with rooms

I am creating an online world much like

I was wondering what is the best way to handle rooms and Real time player chat and movement with the rooms. Rooms like a shop, cafe, town square etc.

Creating matches or challenges would not work in this case I would image

Many thanks

I saw ure post on IrishGameDev..

You could have a match that can be joined after the match is made, and will persist as long as there is one person in it.


A general approach you could take is..

Player goes to join room.. If the room already exists then they join it.. If it doesnt (ie. if theres zero people in it) then they start a new one.

It will be a little awkward to do this as Matches are only created when 2 people are matched, but doable.


In general you can build your own system to do Matchmaking as u want want by.

1. Call custom 'events' from your game to communicate with the server. You can then add cloud code to the events.. Also the events can return data back to your game.

At the end of your events cloud code use Spark.setScriptData.. the that data will be in the reponse to the event call you made in your game.

Spark.setScriptData("name", "florpjons");

2. in your cloud code, you will be frequently using these parts of the cloud code API.

As you can see, you can create matches yourself using cloud code.

3. To persist data on the server use one of these


So a way it might work could be

  •  Theres no-one in the room
  •  player one joins room, he calls a custom event to check your custom server data about who is in the room.. he finds on the server data that no-one is in the room , he enters room in the game,  and then sets some data in the server indicating he is in the room
  •  player 2 joins the room, he finds one person in the room already so a match is created between him and player 1 .
  • player 3 joins the room, he finds in the data that a match has already been created so he just joins that match.

Your question is also super broad, so I can only give a very broad and vague answer. Try searching the forums and reading other forum questions and answers, then implement something and come back here with more specific questions.

Also I have just pieced this together how to do this myself by through trial and error + trawling the forums & documentation.
Maybe this is a terrible approach, but based on my own game I reckon it is a workable solution, or at least a good start.

Hi Brian, thanks for that. I have followed your great advice and have run onto a problem of not being able to add players to an already started Match.

In the MatchMakingRequest when a player requests a Match I add them to an already existing one. For test purposes I have hard coded a running match.

I get the following error in cloud code when another player joins Cannot add players to an in progress drop in drop out match. Use SparkPendingMatch (request/MatchmakingRequest.js#13)`


if (Spark.getData().matchShortCode === "Room_TownCentre")
    var matchId = "5ca6767dd53d810500180ac6";
    var match = Spark.getMultiplayer().loadMatch(matchId);


Another issue I have is I don't have the Real Time option in my match settings. I have posted a message regarding this but I am still waiting on a reply.

Login to post a comment