не работает onShowTextdraw

KelloKello123

Новичок
Автор темы
3
1
Версия MoonLoader
.026-beta
функция получения цен и информации о товарах корректно проходит только 1 цикл, после переключения на другой раздел почему то вообще в таблицу не записываются айдишники текстдравов когда по сути ev.onShowTextDraw сам по себе цикл и при каждой возможности будет записывать значение в эту таблицу

getprice():
function getPrice()
    while not functions.be2 do
        wait(200)
    end
    local table_all = getAllElementsBuyOrSell()
    local ret_table_price_purchase = {}
    local ret_table_price_sale = {}
    for i = 1, #table_all do
        wait(50)
        sampCloseCurrentDialogWithButton(0)
        sampSendClickTextdraw(table_all[i])
        function ev.onShowDialog(dialogId, style, title, button1, button2, text)
            if button1 == 'Купить' then
                local number = getLavochka()
                local price = text:match('$%s*(%d+)')
                local more = string.match(text, "В наличии:%s*(%d+)")
                local name = getFirstFourWords(text)
                table.insert(ret_table_price_purchase,{number, 'purchase', price, more, name})
                table_purchase = ret_table_price_purchase
            -- elseif button1 == 'Продать' then
            --     local number = getLavochka()
            --     local price = text:match('$%s*(%d+)')
            --     table.insert(ret_table_price_sale,{number, 'sale', price})
            --     table_sell = ret_table_price_sale
            elseif button1 == 'Выбрать' then
                sampSendDialogResponse(dialogId, 1, 0, '')
                local number = getLavochka()
                local price = text:match('$%s*(%d+)')
                local more = string.match(text, "В наличии:%s*(%d+)")
                local name = string.match(text,"Предмет:%s*(%S+)") or string.match(text,"Эликсир:%s*(%S+)")
                table.insert(ret_table_price_purchase,{number, 'purchase', price, more, name})
            end
        end
    end -- 2068 - left
    -- 2070 - right
    table_all = {}
    sampSendClickTextdraw(2084)
    sampAddChatMessage('НАЖАТО', -1)
    sampAddChatMessage(#table_all, -1)
    for i = 1, #table_all do
        wait(50)
        sampAddChatMessage('test', -1)
        sampCloseCurrentDialogWithButton(0)
        sampSendClickTextdraw(table_two[i])
        function ev.onShowDialog(dialogId, style, title, button1, button2, text)
            if button1 == 'Продать' then
                local number = getLavochka()
                local price = text:match('$%s*(%d+)')
                local more = string.match(text, "покупает:%s*(%d+)")
                local name = getFirstFourWords(text)
                table.insert(ret_table_price_sale,{number, 'sale', price, more, name})
                table_sell = ret_table_price_sale
            end
        end
    end
    return ret_table_price_purchase, ret_table_price_sale
end

getAllElementsBuyOrSell():
function getAllElementsBuyOrSell()
    local table1 = {}
    while functions.be1 do
        wait(0)
            function ev.onShowTextDraw(textdrawId, textdraw)
                if textdraw.backgroundColor ~= -16777216 then
                    table.insert(table1, textdrawId)
                end
            end
            if #table1 ~= 0 then
                functions.be1 = false
            end
    end
    return table1
end
 
  • Эм
Реакции: MLycoris
Решение
local currentMode = nil
local ret_table_price_purchase = {}
local ret_table_price_sale = {}
local textdraws = {}

function ev.onShowTextDraw(id, textdraw)
if textdraw.backgroundColor ~= -16777216 then
table.insert(textdraws, id)
end
end

function ev.onShowDialog(dialogId, style, title, button1, button2, text)
if currentMode == 'purchase' then
if button1 == 'Купить' or button1 == 'Выбрать' then
local number = getLavochka()
local price = text:match('$%s*(%d+)')
local more = text:match("В наличии:%s*(%d+)")
local name = getFirstFourWords(text)
table.insert(ret_table_price_purchase, {number, 'purchase', price, more, name})
end
elseif...

AdseMods1

Участник
4
0
local currentMode = nil
local ret_table_price_purchase = {}
local ret_table_price_sale = {}
local textdraws = {}

function ev.onShowTextDraw(id, textdraw)
if textdraw.backgroundColor ~= -16777216 then
table.insert(textdraws, id)
end
end

function ev.onShowDialog(dialogId, style, title, button1, button2, text)
if currentMode == 'purchase' then
if button1 == 'Купить' or button1 == 'Выбрать' then
local number = getLavochka()
local price = text:match('$%s*(%d+)')
local more = text:match("В наличии:%s*(%d+)")
local name = getFirstFourWords(text)
table.insert(ret_table_price_purchase, {number, 'purchase', price, more, name})
end
elseif currentMode == 'sale' then
if button1 == 'Продать' then
local number = getLavochka()
local price = text:match('$%s*(%d+)')
local more = text:match("покупает:%s*(%d+)")
local name = getFirstFourWords(text)
table.insert(ret_table_price_sale, {number, 'sale', price, more, name})
end
end
end

function getAllElementsBuyOrSell()
textdraws = {}
functions.be1 = true
while functions.be1 do
wait(100)
if #textdraws > 0 then
functions.be1 = false
end
end
return textdraws
end

function getPrice()
while not functions.be2 do
wait(200)
end

ret_table_price_purchase = {}
ret_table_price_sale = {}

local table_all = getAllElementsBuyOrSell()

currentMode = 'purchase'

for i = 1, #table_all do
wait(100)
sampCloseCurrentDialogWithButton(0)
sampSendClickTextdraw(table_all)
end

wait(500)

sampSendClickTextdraw(2084)

wait(500)

table_all = getAllElementsBuyOrSell()

currentMode = 'sale'

for i = 1, #table_all do
wait(100)
sampCloseCurrentDialogWithButton(0)
sampSendClickTextdraw(table_all)
end

return ret_table_price_purchase, ret_table_price_sale
end

юзани это
 

KelloKello123

Новичок
Автор темы
3
1
local currentMode = nil
local ret_table_price_purchase = {}
local ret_table_price_sale = {}
local textdraws = {}

function ev.onShowTextDraw(id, textdraw)
if textdraw.backgroundColor ~= -16777216 then
table.insert(textdraws, id)
end
end

function ev.onShowDialog(dialogId, style, title, button1, button2, text)
if currentMode == 'purchase' then
if button1 == 'Купить' or button1 == 'Выбрать' then
local number = getLavochka()
local price = text:match('$%s*(%d+)')
local more = text:match("В наличии:%s*(%d+)")
local name = getFirstFourWords(text)
table.insert(ret_table_price_purchase, {number, 'purchase', price, more, name})
end
elseif currentMode == 'sale' then
if button1 == 'Продать' then
local number = getLavochka()
local price = text:match('$%s*(%d+)')
local more = text:match("покупает:%s*(%d+)")
local name = getFirstFourWords(text)
table.insert(ret_table_price_sale, {number, 'sale', price, more, name})
end
end
end

function getAllElementsBuyOrSell()
textdraws = {}
functions.be1 = true
while functions.be1 do
wait(100)
if #textdraws > 0 then
functions.be1 = false
end
end
return textdraws
end

function getPrice()
while not functions.be2 do
wait(200)
end

ret_table_price_purchase = {}
ret_table_price_sale = {}

local table_all = getAllElementsBuyOrSell()

currentMode = 'purchase'

for i = 1, #table_all do
wait(100)
sampCloseCurrentDialogWithButton(0)
sampSendClickTextdraw(table_all)
end

wait(500)

sampSendClickTextdraw(2084)

wait(500)

table_all = getAllElementsBuyOrSell()

currentMode = 'sale'

for i = 1, #table_all do
wait(100)
sampCloseCurrentDialogWithButton(0)
sampSendClickTextdraw(table_all)
end

return ret_table_price_purchase, ret_table_price_sale
end

юзани это
спасибо, но я уже пофиксил данную проблему просто сделав таблицу в функции getallelementbyorsell глобальной
 
  • Нравится
Реакции: AdseMods1