-
Notifications
You must be signed in to change notification settings - Fork 7
Server
Leonid Pospelov edited this page Aug 3, 2019
·
7 revisions
Starts attempt to launch the remote SkyMP server.
let server = new Server({
// The address and port of SkyMP master server
masterAddress: '108.108.108.108',
masterPort: 3000,
// Unique ID for your server
id: 'my_server',
// Public name of the server, will appear in launcher
name: 'My Server',
// Player limit, will appear in launcher
maxPlayers: 5,
// Dev password for server with specified id
// Prevents people from connecting their gamemodes to your server
devPassword: 'changeme',
// Relative path to directory containing frontend files (html, css, js, etc.)
frontEndPath: './front',
});
Limit of a number of users including bots.
let maxPlayers = await server.maxPlayers;
Emitted when the server succeeded or failed to start.
-
errorS
-null
or string containing details of the error.
server.on('init', (error) => {
console.error('Init error:', error);
});
Emitted when your gamemode is connected to the server.
server.on('scriptInit', () => {
console.log('Script init');
});
Emitted when a new User
has just joined the game (launched SkyMP with your server selected).
-
user
- An instance ofUser
.
server.on('userEnter', async user => {
console.log('New User:', user.id);
});
Emitted when User
leaves the game.
-
user
- An instance ofUser
.
server.on('userExit', async user => {
console.log('Exited User:', user.id);
});
Emitted when User
's browser sends a custom packet.
-
user
- An instance ofUser
. -
targetSystem
- A string from client. Should represent one of the systems in your gamemode. -
data
- An object from client containing "body" of the packet.
server.on('userCustomPacket', async (user, targetSystem, data) => {
if (targetSystem === 'Auth') {
// ...
} else if (targetSystem === 'Barbershop') {
// ...
}
}
Emitted when character creation is finished.
-
actor
- An instance ofActor
.
server.on('raceMenuExit', async (actor) => {
// ...
});
Drops connections with server and master server. The server will be removed from the server list in a few seconds.
server.kill();
Creates bot i.e. a dummy user. Bots disconnect when gamemode is disconnected.
let bot = await server.createBot();