πŸ“ƒExtra

In this section, you will learn how to create custom commands that send messages to JGS Chat. You can do this on the client side or server side, depending on your needs.

circle-info

If the command depends on permissions, inventory, money, database, or any β€œserious” verification, do it on the server side.

1. Basic Command Example

Below is the simplest possible command using RegisterCommand and addMessage.

RegisterCommand('helloworld', function(source, args)
    TriggerEvent('chat:addMessage', {
        template = [[
            <div class="cmd-box">
                <div class="cmd-item color-do">{0}</div> 
                <div class="cmd-item color-do">ID {1}</div> 
                <div class="cmd-item color-do">{2}</div> 
                <div class="cmd-text">{3}</div>  
            </div>
        ]],
        args = {
            'System',
            PlayerId(),
            GetPlayerName(PlayerId()),
            table.concat(args, ' ')
        }
    })
end, false)

Last updated

Was this helpful?