How to write an Onset plugin
In this tutorial, we will create our first plugin for Onset servers. Plugins are written in C++ and allow you to extend the game. You can develop code & functions, which can be called in your packages.
To create our first plugin, we will use the official C++ template and the Onset SDK.
C++ Plugin SDK for the Onset Game Server
If we want to write a C++ plugin for our Onset server, we need to use the official Onset Plugin SDK.
We will not download it directly. To initialize our first plugin, we will use a template provided by Talos (the creator of Onset) itself (OnsetIniPlugin).
How to create an Onset plugin
Initialize plugin skeleton
To go further, don't forget to check the requirement!
You can use Windows or Linux. On Ubuntu/Debian, you can easily install all requirements with
sudo apt-get install cmake gcc g++ build-essential.
git clone https://github.com/BlueMountainsIO/OnsetIniPlugin.git
Go to the new
We need to download dependencies like the SDK (it will be in
git submodule update --init --recursive
You have all you need to compile your first plugin ;)
First, we will check that we have all the requirements. We will compile the official skeleton before apply modification to make sure our system is ready.
- Open a terminal.
- Configure CMake:
cmake -DCMAKE_GENERATOR_PLATFORM=x64 .
- For me, the command output:
➜ OnsetIniPlugin git:(master) cmake . -- The C compiler identification is GNU 7.4.0 -- The CXX compiler identification is GNU 7.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found HorizonPluginSDK: /home/seb/Projects/OnsetIniPlugin/libs/sdk/include -- Configuring done -- Generating done -- Build files have been written to: /home/seb/Projects/OnsetIniPlugin
- If you don't have any error, you can launch compilation:
➜ OnsetIniPlugin git:(master) ✗ make Scanning dependencies of target ini-plugin [ 25%] Building CXX object src/CMakeFiles/ini-plugin.dir/HandleManager.cpp.o [ 50%] Building CXX object src/CMakeFiles/ini-plugin.dir/Plugin.cpp.o [ 75%] Building CXX object src/CMakeFiles/ini-plugin.dir/PluginInterface.cpp.o [100%] Linking CXX shared module ini-plugin.so [100%] Built target ini-plugin
- Our plugin is ready. An
ini-plugin.sohas been created in your project root directory witch contains our compiled plugin.
To use the plugin, upload it on your Onset server in
After, edit the
server_config.json file and add the plugin name (
plugins section; and reboot your server.
Check your server console; plugin is loaded!
Now you need to add your own logic; your code will be located in
src/. You have an example of a plugin than you can easily understand.