mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
Using the same promise type of API that the input dialog is using, if the user closes the dialog via esc or the cancel button the promise will resolve `cancel` otherwise the promise will resolve `confirm`
24 lines
445 B
Lua
24 lines
445 B
Lua
local alert = nil
|
|
|
|
function lib.alertDialog(data)
|
|
if alert then return end
|
|
alert = promise.new()
|
|
|
|
SetNuiFocus(true, true)
|
|
SendNUIMessage({
|
|
action = 'sendAlert',
|
|
data = data
|
|
})
|
|
|
|
return Citizen.Await(alert)
|
|
end
|
|
|
|
RegisterNUICallback('closeAlert', function(data, cb)
|
|
cb(1)
|
|
SetNuiFocus(false, false)
|
|
alert:resolve(data)
|
|
alert = nil
|
|
end)
|
|
|
|
RegisterNetEvent('ox_lib:alertDialog', lib.alertDialog)
|