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)Параметры
- player
- BasePlayer
- command
- string
- args
- string[]
Возвращаемое значение
objectВерните не null, чтобы отменить действие игры.
Пример
object — можно повлиять на игру: вернуть значение, чтобы изменить или отменить действие.
private object OnPlayerCommand(BasePlayer player, string command, string[] args)
{
Puts("OnPlayerCommand");
// ничего не меняем — игра продолжит как обычно
return null;
// повлиять на игру:
// return false; // не null — действие игры отменяется
}Работает и в Oxide, и в Carbon: Carbon загружает плагины Oxide без изменений.
Где вызывается
ядро Oxide (Oxide.Rust)
RustCore::TryRunPlayerCommand(BasePlayer basePlayer, string message, string commandPrefix)
Код ядра Oxide — отсюда вызывается хук
// …
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
// …Место встраивания
Carbon
Carbon.Core.CorePlugin.IOnPlayerCommand
Внутри CarbonCarbon.Common
Источники: Rust.opj из OxideMod/Oxide.Rust (MIT) и метаданные хуков документации Carbon (MIT). Код методов — декомпиляция сервера этой ветки.