Files
ox_lib/resource/interface/client/input.lua

34 lines
616 B
Lua
Raw Normal View History

2022-04-18 23:30:58 +10:00
local input
2022-04-11 15:26:10 +02:00
function lib.inputDialog(heading, rows)
if input then return end
input = promise.new()
2022-05-02 13:51:01 +02:00
-- 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
2022-04-11 15:26:10 +02:00
SetNuiFocus(true, true)
SendNUIMessage({
action = 'openDialog',
data = {
heading = heading,
2022-05-02 13:51:01 +02:00
rows = rows
2022-04-11 15:26:10 +02:00
}
})
2022-04-18 23:30:58 +10:00
2022-04-11 15:26:10 +02:00
return Citizen.Await(input)
end
RegisterNUICallback('inputData', function(data, cb)
cb(1)
if not input then return end
if not data then input:resolve() else input:resolve(data) end
SetNuiFocus(false, false)
input = nil
end)