fix collectgarbage + & thread delete, now functions

test-utf-8
rubin 2 years ago
parent c17889ac85
commit 350a253188
  1. 93
      TruckHUD.lua

@ -198,7 +198,7 @@ function main()
createDirectory(AdressFolder)
end
settings_load()
threads_save[#threads_save+1] = lua_thread.create(get_time)
lua_thread.create(get_time)
logAvailable()
for k,v in pairs(prices_mon) do
prices_mon[k] = inifiles.tmonitor[k]
@ -209,10 +209,12 @@ function main()
font = renderCreateFont(inifiles.Render.FontName, inifiles.Render.FontSize, inifiles.Render.FontFlag)
--gmap area
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(transponder)
lua_thread.create(fastmap)
lua_thread.create(renderTruckers)
lua_thread.create(luChecker.checker)
lua_thread.create(doCruise)
--lua_thread.create(script_update.main)
@ -231,7 +233,6 @@ function main()
doPickup()
doPtt()
if script_run then
doCruise()
if not sampIsScoreboardOpen() and sampIsChatVisible() and not isKeyDown(116) and not isKeyDown(121) and fastmapshow == nil then
doRenderStats()
doRenderMon()
@ -476,7 +477,7 @@ function doControl()
delay.dir = 1
end
if i == 7 and script_run then
threads[#threads+1] = lua_thread.create(showTruckers)
lua_thread.create(showTruckers)
end
if i == 8 then
ShowDialog1(1)
@ -829,7 +830,7 @@ function doDialog()
end
if str:find("Î÷èñòèòü íåèñïîëüçóåìóþ ïàìÿòü ñêðèïòà") then
local mem_do = string.format('%0.2f MB', (tonumber(gcinfo()) / 1000))
collectgarbage()
collectgarbage("step")
sampAddChatMessage('Ïàìÿòè î÷èùåíà. Áûëî: '..mem_do..'. Ñòàëî: '..string.format('%0.2f MB', (tonumber(gcinfo()) / 1000)), -1)
ShowDialog1(1)
end
@ -1063,31 +1064,34 @@ end
cruise = false
function doCruise()
if not inifiles.Settings.Cruise then return end
additional_key_stop = { "VK_W", "VK_S", "VK_SPACE" }
local car = storeCarCharIsInNoSave(playerPed)
if not isCharInAnyCar(playerPed) or not isCarEngineOn(car) then
if cruise then
cruise = false
printStringNow('~R~cruise control - OFF', 1500)
end
return
end
if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then
if not cruise and isKeyDown(vkeys["VK_W"]) and isKeyDown(vkeys[inifiles.Settings.Key4]) then
repeat
wait(100)
until not isKeyDown(vkeys["VK_W"])
cruise = true
printStringNow('~G~cruise control - ON', 1500)
elseif cruise and not isKeyDown(vkeys[inifiles.Settings.Key4]) and select(1, check_press_key(additional_key_stop)) then
cruise = false
printStringNow('~R~cruise control - OFF', 1500)
while true do
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 cruise then
cruise = false
printStringNow('~R~cruise control - OFF', 1500)
end
end
if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsCursorActive() then
if not cruise and isKeyDown(vkeys["VK_W"]) and isKeyDown(vkeys[inifiles.Settings.Key4]) then
cruise = true
printStringNow('~G~cruise control - ON', 1500)
repeat
wait(100)
until not isKeyDown(vkeys["VK_W"])
elseif cruise and not isKeyDown(vkeys[inifiles.Settings.Key4]) and select(1, check_press_key(additional_key_stop)) then
cruise = false
printStringNow('~R~cruise control - OFF', 1500)
end
end
if cruise then
setGameKeyState(16, 255)
end
end
end
if cruise then
setGameKeyState(16, 255)
end
end
function doRenderStats()
@ -1973,7 +1977,7 @@ function ShowDialog1(int, dtext, dinput, string_or_number, ini1, ini2)
)
end
if int == 4 then
threads[#threads+1] = lua_thread.create(
lua_thread.create(
function()
wait(100)
local key = ""
@ -2095,23 +2099,24 @@ function loadEvents()
time_send_trailer_sync = 0
function sampev.onSendVehicleSync()
time_send_trailer_sync = os.time()
sampfuncsLog("onSendVehicleSync")
end
function sampev.onSendTrailerSync()
sampfuncsLog("send traile sync")
if os.time() - time_send_trailer_sync >= 2 then
local data = samp_create_sync_data("vehicle")
data.send()
end
end
function sampev.onVehicleSync(playerId, vehicleId, data)
threads[#threads+1] = lua_thread.create(luChecker.vehicleSync, playerId, vehicleId, data)
--lua_thread.create(luChecker.vehicleSync, playerId, vehicleId, data)
luChecker.vehicleSync(playerId, vehicleId, data)
end
function sampev.onTrailerSync(playerId, data)
threads[#threads+1] = lua_thread.create(luChecker.trailerSync, playerId, data)
--lua_thread.create(luChecker.trailerSync, playerId, data)
luChecker.trailerSync(playerId, data)
end
function sampev.onVehicleStreamOut(vehicleId)
threads[#threads+1] = lua_thread.create(luChecker.vehicleStream, false, vehicleId)
--lua_thread.create(luChecker.vehicleStream, false, vehicleId)
luChecker.vehicleStream(false, vehicleId)
end
function sampev.onSendChat(message)
antiflood = os.clock() * 1000
@ -2193,7 +2198,8 @@ function loadEvents()
antiflood = os.clock() * 1000
end
function sampev.onVehicleStreamIn(vehicleId, data)
threads[#threads+1] = lua_thread.create(luChecker.vehicleStream, true, vehicleId, data)
--lua_thread.create(luChecker.vehicleStream, true, vehicleId, data)
luChecker.vehicleStream(true, vehicleId, data)
if inifiles ~= nil and not inifiles.Settings.Tuning and (data.type == 403 or data.type == 515) then
data.modSlots[8] = 0
return {vehicleId, data}
@ -2651,7 +2657,7 @@ function loadEvents()
end
if string.find(Dtitle, "Ðàáîòû") and delay.dir == 3 then
threads[#threads+1] = lua_thread.create(
lua_thread.create(
function()
repeat
wait(0)
@ -2673,7 +2679,7 @@ function loadEvents()
end
function sampev.onCreate3DText(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text) -- f3d1
threads[#threads+1] = lua_thread.create(
lua_thread.create(
function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textt)
for k, v in pairs(find_3dText) do
@ -2765,7 +2771,7 @@ function loadEvents()
end
function sampev.onRemove3DTextLabel(Cid) -- f3d2
threads[#threads+1] = lua_thread.create(function(Cid)
lua_thread.create(function(Cid)
if id_3D_text == Cid then
id_3D_text = msk_timestamp
load_location = false
@ -3631,7 +3637,7 @@ function get_time()
_time = os.time()
if inifiles.Settings.AutoClear then
threads = {}
collectgarbage()
collectgarbage("step")
end
end
end
@ -4104,6 +4110,7 @@ end
function luChecker.checkerLoad(playerId, data, position) -- Ïðîâåðêà êîãäà èãðîê ïîëó÷èë ãðóç
if luChecker.truckers[playerId]["trailerData"]["trailerId"] ~= data["trailerId"] then
say(luChecker.truckers[playerId]["trailerData"]["trailerId"].." - "..data["trailerId"])
sampAddChatMessage(data["trailerId"],-1)
if getLocalPlayerId() ~= playerId then
local trucker_x, trucker_y, trucker_z = position.x, position.y, position.z
@ -4378,7 +4385,7 @@ script_update = {
script_update.menu.init()
end,
command = function()
threads[#threads+1] = lua_thread.create(function()
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

Loading…
Cancel
Save