fix restore config & fix default values binder

test-utf-8
rubin 2 years ago
parent fc43b75078
commit 607a1572dc
  1. 44
      TruckHUD.lua

@ -244,6 +244,7 @@ function main()
end
function settings_load()
wait(0)
local x1, y1 = convertGameScreenCoordsToWindowScreenCoords(14.992679595947, 274.75)
local x2, y2 = convertGameScreenCoordsToWindowScreenCoords(146.17861938477, 345.91665649414)
local x3, y3 = convertGameScreenCoordsToWindowScreenCoords(529.42901611328, 158.08332824707)
@ -333,15 +334,43 @@ function settings_load()
end
end
try(
function()
-- try(
-- function()
-- local file, error = io.open(AdressJson, "r")
-- if file then
-- inifiles = decodeJson(file:read("*a"))
-- io.close(file)
-- end
-- end,
-- function(e)
-- sampAddChatMessage("[TruckHUD] Îøèáêà ÷òåíèÿ êîíôèãà! Ñáðàñûâàþ êîíôèã!", 0xff0000)
-- local file, error = io.open(AdressJson, "w")
-- if file ~= nil then
-- file:write(encodeJson(table_std))
-- file:flush()
-- io.close(file)
-- end
-- end
-- )
local readJson = function()
local file, error = io.open(AdressJson, "r")
if file then
inifiles = decodeJson(file:read("*a"))
if inifiles == nil then
sampAddChatMessage("[TruckHUD] Îøèáêà ÷òåíèÿ êîíôèãà! Ñáðàñûâàþ êîíôèã!", 0xff0000)
local file, error = io.open(AdressJson, "w")
if file ~= nil then
file:write(encodeJson(table_std))
file:flush()
io.close(file)
end
end,
function(e)
end
io.close(file)
end
end
local result = pcall(readJson)
if not result then
sampAddChatMessage("[TruckHUD] Îøèáêà ÷òåíèÿ êîíôèãà! Ñáðàñûâàþ êîíôèã!", 0xff0000)
local file, error = io.open(AdressJson, "w")
if file ~= nil then
@ -350,7 +379,6 @@ function settings_load()
io.close(file)
end
end
)
if inifiles ~= nil then
@ -362,12 +390,14 @@ function settings_load()
if inifiles[k] == nil then
inifiles[k] = v
end
if k ~= "binder" and k ~= "binder_sms" then
for i, s in pairs(v) do
if inifiles[k][i] == nil then
inifiles[k][i] = s
end
end
end
end
settings_save()
else
error_ini = true
@ -1479,9 +1509,9 @@ function doRenderBind()
end
if drawClickableText("{ff0000}õ", (X + renderGetFontDrawTextLength(font, string .. " ")), Y) then
if not binder_mode_sms then
inifiles.binder[k] = nil
table.remove(inifiles.binder, k)
else
inifiles.binder_sms[k] = nil
table.remove(inifiles.binder_sms, k)
end
settings_save()
end

Loading…
Cancel
Save