local WARNING_BUTTONS = {
["SELECT"] = {2^0, 201},
["OK"] = {2^1, 201},
["YES"] = {2^2, 201},
["BACK"] = {2^3, 202},
["CANCEL"] = {2^4, 202},
["NO"] = {2^5, 202},
["RETRY"] = {2^6, 203},
["RESTART"] = {2^7, 203},
["SKIP"] = {2^8, 203},
["QUIT"] = {2^9, 202},
["ADJUST"] = {2^10, 0},
["BLANK"] = {2^11, 203},
["SHARE"] = {2^12, 203},
["SIGNIN"] = {2^13, 203},
["CONTINUE"] = {2^14, 201},
["ADJUST2"] = {2^15, 0},
["SCROLL"] = {2^16, 0},
["OVERWRITE"] = {2^17, 203},
["SOCIALCLUB_SIGNUP"] = {2^18, 201},
["CONFIRM2"] = {2^19, 201},
["QUEUE"] = {2^20, 201},
["RETRY_A"] = {2^21, 201},
["BACK2"] = {2^22, 202},
["SOCIALCLUB"] = {2^23, 201},
["SPECTATE"] = {2^24, 203},
["OK_B"] = {2^25, 202},
["TRANSFER_CANCEL"] = {2^26, 202},
["LOADING"] = {2^27, 0},
["NO_RETURN_TO_GTAV"] = {2^28, 202},
["CANCEL2"] = {2^29, 202},
["BLANK2"] = {2^30, 0},
["JOBS"] = {2^31, 0},
}
for _, v in next, WARNING_BUTTONS do
v[1] = math.floor(v[1])
end
local PROMPT_QUEUE = {}
function ShowPrompt(header, line1, line2, buttons)
table.insert(PROMPT_QUEUE, {header, line1, line2, buttons})
if #PROMPT_QUEUE > 1 then
-- print("Put prompt in queue")
return true
end
_sp(header, line1, line2, buttons)
end
function _sp(header, line1, line2, buttons)
local funcs = {}
local inst_no = 0
for _, button in next, buttons do
local btn_data = WARNING_BUTTONS[button[1]]
if btn_data then
-- print("Button Data for " .. button[1] .. ": " .. json.encode(btn_data))
inst_no = inst_no + btn_data[1]
table.insert(funcs, {
button[1],
btn_data[2],
button[2],
})
else
-- Button entry no existu
end
end
AddTextEntry("OMNI_PMT1", line1)
AddTextEntry("OMNI_PMT2", line2)
AddTextEntry("OMNI_PMTH", header)
if inst_no > 0 then
local _show = true
local _t = 0
local _w = 4
while _show or _w > 0 do
if _t > 2 and _show then
for _, func in next, funcs do
if IsControlJustPressed(2, func[2]) then
-- print("Pressed " .. func[1])
func[3]()
_show = false
_t = 0
break
end
end
end
SetWarningMessage_3("OMNI_PMTH", "OMNI_PMT1", inst_no, "OMNI_PMT2", false, 0, 0, 0, false)
Wait(0)
_t = _t + 1
if not _show then
_w = _w - 1
end
end
end
table.remove(PROMPT_QUEUE, 1)
if #PROMPT_QUEUE > 0 then
-- print("Next prompt in queue")
_sp(PROMPT_QUEUE[1][1], PROMPT_QUEUE[1][2], PROMPT_QUEUE[1][3], PROMPT_QUEUE[1][4])
end
end
AddEventHandler("omni:prompt", function(header, line1, line2, _buttons)
local buttons = {}
for _, button in next, _buttons do
if button[2] == "" or not button[2] then
table.insert(buttons, {button[1], function() end})
else
table.insert(buttons, {button[1], function() TriggerEvent(button[2]) end})
end
end
ShowPrompt(header, line1, line2, buttons)
end)
RegisterCommand("dv", function()
ShowPrompt("/dv", "You are about to delete your vehicle!", "Are you sure you want to do this?", {
{"YES", function() TriggerEvent("gd_utils:notify", "Deleted vehicle!") end},
{"NO", function() TriggerEvent("gd_utils:notify", "Did not delete vehicle") end},
{"LOADING", function() TriggerEvent("gd_utils:notify", "wtf") end},
})
end, false)
RegisterCommand("afk", function()
ShowPrompt("AFK", "You are currently Away From Keyboard", "Press Continue to resume gameplay", {
{"CONTINUE", function() TriggerEvent("gd_utils:notify", "Welcome back!") end},
})
end, false)
Comments