OnPlayerCommand
OxideCarbonPlayerCalled when a server console command is executed.
Useful for auditing or overriding server-side console commands.
object OnPlayerCommand(BasePlayer player, string command, string[] args)Parameters
- player
- BasePlayer
- command
- string
- args
- string[]
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnPlayerCommand(BasePlayer player, string command, string[] args)
{
Puts("OnPlayerCommand");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Where it is called
Oxide core (Oxide.Rust)
RustCore::TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)
Oxide core code — the hook is called from here
// …
if (!basePlayer.IsConnected)
{
Interface.CallHook("OnApplicationCommand", basePlayer, cmd, args);
Interface.CallHook("OnApplicationCommand", basePlayer.IPlayer, cmd, args);
return;
}
// Is the command blocked?
object commandSpecific = Interface.CallHook("OnPlayerCommand", basePlayer, cmd, args);
object commandCovalence = Interface.CallHook("OnUserCommand", basePlayer.IPlayer, cmd, args);
object canBlock = commandSpecific is null ? commandCovalence : commandSpecific;
if (canBlock != null)
{
return;
}
try
// …Injection point
Carbon
Carbon.Core.CorePlugin.IOnPlayerCommand
Inside CarbonCarbon.Common
Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.