Coming from Oxide
Most Rust Legacy plugins were written for Oxide. Porting one is mostly renaming: a NetUser becomes a RustPlayer, a
hook or a library call becomes the line below.
| Oxide (Rust Legacy) | Here |
|---|---|
Init(), Loaded(), OnServerInitialized() |
OnLoaded() (the server is already running) |
Unload() |
OnUnloaded() (commands and timers go away by themselves) |
LoadDefaultConfig(), Config["key"] |
LoadConfig<T>(): a class with default values, written to plugins/config/<Name>.json |
Interface.GetMod().DataFileSystem |
LoadData<T>(), SaveData( data ) |
[ChatCommand( "name" )], cmd.AddChatCommand |
AddCommand( "name", cmd => ..., "help" ) |
CanClientLogin, OnUserApprove |
CanConnect( c ): return the refusal text |
OnPlayerConnected( NetUser ), OnPlayerDisconnected |
OnPlayerConnected( player ), OnPlayerDisconnected( player ) |
OnPlayerSpawn |
OnPlayerRespawn (choose where), OnPlayerRespawned (after) |
OnPlayerChat( NetUser, string ) |
OnPlayerChat( player, message ): return "" to block, a text to replace |
OnHurt, OnKilled |
CanTakeDamage and OnPlayerDeath for players, CanDamageBuilding for buildings and objects |
OnStructureBuilt, OnItemDeployed |
OnBuilt( player, placed ), and CanBuild before it |
OnDoorToggle |
CanUseDoor( player, door ) |
OnItemCraft |
CanCraft( player, item, amount ) |
OnAirdrop( Vector3 ) |
OnAirdrop( crate ): crate.WorldPosition |
| (no Oxide hook) | OnGather, CanSpawnAnimal, CanDropDeathBag, OnDeployableUse, the vehicle hooks (Legacy had no cars) |
rust.SendChatMessage, SendReply |
Reply( player, text ) |
rust.BroadcastChat |
Broadcast( text ) |
rust.Notice, rust.InventoryNotice |
player.Notify( text ) |
rust.FindPlayer, rust.UserIDFromPlayer |
FindPlayer( nameOrSteamId ), player.SteamId |
timer.Once, timer.Repeat, NextFrame |
After( seconds, ... ), Every( seconds, ... ), After( 0, ... ) |
permission.RegisterPermission, UserHasPermission, groups |
RegisterPermission, HasPermission, CreateGroup, AddToGroup… (section 1) |
webrequest.EnqueueGet |
Not available: plugins cannot reach the internet |
OnStructureDecay, OnRunCommand, OnResearchItem, OnItemAdded, loot tables |
Not yet. Decay has its server settings (rl_decay, rl_decay_rate), loot its scale (rl_loot_scale_min) |