Sign In Register

How can we help you today?

Start a new topic
Answered

Letting other team members of the game know something has happened

Heyo, 


So my problem is that I have teams of players and they can explore a dungeon together. 

If for example a dungeon is 1 room. 

There is 2 players. 

Each room of the dungeon has 3 states. 

-Not Entered/Not Cleared

-Entered(claimed by a user)/Not Cleared

-Cleared


If Player1 enters the room, it goes to Entered and thus claimed by him. If Player 2 on his client goes to enter the room(which to him could still say Not Entered) the game will check GS and find that it is already Entered and then update his game to show this. 

If Player1 then clears the room, GS gets updated that the room is cleared and the game will show a button to generate a new dungeon, he can make a new dungeon and keep exploring. 


Player2 will still see the Entered room with no way to update the dungeon to the new one that Player1 is now on.  Is there a way to "Push" to a user that a new dungeon is created or that there has been a change in the dungeon (as in a room state has changed?)


Hope I explained it nice enough, if not I can draw a picture :P


Best Answer
Hi Travis
You will need to set up a listener in unity
For example :
ScriptMessage.Listener = (message) => {
    GSData data = message.Data; 
    String extCode = message.ExtCode; 
    String messageId = message.MessageId; 
    bool? notification = message.Notification; 
    GSEnumerable<GSData> scriptData = message.ScriptData; 
    String subTitle = message.SubTitle; 
    String summary = message.Summary; 
    String title = message.Title; 
};
Thanks
Katie

 

 


Answer
Hi Travis
You will need to set up a listener in unity
For example :
ScriptMessage.Listener = (message) => {
    GSData data = message.Data; 
    String extCode = message.ExtCode; 
    String messageId = message.MessageId; 
    bool? notification = message.Notification; 
    GSEnumerable<GSData> scriptData = message.ScriptData; 
    String subTitle = message.SubTitle; 
    String summary = message.Summary; 
    String title = message.Title; 
};
Thanks
Katie

 

 

I got it working I think (at least it sends the message now, just shoved loadPlayer into a for loop for now. )  


For capturing the message in game and doing stuff with it, will I have to add some extra logic in the actual GameSparks SDK? I'm using Unity and I can see the debug log that I get the message just yeah, not quite sure how to capture that when it happens

Having a bit of an issue trying to put the players that need to be alerted in the message part.



It errors out on the last line saying that it can't convert from native array to SparkPlayer[].  I tried making a new SparkPlayer[] but it didn't want to let me do that either. 

What am I missing here?

Yup it's there again.


Thanks :)

Hi Travis,


There was a slight issue earlier but everything is back to normal now, your collections should be visible again. Can you confirm everything is ok at your end now ? 


Thanks,

Liam

Awesome thanks, I'll give that a whirl. 


Next question of the day is I went to go and check my collections and it seems that all my runtime and meta collectiona 

Any idea what's going on?

Hi Travis
Thanks the video helped me to understand the problem.
To update other player of a change in the game you can use messages. Data can be stored in a json in messages.
When a player creates a new dungeon a logEventRequest  can be called in the event you can use SendMessage

Spark.sendMessage({"newDungeon" : true}, myplayers);


Thanks

Katie


 

I think this would also be the same way that for example, if I wanted to update an image in my game from the GSDownloadables section, how would I tell my game that a new version of a downloadable is ready for the client to download. 

Here, I made a video of the problem in action.


Pretty much the opposite. 


I'm looking for a way to make a Gamesparks push something to the clients so I can then make the clients use one of my already made custom event requests (GetDungeonInfo in this case)


I don't know if I can just send a push message with a message for my game in it or if there is a better way to do this...

Hi Travis

You can use a LogEventRequest to call a custom event from the client and update the server side game logic.
Is that what you are looking to do?

Thanks

 Katie

Nope, the claiming part is already done behind the scenes. 

The part I'm having trouble with is just letting the other team members know when a new dungeon has been made if they are still "technically" waiting for one of the team members to finish the last room (as it will not update since they can't click on it and I don't want to waste calls on letting them have a "refresh" button unless it's the only way)


I thought maybe I could use a push message or something to force the game to update the client but I'm not sure. Basically what I want is a way to force a game client to make a call to GS on one of my custom events. 

Like when the player that has that last room finishes it, I want to just add an extra event into the code I have for that, that will then make other team members game clients just call to GS to get the new dungeon.


If I can't then I'll just put in a refresh button...just wanted to lower possible call spam

Hi Travis

You can use TeamChatMessage when a player claims a room/or goes to another dungeon to alert the other players.
Let me if that will work for you.

Thanks
Katie

 

Login to post a comment