Page 1 of 1

How to put a user in a zone

Posted: 12 Jul 2018, 12:47
by Ardito
Hi,
In my project, I have 2 users that are in the same room to play, when the game ends, I have to put these 2 users in the main zone of the game, with what instruction do I do this?

I tried to use this code, but from errors:
getApi().joinRoom(users[0].user, (Room) getParentRoom().getZone());
getApi().joinRoom(users[1].user, (Room) getParentRoom().getZone());

Yours sincerely

Re: How to put a user in a zone

Posted: 12 Jul 2018, 13:30
by Lapo
Hi,
I don't understand your question:
I have to put these 2 users in the main zone of the game

They are in the Zone as soon as they log in, so when the game ends they are still in that Zone.
Maybe you mean you want to move the Users to another Room when the game ends?

If so you can use getApi().joinRoom() as per your example.

Cheers

Re: How to put a user in a zone

Posted: 12 Jul 2018, 13:47
by Ardito
Users are in a room created by the server, how do I move users from this room to the main zone of the game?

My code:
Image

Re: How to put a user in a zone

Posted: 12 Jul 2018, 14:05
by Lapo
There is probably something missing that I need to understand.
Does your game use multiple Zones?

Can you please explain how your game works in terms of using multiple Zones?

Thanks

Re: How to put a user in a zone

Posted: 12 Jul 2018, 14:51
by Ardito
No, my game uses only 1 zone, but at the moment of the game the users are moved to a game room, when the game ends I have to redirect the users in the main zone

Re: How to put a user in a zone

Posted: 13 Jul 2018, 07:28
by Lapo
A user joins the Zone when he logs and in and he never leaves it until he disconnects or sends a LogOut request.
When your users finish to play a game they can leave the game Room but they are still joined in the main Zone.

Cheers

Re: How to put a user in a zone

Posted: 13 Jul 2018, 07:32
by Lapo
I recommend taking a look here:
http://docs2x.smartfoxserver.com/Develo ... chitecture
To understand the relation between Zones and Rooms

Cheers