From ff71a7d033be133b809cabef2934d0f9cdd63faa Mon Sep 17 00:00:00 2001 From: Luke Date: Mon, 11 Apr 2022 15:26:10 +0200 Subject: [PATCH] feat(client): Input dialog function --- resource/interface/client/input.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 resource/interface/client/input.lua diff --git a/resource/interface/client/input.lua b/resource/interface/client/input.lua new file mode 100644 index 0000000..d1f03d0 --- /dev/null +++ b/resource/interface/client/input.lua @@ -0,0 +1,22 @@ +function lib.inputDialog(heading, rows) + if input then return end + input = promise.new() + + SetNuiFocus(true, true) + SendNUIMessage({ + action = 'openDialog', + data = { + heading = heading, + inputs = rows + } + }) + 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)