Creating your first plugin

Fragsurf uses lua as its runtime scripting solution. Click here to learn more about lua.

It's important to note that plugins developed on the server will be synchronized with the client, allowing for both server and client-side modding. When a client joins a modded server, it downloads all of the plugins to a temporary directory and loads them. Currently there is no way to prevent certain data from being synchronized to the client, so don't include any sensitive information in your server plugins just yet. To determine if the plugin is currently executing on the server or client, check Game.IsHost

function load() 
    if Game.IsHost then
        -- do stuff for the host

If the server/host executes plugins.reload all plugins will be reloaded and synchronized with clients in real-time, no need to restart the server.

For this example we are going to create a plugin that prints Hello World to chat when it loads up. Navigate to Fragsurf_Data/StreamingAssets/Plugins and create a new folder called HelloWorld. This will be where the content of our plugin resides.

All plugins require an plugin.ini to descibe various details of the plugin such as name, author, version, and dependencies. Create plugin.ini with the following content:

name="Hello World"

Plugins are loaded through a file named init. Create init.lua and we can begin writing script. For this example, we will use the plugin load function to call to the game's TextChat component. Place the following script into init.lua:

function load() 
    Game.TextChat:MessageAll('Hello World');

Now when the plugin loads, Hello World will be printed to chat. To see it in action, reload the plugins by typing plugins.reload into the console.