CREATE YOUR WORLD
Multiplay

Removing a specific user from Room

4min

You can kick certain users out of the room at runtime.

  • Please create the server code index.ts Sandbox.

Function definition

kick(client: SandboxPlayer, reason?: string): Promise;

It is a function to kick out the SandboxPlayer after receiving the SandboxPlayer with SessionID. - If you are kicked out, a pop-up will appear informing you that you are kicked out, but the pop-up is the UI of the ZEPETO app and cannot be checked by the editor.

📘 Please refer to the following guide. [ZEPETO.Multiplay(Server) API]



First, to get user information, define Schema Types and RoomState as follows:

Document image


Example of use

  • Use the data in UserInfos to get the session ID of the user who will be kicked out of the userId.
  • After importing the sandbox player with the session ID, call the kick function.
  • I can tell you who was kicked out through broadcast.
TypeScript


👍 By default, users who have been kicked out can enter the room again

  • To prevent this, use the DataStorage management function based on the UserId to store the room information that was kicked out by the user.
  • You can implement it by calling a kick when you try to enter the room.