introzen Posted March 29, 2019 Posted March 29, 2019 (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, 2019 by introzen
robearded Posted March 29, 2019 Posted March 29, 2019 https://wiki.gtanet.work/index.php?title=Getting_Started_with_Commands
introzen Posted March 29, 2019 Author Posted March 29, 2019 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.
robearded Posted March 29, 2019 Posted March 29, 2019 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).
introzen Posted March 29, 2019 Author Posted March 29, 2019 (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, 2019 by introzen
robearded Posted March 29, 2019 Posted March 29, 2019 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)
introzen Posted March 29, 2019 Author Posted March 29, 2019 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 /.
robearded Posted March 29, 2019 Posted March 29, 2019 (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, 2019 by robearded
introzen Posted March 29, 2019 Author Posted March 29, 2019 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...
robearded Posted March 29, 2019 Posted March 29, 2019 (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, 2019 by robearded
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now