Page 1 of 1

PlayerId generator issue in Spectator to Player

Posted: 21 May 2014, 05:24
by albcom
Hi,

We are having an issue with the Player id when converting from Player to Spectator and Spectator to Player.
The issue is happening in the following scenario for a 2 player game.

Player1 joins the room and gets PlayerId = 1
Player2 joins the room and gets PlayerId = 2

Player2 leaves the room
Player1 is converted to a spectator from the server side using "gameRoom.switchPlayerToSpectator(Player1 );"

Then Player1 clicks get a message to Stay in the room or Leave. Once we click on "Stay in the room" we send a request from Flash to Server using "sfs.send(new SpectatorToPlayerRequest());" to make this user a player again.

Now Player1 has the PlayerId = 2 (note, Player1 never left the game room)

Player2 decides to join the game again and in this case PlayerId =0;

Why is playerId coming as 0 for Player2? I thought that PlayerIdGenerator would start from 1 for a game room.

Are we using the proper way of dealing with such a scenario?

Thanks.

Re: PlayerId generator issue in Spectator to Player

Posted: 23 May 2014, 15:45
by albcom
Any thoughts on this ?

Re: PlayerId generator issue in Spectator to Player

Posted: 27 May 2014, 08:52
by Bax
I don't understand why you need to change player 1 to spectator and then back to player. Why don't you just pause the game and ask the player if he wants to leave the Room or stay?

Re: PlayerId generator issue in Spectator to Player

Posted: 29 May 2014, 01:52
by albcom
Nevermind, we actually figured out the issue. Thanks for your help.