progressbar and dialogue update

added props to progressbar
fixed dialogue for nesting
This commit is contained in:
gononono64 committed 2025-02-22 06:42:11 -06:00
1 parent 58782dfcd0
commit f8d46b9f7b
7 files changed
+85 -121

No files matched your search

+42 -3
View File
@@ -1,17 +1,32 @@
local promises = {}
function CloseDialogue(name)
SendNUIMessage({
type = "close",
name = name
})
promises[name] = nil
end
--- Open a dialogue with the player
--- @param name string
--- @param dialogue string
--- @param options table example = {{ id = string, label = string}}
function OpenDialogue(name, dialogue, options)
function OpenDialogue(name, dialogue, options, onSelected, onCancelled)
SendNUIMessage({
type = "open",
text = dialogue,
name = name,
options = options
})
SetNuiFocus(true, true)
local wrappedFunction = function(selected)
SetNuiFocus(false, false)
CloseDialogue(name)
onSelected(selected)
end
promises[name] = wrappedFunction
end
RegisterCommand("dialogue", function()
@@ -23,11 +38,35 @@ RegisterCommand("dialogue", function()
{
label = "Goodbye",
id = 'someotherthing',
}
}
},
},
function(selectedId)
if selectedId == 'something' then
OpenDialogue( "Akmed" , "Thank you for wanting to purchase me lucky charms", {
{
label = "fuck russia",
id = 'something',
},
{
label = "Goodbye",
id = 'someotherthing',
},
},
function(selectedId)
print("fuck russia:", selectedId)
end
)
end
end
)
end)
RegisterNuiCallback("dialogue:SelectOption", function(data)
print("Selected option: " .. data.name)
local promis = promises[data.name]
if not promis then return end
promis(data.id)
end)
-- { label: 'Hello there! this is some long text that i am Dialogueing', id: '1' },
-- { label: 'Trade with me', id: '2' },