Introduction to C++ API

From RW-MP Wiki
Jump to: navigation, search

Building example module on Linux OS:

Download module-API with example via git:


[disi@workstation ]$ git clone https://github.com/rw-mp/modules-api.git
[disi@workstation example]$ cd modules-api/example


After that you should build your MAKEFILE:

[disi@workstation example]$ cmake .
-- The CXX compiler identification is GNU 7.3.1
-- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /home/disi/rwmp/modulesdk/modules-api/example


Execute command make to build our example module:


[disi@workstation example]$ make
Scanning dependencies of target example
[ 50%] Building CXX object CMakeFiles/example.dir/example.cpp.o
[100%] Linking CXX shared library libexample.so
[100%] Built target example


Check your compiled libexample.so :


[disi@workstation example]$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  CMakeLists.txt  example.cpp  libexample.so  Makefile


Create folder with name modules in your root directory of your server and check that you have parameter -> modules 1 in your server.cfg.

Then put our module in to 'modules' dir and launch server, then you will get:


[disi@workstation bin]$ ./rwmp-server
filterscripts = ""  (string)
 
Server Plugins
--------------
 Loaded 0 plugins.
 
 Started Server on port: 8890, with maxplayers: 500 lanmode is OFF.
 
Custom modules
--------------
 CPP module has been loaded!
 
Number of vehicle models: 1