|
|
|
@ -8,6 +8,10 @@ local vkeys = require "lib.vkeys" |
|
|
|
|
local ffi = require("ffi") |
|
|
|
|
ffi.cdef [[ bool SetCursorPos(int X, int Y); ]] |
|
|
|
|
|
|
|
|
|
local encoding = require "encoding" |
|
|
|
|
encoding.default = "CP1251" |
|
|
|
|
local u8 = encoding.UTF8 |
|
|
|
|
|
|
|
|
|
function try(f, catch_f) |
|
|
|
|
local status, exception = pcall(f) |
|
|
|
|
if not status then |
|
|
|
@ -331,7 +335,8 @@ function settings_load() |
|
|
|
|
}, |
|
|
|
|
binder = { '/r На месте', '/r Загружаюсь', '/r Задержусь', '/r Разгружаюсь' }, |
|
|
|
|
binder_sms = { '/sms !ИдПары На месте', '/sms !ИдПары Загружаюсь', '/sms !ИдПары Задержусь', '/sms !ИдПары Разгружаюсь' }, |
|
|
|
|
blacklist = {} |
|
|
|
|
blacklist = {}, |
|
|
|
|
version = thisScript().version |
|
|
|
|
} |
|
|
|
|
if not doesFileExist(AdressJson) then |
|
|
|
|
local file, error = io.open(AdressJson, "w") |
|
|
|
@ -347,7 +352,20 @@ function settings_load() |
|
|
|
|
local readJson = function() |
|
|
|
|
local file, error = io.open(AdressJson, "r") |
|
|
|
|
if file then |
|
|
|
|
inifiles = decodeJson(file:read("*a")) |
|
|
|
|
local fileText = file:read("*a") |
|
|
|
|
inifiles = decodeJson(fileText) |
|
|
|
|
if inifiles["version"] == nil then |
|
|
|
|
inifiles = decodeJson(u8(fileText)) |
|
|
|
|
inifiles["version"] = thisScript().version |
|
|
|
|
os.remove(AdressJson) |
|
|
|
|
addChatMessage("Конфиг был перезаписан в UTF-8!") |
|
|
|
|
local file, error = io.open(AdressJson, "w") |
|
|
|
|
if file ~= nil then |
|
|
|
|
file:write(encodeJson(inifiles)) |
|
|
|
|
file:flush() |
|
|
|
|
io.close(file) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if inifiles == nil then |
|
|
|
|
sampAddChatMessage("[TruckHUD] Ошибка чтения конфига! Сбрасываю конфиг!", 0xff0000) |
|
|
|
|
local file, error = io.open(AdressJson, "w") |
|
|
|
@ -381,7 +399,7 @@ function settings_load() |
|
|
|
|
if inifiles[k] == nil then |
|
|
|
|
inifiles[k] = v |
|
|
|
|
end |
|
|
|
|
if k ~= "binder" and k ~= "binder_sms" then |
|
|
|
|
if k ~= "binder" and k ~= "binder_sms" and type(v) == "table" then |
|
|
|
|
for i, s in pairs(v) do |
|
|
|
|
if inifiles[k][i] == nil then |
|
|
|
|
inifiles[k][i] = s |
|
|
|
|