diff --git a/TruckHUD.lua b/TruckHUD.lua index a764f1f..6a6b6d7 100644 --- a/TruckHUD.lua +++ b/TruckHUD.lua @@ -1,7 +1,6 @@ script_name("TruckHUD") script_author("Serhiy_Rubin") script_version("2209011") -collectgarbage("stop") local inicfg = require "inicfg" local dlstatus = require("moonloader").download_status @@ -158,6 +157,7 @@ binder_mode_sms = false stop_downloading_1, stop_downloading_2, stop_downloading_3, stop_downloading_4, stop_downloading_5 = false, false, false, false, false threads = {} +threads_save = {} function main() if not isSampLoaded() or not isSampfuncsLoaded() then return end @@ -198,7 +198,7 @@ function main() createDirectory(AdressFolder) end settings_load() - lua_thread.create(get_time) + threads_save[#threads_save+1] = lua_thread.create(get_time) logAvailable() for k,v in pairs(prices_mon) do prices_mon[k] = inifiles.tmonitor[k] @@ -209,11 +209,11 @@ function main() font = renderCreateFont(inifiles.Render.FontName, inifiles.Render.FontSize, inifiles.Render.FontFlag) --gmap area - lua_thread.create(transponder) - lua_thread.create(fastmap) - lua_thread.create(renderTruckers) - lua_thread.create(luChecker.checker) - lua_thread.create(script_update.main) + threads_save[#threads_save+1] = lua_thread.create(transponder) + threads_save[#threads_save+1] = lua_thread.create(fastmap) + threads_save[#threads_save+1] = lua_thread.create(renderTruckers) + threads_save[#threads_save+1] = lua_thread.create(luChecker.checker) + --lua_thread.create(script_update.main) @@ -476,7 +476,7 @@ function doControl() delay.dir = 1 end if i == 7 and script_run then - lua_thread.create(showTruckers) + threads[#threads+1] = lua_thread.create(showTruckers) end if i == 8 then ShowDialog1(1) @@ -829,7 +829,7 @@ function doDialog() end if str:find("Очистить неиспользуемую память скрипта") then local mem_do = string.format('%0.2f MB', (tonumber(gcinfo()) / 1000)) - ~() + collectgarbage() sampAddChatMessage('Памяти очищена. Было: '..mem_do..'. Стало: '..string.format('%0.2f MB', (tonumber(gcinfo()) / 1000)), -1) ShowDialog1(1) end @@ -1973,7 +1973,7 @@ function ShowDialog1(int, dtext, dinput, string_or_number, ini1, ini2) ) end if int == 4 then - lua_thread.create( + threads[#threads+1] = lua_thread.create( function() wait(100) local key = "" @@ -2651,7 +2651,7 @@ function loadEvents() end if string.find(Dtitle, "Работы") and delay.dir == 3 then - lua_thread.create( + threads[#threads+1] = lua_thread.create( function() repeat wait(0) @@ -3630,7 +3630,8 @@ function get_time() msk_timestamp = msk_timestamp + (os.time() - _time) _time = os.time() if inifiles.Settings.AutoClear then - --collectgarbage() + threads = {} + collectgarbage() end end end @@ -4296,12 +4297,12 @@ end function openURL(url, fpath) local result = false + local text = "" local file_download = false local download_final = false if doesFileExist(fpath) then - say("remove") os.remove(fpath) end @@ -4320,9 +4321,9 @@ function openURL(url, fpath) until download_final or file_download if file_download then - local text = "" local f = io.open(fpath, "r") if f then + result = true text = f:read("*a") io.close(f) end @@ -4367,9 +4368,9 @@ script_update = { addChatMessage( string.format("Авто-Обновление скрипта включено. Процесс запущен!") ) script_update.command() else - local command = thisScript().name:gsub(" ", "").."_update" + local command = thisScript().name:gsub(" ", "").."-update" sampRegisterChatCommand(command, script_update.command) - addChatMessage( string.format("Авто-Обновление скрипта выключено. Обновить самому: %s", command) ) + addChatMessage( string.format("Авто-Обновление скрипта выключено. Обновить самому: /%s", command) ) end end end @@ -4377,7 +4378,7 @@ script_update = { script_update.menu.init() end, command = function() - lua_thread.create(function() + threads[#threads+1] = lua_thread.create(function() local fpath = os.tmpname() local result, text = openURL(script_update.auto_update_url, fpath) if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then