local ev = require 'lib.samp.events'
local lastDialogText = ""
local dialogOpenTime = nil
function onDialogResponse(dialogId, button, listitem, inputtext)
resetText()
end
function ev.onShowDialog(id, style, title, button1, button2, text)
dialogOpenTime = os.time()
end
function resetText()
lastDialogText = sampGetDialogText()
end
function main()
while not isSampAvailable() do wait(0) end
while true do
wait(0)
local dialogId, dialogText = sampGetCurrentDialogId(), sampGetDialogText()
if dialogId ~= nil and dialogText ~= nil then
if dialogText ~= lastDialogText then
resetText()
elseif dialogOpenTime ~= nil then
if os.difftime(os.time(), dialogOpenTime) >= 10 then
sampCloseCurrentDialogWithButton(0)
dialogOpenTime = nil
dialogText = nil
end
end
else
dialogOpenTime = nil
lastDialogText = ""
end
end
end