Getting started
A plugin changes how a Rust Legacy server plays: a PvP arena, kits, teleports, events, custom chat commands. It is a single C# file that the server owner drops in a folder. The server runs it with s&box’s built-in script engine: no build, no tools to install, and no access to the game’s source code needed.
Plugins run on the server only. Players need nothing: they join as usual and use the plugin through chat commands.
Test on your own computer
You do not need a dedicated server to try a plugin, or to write one:
- Put the plugin in the s&box install’s
data/redfive/rustlegacy/plugins/folder. - Start Rust Legacy, pick host game in the main menu. Your lobby runs the plugin; its messages and errors are in the s&box console.
- Edit and save the file while you play: it restarts within 2 seconds.
To test a dedicated server before opening it to players, start sbox-server on your own computer as in the hosting
guide and join it with connect <id> (the id comes from status in the server console).
Write a plugin
A plugin is one file, <Name>.cs, that declares public class <Name> : RustPlugin. The class name must match the file
name. It overrides the hooks it needs and calls the helpers of RustPlugin.
using RustLegacy;
public class Welcome : RustPlugin{ public override void OnLoaded() { AddCommand( "online", cmd => Reply( cmd.Player, $"{Players.Count()} players online" ), "How many players are online" ); }
public override void OnPlayerConnected( RustPlayer player ) { Broadcast( $"{player.DisplayName} washed up on the beach." ); }}