Skip to content

WindowsGSM/Plugin-Development-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Plugin-Development-Guide

🧩 WindowsGSM Plugin Development Guide - Support more game servers by creating and installing plugins!

Support server

https://discord.gg/bGc7t2R

Table of Contents:

  1. Introduction
  2. Basic Knowledge
  3. Set up a plugin development environment
  4. Creating Your First Plugin
  5. Testing Your First Plugin

WindowsGSM (>= 1.21.0) starts supporting plugins installation since users want to add their own game servers to WindowsGSM which WindowsGSM doesn't support those game servers yet. More importantly, users can wait for a plugin release on the community instead of WindowsGSM release.

(27/01/2020) ! AssaultLine says... We need to know if its possible to add a game now in a custom way.

(14/04/2020) Redyear20 says... I want to know if this game panel is capable to add games not listed. For example I want to add The Isle

(20/07/2020) Kratomasy 🌈 aka Alaric says... is there a way to add a custom steam game server that is not in the list of GSM?

(06/08/2020) Tempus Thales says... If I wanted to add a server that is not listed in your tool, can I still add it with your tool?

(09/08/2020) WindowsGSM v1.21.0 released! 🥳

✔ Before writing plugins, lets understand how it looks like and how it works.

How plugins works?

WindowsGSM scan the plugins folder and loads {PLUGIN_NAME}.cs, {PLUGIN_NAME}.png and author.png files of each plugin.

The plugin file structure is basically like that: (Installed WindowsGSM.ARMA3 and WindowsGSM.PaperMC)

Plugin File Structure

For WindowsGSM.PaperMC plugin, WindowsGSM reads folder PaperMC.cs and loads PaperMC.cs, PaperMC.png and author.png

Plugin File Structure

Now let's set up a plugin development environment.

Prerequisites

  1. .NET Framework 4.7.2
  2. Visual Studio 2019

Preparations

Download or git pull the latest WindowsGSM #master (https://github.com/WindowsGSM/WindowsGSM)

Get Started

Open WindowsGSM.sln with Visual Studio 2019

You should see something like this

The plugin development environment is set up! 🥳

As you know, most game servers use steamcmd to install and update the server. WindowsGSM already created SteamCMDAgent class for inheritance purpose, so adding a game server that uses steamcmd is much easier than adding a server that does not support steamcmd.

1. Create a new plugin script

Create a MyFirstPlugin.cs file inside Plugins folder on WindowsGSM-Plugin-Development project

2. Edit the plugin script

Add WindowsGSM references

using WindowsGSM.Functions;
using WindowsGSM.GameServer.Engine;
using WindowsGSM.GameServer.Query;
using Newtonsoft.Json.Linq;

Change the namespace to WindowsGSM.Plugins

namespace WindowsGSM.Plugins

Setting up plugin info

public Plugin Plugin = new Plugin
{
    name = "WindowsGSM.XXXXX",
    author = "Your name",
    description = "🧩 WindowsGSM plugin for supporting XXXXXX Server",
    version = "1.0",
    url = "https://github.com/XXXXXXXX/XXXXXXXX",
    color = "#ffffff"
};

Continue read ...

Plugin Format that inherits SteamCMDAgent

Set SteamCMDAgent as parent

public class MyFirstPlugin : SteamCMDAgent

Add constructor and properties

public MyFirstPlugin(ServerConfig serverData) : base(serverData) => base.serverData = _serverData = serverData;
private readonly ServerConfig _serverData;

Add properties for SteamCMD installer

public override bool loginAnonymous => false; // true if allows login anonymous on steamcmd, else false
public override string AppId => ""; // Value of app_update <AppId> 

Add standard variables

public override string StartPath => ""; // Game server start path
public string FullName = ""; // Game server FullName
public bool AllowsEmbedConsole = false;  // Does this server support output redirect?
public int PortIncrements = 1; // This tells WindowsGSM how many ports should skip after installation
public object QueryMethod = null; // Query method. Accepted value: null or new A2S() or new FIVEM() or new UT3()

public string Port = ""; // Default port
public string QueryPort = ""; // Default query port
public string Defaultmap = ""; // Default map name
public string Maxplayers = ""; // Default maxplayers
public string Additional = ""; // Additional server start parameter

Add standard functions

public async void CreateServerCFG() { } // Creates a default cfg for the game server after installation

public async Task<Process> Start() { return null; } // Start server function, return its Process
public async Task Stop(Process p) { } // Stop server function

Done! All necessary variables and functions were all created. you can now start edit your script and create your first plugin!

Example plugin with plugin format that inherits SteamCMDAgent: WindowsGSM.ARMA3

Classic Plugin Format

Add constructor and properties

public MyFirstPlugin(ServerConfig serverData) => _serverData = serverData;
private readonly ServerConfig _serverData;
public string Error, Notice;

Add standard variables

public string StartPath = ""; // Game server start path
public string FullName = ""; // Game server FullName
public bool AllowsEmbedConsole = false;  // Does this server support output redirect?
public int PortIncrements = 1; // This tells WindowsGSM how many ports should skip after installation
public object QueryMethod = null; // Query method. Accepted value: null or new A2S() or new FIVEM() or new UT3()

public string Port = ""; // Default port
public string QueryPort = ""; // Default query port
public string Defaultmap = ""; // Default map name
public string Maxplayers = ""; // Default maxplayers
public string Additional = ""; // Additional server start parameter

Add standard functions

public async void CreateServerCFG() { } // Creates a default cfg for the game server after installation

public async Task<Process> Start() { return null; } // Start server function, return its Process
public async Task Stop(Process p) { } // Stop server function
public async Task<Process> Install() { return null; } // Install server function
public async Task<Process> Update() { return null; } // Update server function

public bool IsInstallValid() { return false; } // Check if the installation is successful
public bool IsImportValid(string path) { return false; } // Check is the directory valid for import

public string GetLocalBuild() { return ""; } // Return local server version
public async Task<string> GetRemoteBuild() { return ""; } // Return latest server version

Done! All necessary variables and functions were all created. you can now start edit your script and create your first plugin!

Example plugin with classic plugin format: WindowsGSM.PaperMC

Install Plugin

  1. Set Startup Project to WindowsGSM-Plugin-Development and click Start to start installing your plugins.
  2. Set Startup Project to WindowsGSM and click Start to start WindowsGSM and start debug!

About

🧩 WindowsGSM Plugin Development Guide - Support more game servers by creating and installing plugins!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published