[/B]
script_version("21.03.2020")
item_id = 1141
delivery_id = 1147
accept_id = 1144
lic_day = 0
places = {}
local sampev = require 'lib.samp.events'
local glyph_ranges = ni7
local effil = require 'effil'
local imgui = require 'imgui'
local font_flag = require('moonloader').font_flag
local encoding = require 'encoding'
local res, https = pcall(require, 'ssl.https')
assert(res, 'Library ssl.https not found')
local inicfg = require 'inicfg'
imgui.BufferingBar = require('imgui_addons').BufferingBar
encoding.default = 'CP1251'
u8 = encoding.UTF8
local bNotf, notf = pcall(import, "imgui_notf.lua")
if not doesFileExist('moonloader\\config\\gsorter\\gsorter.ini') then
if not doesDirectoryExist('moonloader\\config\\gsorter') then createDirectory('moonloader\\config\\gsorter') end
local ini =
{
filters =
{
check_gun = true,
check_food = true,
check_furniture = true,
check_furnitur = true,
check_clothes = true,
check_general = true,
check_alcohol = true,
check_transport = true,
check_accessory = true,
check_radio = true,
check_cosmetics = true,
check_pyrotechnics = true,
check_auto = true,
check_sport = true,
int_price_dost = 0,1,
check_parachute = true,
check_type_towar = true,
check_type_product = true,
check_type_auto = true,
check_office = true,
text_maxprice = 6,
int_sklad = 0,
check_fruit = true,
int_sklad2 = 0,
int_quantity = 100,
text_maxdilprice = 0.1,
item_id = 1141,
accept_id = 1144,
delivery_id = 1147,
go_delivery = true,
check_sf = true,
check_ls = true,
check_lv = true,
accept_sleep = 350
}
}
inicfg.save(ini, 'gsorter\\gsorter')
end
local event_dialog = 0
local directIni = 'moonloader\\config\\gsorter\\gsorter.ini'
local mainIni = inicfg.load(nil, directIni)
local fullscreen = imgui.ImBool(false)
local main_window_state = imgui.ImBool(false)
local hud = imgui.ImBool(false)
local window_render_list = imgui.ImBool(false)
local accept_sleep = imgui.ImInt((mainIni.filters.accept_sleep and mainIni.filters.accept_sleep or 350))
local check_gun = imgui.ImBool(mainIni.filters.check_gun)
local check_food = imgui.ImBool(mainIni.filters.check_food)
local check_sf = imgui.ImBool(mainIni.filters.check_sf==true)
local check_ls = imgui.ImBool(mainIni.filters.check_ls==true)
local check_lv = imgui.ImBool(mainIni.filters.check_lv==true)
local check_furniture = imgui.ImBool(mainIni.filters.check_furniture)
local check_clothes = imgui.ImBool(mainIni.filters.check_clothes)
local check_general = imgui.ImBool(mainIni.filters.check_general)
local go_delivery = imgui.ImBool((mainIni.filters.go_delivery and mainIni.filters.go_delivery or true))
local check_fruit = imgui.ImBool(mainIni.filters.check_fruit)
local check_transport = imgui.ImBool(mainIni.filters.check_transport)
local check_accessory = imgui.ImBool(mainIni.filters.check_accessory)
local check_radio = imgui.ImBool(mainIni.filters.check_radio)
local check_cosmetics = imgui.ImBool(mainIni.filters.check_cosmetics)
local check_pyrotechnics = imgui.ImBool(mainIni.filters.check_pyrotechnics)
local check_auto = imgui.ImBool(mainIni.filters.check_auto)
local check_sport = imgui.ImBool(mainIni.filters.check_sport)
local int_price_dost = imgui.ImFloat(mainIni.filters.int_price_dost)
local check_alcohol = imgui.ImBool(mainIni.filters.check_alcohol)
local check_parachute = imgui.ImBool(mainIni.filters.check_parachute)
local check_type_towar = imgui.ImBool(mainIni.filters.check_type_towar)
local check_type_product = imgui.ImBool(mainIni.filters.check_type_product)
local check_type_auto = imgui.ImBool(mainIni.filters.check_type_auto)
local check_office = imgui.ImBool(mainIni.filters.check_office)
local text_maxprice = imgui.ImFloat(mainIni.filters.text_maxprice)
local int_sklad = imgui.ImInt(mainIni.filters.int_sklad)
local int_sklad2 = imgui.ImInt(mainIni.filters.int_sklad2)
local int_quantity = imgui.ImInt(mainIni.filters.int_quantity)
local text_maxdilprice = imgui.ImFloat(mainIni.filters.text_maxdilprice)
local delivery_window_state = imgui.ImBool(false)
local key_order = {}
local accept_product = {}
local check_stats = true
local delivery_stats = {}
local stats_autoupdate = false
local postrequest = {}
local sorter_status = true
require "lib.moonloader"
require "lib.sampfuncs"
function main()
while not isSampAvailable() do wait(100) end
--autoupdate("http://www.zamcontroller.ru/sorter/update.json", '['..string.upper(thisScript().name)..']: ', "http://zamcontroller.ru/PremiumSorter.luac")
local sendstat = {}
local _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
local user = sampGetPlayerNickname(my_id)
sendstat.data = "&user=" ..tostring(user)
sendstat.headers = { ['content-type']='application/x-www-form-urlencoded' }
asyncHttpRequest('POST', 'http://vhost74723.cpsite.ru/sorter/handler.php',sendstat,
function(response)
mystat = decodeJson(response.text)
if (not mystat) then sampAddChatMessage('{00ff00}[Sorter] {ff0000}(Ошибка) {FFFFFF}- Скрипт необходимо купить.', -1);thisScript():unload()
elseif bNotf then notf.addNotification("Сортировщик загружен", 3, 2) end
_G.item_id = mystat.item_id
_G.delivery_id = mystat.delivery_id
_G.accept_id = mystat.accept_id
_G.lic_day = mystat.days
_G.places = mystat.places
sampAddChatMessage('[САРТЕРАВЩИК] Осталось дней лицензии: {00ff00}' .. mystat.days, -1)
sampAddChatMessage('[САРТЕРАВЩИК] Выключить: {00ff00}/sorter', -1)
end)
sampRegisterChatCommand('sorter', cmd_status)
lua_thread.create(function()
while true do wait(0)
if not window_render_list.v and update_product then
update_product = nil
sampSendDialogResponse(event_dialog,0,-1)
elseif (not window_render_list.v and not delivery_window_state.v and isKeyJustPressed(VK_INSERT)) then
sampSendChat('/company')
elseif (not window_render_list.v and not delivery_window_state.v and isKeyJustPressed(VK_DELETE)) then
sampSendChat('/delivery')
end
end
end)
while true do
wait(0)
imgui.Process=true
if window_render_list.v and update_product==1 then
sampSendDialogResponse(local_id,0)
wait(5000)
end
end
end
function apply_custom_style()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
style.WindowRounding = 8
style.WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
style.ChildWindowRounding = 2.0
style.FrameRounding = 3
style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
style.ScrollbarSize = 13.0
style.ScrollbarRounding = 0
style.GrabMinSize = 8.0
style.GrabRounding = 1.0
style.WindowPadding = imgui.ImVec2(4.0, 4.0)
style.FramePadding = imgui.ImVec2(3.5, 3.5)
style.ButtonTextAlign = imgui.ImVec2(0.0, 0.5)
colors[clr.WindowBg] = ImVec4(0.14, 0.12, 0.16, 0.79);
colors[clr.ChildWindowBg] = ImVec4(0.30, 0.20, 0.39, 0.00);
colors[clr.PopupBg] = ImVec4(0.05, 0.05, 0.10, 0.90);
colors[clr.Border] = ImVec4(0.89, 0.85, 0.92, 1.00);
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00);
colors[clr.FrameBg] = ImVec4(0.30, 0.20, 0.39, 0.40);
colors[clr.FrameBgHovered] = ImVec4(0.41, 0.19, 0.63, 0.28);
colors[clr.FrameBgActive] = ImVec4(0.41, 0.19, 0.63, 0.50);
colors[clr.TitleBg] = ImVec4(0.41, 0.19, 0.63, 0.45);
colors[clr.TitleBgCollapsed] = ImVec4(0.41, 0.19, 0.63, 0.35);
colors[clr.TitleBgActive] = ImVec4(0.41, 0.19, 0.63, 0.78);
colors[clr.MenuBarBg] = ImVec4(0.30, 0.20, 0.39, 0.37);
colors[clr.ScrollbarBg] = ImVec4(0.30, 0.20, 0.39, 1.00);
colors[clr.ScrollbarGrab] = ImVec4(0.41, 0.19, 0.63, 0.31);
colors[clr.ScrollbarGrabHovered] = ImVec4(0.41, 0.19, 0.63, 0.48);
colors[clr.ScrollbarGrabActive] = ImVec4(0.41, 0.19, 0.63, 1.00);
colors[clr.ComboBg] = ImVec4(0.30, 0.20, 0.39, 1.00);
colors[clr.CheckMark] = ImVec4(0.56, 0.61, 1.00, 1.00);
colors[clr.SliderGrab] = ImVec4(0.41, 0.19, 0.63, 0.24);
colors[clr.SliderGrabActive] = ImVec4(0.41, 0.19, 0.63, 1.00);
colors[clr.Button] = ImVec4(0.41, 0.19, 0.63, 0.44);
colors[clr.ButtonHovered] = ImVec4(0.41, 0.19, 0.63, 0.86);
colors[clr.ButtonActive] = ImVec4(0.64, 0.33, 0.94, 1.00);
colors[clr.Header] = ImVec4(0.41, 0.19, 0.63, 0.76);
colors[clr.HeaderHovered] = ImVec4(0.41, 0.19, 0.63, 0.86);
colors[clr.HeaderActive] = ImVec4(0.41, 0.19, 0.63, 1.00);
colors[clr.ResizeGrip] = ImVec4(0.41, 0.19, 0.63, 0.20);
colors[clr.ResizeGripHovered] = ImVec4(0.41, 0.19, 0.63, 0.78);
colors[clr.ResizeGripActive] = ImVec4(0.41, 0.19, 0.63, 1.00);
colors[clr.CloseButton] = ImVec4(1.00, 1.00, 1.00, 0.75);
colors[clr.CloseButtonHovered] = ImVec4(0.88, 0.74, 1.00, 0.59);
colors[clr.CloseButtonActive] = ImVec4(0.88, 0.85, 0.92, 1.00);
colors[clr.PlotLines] = ImVec4(0.89, 0.85, 0.92, 1.00);
colors[clr.PlotLinesHovered] = ImVec4(0.41, 0.19, 0.63, 0.10);
colors[clr.PlotHistogram] = ImVec4(0.89, 0.85, 0.92, 0.63);
colors[clr.PlotHistogramHovered] = ImVec4(0.41, 0.19, 0.63, 1.00);
colors[clr.TextSelectedBg] = ImVec4(0.41, 0.19, 0.63, 0.43);
colors[clr.ModalWindowDarkening] = ImVec4(0.20, 0.20, 0.20, 0.35);
end
apply_custom_style()
function cmd_status()
sorter_status = not sorter_status
if not sorter_status then if bNotf then notf.addNotification('Сортировщик нокаутирован', 3, 3) end else
if bNotf then notf.addNotification('Сортировщик включен', 3, 2) end end
end
function onWindowMessage(msg, wparam, lparam)
if(msg == 0x100) then
if(wparam == VK_ESCAPE and window_render_list.v) then
window_render_list.v = false
consumeWindowMessage()
end
end
end
function sampev.onServerMessage(color,text)
if (text == '• {AC0000}[Ошибка] {ffffff}На Ваших складах недостаточно товара для этого заказа' ) and window_render_list.v then
update_product = 1
sampSendChat('/company')
if bNotf then notf.addNotification('На Ваших складах недостаточно товара для этого заказа', 3, 3) end
elseif text:find('Посигнальте, чтобы') then lua_thread.create(function() setVirtualKeyDown(VK_H, true); wait(400); setVirtualKeyDown(VK_H, false) end)
elseif text=='• {AC0000}[Ошибка] {ffffff}Нет свободных заказов на доставку товара' and window_render_list.v then
if bNotf then notf.addNotification('Нет свободных заказов на доставку товара', 3, 3) end
update_product = 1
sampSendChat('/company')
elseif text == ' Добро пожаловать на Diamond Role Play!' then sampSendChat('/mn')
elseif (text:find('Вы доставили заказ. Доход:')) then check_stats = true ;sampSendChat('/mn');sampAddChatMessage(text, -1)
elseif text == 'Прекратите флуд!' and window_render_list.v then
sampSendChat('/company')
end
end
function sampev.onSendDialogResponse(id,button,line,text)
if (id==delivery_id) then
delivery_window_state.v=false
return {id,button,(key_order[line+1] and key_order[line+1] or (id==1108 and 50 or 30) ),text}
end
end
function sampev.onShowDialog(id,style,title,button1,button2,text)
print(id)
event_dialog = id
if id == accept_id and update_product == 2 and window_render_list.v then -- если надо свой заказ принять
lua_thread.create(function()
local keyy = 0
for line in text:gmatch("[^\n]+") do
if line:find(accept_product[3]) then
wait(accept_sleep.v-sampGetPlayerPing(my_id))
sampSendDialogResponse(id,1,keyy)
end
key = key+1
end
end)
return false
--Чек статы
elseif (title:find('Меню игрока') and check_stats) then
sampSendDialogResponse(id,1,3)
return false
elseif (title:find('Работник стоянки') and check_stats) then
for line in text:gmatch("[^\n]+") do
if (line:find('Заработано очков опыта: %{.*%}(%d+)')) then
delivery_stats['score'] = tonumber(line:match('Заработано очков опыта: %{.*%}(%d+)'))
elseif (line:find('Совершено рейсов: %{.*%}(%d+)')) then
delivery_stats['reise'] = tonumber(line:match('Совершено рейсов: %{.*%}(%d+)'))
elseif (line:find('Заработано денег: %{.*%}%$(%d+)')) then
delivery_stats['money'] = tonumber(line:match('Заработано денег: %{.*%}%$(%d+)'))
end
end
sampAddChatMessage(delivery_stats['score'], -1)
check_stats = false
sampSendDialogResponse(id,1,1)
return false
elseif (title:find('Трудовая книжка') and check_stats) then
sampSendDialogResponse(id,1,1)
return false
elseif (title:find('Выберите стоянку') and update_product==2 and go_delivery.v) then
lua_thread.create(function()
wait(accept_sleep.v-sampGetPlayerPing(my_id))
accept_product[6] = nil
sampSendDialogResponse(id,1,0)
end)
return false
elseif (title:find('Свободные заказы') and update_product==2) then
lua_thread.create(function()
wait(accept_sleep.v-sampGetPlayerPing(my_id))
sampSendDialogResponse(id,1,65535,65535)
if not accept_product[6] then
update_product=1
if bNotf then notf.addNotification("Заказ принят на стоянку", 3, 2) end
sampSendChat('/cm Заказчик: '.. accept_product[1]..', товар: '..accept_product[2])
wait(400)
sampSendChat('/cm Количество: '..accept_product[3]..'ед. Доставка: ' ..accept_product[5]..'$/ед.')
end
sampSendChat('/company')
end)
return false
elseif (id==delivery_id and sorter_status) then
delivery_window_state.v = true
order=''
local_id = id
key_order={}
count=-1
for line in text:gmatch("[^\n]+") do
count=count+1
if (line:find("%{FFDF80%}(%d+)%.%{FFFFFF%}%s+([А-Яа-я ]+)%s+([A-Za-zА-Я а-я%-]+)%s+(%d+)ед%.%s+%$([%.0-9]+)%s+%/%s+ед%s+%[([A-Z-a-zА-Яа-я0-9№/ ]+)%s-%s+([A-Z-a-zА-Яа-я0-9№/ ]+)%]")) then
key,service,product,quantity,price,where,destination = line: match("%{FFDF80%}(%d+)%.%{FFFFFF%}%s+([A-Za-zА-Я а-я%-]+)%s+([A-Za-zА-Я а-я%-]+)%s+(%d+)ед%.%s+%$([%.0-9]+)%s+%/%s+ед%s+%[([A-Z-a-zА-Яа-я0-9№/ ]+)%s-%s+([A-Z-a-zА-Яа-я0-9№/ ]+)%]")
if ((product == (check_gun.v==true and 'Оружие'or'') or product == (check_food.v==true and 'Продукты питания'or'') or product == (check_furniture.v==true and 'Мебель'or'') or product == (check_sport.v==true and 'Спорт-Товары'or'') or product == (check_clothes.v==true and 'Одежда'or'') or product == (check_pyrotechnics.v==true and 'Пиротехника'or'') or product == (check_radio.v==true and 'Радиоигрушки' or '') or product == (check_parachute.v==true and 'Парашютное снаряжение'or'') or product == (check_parachute.v==true and 'Парашютное снаряжение'or'') or product == (check_accessory.v==true and 'Аксессуары'or'') or product == (check_alcohol.v==true and 'Алкоголь'or'') or product == (check_cosmetics.v==true and 'Косметические средства'or'') or product == (check_fruit.v==true and 'Фрукты'or'') or product == (check_office.v==true and 'Канцелярские товары'or'') or product == (check_general.v==true and 'Товары общего пользования'or'') or product == (check_auto.v==true and 'Автозапчасти'or'') or product == (check_transport.v==true and 'Транспорт'or'')) and (tonumber(price)>=int_price_dost.v)and (int_quantity.v<=tonumber(quantity)) and (int_sklad.v==0 or where:find('№'..int_sklad.v..'( |-)') or where:find('№'..int_sklad2.v..'( |-)') or destination:find('№'..int_sklad2.v) or destination:find('№'..int_sklad.v)) and (int_quantity.v<=tonumber(quantity)) and (service==(check_type_product.v==true and 'Перевозка продуктов'or'') or service==(check_type_towar.v==true and 'Перевозка товаров'or'') or service==(check_type_auto.v==true and 'Перевозка транспорта'or''))) then
order = (order==''and '' or order..'\n') ..service..'\t'..product..'['..quantity..']\t'..price..'\t'..where..' - '..destination
key_order[#key_order+1] = count-1
end
end
end
if order == '' then
sampAddChatMessage('Увы, фильтр убрал все варианты',-1)
sampSendDialogResponse(id,0,-1)
return false
else
order = 'Услуга\tПродукт[Кол-во] \tЦена\tОткуда-куда\n'..order..'\n{00ff00}Следующая страница'
return {id, style, title, button1, button2, order}
end
elseif (title:find('Выберите склад') and update_product==2) then
sampSendDialogResponse(id,-1,0)
return false
elseif (style==5 and id==item_id and sorter_status) then
window_render_list.v = true
order={}
count=-1
for line in text:gmatch("[^\n]+") do
count=count+1
if (line:find("%{FFDF80%}(%d+)%.%{FFFFFF%}%s+([A-Za-zА-Я а-я]+)%s+([A-Za-zА-Я а-я%-]+)%s+(%d+)%s+-%s+%$(%d+%.%d+)%s+%$(%d+%.%d+)")) then
key,pos,product,quantity,price,delprice = line: match("%{FFDF80%}(%d+)%.%{FFFFFF%}%s+([A-Za-zА-Я а-я]+)%s+([A-Za-zА-Я а-я%-]+)%s+(%d+)%s+-%s+%$(%d+%.%d+)%s+%$(%d+%.%d+)")
if ((product == (check_gun.v==true and 'Оружие'or'') or product == (check_food.v==true and 'Продукты питания'or'') or product == (check_furniture.v==true and 'Мебель'or'') or product == (check_fruit.v==true and 'Фрукты'or'') or product == (check_sport.v==true and 'Спорт-Товары'or'') or product == (check_pyrotechnics.v==true and 'Пиротехника'or'') or product == (check_clothes.v==true and 'Одежда'or'') or product == (check_radio.v==true and 'Радиоигрушки' or '') or product == (check_parachute.v==true and 'Парашютное снаряжение'or'') or product == (check_parachute.v==true and 'Парашютное снаряжение'or'') or product == (check_accessory.v==true and 'Аксессуары'or'') or product == (check_alcohol.v==true and 'Алкоголь'or'') or product == (check_cosmetics.v==true and 'Косметические средства'or'') or product == (check_office.v==true and 'Канцелярские товары'or'') or product == (check_sport.v==true and 'Спорт-Товары'or'')or product == (check_general.v==true and 'Товары общего пользования'or'') or product == (check_auto.v==true and 'Автозапчасти'or'') or product == (check_transport.v==true and 'Транспорт'or'')) and ( (places[u8:encode(pos)]=='LS' and check_ls.v ) or (places[u8:encode(pos)]=='SF' and check_sf.v ) or (places[u8:encode(pos)]=='LV' and check_lv.v )) and (text_maxdilprice.v <= tonumber(delprice)) and (tonumber(price)<=text_maxprice.v) ) then
table.insert(order, {pos,product,quantity,price,delprice,key-1})
end
end
end
local_id = id
if order == {} then
sampAddChatMessage('Увы, фильтр убрал все варианты',-1)
sampSendDialogResponse(id,0,-1)
return false
else
update_product = 1
window_render_list.v = true
return false
end
elseif update_product and title=="{FFDF80}Компания" then
if update_product == 1 then
sampSendDialogResponse(id,-1,2)
elseif update_product == 2 and go_delivery.v then
sampSendDialogResponse(id,-1,3)
elseif update_product == 2 and not go_delivery.v then
update_product=1
elseif window_render_list.v then
sampSendDialogResponse(id,0,-1)
return false
end
return false
end
end
function imgui.BeforeDrawFrame()
if glyph_ranges == nil then
glyph_ranges = imgui.GetIO().Fonts:GetGlyphRangesCyrillic()
imgui.GetIO().Fonts:Clear()
imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\arialbd.ttf', 15 , nil, glyph_ranges)
imgui.RebuildFonts()
end
end
function imgui.OnDrawFrame()
local _, my_id = sampGetPlayerIdByCharHandle(PLAYER_PED)
local user = sampGetPlayerNickname(my_id)
if delivery_window_state.v or window_render_list.v then imgui.ShowCursor = true else imgui.ShowCursor = false end
local iScreenWidth, iScreenHeight = getScreenResolution()
if isCharInAnyCar(PLAYER_PED) and (getCarModel(storeCarCharIsInNoSave(PLAYER_PED))==499 or getCarModel(storeCarCharIsInNoSave(PLAYER_PED))==413 ) and delivery_stats['score']~=nil then
imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth - 135, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(250, 150), imgui.Cond.FirstUseEver)
imgui.Begin(u8"PremiumSorter | HUD",-1, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
imgui.SetCursorPos(imgui.ImVec2(50, 25))
imgui.Text( u8 ' ' .. user .. '[' .. my_id ..']')
imgui.Separator()
imgui.Columns(2)
imgui.SetColumnWidth(-1, 180)
imgui.Text(u8'Ваш навык:')
imgui.Text(u8'Совершено рейсов:')
imgui.Text(u8'Заработано опыта:')
imgui.Text(u8'Заработано денег:')
imgui.NextColumn()
imgui.Text(u8:encode(delivery_stats['score']<250 and 'Чайник' or (delivery_stats['score']<2500 and 'Любитель' or (delivery_stats['score']<5000 and 'Перевозчик' or 'Король') )))
imgui.Text(tostring(delivery_stats['reise']))
imgui.Text(tostring(delivery_stats['score']))
imgui.Text(tostring(delivery_stats['money']) ..'$')
imgui.Columns(1)
imgui.Separator()
imgui.SetCursorPos(imgui.ImVec2(100, 126))
imgui.Text(os.date("%X",os.time()))
imgui.Separator()
imgui.End()
end
if (window_render_list.v) then
if not fullscreen.v then
imgui.SetNextWindowPos(imgui.ImVec2(iScreenWidth/2, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(iScreenWidth/1.5, iScreenHeight/1.3), imgui.Cond.FirstUseEver)
imgui.Begin(u8"PremiumSorter ["..lic_day.."]",window_render_list, imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse+imgui.WindowFlags.ShowBorders)
else
imgui.SetNextWindowPos(imgui.ImVec2(0,0))
imgui.SetNextWindowSize(imgui.ImVec2(iScreenWidth, iScreenHeight))
imgui.Begin(u8"PremiumSorter ["..lic_day.."]",window_render_list, imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse+imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoResize + imgui.WindowFlags.NoMove )
end
imgui.CenterTextColoredRGB(' {008B8B}ZAKO')
imgui.SetCursorPos(imgui.ImVec2(160,25))
imgui.TextColored(imgui.ImColor(255.0, 255.0, 255.0, 255.0):GetVec4(),u8'[ID] Заказ')
imgui.SameLine(390.0)
imgui.TextColored(imgui.ImColor(255.0, 255.0, 255.0, 255.0):GetVec4(),u8'Товар')
imgui.SameLine(550.0)
imgui.TextColored(imgui.ImColor(255.0, 255.0, 255.0, 255.0):GetVec4(),u8'Количество (ед.)')
imgui.SameLine(670.0)
imgui.TextColored(imgui.ImColor(255.0, 255.0, 255.0, 255.0):GetVec4(),u8'Стоимость (1 ед.)')
imgui.SameLine(800.0)
imgui.TextColored(imgui.ImColor(255.0, 255.0, 255.0, 255.0):GetVec4(),u8'Цена доставки (1 ед.)')
imgui.SameLine(970.0)
imgui.TextColored(imgui.ImColor(255.0, 255.0, 255.0, 255.0):GetVec4(),u8'Город')
if imgui.Checkbox(u8'Оружие',check_gun) or
imgui.Checkbox(u8'Канцелярия',check_office) or
imgui.Checkbox(u8'Мебель',check_furniture) or
imgui.Checkbox(u8'Продукты питания',check_food) or
imgui.Checkbox(u8'Алкоголь',check_alcohol) or
imgui.Checkbox(u8'Одежда',check_clothes) or
imgui.Checkbox(u8'Транспорт',check_transport) or
imgui.Checkbox(u8'Радиоигрушки',check_radio) or
imgui.Checkbox(u8'Аксессуары',check_accessory) or
imgui.Checkbox(u8'Фрукты',check_fruit) or
imgui.Checkbox(u8'Косметика',check_cosmetics) or
imgui.Checkbox(u8'Парашюты',check_parachute) or
imgui.Checkbox(u8'Спорт',check_sport) or
imgui.Checkbox(u8'Общее пользование',check_general) or
imgui.Checkbox(u8'Пиротехника',check_pyrotechnics) or
imgui.Checkbox(u8'Автозапчасти',check_auto) or
imgui.Checkbox(u8'Los-Santos',check_ls) or
imgui.Checkbox(u8'San-Fierro',check_sf) or
imgui.Checkbox(u8'Las-Venturas',check_lv) then
mainIni.filters.check_type_towar = check_type_towar.v
mainIni.filters.check_type_product = check_type_product.v
mainIni.filters.check_type_auto = check_type_auto.v
mainIni.filters.check_gun = check_gun.v
mainIni.filters.check_ls = check_ls.v
mainIni.filters.check_sf = check_sf.v
mainIni.filters.check_lv = check_lv.v
mainIni.filters.check_office = check_office.v
mainIni.filters.check_furniture = check_furniture.v
mainIni.filters.check_food = check_food.v
mainIni.filters.check_transport = check_transport.v
mainIni.filters.check_clothes = check_clothes.v
mainIni.filters.check_alcohol = check_alcohol.v
mainIni.filters.check_radio = check_radio.v
mainIni.filters.check_fruit = check_fruit.v
mainIni.filters.check_accessory = check_accessory.v
mainIni.filters.check_cosmetics = check_cosmetics.v
mainIni.filters.check_parachute = check_parachute.v
mainIni.filters.check_sport = check_sport.v
mainIni.filters.check_general = check_general.v
mainIni.filters.check_pyrotechnics = check_pyrotechnics.v
mainIni.filters.int_price_dost = int_price_dost.v
mainIni.filters.int_sklad = int_sklad.v
mainIni.filters.int_sklad2 = int_sklad2.v
mainIni.filters.int_quantity = int_quantity.v
mainIni.filters.check_auto = check_auto.v
update_product = 1
inicfg.save(mainIni, directIni)
end
imgui.SetCursorPos(imgui.ImVec2(160,45))
imgui.BeginChild('items', imgui.ImVec2(imgui.GetWindowSize().x-imgui.GetWindowSize().x/5,imgui.GetWindowSize().y-255), true)
local prices_item = {}
local prices_del = {}
for i = 1,table.maxn(order) do
if imgui.Selectable(u8:encode('['..(i-1)..'] ' ..order[i][1])) then
while local_id ~= item_id do wait(0) end
sampSendDialogResponse(local_id,-1,order[i][6])
accept_product = order[i]
update_product = 2
end
imgui.SameLine(240.0)
imgui.CenterTextColoredRGB(order[i][2])
imgui.SameLine(470.0)
imgui.CenterTextColoredRGB(order[i][3])
imgui.SameLine(600.0)
imgui.CenterTextColoredRGB(order[i][4])
imgui.SameLine(700.0)
imgui.CenterTextColoredRGB(order[i][5])
if places[u8:encode(order[i][1])] then
imgui.SameLine(830.0)
imgui.CenterTextColoredRGB(places[u8:encode(order[i][1])])
end
prices_item[i] = order[i][4]
prices_del[i] = order[i][5]
end
imgui.EndChild()
imgui.Columns(2)
imgui.NewLine()
imgui.SameLine(160)
imgui.Text(u8' Мониторинг цен на товары')
imgui.NewLine()
imgui.SameLine(160)
imgui.PlotHistogram('##item',prices_item,0,'', 0, 6, imgui.ImVec2(400, 60))
imgui.NewLine()
imgui.SameLine(160)
imgui.Text(u8' Мониторинг цен на доставку')
imgui.NewLine()
imgui.SameLine(160)
imgui.PlotHistogram('##del',prices_del, 0,'', 0, 1.5, imgui.ImVec2(400, 60))
imgui.NextColumn()
imgui.NewLine(70)
imgui.SliderFloat(u8'Мин. цена доставки', text_maxdilprice, 0.1, 1.5)
imgui.SliderFloat(u8'Макс. цена закупа', text_maxprice, 0.0, 6)
if imgui.InputInt(u8'Стартовая задержка', accept_sleep) then
mainIni.filters.accept_sleep = accept_sleep.v
inicfg.save(mainIni, directIni)
end
if imgui.Checkbox(u8'Автоматически забирать заказ на доставку',go_delivery) then
mainIni.filters.go_delivery = go_delivery.v
inicfg.save(mainIni, directIni)
end
imgui.Checkbox(u8'Полноэкранный режим',fullscreen)
if sampGetPlayerPing(my_id) > accept_sleep.v then
imgui.CenterTextColoredRGB('{ff0000}Задержка должна быть больше пинга! Пинг: {ffffff}' .. sampGetPlayerPing(my_id))
end
imgui.Columns(1)
imgui.End()
elseif delivery_window_state.v then
imgui.SetNextWindowPos(imgui.ImVec2(30, iScreenHeight / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(350, 470), imgui.Cond.FirstUseEver)
imgui.Begin(u8"Сортировщик заказов",delivery_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.ShowBorders + imgui.WindowFlags.NoCollapse+imgui.WindowFlags.ShowBorders)
imgui.Columns(2)
imgui.Text( u8 'Минимальная цена за ед.')
imgui.SliderFloat(u8'за ед.', int_price_dost, 0.1, 1.5)
imgui.Text( u8 'Желаемый склад.')
imgui.InputInt(u8'##3', int_sklad)
imgui.Text( u8 'Ещё желаемый склад.')
imgui.InputInt(u8'##7', int_sklad2)
imgui.Text( u8 'Минимальное количество')
imgui.InputInt(u8'##4 ', int_quantity)
if imgui.Button( u8"Сохранить") then
update_product = 1
mainIni.filters.check_type_towar = check_type_towar.v
mainIni.filters.check_type_product = check_type_product.v
mainIni.filters.check_type_auto = check_type_auto.v
mainIni.filters.check_gun = check_gun.v
mainIni.filters.check_office = check_office.v
mainIni.filters.check_furniture = check_furniture.v
mainIni.filters.check_food = check_food.v
mainIni.filters.check_transport = check_transport.v
mainIni.filters.check_clothes = check_clothes.v
mainIni.filters.check_radio = check_radio.v
mainIni.filters.check_fruit = check_fruit.v
mainIni.filters.check_accessory = check_accessory.v
mainIni.filters.check_cosmetics = check_cosmetics.v
mainIni.filters.check_parachute = check_parachute.v
mainIni.filters.check_sport = check_sport.v
mainIni.filters.check_general = check_general.v
mainIni.filters.check_alcohol = check_alcohol.v
mainIni.filters.check_pyrotechnics = check_pyrotechnics.v
mainIni.filters.int_price_dost = int_price_dost.v
mainIni.filters.int_sklad = int_sklad.v
mainIni.filters.int_sklad2 = int_sklad2.v
mainIni.filters.int_quantity = int_quantity.v
mainIni.filters.check_auto = check_auto.v
mainIni.filters.check_fruit = check_fruit.v
inicfg.save(mainIni, directIni)
sampCloseCurrentDialogWithButton(0)
sampSendChat('/delivery')
end
imgui.NextColumn()
imgui.Checkbox(u8'Перевозка товаров',check_type_towar)
imgui.Checkbox(u8'Перевозка продуктов',check_type_product)
imgui.Checkbox(u8'Перевозка транспорта',check_type_auto)
imgui.NextColumn()
imgui.Separator()
imgui.Checkbox(u8'Оружие',check_gun)
imgui.Checkbox(u8'Канцелярия',check_office)
imgui.Checkbox(u8'Мебель',check_furniture)
imgui.Checkbox(u8'Продукты питания',check_food)
imgui.Checkbox(u8'Алкоголь',check_alcohol)
imgui.Checkbox(u8'Одежда',check_clothes)
imgui.Checkbox(u8'Транспорт',check_transport)
imgui.NextColumn()
imgui.Checkbox(u8'Радиоигрушки',check_radio)
imgui.Checkbox(u8'Аксессуары',check_accessory)
imgui.Checkbox(u8'Косметика',check_cosmetics)
imgui.Checkbox(u8'Парашюты',check_parachute)
imgui.Checkbox(u8'Фрукты',check_fruit)
imgui.Checkbox(u8'Спорт',check_sport)
imgui.Checkbox(u8'Общее пользование',check_general)
imgui.Checkbox(u8'Пиротехника',check_pyrotechnics)
imgui.Checkbox(u8'Автозапчасти',check_auto)
imgui.Columns(1)
imgui.End()
end
end
function imgui.CenterTextColoredRGB(text)
local width = imgui.GetWindowWidth()
local style = imgui.GetStyle()
local colors = style.Colors
local ImVec4 = imgui.ImVec4
local explode_argb = function(argb)
local a = bit.band(bit.rshift(argb, 24), 0xFF)
local r = bit.band(bit.rshift(argb, 16), 0xFF)
local g = bit.band(bit.rshift(argb, 8), 0xFF)
local b = bit.band(argb, 0xFF)
return a, r, g, b
end
local getcolor = function(color)
if color:sub(1, 6):upper() == 'SSSSSS' then
local r, g, b = colors[1].x, colors[1].y, colors[1].z
local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
return ImVec4(r, g, b, a / 255)
end
local color = type(color) == 'string' and tonumber(color, 16) or color
if type(color) ~= 'number' then return end
local r, g, b, a = explode_argb(color)
return imgui.ImColor(r, g, b, 1000):GetVec4()
end
local render_text = function(text_)
for w in text_:gmatch('[^\r\n]+') do
local textsize = w:gsub('{.-}', '')
local text_width = imgui.CalcTextSize(u8(textsize))
local text, colors_, m = {}, {}, 1
w = w:gsub('{(......)}', '{%1FF}')
while w:find('{........}') do
local n, k = w:find('{........}')
local color = getcolor(w:sub(n + 1, k - 1))
if color then
text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
colors_[#colors_ + 1] = color
m = n
end
w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
end
if text[0] then
for i = 0, #text do
imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
imgui.SameLine(nil, 0)
end
imgui.NewLine()
else
imgui.Text(u8(w))
end
end
end
render_text(text)
end
function asyncHttpRequest(method, url, args, resolve, reject)
local request_thread = effil.thread(function (method, url, args)
local requests = require 'requests'
local result, response = pcall(requests.request, method, url, args)
if result then
response.json, response.xml = nil, nil
return true, response
else
return false, response
end
end)(method, url, args)
-- Если запрос без функций обработки ответа и ошибок.
if not resolve then resolve = function() end end
if not reject then reject = function() end end
-- Проверка выполнения потока
lua_thread.create(function()
local runner = request_thread
while true do
local status, err = runner:status()
if not err then
if status == 'completed' then
result, response = runner:get()
if result then
resolve(response)
else
reject(response)
end
return
elseif status == 'canceled' then
return reject(status)
end
else
return reject(err)
end
wait(0)
end
end)
end
function autoupdate(json_url, prefix, url)
local dlstatus = require('moonloader').download_status
local json = getWorkingDirectory() .. '\\'..thisScript().name..'-version.json'
if doesFileExist(json) then os.remove(json) end
downloadUrlToFile(json_url, json,
function(id, status, p1, p2)
if status == dlstatus.STATUSEX_ENDDOWNLOAD then
if doesFileExist(json) then
local f = io.open(json, 'r')
if f then
local info = decodeJson(f:read('*a'))
updatelink = info.updateurl
updateversion = info.latest
f:close()
os.remove(json)
if updateversion ~= thisScript().version then
lua_thread.create(function(prefix)
local dlstatus = require('moonloader').download_status
local color = -1
if bNotf then notf.addNotification("Обнаружено обновление, загружаю...", 3, 2) end
wait(250)
downloadUrlToFile(updatelink, thisScript().path,
function(id3, status1, p13, p23)
if status1 == dlstatus.STATUS_DOWNLOADINGDATA then
print(string.format('Загружено %d из %d.', p13, p23))
elseif status1 == dlstatus.STATUS_ENDDOWNLOADDATA then
print('Загрузка обновления завершена.')
if bNotf then notf.addNotification("Обновление загружено, запускаю...", 3, 2) end
goupdatestatus = true
lua_thread.create(function() wait(500) thisScript():reload() end)
end
if status1 == dlstatus.STATUSEX_ENDDOWNLOAD then
if goupdatestatus == nil then
if bNotf then notf.addNotification("Ошибка обновления, запускаю старую версию", 3, 3) end
update = false
end
end
end
)
end, prefix
)
else
update = false
print('v'..thisScript().version..': Обновление не требуется.')
end
end
else
print('v'..thisScript().version..': Не могу проверить обновление. Смиритесь или проверьте самостоятельно на '..url)
update = false
end
end
end
)
while update ~= false do wait(100) end
end
[B]