For our upcoming game Onset we have developed a custom dedicated server with support for Lua scripting, modding and more.
This post is to give you a technical overview about Onset's custom multiplayer solution.
Features
- Player, NPC, vehicle and object synchronization
- Server side spatial algorithm for smart network replication
- 300 player slots
- Lua scripting on the server and client
- Embedded HTTP server to serve .pak files (mods), scripts, HTML UI files etc.
- Game server query (query info like ping, hostname, player count)
- C++ Plugin interface to create new functions for Lua
- Steam authentication of clients
- VoIP
- Master server
- Linux support
Lua Scripting
This is Onset's key feature. Scripts can be executed on the client and server. Lua is easy to learn and safe to execute in a sandbox.
Scripts on the server can create entities in the game world that are automatically synced. A list of functions can be found on Onset's dev wiki: https://dev.playonset.com/wiki/Main_Page
Some examples of what you can script in Lua:
- Spawn vehicles, NPCs, objects (static meshes), lights, text widgets, etc.
- Use one of the hundreds of functions to manipulate the world (changing time/weather, etc.)
- Play audio files (.mp3, .wav, .flac, .ogg, network audio streams)
- Intercept events, for example player spawn/death
- Import .pak files to use its assets
- Create UIs with HTML/CSS/JS and communicate between Lua
We have also released some example scripts so you can get a sense of how Lua scripting works in Onset before it's release.
https://github.com/BlueMountainsIO/OnsetLuaScripts
C++ Plugin SDK
This feature enables the server to load C++ code. You can create new Lua functions in plugins to extend the functionality of Lua.
A good example is the MariaDB (MySQL) plugin. It adds functions to interact with databases. This is useful to save and load player data.
https://dev.playonset.com/wiki/MariaDB
https://dev.playonset.com/wiki/Templ...riaDBFunctions
The MariaDB plugin will be made open source at Onset's release.
The plugin interface C++ SDK for Onset is already open source: https://github.com/BlueMountainsIO/OnsetSDK
HTTP Downloading
The server embeds the boost beast library. Clients download files over the HTTP protocol. Only connected clients can download files.
That includes Lua scripts, sound files, HTML/CSS/JS files, images, PAK files, etc.
300 players?
Yes, the server side spatial algorithm keeps track of where things are in the game world. The algorithm supports dimensions meaning you can set entities in different virtualized worlds. Useful for gamemodes that have apartment housing or minigames. The server only sends network updates to players if it is relevant to them.
Onset's map is about 20km2, we hope that 300 fit on the map. Of course having dozens of players at the same location can result in FPS drops. But most of the time you won't have that many players on screen.
Algorithm benchmark in an i7 4Ghz
- 1000 players
- 4000 vehicles
- 100000 objects (spawned meshes)
-> 20ms per algorithm update tick
= 400ms per second for update ticks when ticking each 50ms
The image shows the randomly (normal gauss) distributed entities on a coordinate map. The big spots are natural hot spots that may arise.
This post is to give you a technical overview about Onset's custom multiplayer solution.
Features
- Player, NPC, vehicle and object synchronization
- Server side spatial algorithm for smart network replication
- 300 player slots
- Lua scripting on the server and client
- Embedded HTTP server to serve .pak files (mods), scripts, HTML UI files etc.
- Game server query (query info like ping, hostname, player count)
- C++ Plugin interface to create new functions for Lua
- Steam authentication of clients
- VoIP
- Master server
- Linux support
Lua Scripting
This is Onset's key feature. Scripts can be executed on the client and server. Lua is easy to learn and safe to execute in a sandbox.
Scripts on the server can create entities in the game world that are automatically synced. A list of functions can be found on Onset's dev wiki: https://dev.playonset.com/wiki/Main_Page
Some examples of what you can script in Lua:
- Spawn vehicles, NPCs, objects (static meshes), lights, text widgets, etc.
- Use one of the hundreds of functions to manipulate the world (changing time/weather, etc.)
- Play audio files (.mp3, .wav, .flac, .ogg, network audio streams)
- Intercept events, for example player spawn/death
- Import .pak files to use its assets
- Create UIs with HTML/CSS/JS and communicate between Lua
We have also released some example scripts so you can get a sense of how Lua scripting works in Onset before it's release.
https://github.com/BlueMountainsIO/OnsetLuaScripts
C++ Plugin SDK
This feature enables the server to load C++ code. You can create new Lua functions in plugins to extend the functionality of Lua.
A good example is the MariaDB (MySQL) plugin. It adds functions to interact with databases. This is useful to save and load player data.
https://dev.playonset.com/wiki/MariaDB
https://dev.playonset.com/wiki/Templ...riaDBFunctions
The MariaDB plugin will be made open source at Onset's release.
The plugin interface C++ SDK for Onset is already open source: https://github.com/BlueMountainsIO/OnsetSDK
HTTP Downloading
The server embeds the boost beast library. Clients download files over the HTTP protocol. Only connected clients can download files.
That includes Lua scripts, sound files, HTML/CSS/JS files, images, PAK files, etc.
300 players?
Yes, the server side spatial algorithm keeps track of where things are in the game world. The algorithm supports dimensions meaning you can set entities in different virtualized worlds. Useful for gamemodes that have apartment housing or minigames. The server only sends network updates to players if it is relevant to them.
Onset's map is about 20km2, we hope that 300 fit on the map. Of course having dozens of players at the same location can result in FPS drops. But most of the time you won't have that many players on screen.
Algorithm benchmark in an i7 4Ghz
- 1000 players
- 4000 vehicles
- 100000 objects (spawned meshes)
-> 20ms per algorithm update tick
= 400ms per second for update ticks when ticking each 50ms
The image shows the randomly (normal gauss) distributed entities on a coordinate map. The big spots are natural hot spots that may arise.