How to do a chat command


#1

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


#2

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)

#3

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

end)

Instead…


#4

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


#5

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.