- 148
- 15
- Версия MoonLoader
- .025-beta
Как в диалоге найти номер строчки, в которой название "{B0E73A}Вперед >>>"?
ой такая дичь. Хз. Мой код рабочий, осталось узнать как аризона работает. Играйся)
Это я уже понял, но не понял как реализовать. Нашел такой способ, но не понял, что тут под "123" подразумевается.поделить все на строки. проверить последний элемент на название, записать номер элемента и отнять один
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
local index = 0
for line in text:gmatch("[^\n]*\n?") do -- line будет включать также "\n" вконце строки
if title:match("123") then
if line:match("Ищем это") then
sampSendDialogResponse(dialogid, 1, index , -1)
break
end
index = index+1
end
end
end
Замени match на find, везде. 123 это заголовок диалогаЭто я уже понял, но не понял как реализовать. Нашел такой способ, но не понял, что тут под "123" подразумевается.
Lua:function sampev.onShowDialog(dialogId, style, title, button1, button2, text) local index = 0 for line in text:gmatch("[^\n]*\n?") do -- line будет включать также "\n" вконце строки if title:match("123") then if line:match("Ищем это") then sampSendDialogResponse(dialogid, 1, index , -1) break end index = index+1 end end end
Выдаёт смэрт.Замени match на find, везде. 123 это заголовок диалога
покажи 46 строкуВыдаёт смэрт.
[ML] (error) CheckListFam: ... GameWorld - GTA San Andreas\moonloader\checklistfam.lua:46: attempt to call a string value
[ML] (error) CheckListFam: Script died due to error. (210B9144)
ужас какой-то. я просил заменить только match, но не gmatch[ML] (error) CheckListFam: ... GameWorld - GTA San Andreas\moonloader\checklistfam.lua:51: attempt to call a number value
[ML] (error) CheckListFam: Script died due to error. (33EFE31C)
Посмотреть вложение 47133
Изменил на gmatch. Скрипт не умирает, но ничего не происходит.ужас какой-то. я просил заменить только match, но не gmatch
потому-что кидай код не картинкой а текстом. ПерепишуИзменил на gmatch. Скрипт не умирает, но ничего не происходит.
Кинул полностью функциюпотому-что кидай код не картинкой а текстом. Перепишу
function sampev.onShowDialog(id, style, title, button1, button2, text)
if check == 1 then
if id == 2920 then
lua_thread.create(function()
sampSendDialogResponse(id, 1, 2, -1)
end)
end
if id == 0 then
FileWrite = io.open(FileNameWrite, "w")
FileWrite:write(text)
sampAddChatMessage("OK", -100000)
sampCloseCurrentDialogWithButton(0)
lua_thread.create(function()
sampSendChat('/fammenu')
end)
check = 2
end
end
if check == 2 then
if id == 2920 then
lua_thread.create(function()
sampSendDialogResponse(id, 1, 3, -1)
end)
end
if id == 2931 then
lua_thread.create(function()
for line in text:gmatch("[^\n]*\n?") do -- line будет включать также "\n" вконце строки
if title:find("{BFBBBA}Участники семьи (оффлайн)") then
if line:find("{B0E73A}Вперед >>>") then
sampSendDialogResponse(id, 1, index , -1)
sampAddChatMessage("sasa", -100)
break
end
index = index+1
end
end
end)
end
end
end
Кинул полностью функцию
Lua:function sampev.onShowDialog(id, style, title, button1, button2, text) if check == 1 then if id == 2920 then lua_thread.create(function() sampSendDialogResponse(id, 1, 2, -1) end) end if id == 0 then FileWrite = io.open(FileNameWrite, "w") FileWrite:write(text) sampAddChatMessage("OK", -100000) sampCloseCurrentDialogWithButton(0) lua_thread.create(function() sampSendChat('/fammenu') end) check = 2 end end if check == 2 then if id == 2920 then lua_thread.create(function() sampSendDialogResponse(id, 1, 3, -1) end) end if id == 2931 then lua_thread.create(function() for line in text:gmatch("[^\n]*\n?") do -- line будет включать также "\n" вконце строки if title:find("{BFBBBA}Участники семьи (оффлайн)") then if line:find("{B0E73A}Вперед >>>") then sampSendDialogResponse(id, 1, index , -1) sampAddChatMessage("sasa", -100) break end index = index+1 end end end) end end end
function split(str, delim, plain)
local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
repeat
local npos, epos = string.find(str, delim, pos, plain)
table.insert(tokens, string.sub(str, pos, npos and npos - 1))
pos = epos and epos + 1
until not pos
return tokens
end
function sampev.onShowDialog(id, style, title, button1, button2, text)
if check == 1 then
if id == 2920 then
sampSendDialogResponse(id, 1, 2, -1)
end
if id == 0 then
FileWrite = io.open(FileNameWrite, "w")
FileWrite:write(text)
sampAddChatMessage("OK", -100000)
sampCloseCurrentDialogWithButton(0)
lua_thread.create(function()
sampSendChat('/fammenu')
end)
check = 2
end
end
if check == 2 then
if id == 2920 then
sampSendDialogResponse(id, 1, 3, -1)
end
if id == 2931 then
local tLines = split(text, "\n")
if tLines[#tLines]:find("{B0E73A}Вперед >>>", 1, true) then
sampSendDialogResponse(id, 1, #tLines-1 , "")
end
end
end
end
end
К сожалению, кнопка далее не нажалась, либо она не нашлась. (end лишний убрал)Lua:function split(str, delim, plain) local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]] repeat local npos, epos = string.find(str, delim, pos, plain) table.insert(tokens, string.sub(str, pos, npos and npos - 1)) pos = epos and epos + 1 until not pos return tokens end function sampev.onShowDialog(id, style, title, button1, button2, text) if check == 1 then if id == 2920 then sampSendDialogResponse(id, 1, 2, -1) end if id == 0 then FileWrite = io.open(FileNameWrite, "w") FileWrite:write(text) sampAddChatMessage("OK", -100000) sampCloseCurrentDialogWithButton(0) lua_thread.create(function() sampSendChat('/fammenu') end) check = 2 end end if check == 2 then if id == 2920 then sampSendDialogResponse(id, 1, 3, -1) end if id == 2931 then local tLines = split(text, "\n") if tLines[#tLines]:find("{B0E73A}Вперед >>>", 1, true) then sampSendDialogResponse(id, 1, #tLines-1 , "") end end end end end
К сожалению, кнопка далее не нажалась, либо она не нашлась. (end лишний убрал)
function split(str, delim, plain)
local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
repeat
local npos, epos = string.find(str, delim, pos, plain)
table.insert(tokens, string.sub(str, pos, npos and npos - 1))
pos = epos and epos + 1
until not pos
return tokens
end
function sampev.onShowDialog(id, style, title, button1, button2, text)
if check == 1 then
if id == 2920 then
sampSendDialogResponse(id, 1, 2, -1)
end
if id == 0 then
FileWrite = io.open(FileNameWrite, "w")
FileWrite:write(text)
sampAddChatMessage("OK", -100000)
sampCloseCurrentDialogWithButton(0)
sampSendChat('/fammenu')
check = 2
end
end
if check == 2 then
if id == 2920 then
sampSendDialogResponse(id, 1, 3, -1)
end
if id == 2931 then
local tLines = split(text, "\n")
if tLines[#tLines]:find("{B0E73A}Вперед >>>", 1, true) then
sampSendDialogResponse(id, 1, #tLines-1 , "")
end
end
end
end
Теперь окно диалога появляется и становиться неактивным (кнопки и строчки нажимаются, но не несут последствий) id диалога = 2931Lua:function split(str, delim, plain) local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]] repeat local npos, epos = string.find(str, delim, pos, plain) table.insert(tokens, string.sub(str, pos, npos and npos - 1)) pos = epos and epos + 1 until not pos return tokens end function sampev.onShowDialog(id, style, title, button1, button2, text) if check == 1 then if id == 2920 then sampSendDialogResponse(id, 1, 2, -1) end if id == 0 then FileWrite = io.open(FileNameWrite, "w") FileWrite:write(text) sampAddChatMessage("OK", -100000) sampCloseCurrentDialogWithButton(0) sampSendChat('/fammenu') check = 2 end end if check == 2 then if id == 2920 then sampSendDialogResponse(id, 1, 3, -1) end if id == 2931 then local tLines = split(text, "\n") if tLines[#tLines]:find("{B0E73A}Вперед >>>", 1, true) then sampSendDialogResponse(id, 1, #tLines-1 , "") end end end end