diff --git a/resources/Rust.opj b/resources/Rust.opj index c447b54f1..05fa47dc0 100644 --- a/resources/Rust.opj +++ b/resources/Rust.opj @@ -19014,30 +19014,7 @@ { "Type": "Simple", "Hook": { - "InjectionIndex": 86, - "ReturnBehavior": 0, - "ArgumentBehavior": 4, - "ArgumentString": "this.player, this.message", - "HookTypeName": "Simple", - "Name": "IOnPlayerCommand", - "HookName": "IOnPlayerCommand", - "AssemblyName": "Assembly-CSharp.dll", - "TypeName": "ConVar.Chat/d__18", - "Flagged": false, - "Signature": { - "Exposure": 0, - "Name": "MoveNext", - "ReturnType": "System.Void", - "Parameters": [] - }, - "MSILHash": "iYnKlc55a6+MPJFdD5TPPrlc3MCC9S8TqbfO9DTb0xQ=", - "HookCategory": "Player" - } - }, - { - "Type": "Simple", - "Hook": { - "InjectionIndex": 101, + "InjectionIndex": 76, "ReturnBehavior": 3, "ArgumentBehavior": 4, "ArgumentString": "this.userId, this.username, this.5__2, this.targetChannel, this.player => l1", @@ -19054,20 +19031,19 @@ "Parameters": [] }, "MSILHash": "iYnKlc55a6+MPJFdD5TPPrlc3MCC9S8TqbfO9DTb0xQ=", - "BaseHookName": "IOnPlayerCommand", "HookCategory": "Player" } }, { "Type": "Modify", "Hook": { - "InjectionIndex": 123, + "InjectionIndex": 98, "RemoveCount": 0, "Instructions": [ { "OpCode": "leave", "OpType": "Instruction", - "Operand": 810 + "Operand": 803 } ], "HookTypeName": "Modify", @@ -19090,13 +19066,13 @@ { "Type": "Modify", "Hook": { - "InjectionIndex": 119, + "InjectionIndex": 94, "RemoveCount": 1, "Instructions": [ { "OpCode": "beq_s", "OpType": "Instruction", - "Operand": 124 + "Operand": 99 } ], "HookTypeName": "Modify", diff --git a/src/RustHooks.cs b/src/RustHooks.cs index dca414788..c8121515c 100644 --- a/src/RustHooks.cs +++ b/src/RustHooks.cs @@ -286,6 +286,16 @@ private object IOnPlayerChat(ulong playerId, string playerName, string message, return true; } + // Check if chat command + string chatCommandPrefix = CommandHandler.GetChatCommandPrefix(message); + if ( chatCommandPrefix != null ) + { + TryRunPlayerCommand( basePlayer, message.Substring( chatCommandPrefix.Length ) ); + return false; + } + + message = message.EscapeRichText(); + // Check if using Rust+ app if (basePlayer == null || !basePlayer.IsConnected) { @@ -305,8 +315,7 @@ private object IOnPlayerChat(ulong playerId, string playerName, string message, /// /// /// - [HookMethod("IOnPlayerCommand")] - private void IOnPlayerCommand(BasePlayer basePlayer, string message) + private void TryRunPlayerCommand(BasePlayer basePlayer, string message) { if (basePlayer == null) { @@ -316,13 +325,13 @@ private void IOnPlayerCommand(BasePlayer basePlayer, string message) string str = message.Replace("\n", "").Replace("\r", "").Trim(); // Check if it is a chat command - if (string.IsNullOrEmpty(str) || str[0] != '/' || str.Length <= 1) + if (string.IsNullOrEmpty(str)) { return; } // Parse the command - ParseCommand(str.TrimStart('/'), out string cmd, out string[] args); + ParseCommand(str, out string cmd, out string[] args); if (cmd == null) { return;