Skip to Content
ResourcesChatEventschat:addTemplate: Register Trusted Chat Markup
Report an error
Open in ChatGPTOpen in Claude

chat:addTemplate

Context: client-side display configuration. The event accepts (templateID, htmlString). Register a unique template name and refer to it using templateId in the message object. The message’s separate template field is inline markup, not a registered ID.

-- client.lua, after the stock chat resource is available. TriggerEvent('chat:addTemplate', 'fd_workshop_note', '<strong>{0}</strong>: {1}') TriggerEvent('chat:addMessage', { templateId = 'fd_workshop_note', args = { 'Workshop', 'Preview complete; no server setting changed.' } })

The markup above is a developer-controlled constant. Put content in args; do not construct HTML by concatenating user names or chat text into a template string. For custom themes or replacement chat implementations, review their escaping behavior rather than assuming every renderer treats text identically.

Re-register templates when the provider is restarted if your resource depends on them; a consumer starting before chat or registering a name already used by another resource can produce confusing results. Test one message, restart chat in development and confirm the template is restored before claiming restart compatibility.

Source: official chat:addTemplate documentation . Related: message fields and stock-event contracts.