Multiplayer - how to recover the status of a peer - It is important

0 favourites
  • 10 posts
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • Hello to all

    In the game I am creating, 4 players must be present before playing. this condition can create a scenario where the last player connects to the chat maybe after several minutes from the first (host). The already colegated players may have exchanged messages and chosen the color of the player. For the last one that connects, but not only, it does not have the updated chat and even what color is left to choose from. How do you align the chat and the modified data? Thank you

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Write down messages in an array on the host and whenever a new player joins, for each x in array, send message reliable ordered array.curx

  • Are you wanting the last player to see what chat information has been exchanged before they join? Sorry if I may be confused. I am working on the same thing and I have a function that goes through an array with x value and then attach it to the cur value as said above my post. Its a way to make sure each log is updated for each array and the function that calls it, for each peer. If that makes sense.

    So, make an array, that says for x (only x since we are just looking at lines of value), and make it as large as you want to see it (array x >= say 5 if you only want to see 5 lines of it at a time).

    Then when a function is called (start of layout, or connected, etc), itll go through that array and the length of it, and show the "appended"/ attached message currently in the arrays last 5 events of chat broadcasting from anyone.

    Then, when the player is in game, make a function that they can add to that chat. Then player by player should all each see the same chat info.

    Im sorry if that is totally off, but from what I read, I think that may help a bit!

    BTW, its appended to the curX BECAUSE that would be the "current X" inputted or in other words, the last broadcasted chat message. Then it reads up from there in the array. and them boom everything in that function shows up.

  • Thank you

    more or less it was quallo that I asked, for the chat, but for the objects?

    In the first screen after login, the player must choose which color he wants to play with, by double clicking on a sprite of the color, which when clicked becomes invisible. If the players are colegated they see the colors disappear according to the choices of the others. But if a player logs in after the other three have already chosen, I do not know how to update the sprites of the various colors so that those who enter have only the color that others have left

    Thank's

  • I gotcha. So basically the color objects that are supposedly already chosen still show for players that log in later, and they cant do anything with them. The colors just sit there, right?

    If so, maybe create an object where each color is a frame and then have a 5th frame blank. Make all of them initially frame 5, so they don't show.

    Then check player count every tick in that layout, and when it is > = 4, change the instances to the frame that has the colors, by using a for each event.

    And since there are only 4 colors, frame 5 will not apply in that loop as long as you do a trigger only once, and/or set speed of animation to 0 (might want to test each of those).

    Then each color will have a frame #. So, when a player clicks, only then can they be assigned, and either deleted, or even changed back to frame 5. And assign that color to the player with a player variable that is equal to the frame of the object that holds the colors.

    So, it will only show the colors when 4 or more players are in, that way no one can click on them until they = a frame that is 0-3(array based). And when they can click, make it frame 4(5th one that is blank.

    Hope that makes sense.

    Does that help?

  • Thank you

    but now if I double click on the color from peer does not do anything, it do not change the frame of the chosen color.

    Where should I place the mouse event inside the peer or inside the common, now is inside the peer

    Tank's

  • YW. So, if the event is in the peer, it has to by synced by using the sync object in the signalling. Also, the event in the peer is not to be the only/and main event for this action. The main event should be in the host side. THEN, the peer should have a setbit for the same action where the host can getbit from the peer and control it from there. The signalling allows that to happen by syncing.

    For example, if you want every peer to say change color, or an object the peer touches, then in the signalling, first sync the object. THEN, if the color is changed by ANY instance variable, you sync the variable AFTER the object.

    Thats the first thing. Now, that object is synced.

    Then, on the host side, directly under host as an event, make an event that says for each peer(or object of player - whatever you called your player), if the players multiplayer id is = to multiplayer.myid(allows each peer to take action independent of each other locally), then do ......

    The action is change color (for example).

    So, this can be done by clicking, or keyboard, etc. IF clicking, the setup is a bit different than keyboard.

    Keyboard is a simple getbit on the host side, to get the keyboard event from each peer to take action.

    The mouse, however, is like this:

    in the host event, you only need a single event for mouse, since everyone has a mouse.

    You DO NOT have to put anything in the peer side, unless you are doing some aiming stuff with variables. SO, dont worry about peer yet still.

    Still host.

    Put in the host, if mouse button left down, for example, as the condition, and the action is a SETBIT instead of a GETBIT. Because we are sending this "mouse down" across the signalling server to everyone INCLUDING the host. So, for your next number in setbit (keep track lol), that will be that event.

    Then everyone that clicks will register on the server as their own click(or should).

    And then in the common section, you can put the action of clicked as a GETBIT (NOT MOUSE EVENT), on the object, because you want everyone to see it, and interact somehow with it.

    Thats the best I can explain it at the moment :P Hope it makes sense!

    I def recommend not worrying about any other code until it works, otherwise you will get confused and overwhelmed quite easily with this loom of the game setup lol.

    So, in conclusion:

    Set up syncing the object first, then the variables if used (sometimes people just use animation but if using var, sync it).

    then host side, make a mouse down, and the action a setbit for the next setbit number.

    then common, have the getbit action do something to the object, like change its color.

    NOTE: setbit and getbit HAVE to be the same number otherwise it will either do nothing, or control something else lol.

    Hope that helps!

  • Thanks so much

    Now Work

    I have another problem but I start another post

    Regards

    Mimmo

  • ok great! Glad it worked out :) I learned a LOT about the multiplayer by a HUGE amount of testing and trial and many error lol.

    Ill see if I can help in the other also. Whats the post?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)