Compare commits

...

4 Commits

  1. 611
      ProdHUD.lua
  2. 21
      README.md
  3. 6
      changelog
  4. BIN
      pictures/download.png

@ -1,14 +1,17 @@
script_name('ProdHUD') script_name('ProdHUD')
script_authors("RuBin") script_authors("rubin")
local samp = require 'samp.events' script_version("23.11.2024")
samp = require 'samp.events'
local inicfg = require 'inicfg' local inicfg = require 'inicfg'
dlstatus = require("moonloader").download_status
function main() function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end while not isSampAvailable() do wait(100) end
iniLoad() iniLoad()
font = renderCreateFont(ini.settings.font_name, ini.settings.font_size, ini.settings.font_flag) font = renderCreateFont(ini.settings.font_name, ini.settings.font_size, ini.settings.font_flag)
lua_thread.create(script_update.main)
loadEvents()
while true do while true do
wait(0) wait(0)
doRenderMenu() doRenderMenu()
@ -18,152 +21,160 @@ function main()
end end
end end
function samp.onServerMessage(color, message) function loadEvents()
if message:find("Âû äîëæíû íàõîäèòüñÿ íà ñêëàäå, ñ âûáðàííûì âàìè òèïîì áèçíåñà") or function samp.onServerMessage(color, message)
message:find("Íåâåðíî óêàçàíî êîëè÷åñòâî") or if message:find("Вы должны находиться на складе, с выбранным вами типом бизнеса") or
message:find("Â ôóðãîíå íåò ìåñòà") or message:find("Неверно указано количество") or
message:find("Ó âàñ íåò ïðîäóêòîâ") or message:find("В фургоне нет места") or
message:find("Íóæíî íàõîäèòüñÿ ðÿäîì ñ áèçíåñîì, êîòîðîìó õîòèòå ïðîäàòü") or message:find("У вас нет продуктов") or
message:find("Ó âàñ íåäîñòàòî÷íî äåíåã") or message:find("Нужно находиться рядом с бизнесом, которому хотите продать") or
(isCar() and message:find("Âû çàðàáîòàëè %d+ âèðò, èç êîòîðûõ %d+ âèðò áóäåò äîáàâëåíî ê âàøåé çàðïëàòå")) then message:find("У вас недостаточно денег") or
if buyMode ~= nil then scip = true end (isCar() and message:find("Вы заработали %d+ вирт, из которых %d+ вирт будет добавлено к вашей зарплате")) then
buyMode = nil if buyMode ~= nil then scip = true end
if checkMon ~= nil then buyMode = nil
return false if checkMon ~= nil then
return false
end
end
if string.find(message, " Еда: (%d+) / (%d+)") then
prod.food, prod_count = string.match(message, " Еда: (%d+) / (%d+)")
if prod_count == prod.food and buyMode then scip = true end
if prod.food == "0" and buyMode then scip = true end
buyMode = nil
end
if string.find(message, " Бензин: (%d+) / (%d+)") then
prod.benz, prod_count = string.match(message, " Бензин: (%d+) / (%d+)")
if prod_count == prod.benz and buyMode then scip = true end
if prod.benz == "0" and buyMode then scip = true end
buyMode = nil
end
if string.find(message, " Товары: (%d+) / (%d+)") then
prod.products, prod_count = string.match(message, " Товары: (%d+) / (%d+)")
if prod_count == prod.products and buyMode then scip = true end
if prod.products == "0" and buyMode then scip = true end
buyMode = nil
end
if string.find(message, " Алкоголь: (%d+) / (%d+)") then
prod.alcohol, prod_count = string.match(message, " Алкоголь: (%d+) / (%d+)")
if prod_count == prod.alcohol and buyMode then scip = true end
if prod.alcohol == "0" and buyMode then scip = true end
buyMode = nil
end end
end end
if string.find(message, " Åäà: (%d+) / (%d+)") then
prod.food, prod_count = string.match(message, " Åäà: (%d+) / (%d+)")
if prod_count == prod.food and buyMode then scip = true end
if prod.food == "0" and buyMode then scip = true end
buyMode = nil
end
if string.find(message, " Áåíçèí: (%d+) / (%d+)") then
prod.benz, prod_count = string.match(message, " Áåíçèí: (%d+) / (%d+)")
if prod_count == prod.benz and buyMode then scip = true end
if prod.benz == "0" and buyMode then scip = true end
buyMode = nil
end
if string.find(message, " Òîâàðû: (%d+) / (%d+)") then
prod.products, prod_count = string.match(message, " Òîâàðû: (%d+) / (%d+)")
if prod_count == prod.products and buyMode then scip = true end
if prod.products == "0" and buyMode then scip = true end
buyMode = nil
end
if string.find(message, " Àëêîãîëü: (%d+) / (%d+)") then
prod.alcohol, prod_count = string.match(message, " Àëêîãîëü: (%d+) / (%d+)")
if prod_count == prod.alcohol and buyMode then scip = true end
if prod.alcohol == "0" and buyMode then scip = true end
buyMode = nil
end
end
function samp.onShowDialog(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext) function samp.onShowDialog(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext)
dialogActiveTime = os.clock() * 1000 dialogActiveTime = os.clock() * 1000
if buyMode ~= nil or (buyMode == nil and scip ~= nil) then if buyMode ~= nil or (buyMode == nil and scip ~= nil) then
if Dtitle:find("Ðàçâîç÷èê ïðîäóêòîâ") then if Dtitle:find("Развозчик продуктов") then
if scip == nil then if scip == nil then
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = (sell and 1 or 0), input = "" } send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = (sell and 1 or 0), input = "" }
end
return false
end end
return false if Dtext:find("Бары и клубы") and Dtext:find("Заправки") then
end if scip == nil then
if Dtext:find("Áàðû è êëóáû") and Dtext:find("Çàïðàâêè") then local list = { alcohol = 0, benz = 1, products = 3, food = 2 }
if scip == nil then send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = list[buyMode], input = "" }
local list = { alcohol = 0, benz = 1, products = 3, food = 2 } exit_time = os.clock() * 1000
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = list[buyMode], input = "" } end
return false
end end
return false if Dtitle:find("Ввод параметра") and Dtext:find("Введите количество продуктов от %d+ до (%d+)") then
end if scip == nil then
if Dtitle:find("Ââîä ïàðàìåòðà") and Dtext:find("Ââåäèòå êîëè÷åñòâî ïðîäóêòîâ îò %d+ äî (%d+)") then local count = tonumber(Dtext:match("Введите количество продуктов от %d+ до (%d+)")) - prod[buyMode]
if scip == nil then send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = 0, input = tostring(count) }
local count = tonumber(Dtext:match("Ââåäèòå êîëè÷åñòâî ïðîäóêòîâ îò %d+ äî (%d+)")) - prod[buyMode] end
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = 0, input = tostring(count) } return false
end end
return false if Dtitle:find("Сообщение") and Dtext:find("Стоимость")and Dtext:find("Количество") then
end if scip == nil then
if Dtitle:find("Ñîîáùåíèå") and Dtext:find("Ñòîèìîñòü")and Dtext:find("Êîëè÷åñòâî") then send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = 0, input = "" }
if scip == nil then end
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = 0, input = "" } return false
end
elseif exit_time ~= nil then
if (Dtext:find("Бары и клубы") and Dtext:find("Заправки")) or Dtitle:find("Развозчик продуктов") then
if os.clock() * 1000 - exit_time < 1000 then
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 0, listitem = 0, input = "" }
end
end end
return false
end
end
if DdialogId == 22 and Dstyle == 0 and Dtitle == "Ñîîáùåíèå" and string.find(Dtext, "Áèçíåñ") and string.find(Dtext, "Ñêîëüêî ìîæåò êóïèòü") then
if string.find(Dtext, "Cluc") or string.find(Dtext, "Pizza") or string.find(Dtext, "Cluck") or string.find(Dtext, "Burger") then
monArray["food"] = Dtext
elseif string.find(Dtext, "24%-7") then
monArray["products"] = Dtext
elseif string.find(Dtext, "gas") or string.find(Dtext, "Gas") or string.find(Dtext, "Gsa") then
monArray["benz"] = Dtext
else
monArray["alcohol"] = Dtext
end
if checkMon ~= nil then
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 0, listitem = 0, input = "" }
return false
end end
end if DdialogId == 22 and Dstyle == 0 and Dtitle == "Сообщение" and string.find(Dtext, "Бизнес") and string.find(Dtext, "Сколько может купить") then
if checkMon ~= nil then if string.find(Dtext, "Cluc") or string.find(Dtext, "Pizza") or string.find(Dtext, "Cluck") or string.find(Dtext, "Burger") then
if Dtitle:find("Ðàçâîç÷èê ïðîäóêòîâ") then monArray["food"] = Dtext
if scip == nil then elseif string.find(Dtext, "24%-7") then
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = 2, input = "" } monArray["products"] = Dtext
elseif string.find(Dtext, "gas") or string.find(Dtext, "Gas") or string.find(Dtext, "Gsa") then
monArray["benz"] = Dtext
else
monArray["alcohol"] = Dtext
end
if checkMon ~= nil then
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 0, listitem = 0, input = "" }
return false
end end
return false
end end
if Dtitle:find("Ìîíèòîðèíã") then if checkMon ~= nil then
if checkMon == "" then if Dtitle:find("Развозчик продуктов") then
checkMon = nil if scip == nil then
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = 2, input = "" }
end
return false return false
end end
if scip == nil then if Dtitle:find("Мониторинг") then
local arr_sled = { alcohol = "benz", benz = "food", food = "products", products = "" } if checkMon == "" then
local arr_button = { alcohol = 0, benz = 1, food = 2, products = 3 } checkMon = nil
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = arr_button[checkMon], input = "" } return false
checkMon = arr_sled[checkMon] end
if scip == nil then
local arr_sled = { alcohol = "benz", benz = "food", food = "products", products = "" }
local arr_button = { alcohol = 0, benz = 1, food = 2, products = 3 }
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = arr_button[checkMon], input = "" }
checkMon = arr_sled[checkMon]
end
return false
end end
return false
end end
end if Dtitle:find("GPS") and bizname ~= nil then
if Dtitle:find("GPS") and bizname ~= nil then local arr_sled = { alcohol = 2, benz = 8, food = 10, products = 9 }
local arr_sled = { alcohol = 2, benz = 8, food = 10, products = 9 } send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = arr_sled[monMode], input = "" }
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = arr_sled[monMode], input = "" }
return false
end
if (bizname ~= nil or ( bizname == nil and scip ~= nil)) and (Dtitle:find("Áåíçîçàïðàâêè") or Dtitle:find("Ìàãàçèíû") or Dtitle:find("Áàðû") or Dtitle:find("Çàêóñî÷íûå") ) then
if scip ~= nil then
scip = nil
return false return false
end end
local arr = split(Dtext, "\n") if (bizname ~= nil or ( bizname == nil and scip ~= nil)) and (Dtitle:find("Бензозаправки") or Dtitle:find("Магазины") or Dtitle:find("Бары") or Dtitle:find("Закусочные") ) then
local result = -1 if scip ~= nil then
for i = 1, #arr do scip = nil
local str = arr[i]:gsub("%-", " ") return false
local findText = bizname:gsub("%-", " ")
if monMode == "benz" and not findText:find("Emerald") and not findText:find("Tierra") then
bizname = string.gsub(bizname, " ", "")
end end
local arr = split(Dtext, "\n")
local result = -1
for i = 1, #arr do
local str = arr[i]:gsub("%-", " ")
local findText = bizname:gsub("%-", " ")
if monMode == "benz" and not findText:find("Emerald") and not findText:find("Tierra") then
bizname = string.gsub(bizname, " ", "")
end
if str:gsub("%-", " "):find(findText) then if str:gsub("%-", " "):find(findText) then
result = i - 1 result = i - 1
break break
end
end end
if result ~= -1 then
scip = true
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = result, input = "" }
else
sampAddChatMessage(bizname, -1)
end
bizname = nil
return false
end end
if result ~= -1 then
scip = true
send_dialog = { time = os.clock() * 1000, id = DdialogId, button = 1, listitem = result, input = "" }
else
sampAddChatMessage(bizname, -1)
end
bizname = nil
return false
end
scip = nil scip = nil
end end
function samp.onSendDialogResponse(dialogId, button, listboxId, input)
utf8({ "samp", "onShowDialog" }, "AnsiToUtf8", "Utf8ToAnsi")
utf8({ "samp", "onServerMessage" }, "AnsiToUtf8", "Utf8ToAnsi")
end end
function isCar() function isCar()
@ -173,7 +184,6 @@ function isCar()
end end
-->> RENDER MENU -->> RENDER MENU
function doRenderMenu() function doRenderMenu()
if not isCar() or sampIsDialogActive() or sampIsChatInputActive() or not isKeyDown(2) then if not isCar() or sampIsDialogActive() or sampIsChatInputActive() or not isKeyDown(2) then
if control then if control then
@ -182,23 +192,16 @@ function doRenderMenu()
control = false control = false
return return
end end
if not control then if not control then
control = true control = true
end end
sampSetCursorMode(3) sampSetCursorMode(3)
-->> Render MENU -->> Render MENU
local height = renderGetFontDrawHeight(font) local height = renderGetFontDrawHeight(font)
local plus = height + (height / 4) local plus = height + (height / 4)
local X, Y = getScreenResolution() local X, Y = getScreenResolution()
Y = ((Y / 2.0) - (height * 3)) Y = ((Y / 2.0) - (height * 3))
local textLength = renderGetFontDrawTextLength(font, "Продать для Закусочной")
local textLength = renderGetFontDrawTextLength(font, "Ïðîäàòü äëÿ Çàêóñî÷íîé")
renderDrawBox((X - textLength), Y, textLength, (plus * 11), 0x80000000) renderDrawBox((X - textLength), Y, textLength, (plus * 11), 0x80000000)
local x, y = (X - textLength) - 72, Y local x, y = (X - textLength) - 72, Y
for i = 10, 80 do for i = 10, 80 do
@ -206,76 +209,63 @@ function doRenderMenu()
local color = string.format("0x%d000000", i) local color = string.format("0x%d000000", i)
renderDrawBox(x, y, 1, (plus * 11), color) renderDrawBox(x, y, 1, (plus * 11), color)
end end
string = "Купить для Бара"
string = "Êóïèòü äëÿ Áàðà"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = false sell = false
buyMode = "alcohol" buyMode = "alcohol"
end end
Y = Y + plus Y = Y + plus
string = "Ïðîäàòü äëÿ Áàðà" string = "Продать для Бара"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = true sell = true
buyMode = "alcohol" buyMode = "alcohol"
end end
Y = Y + plus + plus Y = Y + plus + plus
string = "Купить для Заправки"
string = "Êóïèòü äëÿ Çàïðàâêè"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = false sell = false
buyMode = "benz" buyMode = "benz"
end end
Y = Y + plus Y = Y + plus
string = "Ïðîäàòü äëÿ Çàïðàâêè" string = "Продать для Заправки"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = true sell = true
buyMode = "benz" buyMode = "benz"
end end
Y = Y + plus + plus Y = Y + plus + plus
string = "Купить для Магазина"
string = "Êóïèòü äëÿ Ìàãàçèíà"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = false sell = false
buyMode = "products" buyMode = "products"
end end
Y = Y + plus Y = Y + plus
string = "Ïðîäàòü äëÿ Ìàãàçèíà" string = "Продать для Магазина"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = true sell = true
buyMode = "products" buyMode = "products"
end end
Y = Y + plus + plus Y = Y + plus + plus
string = "Купить для Закусочной"
string = "Êóïèòü äëÿ Çàêóñî÷íîé"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = false sell = false
buyMode = "food" buyMode = "food"
end end
Y = Y + plus Y = Y + plus
string = "Ïðîäàòü äëÿ Çàêóñî÷íîé" string = "Продать для Закусочной"
if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then if drawClickableText(string, (X - renderGetFontDrawTextLength(font, string.." ")), Y) then
sell = true sell = true
buyMode = "food" buyMode = "food"
end end
-->> Render Monitoring -->> Render Monitoring
local X, Y = getScreenResolution() local X, Y = getScreenResolution()
Y = ((Y / 2.2) - (height * 3)) Y = ((Y / 2.2) - (height * 3))
string = "[Обновить цены]"
string = "[Îáíîâèòü öåíû]"
if drawClickableText(string, (X / 2 - (renderGetFontDrawTextLength(font, string.." ") / 2 )), Y) then if drawClickableText(string, (X / 2 - (renderGetFontDrawTextLength(font, string.." ") / 2 )), Y) then
checkMon = "alcohol" checkMon = "alcohol"
end end
Y = Y + plus Y = Y + plus
string = string.format("{%s}Алкоголь {%s}| {%s}Заправки {%s}| {%s}Магазины {%s}| {%s}Закусочные",
string = string.format("{%s}Àëêîãîëü {%s}| {%s}Çàïðàâêè {%s}| {%s}Ìàãàçèíû {%s}| {%s}Çàêóñî÷íûå",
(monMode == "alcohol" and ini.settings.color2 or ini.settings.color1), (monMode == "alcohol" and ini.settings.color2 or ini.settings.color1),
ini.settings.color1, ini.settings.color1,
(monMode == "benz" and ini.settings.color2 or ini.settings.color1), (monMode == "benz" and ini.settings.color2 or ini.settings.color1),
@ -290,17 +280,14 @@ function doRenderMenu()
end end
local delta = getMousewheelDelta() local delta = getMousewheelDelta()
if delta > 0 then if delta > 0 then
local mode_sled = { alcohol = "benz", benz = "products", products = "food", food = "alcohol" } local mode_sled = { alcohol = "food", benz = "alcohol", products = "benz", food = "products" }
monMode = mode_sled[monMode] monMode = mode_sled[monMode]
elseif delta < 0 then elseif delta < 0 then
local mode_sled = { alcohol = "food", benz = "alcohol", products = "benz", food = "products" } local mode_sled = { alcohol = "benz", benz = "products", products = "food", food = "alcohol" }
monMode = mode_sled[monMode] monMode = mode_sled[monMode]
end end
Y = Y + plus Y = Y + plus
local arr = split(monArray[monMode], "\n") local arr = split(monArray[monMode], "\n")
for i = 1, #arr do for i = 1, #arr do
local string = arr[i] local string = arr[i]
if drawClickableText(string, (X / 2 - (renderGetFontDrawTextLength(font, string.." ") / 2 )), Y) then if drawClickableText(string, (X / 2 - (renderGetFontDrawTextLength(font, string.." ") / 2 )), Y) then
@ -313,8 +300,8 @@ function doRenderMenu()
[" 24%-7"] = "", [" 24%-7"] = "",
[" Gas"] = "", [" Gas"] = "",
[" Gsa"] = "", [" Gsa"] = "",
["Four dragon"] = "Ñêëàä áàðà 4Äðàêîíîâ", ["Four dragon"] = "Склад бара 4Драконов",
["Caligula"] = "Ñêëàä áàðà Êàëèãóëû", ["Caligula"] = "Склад бара Калигулы",
[" Bar"] = "", [" Bar"] = "",
[" bar"] = "", [" bar"] = "",
["Quebrados"] = "Guebrabos" ["Quebrados"] = "Guebrabos"
@ -327,7 +314,6 @@ function doRenderMenu()
end end
Y = Y + plus Y = Y + plus
end end
end end
-->> BuyMode -->> BuyMode
@ -354,7 +340,6 @@ function doCheckMonMode()
end end
end end
-->> SEND DIALOG -->> SEND DIALOG
function doSendDialog() function doSendDialog()
if send_dialog == nil then return end if send_dialog == nil then return end
@ -364,7 +349,6 @@ function doSendDialog()
end end
-->> INIFILES -->> INIFILES
function iniLoad() function iniLoad()
ini = inicfg.load({ ini = inicfg.load({
settings = { settings = {
@ -379,12 +363,10 @@ function iniLoad()
prod = { alcohol = 0, benz = 0, products = 0, food = 0 } prod = { alcohol = 0, benz = 0, products = 0, food = 0 }
monMode = "alcohol" monMode = "alcohol"
monArray = { alcohol = "Ïóñòî", benz = "Ïóñòî", products = "Ïóñòî", food = "Ïóñòî" } monArray = { alcohol = "Пусто", benz = "Пусто", products = "Пусто", food = "Пусто" }
end end
-->> New Func -->> New Func
function drawClickableText(text, posX, posY) function drawClickableText(text, posX, posY)
renderFontDrawText(font, text, posX, posY, '0xFF'..ini.settings.color1) renderFontDrawText(font, text, posX, posY, '0xFF'..ini.settings.color1)
local textLenght = renderGetFontDrawTextLength(font, text) local textLenght = renderGetFontDrawTextLength(font, text)
@ -407,3 +389,288 @@ function split(str, delim, plain)
until not pos until not pos
return tokens return tokens
end end
function start_dialog(_menu, put) -- module by trefa & modify (put & list in [])
function _dialog(_menu, id, outs, put)
sampShowDialog(id, _menu.settings.title, tbl_split(_menu.settings.style, _menu, _menu.settings.forward ,_menu.settings.backwards ,_menu.settings.score), _menu.settings.btn1, (_menu.settings.btn2 ~= nil and _menu.settings.btn2 or _), _menu.settings.style)
repeat
wait(0)
if put ~= nil and sampIsDialogActive() then
sampSetCurrentDialogEditboxText(put)
put = nil
end
local result, button, list, input = sampHasDialogRespond(id)
if result then
local out, outs = _menu[((_menu.settings.style == 0 or _menu.settings.style == 1 or _menu.settings.style == 3) and 1 or ((list + 1) > #_menu[1] and 2 or 1))][((_menu.settings.style == 0 or _menu.settings.style == 1 or _menu.settings.style == 3) and 1 or ((list + 1) > #_menu[1] and (list - #_menu[1]) + 1 or list + 1))].click(button, list, input, outs)
if type(out) == "table" then
return _dialog(out, id - 1, outs, put)
elseif type(out) == "boolean" then
if not out then
return out
end
return _dialog(_menu, id, outs, put)
end
end
until result or menu.show[1]
end
function tbl_split(style, tbl, forward ,backwards ,score)
if style == 2 or style == 4 or style == 5 then
text = (style == 5 and tbl[1].text.."\n" or "")
for i, val in ipairs(tbl[1]) do
text = text..""..forward..""..(score and "["..(i-1).."] " or "")..""..val.title..""..backwards
end
if tbl[2] ~= nil then
for _, val in ipairs(tbl[2]) do
text = text..""..forward..""..val.title..""..backwards
end
end
return text
end
return tbl[1].text
end
return _dialog(_menu, 1337, outs, put)
end
-->> UPDATE MODULE
function openURL(url, fpath)
local text = ""
local file_download = false
local download_final = false
if doesFileExist(fpath) then
os.remove(fpath)
end
downloadUrlToFile(url, fpath, function(id, status, p1, p2)
if status == dlstatus.STATUS_ENDDOWNLOADDATA then
file_download = true
end
if status == dlstatus.STATUSEX_ENDDOWNLOAD then
download_final = true
end
end
)
repeat
wait(1000)
until download_final or file_download
if file_download then
local f = io.open(fpath, "r")
if f then
text = f:read("*a")
io.close(f)
end
os.remove(fpath)
end
if (text:find("Not found") and not text:find('"Not found"')) or text == "" then
text = ""
addChatMessage("Не удалось скачать обновление по ссылке:")
addChatMessage(url)
end
return text
end
function addChatMessage(text)
local tag = string.format("{667dff}[%s]{FFFFFF} ", thisScript().name)
sampAddChatMessage(tag..text, 0xFFFFFFFF)
end
script_update = {
version_url = "http://git.deadpoo.net/rubin/ProdHUD/raw/branch/master/version",
script_url = "http://git.deadpoo.net/rubin/ProdHUD/raw/branch/master/ProdHUD.lua",
changelog_url = "http://git.deadpoo.net/rubin/ProdHUD/raw/branch/master/changelog",
address_ini = string.format("rubin-mods-updates\\%s.ini", thisScript().name),
main = function()
if not doesDirectoryExist("moonloader\\config\\rubin-mods-updates") then
createDirectory("moonloader\\config\\rubin-mods-updates")
end
local ini = inicfg.load({
settings = {
check_update = true,
auto_update = true,
server_version = ""
}
}, script_update.address_ini)
ini.settings.version_url = script_update.version_url
ini.settings.script_url = script_update.script_url
ini.settings.changelog_url = script_update.changelog_url
ini.settings.version = thisScript().version
ini.settings.script_name = thisScript().name
local command = (thisScript().name:gsub(" ", "").."-update"):lower()
sampRegisterChatCommand(command, script_update.command)
if ini.settings.check_update or ini.settings.auto_update then
local fpath = os.tmpname()
local result, text = pcall(openURL, script_update.version_url, fpath)
if result then
ini.settings.server_version = text
if text ~= "" and text ~= thisScript().version then
addChatMessage( string.format("Вышла новая версия '%s'. Текущая: '%s'", text, thisScript().version) )
if ini.settings.auto_update then
addChatMessage( string.format("Автообновление скрипта включено. Процесс запущен!") )
script_update.command()
else
addChatMessage( string.format("Автообновление скрипта выключено. Обновить самому: /%s", command) )
end
end
end
end
inicfg.save(ini, script_update.address_ini)
script_update.menu.init()
end,
command = function()
lua_thread.create(function()
local fpath = os.tmpname()
local result, text = pcall(openURL, script_update.version_url, fpath)
if result then
if text ~= "" and text ~= thisScript().version then
addChatMessage( string.format("Вышла новая версия '%s'. Текущая: '%s'", text, thisScript().version) )
local fpath = os.tmpname()
local result, text = pcall(openURL, script_update.script_url, fpath)
if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then
local file, error = io.open(thisScript().path, "w")
if file ~= nil then
file:write(text)
file:flush()
io.close(file)
addChatMessage("Обновление завершено, скрипт перезагружен!")
wait(500)
thisScript():reload()
end
end
else
addChatMessage("У Вас установлена последняя версия!")
end
end
end)
end,
menu = {
dialog = {},
ini = {},
init = function()
if not sampIsChatCommandDefined("rubin-mods") then
sampAddChatMessage("{667dff}[RUBIN MODS]{FFFFFF} Управление обновлениями скриптов: /rubin-mods", 0xFFFFFFFF)
sampRegisterChatCommand("rubin-mods",script_update.menu.show)
while true do
wait(0)
local result, button, list, input = sampHasDialogRespond(2160)
if result and button == 1 then
if script_update.menu.ini[list+1] ~= nil and script_update.menu.dialog[list+1] ~= nil then
script_update.menu.dialog[list+1](script_update.menu.ini[list+1])
end
end
local result, button, list, input = sampHasDialogRespond(2162)
if result then
if button == 1 then
if script_update.menu2.text[list+1] ~= nil and script_update.menu2.dialog[list+1] ~= nil then
script_update.menu2.dialog[list+1]()
end
else
script_update.menu.show()
end
end
local result, button, list, input = sampHasDialogRespond(2161)
if result then
script_update.menu2.show(script_update.menu2.data)
end
end
end
end,
show = function()
script_update.menu.dialog = {}
script_update.menu.ini = {}
local text = ""
if doesDirectoryExist("moonloader\\config\\rubin-mods-updates") then
local FileHandle, FileName = findFirstFile("moonloader\\config\\rubin-mods-updates\\*")
while FileName ~= nil do
if FileName ~= nil and FileName ~= ".." and FileName ~= "." and FileName:find("%.ini") then
local address = string.format("moonloader\\config\\rubin-mods-updates\\%s", FileName)
if doesFileExist(address) then
local ini = inicfg.load({}, address)
script_update.menu.ini[#script_update.menu.ini+1] = address
text = string.format("%s%s\n", text, string.format("%s\t%s%s", ini.settings.script_name, (ini.settings.version == ini.settings.server_version and "{59fc30}" or "{ff0000}"),ini.settings.version))
script_update.menu.dialog[#script_update.menu.dialog+1] = function(data)
script_update.menu2.show(data)
end
end
end
FileName = findNextFile(FileHandle)
end
findClose(FileHandle)
else
text = "Не найдена директория:\t\n moonloader\\config\\rubin-mods-updates\t"
end
sampShowDialog(2160,"Обновление скриптов: Rubin Mods","Скрипт\tВерсия\n"..text,"Выбрать","Закрыть",5)
end
},
menu2 = {
data = {},
text = {},
dialog = {},
show = function(data)
script_update.menu2.data = data
script_update.menu2.text = {}
script_update.menu2.dialog = {}
if doesFileExist(data) then
local ini = inicfg.load({}, data)
script_update.menu2.text[#script_update.menu2.text+1] = string.format("Автообновление %s", (ini.settings.auto_update and "{59fc30}ON" or "{ff0000}OFF"))
script_update.menu2.dialog[#script_update.menu2.dialog+1] = function()
ini.settings.auto_update = not ini.settings.auto_update
inicfg.save(ini, data)
script_update.menu2.show(data)
end
if not ini.settings.auto_update then
script_update.menu2.text[#script_update.menu2.text+1] = string.format("Проверять обновления %s", (ini.settings.check_update and "{59fc30}ON" or "{ff0000}OFF"))
script_update.menu2.dialog[#script_update.menu2.dialog+1] = function()
ini.settings.check_update = not ini.settings.check_update
inicfg.save(ini, data)
script_update.menu2.show(data)
end
end
script_update.menu2.text[#script_update.menu2.text+1] = string.format("Последние изменения")
script_update.menu2.dialog[#script_update.menu2.dialog+1] = function()
script_update.changelog(ini.settings.changelog_url, ini.settings.script_name)
end
script_update.menu2.text[#script_update.menu2.text+1] = string.format("Удалить из списка")
script_update.menu2.dialog[#script_update.menu2.dialog+1] = function()
os.remove(data)
script_update.menu.show()
end
local text = ""
for i = 1, #script_update.menu2.text do
text = text..script_update.menu2.text[i].."\n"
end
sampShowDialog(2162,"Настройки обновления для "..ini.settings.script_name,text,"Выбрать","Назад",2)
end
end
},
changelog = function(url, name)
local fpath = os.tmpname()
local result, text = pcall(openURL, url, fpath)
if result then
sampShowDialog(2161,"Changelog - "..name,text,"Выбрать","Назад",4)
end
end
}
-->> SCRIPT UTF-8
-->> utf8(table path, incoming variables encoding, outcoming variables encoding)
-->> table path example { "sampev", "onShowDialog" }
-->> encoding options nil | AnsiToUtf8 | Utf8ToAnsi
_utf8 = load([=[return function(utf8_func, in_encoding, out_encoding); if encoding == nil then; encoding = require("encoding"); encoding.default = "CP1251"; u8 = encoding.UTF8; end; if type(utf8_func) ~= "table" then; return false; end; if AnsiToUtf8 == nil or Utf8ToAnsi == nil then; AnsiToUtf8 = function(text); return u8(text); end; Utf8ToAnsi = function(text); return u8:decode(text); end; end; if _UTF8_FUNCTION_SAVE == nil then; _UTF8_FUNCTION_SAVE = {}; end; local change_var = "_G"; for s = 1, #utf8_func do; change_var = string.format('%s["%s"]', change_var, utf8_func[s]); end; if _UTF8_FUNCTION_SAVE[change_var] == nil then; _UTF8_FUNCTION = function(...); local pack = table.pack(...); readTable = function(t, enc); for k, v in next, t do; if type(v) == 'table' then; readTable(v, enc); else; if enc ~= nil and (enc == "AnsiToUtf8" or enc == "Utf8ToAnsi") then; if type(k) == "string" then; k = _G[enc](k); end; if type(v) == "string" then; t[k] = _G[enc](v); end; end; end; end; return t; end; return table.unpack(readTable({_UTF8_FUNCTION_SAVE[change_var](table.unpack(readTable(pack, in_encoding)))}, out_encoding)); end; local text = string.format("_UTF8_FUNCTION_SAVE['%s'] = %s; %s = _UTF8_FUNCTION;", change_var, change_var, change_var); load(text)(); _UTF8_FUNCTION = nil; end; return true; end]=])
function utf8(...)
pcall(_utf8(), ...)
end
utf8({ "sampShowDialog" }, "Utf8ToAnsi")
utf8({ "sampSendChat" }, "Utf8ToAnsi")
utf8({ "sampAddChatMessage" }, "Utf8ToAnsi")
utf8({ "print" }, "Utf8ToAnsi")
utf8({ "sampHasDialogRespond" }, nil, "AnsiToUtf8")
utf8({ "renderFontDrawText" }, "Utf8ToAnsi")
utf8({ "renderGetFontDrawTextLength" }, "Utf8ToAnsi")

@ -0,0 +1,21 @@
[![Cкачать](pictures/download.png)](ProdHUD.lua)
# [**Cкачать**](ProdHUD.lua)
Перенести файл ProdHUD.lua в папку moonloader
# Описание
Скрипт сделан для быстрой загрузки/разгрузки и просмотра мониторинга
# Активация
Для активации меню нужно зажать ПКМ (правую кнопку мыши) сидя в машине развозчика продуктов!
# Мониторинг цен
Для обновления нажать на кнопку [Обновить цены]\
Имеет четыре страницы с ценами\
Для перемещения по ним используйте колёсико мыши\
Либо просто кликайте на пункты и они будут перелистываться
# Загрузка / Разгрузка
Берёт максимальное кол-во товара
# GPS
При нажатии на название бизнеса установится метка GPS

@ -0,0 +1,6 @@
Версия от 23.11.2024
Пофикшен не работающий GPS на бизы
Скрипт добавлен на git
Переведен в UTF-8
Добавлено авто-обновление
Убраны надоедливые диалоги после разгрузки

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Loading…
Cancel
Save