OnUserChat
OxideCarbonPlayerCalled when an user chats.
void OnUserChat(Oxide.Core.Libraries.Covalence.IPlayer player, string message)Works — the game method in this build is the one the hook was written for.
Parameters
- player
- Oxide.Core.Libraries.Covalence.IPlayer
- message
- string
Return value
voidBehaviour is not described.
Example
private void OnUserChat(Oxide.Core.Libraries.Covalence.IPlayer player, string message)
{
Puts("OnUserChat");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Where it is called
Oxide core (Oxide.Rust)
RustCore::IOnPlayerChat(ulong playerId, string playerName, string message, Chat.ChatChannel channel, BasePlayer basePlayer)
Oxide core code — the hook is called from here
// …
if (basePlayer == null || !basePlayer.IsConnected)
{
// Call offline chat hook
return Interface.CallHook("OnPlayerOfflineChat", playerId, playerName, message, channel);
}
// Call hooks for plugins
object chatSpecific = Interface.CallHook("OnPlayerChat", basePlayer, message, channel);
object chatCovalence = Interface.CallHook("OnUserChat", basePlayer.IPlayer, message);
return chatSpecific is null ? chatCovalence : chatSpecific;
}Injection point
Rust.opj (Oxide)
void ConVar.Chat.<sayAs>d__22.MoveNext()
Injected internal hook IOnPlayerChat — this hook is called by its handler in the Oxide/Carbon core
WorksReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (this.userId, this.username, this.<strChatText>5__2, this.targetChannel, this.player => l1)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
if (<strChatText>5__2.Length > 128)
{
<strChatText>5__2 = <strChatText>5__2.Substring(0, 128);
}
if (<strChatText>5__2.Length <= 0)
{
result = false;
}
Interface.CallHook("IOnPlayerChat", this.userId, this.username, this.<strChatText>5__2, this.targetChannel, this.player => l1);
else if (<strChatText>5__2.StartsWith("/") || <strChatText>5__2.StartsWith("\\"))
{
result = false;
}
else
{
<strChatText>5__2 = <strChatText>5__2.EscapeRichText();
if (!Server.emojiOwnershipCheck || !<strChatText>5__2.Contains(":") || !(player != null))
// …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.