PlayerId generator issue in Spectator to Player

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
albcom
Posts: 24
Joined: 06 Jan 2014, 00:28

PlayerId generator issue in Spectator to Player

Post 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.
albcom
Posts: 24
Joined: 06 Jan 2014, 00:28

Re: PlayerId generator issue in Spectator to Player

Post by albcom »

Any thoughts on this ?
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: PlayerId generator issue in Spectator to Player

Post 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?
Paolo Bax
The SmartFoxServer Team
albcom
Posts: 24
Joined: 06 Jan 2014, 00:28

Re: PlayerId generator issue in Spectator to Player

Post by albcom »

Nevermind, we actually figured out the issue. Thanks for your help.
Post Reply