π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.
1. Basic Command Example
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)RegisterCommand('helloworld', function(source, args)
TriggerClientEvent('chat:addMessage', source, {
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',
source,
GetPlayerName(source),
table.concat(args, ' ')
}
})
end, false)Last updated