How to put a user in a zone

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Ardito
Posts: 20
Joined: 12 Sep 2016, 11:26
Location: Italy

How to put a user in a zone

Postby Ardito » 12 Jul 2018, 12:47

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
User avatar
Lapo
Site Admin
Posts: 20146
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to put a user in a zone

Postby Lapo » 12 Jul 2018, 13:30

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
Lapo
--
gotoAndPlay()
...addicted to flash games
Ardito
Posts: 20
Joined: 12 Sep 2016, 11:26
Location: Italy

Re: How to put a user in a zone

Postby Ardito » 12 Jul 2018, 13:47

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
User avatar
Lapo
Site Admin
Posts: 20146
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to put a user in a zone

Postby Lapo » 12 Jul 2018, 14:05

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
Lapo

--

gotoAndPlay()

...addicted to flash games
Ardito
Posts: 20
Joined: 12 Sep 2016, 11:26
Location: Italy

Re: How to put a user in a zone

Postby Ardito » 12 Jul 2018, 14:51

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
User avatar
Lapo
Site Admin
Posts: 20146
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to put a user in a zone

Postby Lapo » 13 Jul 2018, 07:28

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
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 20146
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to put a user in a zone

Postby Lapo » 13 Jul 2018, 07:32

I recommend taking a look here:
http://docs2x.smartfoxserver.com/Develo ... chitecture
To understand the relation between Zones and Rooms

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 6 guests