Forum ActionScript 3.0 The number of user in room

Problems and discussions relating to ActionScript 3.0 here.

The number of user in room

Postby kustrle » February 13th, 2011, 4:23 pm

Is there a way to obtain a number of user in specific room. I'm making a game, where each user controls his own character. So user 1 will control character 1, user 2 will control character 2,... Basically, I would like each of the users to have a number from 1-5 assigned to them (but each of the numbers can be used only once). Thanks for help!
P.S.: Now I call listRooms to know how many users specific room has. When user joins a room, I give him a number of users that are already in this room+1. But there must be a better solution.
kustrle
 
Posts: 10
Joined: February 11th, 2011, 10:16 pm

Re: The number of user in room

Postby Benjaminsen » February 14th, 2011, 9:11 am

I think you are looking for the PlayerCount attribute on Game<P>

http://playerio.com/documentation/refer ... layerCount

You might however have to do something more clever than what you describe below, as users might leave your game in the middle of a game session. If you wish a new user to be able to join at this point a solution would be to simply loop over your player slots until you find an empty one and assign it to the newly joined user. If there is no empty slots, the room is full and you can send an error to the user and disconnect him/her.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: The number of user in room

Postby kustrle » February 15th, 2011, 10:12 pm

I am working on peer-to-peer game but what you linked to me is some server-side coding. I'm sorry, I forgot to mention.
kustrle
 
Posts: 10
Joined: February 11th, 2011, 10:16 pm


Return to ActionScript 3.0