From 10b073a229167ac81d2af2dfe9387ffbba9f9403 Mon Sep 17 00:00:00 2001 From: rubin Date: Sat, 10 Dec 2022 21:00:41 +0300 Subject: [PATCH] add send solo checker --- TruckHUD.lua | 102 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 24 deletions(-) diff --git a/TruckHUD.lua b/TruckHUD.lua index aba86b1..833c60e 100755 --- a/TruckHUD.lua +++ b/TruckHUD.lua @@ -56,13 +56,14 @@ local menu = { [2] = {[1] = "Load/Unload: {06940f}ON", [2] = "Load/Unload: {d10000}OFF", run = false}, [3] = {[1] = "Авто-Доклад: {06940f}ON", [2] = "Авто-Доклад: {d10000}OFF", run = false}, [4] = {[1] = "SMS » Serhiy_Rubin[777]", [2] = "Режим пары: {d10000}OFF", run = false}, - [5] = {[1] = "Дальнобойщики онлайн", [2] = "Дальнобойщики онлайн", run = false}, - [6] = {[1] = "Дальнобойщики со скриптом", [2] = "Дальнобойщики со скриптом", run = false}, - [7] = {[1] = "Настройки", [2] = "Настройки", run = false}, - [8] = {[1] = "Мониторинг цен", [2] = "Мониторинг цен", run = false}, - [9] = {[1] = "Купить груз", [2] = "Купить груз", run = false}, - [10] = {[1] = "Продать груз", [2] = "Продать груз", run = false}, - [11] = {[1] = "Восстановить груз", [2] = "Восстановить груз", run = false} + [5] = {[1] = "Соло-Чекер: ", [2] = "Соло-Чекер: ", run = false}, + [6] = {[1] = "Дальнобойщики онлайн", [2] = "Дальнобойщики онлайн", run = false}, + [7] = {[1] = "Дальнобойщики со скриптом", [2] = "Дальнобойщики со скриптом", run = false}, + [8] = {[1] = "Настройки", [2] = "Настройки", run = false}, + [9] = {[1] = "Мониторинг цен", [2] = "Мониторинг цен", run = false}, + [10] = {[1] = "Купить груз", [2] = "Купить груз", run = false}, + [11] = {[1] = "Продать груз", [2] = "Продать груз", run = false}, + [12] = {[1] = "Восстановить груз", [2] = "Восстановить груз", run = false} } local pair_mode, sms_pair_mode, report_text, pair_mode_id, pair_mode_name, BinderMode = false, "", "", -1, "Нет", true @@ -389,6 +390,12 @@ function doControl() Y = ((Y / 2.2) - (renderGetFontDrawHeight(font) * 3)) for i = 1, 11 do local string_render = (menu[i].run and menu[i][1] or menu[i][2]) + if i == 5 then + local text = { "{d10000}OFF", "{06940f}Нефть", "{06940f}Уголь", "{06940f}Дерево" } + if text[inifiles.Settings.luCheckerCargo+1] ~= nil then + string_render = string.format("%s%s", string_render, text[inifiles.Settings.luCheckerCargo+1]) + end + end if drawClickableText(string_render, ((X / 2) - (renderGetFontDrawTextLength(font, string_render) / 2)), Y) then if i == 1 then script_run = not script_run @@ -415,24 +422,32 @@ function doControl() end end if i == 5 then + inifiles.Settings.luCheckerCargo = inifiles.Settings.luCheckerCargo + 1 + if inifiles.Settings.luCheckerCargo >= 4 then + inifiles.Settings.luCheckerCargo = 0 + end + luChecker.load_position.x, luChecker.load_position.y, luChecker.load_position.z = 7777.0, 7777.0, 7777.0 + settings_save() + end + if i == 6 then delay.dir = 1 end - if i == 6 and script_run then + if i == 7 and script_run then lua_thread.create(showTruckers) end - if i == 7 then + if i == 8 then ShowDialog1(1) end - if i == 8 then + if i == 9 then sampSendChat("/truck mon") end - if i == 9 then + if i == 10 then sampSendChat("/truck load " .. GetGruz()) end - if i == 10 then + if i == 11 then sampSendChat("/truck unload") end - if i == 11 then + if i == 12 then sampSendChat("/truck trailer") end end @@ -2073,7 +2088,7 @@ function loadEvents() function() local fpath = os.getenv("TEMP") .. "\\TruckHUD-up.txt" downloadUrlToFile( - "http://th.deadpoo.net/download/changelog", + "http://thprivate.deadpoo.net/download/changelog", fpath, function(id, status, p1, p2) if stop_downloading_3 then @@ -2937,7 +2952,7 @@ end function check_version(update, downgrade_ver) local fpath = os.getenv("TEMP") .. "\\truck-version.txt" downloadUrlToFile( - "http://th.deadpoo.net/download/version", + "http://thprivate.deadpoo.net/download/version", fpath, function(id, status, p1, p2) if status == dlstatus.STATUS_ENDDOWNLOADDATA then @@ -2981,7 +2996,7 @@ function check_version(update, downgrade_ver) lua_thread.create(function(data) wait(1000) fpath = os.getenv("TEMP").."\\truck-update.txt" - downloadUrlToFile("http://th.deadpoo.net/download/"..downgrade_ver, fpath, + downloadUrlToFile("http://thprivate.deadpoo.net/download/"..downgrade_ver, fpath, function(id3, status1, p13, p23) if status1 == dlstatus.STATUS_ENDDOWNLOADDATA then local f = io.open(fpath, "r") @@ -3268,9 +3283,20 @@ end --------------------------------------GMAP-------------------------------------- -------------------------------------------------------------------------------- delay_start = 0 + +function clearSoloMessage() + solo_message_send = { + name = "", + id = -1, + cargo = 0, + time = 0 + } +end + function transponder() new_pair = {} error_array = {} + clearSoloMessage() while true do wait(0) if script_run and inifiles.Settings.transponder then @@ -3287,6 +3313,10 @@ function transponder() local result, myid = sampGetPlayerIdByCharHandle(PLAYER_PED) local myname = sampGetPlayerNickname(myid) + if os.time() - solo_message_send.time > 5 then -- Очистить если данные устарели + clearSoloMessage() + end + request_table["info"] = { server = ip .. ":" .. tostring(port), sender = myname, @@ -3301,7 +3331,8 @@ function transponder() paraid = pair_mode_id, timer = timer, tmonitor = inifiles.tmonitor - } + }, + solo_message = solo_message_send } request_table['random'] = tostring(os.clock()):gsub('%.', '') @@ -3317,7 +3348,7 @@ function transponder() local response_path = os.tmpname() down = false download_id_4 = downloadUrlToFile( - "http://th.deadpoo.net/" .. encodeJson(request_table), + "http://thprivate.deadpoo.net/" .. encodeJson(request_table), response_path, function(id, status, p1, p2) if stop_downloading_4 then @@ -3350,6 +3381,7 @@ function transponder() print("{ff0000}[" .. string.upper(thisScript().name) .. "]: Был получен некорректный ответ от сервера.") else if download_call == 0 then + clearSoloMessage() transponder_delay = info.delay response_timestamp = info.timestamp if info.base ~= nil then @@ -3478,7 +3510,7 @@ function dn(nam) file = getGameDirectory() .. "\\moonloader\\resource\\TruckHUD\\" .. nam if not doesFileExist(file) then downloadUrlToFile( - "http://th.deadpoo.net/download/" .. nam, + "http://thprivate.deadpoo.net/download/" .. nam, file ) end @@ -3599,7 +3631,7 @@ function get_time() _time = os.time() if inifiles.Settings.transponder then local adress = os.getenv('TEMP')..'\\truck-timestamp' - local url = 'http://th.deadpoo.net/timestamp' + local url = 'http://thprivate.deadpoo.net/timestamp' downloadUrlToFile(url, adress, function(id, status, p1, p2) if status == dlstatus.STATUSEX_ENDDOWNLOAD then if doesFileExist(adress) then @@ -4114,6 +4146,13 @@ function luChecker.checkerLoad(playerId, data, position) -- local dist_trucker_storage = getDistanceBetweenCoords3d(trucker_x, trucker_y, trucker_z, x, y, z) if dist_localPlayer_storage <= 120.0 and dist_trucker_storage <= 50.0 then + solo_message_send = { + name = getNameById(playerId), + id = playerId, + action = "load" + cargo = inifiles.Settings.luCheckerCargo, + time = os.time() + } sampAddChatMessage("игрок получил груз "..playerId.." "..dist_localPlayer_storage.." "..dist_trucker_storage.." +++ "..luChecker.truckers[playerId]["trailerData"]["trailerId"].." ++++ "..data["trailerId"],-1) end end @@ -4121,7 +4160,6 @@ function luChecker.checkerLoad(playerId, data, position) -- end function luChecker.set3Dtext(type, data_old, data, position) - inifiles.Settings.luCheckerCargo = 1 if type == "Порт" then local key = inifiles.Settings.luCheckerCargo say(string.format("%s %s", data_old[key], data[key])) @@ -4157,9 +4195,17 @@ function luChecker.checker() if getLocalPlayerId() ~= playerId then local dist = getDistanceBetweenCoords3d(position_3dtext.x,position_3dtext.y,position_3dtext.z,position_trailer.x,position_trailer.y,position_trailer.z) - - local text = string.format("игрок %s %s %s %s", playerId, (type == "load" and "загрузил" or "разгрузил"), inifiles.Settings.luCheckerCargo, dist ) - say(">> "..text) + if dist < 50 then + solo_message_send = { + name = getNameById(playerId), + id = playerId, + action = "unload" + cargo = inifiles.Settings.luCheckerCargo, + time = os.time() + } + local text = string.format("игрок %s %s %s %s", playerId, (type == "load" and "загрузил" or "разгрузил"), inifiles.Settings.luCheckerCargo, dist ) + say(">> "..text) + end end table.remove(luChecker.trailer_delete, 1) @@ -4172,6 +4218,14 @@ function getLocalPlayerId() return select(2,sampGetPlayerIdByCharHandle(PLAYER_PED)) end +function getNameById(i) + local name = "" + if sampIsPlayerConnected(i) or i == select(2,sampGetPlayerIdByCharHandle(PLAYER_PED)) then + local name = sampGetPlayerNickname(i) + end + return name +end + function clear_old_value(key) local delete = {} for i = 1, #luChecker[key] do