SA:MP Диалог окна arizona

ArizonaM

Участник
Автор темы
71
35
Помогите как сделать что бы он нормально отыскивал и принимал обычные объявление. Нормально скипал если нету объявлений. У меня он открывает нормально 1 окно, второе окно, но когда есть объявление которые нужно отредактировать то он ниче не делает.


Lua:
Function samp.onShowDialog(id, style, title, btn1, btn2, text)
if not ui.skip_on[0] then return end
if stat.busy and not clean(title):lower():find("редактирование") then return end
local currentTime = os.clock()
if id == lastDialogId and (currentTime - lastProcessTime) < 0.1 then
return false
end
local title_c = clean(title):lower()
local clean_text = clean(text)
local text_l = clean_text:lower()
if title_c:find("редак") and (text_l:find("сообщений%s+нет") or text_l:find("нет%s+объявлений")) then
lastDialogId = id
lastProcessTime = os.clock()
lua_thread.create(function()
wait(60)
setVirtualKeyDown(27, true)
wait(60)
setVirtualKeyDown(27, false)
sampSendDialogResponse(id, 0, 0, "")
stat.ready = true
stat.busy = false
end)
return false
end
if id == 25896 or title_c:find("редактирование объявлений") then
lastDialogId = id
lastProcessTime = os.clock()
lua_thread.create(function()
wait(100)
sampSendDialogResponse(id, 1, 0, "")
end)
return false
end
if id == 556 or ((title_c:find("редакция") or title_c == "редак") and text_l:find("тип объявления")) then
local found_idx = -1
local current_row = 0
for line in text:gmatch("[^\r\n]+") do
local lc = clean(line):lower()
if not lc:find("отправитель") and not lc:find("время") and not lc:find("тип объявления") then
if lc:find("обычн") and not lc:find("vip") and not lc:find("в редакции") then
found_idx = current_row
break
end
current_row = current_row + 1
end
end
lastDialogId = id
lastProcessTime = os.clock()
if found_idx ~= -1 then
lua_thread.create(function()
wait(20)
sampSendDialogResponse(id, 1, found_idx, "")
end)
else
lua_thread.create(function()
wait(50)
setVirtualKeyDown(27, true)
wait(60)
setVirtualKeyDown(27, false)
sampSendDialogResponse(id, 0, 0, "")
stat.ready = true
stat.busy = false
end)
end
return false
end
if (id == 557) or (title_c:find("редактирование") and (style == 1 or text_l:find("сообщение:"))) then
if stat.busy then return false end
local msg = clean_text:match("[Сс]ообщение:%s*(.-)%s*\n\n") or
clean_text:match("[Сс]ообщение:%s*(.-)%s*\n") or
clean_text:match("[Сс]ообщение:%s*(.+)")
if not msg or msg == "" then
stat.ready = true
return true
end
stat.busy = true
lastDialogId = id
lastProcessTime = os.clock()
if ui.use_cache[0] and cache[msg] then
local res = cache[msg]
local low = res:lower()
local is_fail = low:find("отказано") or low:find("причина")
lua_thread.create(function()
wait(ui.delay_on[0] and ui.delay_ms[0] or 400)
sampSendDialogResponse(id, is_fail and 0 or 1, 0, res)
stat.ready = true
stat.busy = false
end)
return false
end

Вот по этому коду делал
Lua:
local sampev = require "lib.samp.events"
function sampev.onShowDialog(id, style, title, button1, button2, text)
local styleName = ({
[0] = "DIALOG_STYLE_MSGBOX",
[1] = "DIALOG_STYLE_INPUT",
[2] = "DIALOG_STYLE_LIST",
[3] = "DIALOG_STYLE_PASSWORD",
[4] = "DIALOG_STYLE_TABLIST",
[5] = "DIALOG_STYLE_TABLIST_HEADERS"
})[style] or ("UNKNOWN_STYLE_"..style)
local formattedText = text:gsub("\", "\\"):gsub(""", "\""):gsub("\n", "\n\\n"):gsub("\t", "\t")
local dialogCode = string.format(
"ShowPlayerDialog(playerid, %d, %s, "%s",\n"%s",\n"%s", "%s");",
id, styleName, title:gsub(""", "\""),
formattedText,
button1:gsub(""", "\""), button2:gsub(""", "\"")
)
print("=== FULL DIALOG CODE ===")
print(dialogCode)
local logFile = io.open('dialog_codes.log', 'a+')
logFile:write(dialogCode .. "\n\n")
logFile:close()
end
 
Последнее редактирование: