Settings / RoomSettings
RoomSettings Class
Room Settings
Example usage: Create a script named "ClassExample", place it in the object bar, open the script, enter the following code to save, run the game, and you will see the corresponding method call information in the server log. The code is as follows:
ts
@Component
export default class ClassExample extends Script {
protected onStart(): void {
this.RoomSettings();
}
@mw.RemoteFunction(mw.Server)
public RoomSettings(){
//Set whether players can join the game midway
RoomSettings.enableJoiningMidgame(true);
let joinPeople = RoomSettings.isJoiningMidgameEnabled();
Console.log ("Can players join the game midway:"+joinPeople);
let players = RoomSettings.getMaxPlayers();
Console. log ("The maximum number of Player in the game is:"+players+"people.");
let resEnable = RoomSettings.isPlayerReserveEnabled();
Console. log ("Whether the server reserved Player is enabled:"+resEnable);
let resPlayers = RoomSettings.getReservedPlayers();
Console. log ("The number of Player reserved by the server is:"+resPlayers+"people.");
}
}
@Component
export default class ClassExample extends Script {
protected onStart(): void {
this.RoomSettings();
}
@mw.RemoteFunction(mw.Server)
public RoomSettings(){
//Set whether players can join the game midway
RoomSettings.enableJoiningMidgame(true);
let joinPeople = RoomSettings.isJoiningMidgameEnabled();
Console.log ("Can players join the game midway:"+joinPeople);
let players = RoomSettings.getMaxPlayers();
Console. log ("The maximum number of Player in the game is:"+players+"people.");
let resEnable = RoomSettings.isPlayerReserveEnabled();
Console. log ("Whether the server reserved Player is enabled:"+resEnable);
let resPlayers = RoomSettings.getReservedPlayers();
Console. log ("The number of Player reserved by the server is:"+resPlayers+"people.");
}
}
Table of contents
Methods
enableJoiningMidgame(isEnable : boolean ): void other |
---|
Set the switch to add midway |
getMaxPlayers(): number other |
Get the maximum number of Player |
getReservedPlayers(): number other |
Get the number of Player reserved on the server |
isJoiningMidgameEnabled(): boolean other |
Get whether to enable mid join or not |
isPlayerReserveEnabled(): boolean other |
Get whether the reserved Player on the server is enabled |
Methods
enableJoiningMidgame
• Static
enableJoiningMidgame(isEnable
): void
other
Set the switch to add midway
Parameters
isEnable boolean | Usage: - true: enable mid join - false: disable mid join |
---|
getMaxPlayers
• Static
getMaxPlayers(): number
other
Get the maximum number of Player
Returns
number | The maximum number of Player in the DS room. If the return value is undefined, please check whether the server call or the maximum number of Player is empty |
---|
getReservedPlayers
• Static
getReservedPlayers(): number
other
Get the number of Player reserved on the server
Returns
number | The server reserves the number of Player. If the return value is undefined, please check if it is called on the server or if the reserved number of players is empty |
---|
isJoiningMidgameEnabled
• Static
isJoiningMidgameEnabled(): boolean
other
Get whether to enable mid join or not
Returns
boolean | True: Enable mid join false: Disable mid join. If the return value is undefined, please check whether the server call |
---|
isPlayerReserveEnabled
• Static
isPlayerReserveEnabled(): boolean
other
Get whether the reserved Player on the server is enabled
Returns
boolean | Is the reserved player function enabled. If the return value is undefined, please check whether the server call or the reserved Player is empty |
---|