sendNuiMessage
Client
Sends a message to the interface page of the calling resource. The page receives it in the window's message event.
bool sendNuiMessage(table|string message)
Parameters
| Name | Type | Description |
|---|---|---|
| message | table|string | A table, sent as JSON, or a string already in JSON. |
Returns
true if the message was sent. false if the resource shows no page or the message is neither a table nor a string (logs a warning).
It only works if the resource declares a page with <ui src="..."> in its meta.xml. A message sent before the page has loaded waits and is delivered once it loads.
Example
addCommandHandler("hud", function()
sendNuiMessage({ action = "show", money = 2500 })
end)NoteA string reaches the page exactly as written, so it must be valid JSON.