Service / RoomService
RoomService Class
Game Service and related APIs such as player information, data, avatars, etc.
Table of contents
Methods
kick(player : number Player , message? : string ): void other |
---|
Kick a player offline |
Methods
kick
• Static
kick(player
, message?
): void
other
Kick a player offline
Parameters
player number Player | Kick the player offline |
---|---|
message? string | When the Player is kicked out, the message that pops up when the player exits the UI will be triggered. default: null range: prompt: information of suitable length |
Usage example: create a script named NewScript, place it in the object bar, open the script, modify the original content to the following, save and run the game, press G to kick out the character.
Returns
boolean |
---|
Parameters
resp | MGSResponse |
---|
string |
---|
Returns
string |
---|
ts
@Component
export default class NewScript extends Script {
if(SystemUtil.isServer()) {
Player.spawnDefaultCharacter();
}
let player = await mw.Player.asyncGetLocalPlayer();
if(SystemUtil.isClient()) {
mw.InputUtil.onKeyDown(Keys.G,()=>{
mw.Event.dispatchToServer(`AddPlayerPassable`,player);
})
}
if(SystemUtil.isServer()) {
mw.Event.addClientListener(`AddPlayerPassable`,(player : Player)=>{
RoomService.kick(player);
})
}
}
}
@Component
export default class NewScript extends Script {
if(SystemUtil.isServer()) {
Player.spawnDefaultCharacter();
}
let player = await mw.Player.asyncGetLocalPlayer();
if(SystemUtil.isClient()) {
mw.InputUtil.onKeyDown(Keys.G,()=>{
mw.Event.dispatchToServer(`AddPlayerPassable`,player);
})
}
if(SystemUtil.isServer()) {
mw.Event.addClientListener(`AddPlayerPassable`,(player : Player)=>{
RoomService.kick(player);
})
}
}
}
Parameters
player number Player | Kick the player offline |
---|---|
message? string | When the Player is kicked out, the message that pops up when the player exits the UI will be triggered. default: null range: prompt: information of suitable length |