update formula skill/rank / fix dialog dir / added check boostinfo

master
rubin 1 month ago
parent 37e7704e0c
commit 6f977f6ce4
  1. 159
      TruckHUD.lua

@ -1,6 +1,6 @@
script_name("TruckHUD")
script_author("Serhiy_Rubin")
script_version("28.06.2026")
script_version("27.07.2026")
local inicfg = require "inicfg"
local dlstatus = require("moonloader").download_status
@ -93,7 +93,7 @@ local prices_3dtext = { n1 = 0, n2 = 0, y1 = 0, y2 = 0, l1 = 0, l2 = 0, lsn = 0,
local prices_mon = { n1 = 0, n2 = 0, y1 = 0, y2 = 0, l1 = 0, l2 = 0, lsn = 0, lsy = 0, lsl = 0, sfn = 0, sfy = 0, sfl = 0 }
local prices_smon = { n1 = 0, n2 = 0, y1 = 0, y2 = 0, l1 = 0, l2 = 0, lsn = 0, lsy = 0, lsl = 0, sfn = 0, sfy = 0, sfl = 0 }
local delay, d = {chatMon = 0, chat = 0, skill = -1, mon = 0, load = 0, unload = 0, sms = 0, dir = 0, paycheck = 0}, {[3] = ""}
local delay, d = {chatMon = 0, chat = 0, skill = -1, mon = 0, load = 0, unload = 0, sms = 0, dir = 0, paycheck = 0, boostinfo = 0}, {[3] = ""}
local pickupLoad = {
[1] = {251.32167053223, 1420.3039550781, 11.5}, -- N1
[2] = {839.09020996094, 880.17510986328, 14.3515625}, -- Y1
@ -352,6 +352,11 @@ function settings_load()
platinum = {
status = false,
time = 0
},
boostinfo = {
pay = 1.0,
exp = 1.0,
date = 0
}
}
if not doesFileExist(AdressJson) then
@ -1125,6 +1130,7 @@ function doCruise()
end
function doRenderStats()
boostinfo.start()
if pos[1] then
sampSetCursorMode(3)
local X, Y = getCursorPos()
@ -2547,8 +2553,7 @@ function loadEvents()
if string.find(message, "Вы заработали (%d+) вирт, из которых (%d+) вирт будет добавлено к вашей зарплате") and isTruckCar() then
pttModule()
timer = msk_timestamp
local Z1, Z2 =
string.match(message, " Вы заработали (%d+) вирт, из которых (%d+) вирт будет добавлено к вашей зарплате")
local Z1, Z2 = string.match(message, " Вы заработали (%d+) вирт, из которых (%d+) вирт будет добавлено к вашей зарплате")
if texts_of_reports[current_warehouse] ~= nil and gruzLOAD ~= nil then
local cena = Z1 / (gruzLOAD / 1000)
local sklad = texts_of_reports[current_warehouse]
@ -2562,6 +2567,11 @@ function loadEvents()
delay.sms = 1
end
end
if inifiles.boostinfo.pay > 1.0 then
local cena_gruz = tonumber(Z1) - tonumber(Z2)
Z2 = tonumber(Z2) * inifiles.boostinfo.pay
Z1 = cena_gruz + Z2
end
if inifiles.Trucker.MaxZP > tonumber(inifiles.log[os.date("%d.%m.%Y", msk_timestamp)].hour[os.date("%H", msk_timestamp)].zp + Z2) then
write_table_log('razgruzka', {Z1, Z2, (Z1 - Z2)}, 2)
else
@ -2587,6 +2597,10 @@ function loadEvents()
auto = false
end
delay.paycheck = 1
if inifiles.boostinfo.pay > 1.0 then
text = string.format(" Вы заработали %d вирт, из которых %d вирт будет добавлено к вашей зарплате", Z1, Z2)
return {color, text}
end
end
if message == " Не флуди!" then
if delay.skill == 2 then
@ -2641,6 +2655,10 @@ function loadEvents()
local Z1 = string.match(message, " Вы купили канистру с 50 литрами бензина за (%d+) вирт")
write_table_log('kanistr', {Z1}, 8)
end
if boostinfo.onServerMessage(color, message) then
return false
end
end
function sampev.onShowDialog(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext)
@ -2657,12 +2675,20 @@ function loadEvents()
local S1 = gruzs / 100 * (1.1 ^ (50 - inifiles.Trucker.Skill))
local S2 = 10000 * (1.1 ^ inifiles.Trucker.Skill)
local S3 = (S1 * 100) / S2
inifiles.Trucker.ReysSkill = math.ceil((100.0 - SkillP) / S3)
inifiles.Trucker.ReysSkill = math.ceil((100.0 - SkillP) / S3) / inifiles.boostinfo.exp
inifiles.Trucker.ProcSkill = SkillP
if inifiles.Trucker.ProcRank ~= RankP then
inifiles.Trucker.ReysRank = math.ceil((100.0 - RankP) / (RankP - inifiles.Trucker.ProcRank))
inifiles.Trucker.ProcRank = RankP
end
-- if inifiles.Trucker.ProcRank ~= RankP then
-- inifiles.Trucker.ReysRank = math.ceil((100.0 - RankP) / (RankP - inifiles.Trucker.ProcRank))
-- inifiles.Trucker.ProcRank = RankP
-- end
local currentRankExp = gruzs * (1.1 ^ Rank) -- Сколько опыта нужно всего для текущего ранга
local expPerTrip = 10000 / 100 * (1.1 ^ (50 - Rank)) -- Опыта в ранг дает один рейс
local percentPerTrip = expPerTrip / currentRankExp * 100 -- В процентах один рейс
-- 0.27 0.135
local trips = (100 - RankP) / percentPerTrip -- Кол-во рейсов осталось до нового ранга
inifiles.Trucker.ReysRank = math.ceil(trips / inifiles.boostinfo.exp)
inifiles.Trucker.ProcRank = RankP
inifiles.Trucker.Skill = Skill
inifiles.Trucker.Rank = Rank
inifiles.Trucker.MaxZP = math.ceil( 50000 + (2500 * (1.1 ^ Skill)) + (2500 * (1.1 ^ Rank)) )
@ -2729,32 +2755,50 @@ function loadEvents()
end
if delay.dir ~= 0 then
if string.find(Dtitle, "Тел.справочник") and delay.dir == 2 then
sampSendDialogResponse(DdialogId, 1, 1, "")
if string.find(Dtitle, "справочник") and delay.dir == 2 then
sampSendDialogResponse(DdialogId, 1, 1, "Работы")
delay.dir = 3
return false
end
if string.find(Dtitle, "Работы") and delay.dir == 3 then
lua_thread.create(
function()
repeat
wait(0)
until delay.dir == 4
wait(150)
sampSendDialogResponse(DdialogId, 1, 8, "[8] Дальнобойщик")
if Dtext:find("Дальнобойщик") then
local arr = split(Dtext, "\n")
dir_list = 0
dir_list_text = ""
for i = 1, #arr do
if arr[i]:find("Дальнобойщик") then
dir_list = i
dir_list_text = arr[i]
break
end
end
)
lua_thread.create(
function()
repeat
wait(0)
until delay.dir == 4
wait(550)
sampSendDialogResponse(DdialogId, 1, dir_list - 1, "Дальнобойщик")
end
)
else
sampShowDialog(0,"Дальнобойщик","{ffffff}Список пуст","Закрыть","",0)
end
delay.dir = 4
return false
end
if string.find(Dtitle, "Меню") and string.find(Dtext, "AFK секунд") and delay.dir == 4 then
if string.find(Dtitle, "Дальнобойщик") and string.find(Dtext, "AFK секунд") and delay.dir == 4 then
delay.dir = 0
sampShowDialog(222, Dtitle, Dtext, Dbutton1, Dbutton2, Dstyle)
return false
end
end
if boostinfo.dialog(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext) then
return false
end
end
function sampev.onCreate3DText(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text)
@ -3956,6 +4000,80 @@ function pttModule()
end
end
-->> boostinfo checker
boostinfo = {}
boostinfo.wait = 0
boostinfo.start = function()
if delay.boostinfo == 1 then
if os.clock() * 1000 - antiflood > 3000 then
boostinfo.wait = os.time()
sampSendChat("/boostinfo")
end
end
if delay.boostinfo == 0 then
delay.boostinfo = 1
end
if inifiles.boostinfo.date ~= 0 then
if os.time() > inifiles.boostinfo.date then
inifiles.boostinfo.pay = 1.0
inifiles.boostinfo.exp = 1.0
inifiles.boostinfo.date = 0
settings_save()
end
end
end
boostinfo.dialog = function(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext)
if delay.boostinfo > 0 then
if Dtitle:find("Бонусы") then
sampSendDialogResponse(DdialogId,(delay.boostinfo == 1 and 1 or 0),0,"[0] Общие бонусы")
delay.boostinfo = 2
return true
end
if Dtitle:find("Общие бонусы") then
local arr = split(Dtext, "\n")
for k,v in pairs(arr) do
if v:find("Зарплаты") then
inifiles.boostinfo.pay = tonumber(v:match("(%d+%.%d+)"))
end
if v:find("Дальнобойщика") then
inifiles.boostinfo.exp = tonumber(v:match("(%d+%.%d+)"))
end
end
settings_save()
sampSendDialogResponse(DdialogId,0,0,"[0] Общие бонусы")
return true
end
end
if os.time() - boostinfo.wait < 4 and Dtitle:find("онусы") then
sampSendDialogResponse(DdialogId,0,0,"[0] Общие бонусы")
return true
end
end
boostinfo.onServerMessage = function(color, message)
if delay.boostinfo > 0 then
if message:find("Действует до: (....)/(..)/(..) (..):(..):(..)") then
local year, month, day, hour, min, sec = message:match("Действует до: (....)/(..)/(..) (..):(..):(..)")
datetime = { year = year, month = month, day = day, hour = hour, min = min, sec = sec }
inifiles.boostinfo.date = os.time(datetime)
settings_save()
delay.boostinfo = -1
return true
end
if message:find("Бонусы отключены") then
inifiles.boostinfo.pay = 1.0
inifiles.boostinfo.exp = 1.0
inifiles.boostinfo.date = 0
settings_save()
delay.boostinfo = -1
return true
end
end
if os.time() - boostinfo.wait < 4 and (message:find("Действует до: (....)/(..)/(..) (..):(..):(..)") or message:find("Бонусы отключены")) then
return true
end
end
--> LOAD & UNLOAD CHECKER
luChecker = {
@ -4504,3 +4622,4 @@ utf8({ "sampSet3dTextString" }, "Utf8ToAnsi")
utf8({ "sampGetDialogText" }, nil, "AnsiToUtf8")
utf8({ "sampGetDialogCaption" }, nil, "AnsiToUtf8")
utf8({ "sampHasDialogRespond" }, nil, "AnsiToUtf8")
utf8({ "sampSendDialogResponse" }, "Utf8ToAnsi")
Loading…
Cancel
Save