From c317b6471922ebf3f99418b747dede70db67e3a7 Mon Sep 17 00:00:00 2001 From: rubin Date: Fri, 13 Jan 2023 19:47:35 +0300 Subject: [PATCH] fix destroy 3d text & fix get vehicle --- TruckHUD.lua | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/TruckHUD.lua b/TruckHUD.lua index 587c61f..bcb17db 100644 --- a/TruckHUD.lua +++ b/TruckHUD.lua @@ -1069,8 +1069,7 @@ function doCruise() wait(0) if inifiles.Settings.Cruise and script_run then additional_key_stop = { "VK_W", "VK_S", "VK_SPACE" } - local car = storeCarCharIsInNoSave(playerPed) - if not isCharInAnyCar(playerPed) or not isCarEngineOn(car) then + if not isCharInAnyCar(playerPed) or not isCarEngineOn(storeCarCharIsInNoSave(playerPed)) then if cruise then cruise = false printStringNow('~R~cruise control - OFF', 1500) @@ -3595,7 +3594,9 @@ function onScriptTerminate(LuaScript, quitGame) end delete_all__3dTextplayers() removeBlip(pttBlip) - sampDestroy3dText(ptt3dText) + if sampIs3dTextDefined(ptt3dText) then + sampDestroy3dText(ptt3dText) + end deleteActor(999) end end @@ -4311,7 +4312,6 @@ end -->> UPDATE MODULE function openURL(url, fpath) - local result = false local text = "" local file_download = false local download_final = false @@ -4338,16 +4338,19 @@ function openURL(url, fpath) if file_download then local f = io.open(fpath, "r") if f then - result = true text = f:read("*a") io.close(f) end os.remove(fpath) - else + end + + if text:find("Not found") or text == "" then + text = "" addChatMessage("Не удалось скачать обновление по ссылке:") addChatMessage(url) end - return result, text + + return text end @@ -4366,18 +4369,20 @@ script_update = { local ini = inicfg.load({ [name] = { check_update = true, - auto_update = true + auto_update = true, + server_version = "" } }, script_update.address_ini) ini[name].version_url = script_update.version_url ini[name].script_url = script_update.script_url ini[name].changelog_url = script_update.changelog_url + ini[name].version = thisScript().version ini[name].script_name = thisScript().name - inicfg.save(ini, script_update.address_ini) if ini[name].check_update or ini[name].auto_update then local fpath = os.tmpname() - local result, text = openURL(script_update.version_url, fpath) + local result, text = pcall(openURL, script_update.version_url, fpath) if result then + ini[name].server_version = text if text ~= "" and not string.find(text, thisScript().version) then addChatMessage( string.format("Вышла новая версия '%s'. Текущая: '%s'", text, thisScript().version) ) if ini[name].auto_update then @@ -4391,12 +4396,13 @@ script_update = { 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 = openURL(script_update.script_url, fpath) + -- 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 @@ -4441,8 +4447,6 @@ script_update = { script_update.menu2.show(script_update.menu2.data) end end - else - say("Команда зарегана") end end, show = function() @@ -4452,9 +4456,8 @@ script_update = { local ini = inicfg.load({}, script_update.address_ini) for k,v in pairs(ini) do script_update.menu.ini[#script_update.menu.ini+1] = v - script_update.menu.text[#script_update.menu.text+1] = string.format("%s", k) + script_update.menu.text[#script_update.menu.text+1] = string.format("%s\t%s%s", k, (v.version == v.server_version and "{59fc30}" or "{ff0000}"),v.version) script_update.menu.dialog[#script_update.menu.dialog+1] = function(data) - -- script_update.menu.show() script_update.menu2.show(data) end end @@ -4462,7 +4465,7 @@ script_update = { for i = 1, #script_update.menu.text do text = text..script_update.menu.text[i].."\n" end - sampShowDialog(2160,"Обновление скриптов: Rubin Mods",text,"Выбрать","Закрыть",2) + sampShowDialog(2160,"Обновление скриптов: Rubin Mods","Скрипт\tВерсия\n"..text,"Выбрать","Закрыть",5) end }, menu2 = { @@ -4509,7 +4512,7 @@ script_update = { }, changelog = function(url, data) local fpath = os.tmpname() - local result, text = openURL(url, fpath) + local result, text = pcall(openURL, url, fpath) if result then sampShowDialog(2161,"Changelog - "..thisScript().name,text,"Выбрать","Назад",4) end