Building your own Oxide plugins lets you create exactly the server experience you want. If you know basic programming concepts, Rust plugin development is approachable.
Plugin Basics
Oxide plugins for Rust are written in C#. Each plugin is a single .cs file placed in oxide/plugins/. Oxide compiles and loads it automatically.
Minimal Plugin
namespace Oxide.Plugins
{
[Info("HelloWorld", "YourName", "1.0.0")]
class HelloWorld : RustPlugin
{
void Init()
{
Puts("Hello World loaded!");
}
[ChatCommand("hello")]
void HelloCommand(BasePlayer player, string command, string[] args)
{
player.ChatMessage("Hello from your custom plugin!");
}
}
}
Drop this in oxide/plugins/ and it loads instantly. Players type /hello and get a message.
Hook System
Oxide provides hooks - events that fire when things happen in the game:
Player Hooks
void OnPlayerConnected(BasePlayer player)
{
PrintToChat($"{player.displayName} joined the server!");
}
void OnPlayerDisconnected(BasePlayer player, string reason)
{
Puts($"{player.displayName} left: {reason}");
}
object OnPlayerChat(BasePlayer player, string message)
{
// Return non-null to cancel the chat message
if (message.Contains("badword"))
return false;
return null;
}
Entity Hooks
void OnEntityBuilt(Planner plan, GameObject go)
{
BaseEntity entity = go.ToBaseEntity();
Puts($"Entity built: {entity.ShortPrefabName}");
}
void OnEntityDeath(BaseCombatEntity entity, HitInfo info)
{
if (entity is BasePlayer player)
Puts($"{player.displayName} was killed");
}
Configuration Files
Add persistent configuration:
class MyPlugin : RustPlugin
{
private Configuration config;
class Configuration
{
public string WelcomeMessage = "Welcome to the server!";
public int MaxHomes = 3;
public float TeleportCooldown = 60f;
}
protected override void LoadDefaultConfig()
{
config = new Configuration();
}
protected override void LoadConfig()
{
base.LoadConfig();
config = Config.ReadObject<Configuration>();
}
protected override void SaveConfig()
{
Config.WriteObject(config);
}
}
This creates a JSON config in oxide/config/MyPlugin.json that server admins can edit.
Permissions
Integrate with Oxide's permission system:
void Init()
{
permission.RegisterPermission("myplugin.use", this);
permission.RegisterPermission("myplugin.admin", this);
}
[ChatCommand("mycommand")]
void MyCommand(BasePlayer player, string command, string[] args)
{
if (!permission.UserHasPermission(player.UserIDString, "myplugin.use"))
{
player.ChatMessage("You don't have permission.");
return;
}
// Command logic here
}
Data Storage
Save persistent data (survives server restarts):
private Dictionary<ulong, PlayerData> playerData;
class PlayerData
{
public int Kills;
public int Deaths;
public List<string> Homes = new List<string>();
}
void Init()
{
playerData = Interface.Oxide.DataFileSystem
.ReadObject<Dictionary<ulong, PlayerData>>("MyPluginData")
?? new Dictionary<ulong, PlayerData>();
}
void SaveData()
{
Interface.Oxide.DataFileSystem.WriteObject("MyPluginData", playerData);
}
Testing
- Write your plugin on your local machine
- Upload to a test server's
oxide/plugins/ - Watch the server console for compilation errors
- Test commands and hooks in-game
- Check
oxide/logs/for detailed error messages
Use a dedicated test server on Space-Node - the Stone plan (€10.20/mo) is perfect for development and testing.
Publishing
Share your plugin on umod.org:
- Create an account
- Submit your plugin with documentation
- Include configuration examples
- Respond to user feedback and bug reports
The Oxide/uMod community is active and appreciative of well-documented, well-tested plugins.
