Files
ox_lib/resource/interface/client/input.lua
Luke 82d052a1bb fix(client/interface): cache input promise
Caching the promise into a variable allows us to set input to nil and resolve the promise after, which fixes an issue with opening 2 input dialogs back to back
2022-08-17 23:42:36 +02:00

34 lines
569 B
Lua

local input
function lib.inputDialog(heading, rows)
if input then return end
input = promise.new()
-- Backwards compat with string tables
for i = 1, #rows do
if type(rows[i]) == 'string' then
rows[i] = {type = 'input', label = rows[i]}
end
end
SetNuiFocus(true, true)
SendNUIMessage({
action = 'openDialog',
data = {
heading = heading,
rows = rows
}
})
return Citizen.Await(input)
end
RegisterNUICallback('inputData', function(data, cb)
cb(1)
SetNuiFocus(false, false)
local promise = input
input = nil
promise:resolve(data)
end)