subclasses.lua
local PromptWithCooldown = Uiprompt()
function PromptWithCooldown:new(controls, text, cooldown, group, enabled)
local self = Uiprompt.new(self, controls, text, group, enabled)
self.cooldown = cooldown
return self
end
function PromptWithCooldown:startCooldown()
self:setEnabled(false)
local text = self:getText()
Citizen.CreateThread(function()
for secs = self.cooldown, 1, -1 do
self:setText(text .. " (" .. secs .. "s)")
Citizen.Wait(1000)
end
self:setText(text)
self:setEnabled(true)
end)
end
local TestPrompt = PromptWithCooldown()
function TestPrompt:new(controls, text, cooldown, group, enabled)
local self = PromptWithCooldown.new(self, controls, text, cooldown, group, enabled)
self:setHoldMode(true)
return self
end
function TestPrompt:onHoldModeJustCompleted()
TriggerEvent("chat:addMessage", {args = {"Held " .. self:getText() .. "!"}})
self:startCooldown()
end
local promptGroup = UipromptGroup:new("Test")
local prompt1 = TestPrompt:new(`INPUT_DYNAMIC_SCENARIO`, "Test 1", 5, promptGroup)
local prompt2 = TestPrompt:new(`INPUT_RELOAD`, "Test 2", 10, promptGroup)
UipromptManager:startEventThread()