- Версия MoonLoader
- Другое
У меня есть такой код
Как не выводить ~(нету данных), если это аксессуар, я полностью запутался в этом всем
Из аксессуаром в типе предмет получилось, из аксессуаром нет(
Lua:
function ev.onShowDialog(id,style,title,b1,b2,text)
if title:find('Покупка предмета') then
if text:find('Предмет: {%x-}(.-){%x-}\n') or text:find('Аксессуар: {%x-}(.-){%x-}\n') then
if text:find('Стоимость: $(.+) за %d+ шт%.') then
if text:find('%- Улучшение: {%x+}(%d+)/%d+') then
price, item, sharpening = text:match('Стоимость: $(.+) за %d+ шт%.'), text:match('Предмет: {%x-}(.-){%x-}\n') or text:match('Аксессуар: {%x-}(.-){%x-}\n'), text:match('%- Улучшение: {%x+}(%d+)/%d+')
table_insert_aks(list,{price = price:gsub('%.', ''), item = item, sharpening = sharpening})
json('test2.json'):Save(list)
else
price, item = text:match('Стоимость: $(.+) за %d+ шт%.'), text:match('Предмет: {%x-}(.-){%x-}\n')
table_insert(list,{price = price:gsub('%.', ''), item = item})
json('test2.json'):Save(list)
end
end
count, list_price = 0, {}
for i = 1, #list do
if list[i].item == item then
count = count + 1
price = tonumber(list[i].price)
table.insert(list_price, price)
end
if list[i].item == item and list[i].sharpening == sharpening and sharpening ~= nil then
sampAddChatMessage(list[i].item..' +'..list[i].sharpening..' | $'..list[i].price,-1)
end
end
if count > 1 then
a_price = sum(list_price)/count
a_price = math.modf(a_price)
a_price = math.floor(a_price)
if not text:find('%- Улучшение: {%x+}(%d+)/%d+') then
text = text:gsub('Стоимость: $(.+) за %d+ шт%.', '%0 {FFDAB9}~('..a_price..'$)')
return {id,style,title,b1,b2,text}
end
else
text = text:gsub('Стоимость: $(.+) за %d+ шт%.', '%0 {FFDAB9}~(Нету данных)')
return {id,style,title,b1,b2,text}
end
end
end
end
Из аксессуаром в типе предмет получилось, из аксессуаром нет(