How to do a chat command


How would I do if (command is typed in chat) than do this


Make a folder

Add a __resource.lua file containing.

client_script 'client.lua

Then create a client.lua containing

RegisterCommand("", function(source, args, rawCommand)
    -- TriggerEvent Here
end, false)


The false is not 100% needed unless you whitelist the command.
I would use




Well yeah I suppose, but I just have a habbit of using it as most of my commands needs whitelisting :joy:


it’s not required in lua, but it is when using c#.

Also, just because it’s not required it’s never a bad idea to just add it anyway to be clear that it’s not restricted. That way (when debugging, especially someone else’s code) it’s easy to spot which commands are whitelisted/restricted (true) and which ones aren’t (false). It’s not bad, just better to include it imo.