fix collectgarbage

test-utf-8
rubin 2 years ago
parent 43e113afeb
commit c17889ac85
  1. 35
      TruckHUD.lua

@ -1,7 +1,6 @@
script_name("TruckHUD") script_name("TruckHUD")
script_author("Serhiy_Rubin") script_author("Serhiy_Rubin")
script_version("2209011") script_version("2209011")
collectgarbage("stop")
local inicfg = require "inicfg" local inicfg = require "inicfg"
local dlstatus = require("moonloader").download_status 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 stop_downloading_1, stop_downloading_2, stop_downloading_3, stop_downloading_4, stop_downloading_5 = false, false, false, false, false
threads = {} threads = {}
threads_save = {}
function main() function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end if not isSampLoaded() or not isSampfuncsLoaded() then return end
@ -198,7 +198,7 @@ function main()
createDirectory(AdressFolder) createDirectory(AdressFolder)
end end
settings_load() settings_load()
lua_thread.create(get_time) threads_save[#threads_save+1] = lua_thread.create(get_time)
logAvailable() logAvailable()
for k,v in pairs(prices_mon) do for k,v in pairs(prices_mon) do
prices_mon[k] = inifiles.tmonitor[k] prices_mon[k] = inifiles.tmonitor[k]
@ -209,11 +209,11 @@ function main()
font = renderCreateFont(inifiles.Render.FontName, inifiles.Render.FontSize, inifiles.Render.FontFlag) font = renderCreateFont(inifiles.Render.FontName, inifiles.Render.FontSize, inifiles.Render.FontFlag)
--gmap area --gmap area
lua_thread.create(transponder) threads_save[#threads_save+1] = lua_thread.create(transponder)
lua_thread.create(fastmap) threads_save[#threads_save+1] = lua_thread.create(fastmap)
lua_thread.create(renderTruckers) threads_save[#threads_save+1] = lua_thread.create(renderTruckers)
lua_thread.create(luChecker.checker) threads_save[#threads_save+1] = lua_thread.create(luChecker.checker)
lua_thread.create(script_update.main) --lua_thread.create(script_update.main)
@ -476,7 +476,7 @@ function doControl()
delay.dir = 1 delay.dir = 1
end end
if i == 7 and script_run then if i == 7 and script_run then
lua_thread.create(showTruckers) threads[#threads+1] = lua_thread.create(showTruckers)
end end
if i == 8 then if i == 8 then
ShowDialog1(1) ShowDialog1(1)
@ -829,7 +829,7 @@ function doDialog()
end end
if str:find("Î÷èñòèòü íåèñïîëüçóåìóþ ïàìÿòü ñêðèïòà") then if str:find("Î÷èñòèòü íåèñïîëüçóåìóþ ïàìÿòü ñêðèïòà") then
local mem_do = string.format('%0.2f MB', (tonumber(gcinfo()) / 1000)) local mem_do = string.format('%0.2f MB', (tonumber(gcinfo()) / 1000))
~() collectgarbage()
sampAddChatMessage('Ïàìÿòè î÷èùåíà. Áûëî: '..mem_do..'. Ñòàëî: '..string.format('%0.2f MB', (tonumber(gcinfo()) / 1000)), -1) sampAddChatMessage('Ïàìÿòè î÷èùåíà. Áûëî: '..mem_do..'. Ñòàëî: '..string.format('%0.2f MB', (tonumber(gcinfo()) / 1000)), -1)
ShowDialog1(1) ShowDialog1(1)
end end
@ -1973,7 +1973,7 @@ function ShowDialog1(int, dtext, dinput, string_or_number, ini1, ini2)
) )
end end
if int == 4 then if int == 4 then
lua_thread.create( threads[#threads+1] = lua_thread.create(
function() function()
wait(100) wait(100)
local key = "" local key = ""
@ -2651,7 +2651,7 @@ function loadEvents()
end end
if string.find(Dtitle, "Ðàáîòû") and delay.dir == 3 then if string.find(Dtitle, "Ðàáîòû") and delay.dir == 3 then
lua_thread.create( threads[#threads+1] = lua_thread.create(
function() function()
repeat repeat
wait(0) wait(0)
@ -3630,7 +3630,8 @@ function get_time()
msk_timestamp = msk_timestamp + (os.time() - _time) msk_timestamp = msk_timestamp + (os.time() - _time)
_time = os.time() _time = os.time()
if inifiles.Settings.AutoClear then if inifiles.Settings.AutoClear then
--collectgarbage() threads = {}
collectgarbage()
end end
end end
end end
@ -4296,12 +4297,12 @@ end
function openURL(url, fpath) function openURL(url, fpath)
local result = false local result = false
local text = ""
local file_download = false local file_download = false
local download_final = false local download_final = false
if doesFileExist(fpath) then if doesFileExist(fpath) then
say("remove")
os.remove(fpath) os.remove(fpath)
end end
@ -4320,9 +4321,9 @@ function openURL(url, fpath)
until download_final or file_download until download_final or file_download
if file_download then if file_download then
local text = ""
local f = io.open(fpath, "r") local f = io.open(fpath, "r")
if f then if f then
result = true
text = f:read("*a") text = f:read("*a")
io.close(f) io.close(f)
end end
@ -4367,9 +4368,9 @@ script_update = {
addChatMessage( string.format("Àâòî-Îáíîâëåíèå ñêðèïòà âêëþ÷åíî. Ïðîöåññ çàïóùåí!") ) addChatMessage( string.format("Àâòî-Îáíîâëåíèå ñêðèïòà âêëþ÷åíî. Ïðîöåññ çàïóùåí!") )
script_update.command() script_update.command()
else else
local command = thisScript().name:gsub(" ", "").."_update" local command = thisScript().name:gsub(" ", "").."-update"
sampRegisterChatCommand(command, script_update.command) sampRegisterChatCommand(command, script_update.command)
addChatMessage( string.format("Àâòî-Îáíîâëåíèå ñêðèïòà âûêëþ÷åíî. Îáíîâèòü ñàìîìó: %s", command) ) addChatMessage( string.format("Àâòî-Îáíîâëåíèå ñêðèïòà âûêëþ÷åíî. Îáíîâèòü ñàìîìó: /%s", command) )
end end
end end
end end
@ -4377,7 +4378,7 @@ script_update = {
script_update.menu.init() script_update.menu.init()
end, end,
command = function() command = function()
lua_thread.create(function() threads[#threads+1] = lua_thread.create(function()
local fpath = os.tmpname() local fpath = os.tmpname()
local result, text = openURL(script_update.auto_update_url, fpath) local result, text = openURL(script_update.auto_update_url, fpath)
if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then if result and text ~= "" and text:find(thisScript().name:gsub("%-", "%%-")) then

Loading…
Cancel
Save