Sign In Register

How can we help you today?

Start a new topic

Custom Script Message sent from Cloud Code duplicated

I have a custom script message that I am sending in my cloud code at two points:

Point 1) MatchmakingRequest

Point 2) MatchFound

Relevant Code for both:

| if (Spark.getData().matchShortCode == "HostedMatch") {


|    var refreshLobbyGamesMessage = Spark.message("RefreshLobbyGames");

|    refreshLobbyGamesMessage.setMessageData({"RefreshGames" : true});

|    refreshLobbyGamesMessage.setPlayerIds(Spark.getTeams().getTeam(0).getMemberIds());

|    refreshLobbyGamesMessage.send();

| }

My goal is to send a single message to all players in Team with teamID 0. This works, except that after the cloud code is executed, the message is sent to every player in Team 0 multiplied by the number of players in team 0. (MessageDuplicateCount = Team0MemberCount)

The messages show up both in the Test Harness as well as the Unity game.

How do I prevent the message from being sent multiple times to each player?

Login to post a comment