introzen 2 Posted March 29 (edited) It would be nice to have a ServerEvent triggered when a player enters a command. Currently there seems to be one only on client-side, which is dangerous to use for permission checks etc. While the wiki actually covers the server-side event in JS, it doesn't seem to exist in C#. Edited March 29 by introzen Share this post Link to post Share on other sites
robearded 21 Posted March 29 https://wiki.gtanet.work/index.php?title=Getting_Started_with_Commands Share this post Link to post Share on other sites
introzen 2 Posted March 29 Just now, robearded said: https://wiki.gtanet.work/index.php?title=Getting_Started_with_Commands Not what I mean. I'm looking for an event that is triggered everytime a player sends a command, which can be used to intercept the command before it executes it's method. Share this post Link to post Share on other sites
robearded 21 Posted March 29 23 minutes ago, introzen said: Not what I mean. I'm looking for an event that is triggered everytime a player sends a command, which can be used to intercept the command before it executes it's method. This is literally what i gave you. The server side command event that you gonna use to register your commands and to process what's done when player types the command. It's the equivalent of the playerCommand(the wiki link you posted). Share this post Link to post Share on other sites
introzen 2 Posted March 29 (edited) 30 minutes ago, robearded said: This is literally what i gave you. The server side command event that you gonna use to register your commands and to process what's done when player types the command. It's the equivalent of the playerCommand(the wiki link you posted). Then can you please let me know how I can utilize that to make an OnPlayerCommand event server-side in C#? Each time a player writes a command (no specific command, just a command), the method OnPlayerCommand should be called. Thanks in advance! Edited March 29 by introzen Share this post Link to post Share on other sites
robearded 21 Posted March 29 2 hours ago, introzen said: Then can you please let me know how I can utilize that to make an OnPlayerCommand event server-side in C#? Each time a player writes a command (no specific command, just a command), the method OnPlayerCommand should be called. Thanks in advance! You have to register commands in server-side C#. If you want to get any command, then try catching the event 'chatMessage' cause that is what the rage.mp chat calls when the message starts with '/' (command) Share this post Link to post Share on other sites
introzen 2 Posted March 29 16 minutes ago, robearded said: You have to register commands in server-side C#. If you want to get any command, then try catching the event 'chatMessage' cause that is what the rage.mp chat calls when the message starts with '/' (command) Already tried it. Server-event ChatMessage isn't triggered when the message starts with /. Share this post Link to post Share on other sites
robearded 21 Posted March 29 (edited) 3 minutes ago, introzen said: Already tried it. Server-event ChatMessage isn't triggered when the message starts with /. Sorry, i gave the wrong event. Here is the event triggered by the chat browser when message starts with /: "command" (without ") Catch it like any other custom event sent from your client script to your server script (using RemoteEvent) If that doesn't works try catching the same event as you would do on javascript ('playerCommand') using the same method (RemoteEvent) Edited March 29 by robearded Share this post Link to post Share on other sites
introzen 2 Posted March 29 1 minute ago, robearded said: Sorry, i gave the wrong event. Here is the event triggered by the chat browser when message starts with /: "command" (without ") No worries, however it doesn't seem to be accessable from the API. [ServerEvent(Event.command)] public void OnPlayerCommand(Client player, string cmdText) { player.SendChatMessage("You wrote a command"); } 'Event' does not contain a definition for 'command' That is what I get... Share this post Link to post Share on other sites
robearded 21 Posted March 29 (edited) 10 minutes ago, introzen said: No worries, however it doesn't seem to be accessable from the API. [ServerEvent(Event.command)] public void OnPlayerCommand(Client player, string cmdText) { player.SendChatMessage("You wrote a command"); } 'Event' does not contain a definition for 'command' That is what I get... You have to catch it as custom event, not like normal server events. [RemoteEvent("command")] if not working with 'command' try with 'playerCommand' Edited March 29 by robearded Share this post Link to post Share on other sites