Client Usage

This demonstrates how the user would send data to the UI, and receive data from the UI.

Register the UI in client.lua

Add a command to open your UI:

RegisterCommand('openui', function()
    SendNuiMessage(json.encode({ action = 'setDisplay' }))
    SetNuiFocus(true, true)
end)

Handle UI Close in client.lua

RegisterNUICallback('closeUI', function(data, cb)
    SetNuiFocus(false, false)
    SendNUIMessage({ action = "hideUI" })
    cb(json.encode({ success = true }))
end)

Now, clicking the close button will hide the UI and remove focus.