|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
script_name('corn-hud') |
|
|
|
|
script_author("Serhiy_Rubin") |
|
|
|
|
script_version("25.01.2023") |
|
|
|
|
script_version("27.01.2023") |
|
|
|
|
require 'lib.sampfuncs' |
|
|
|
|
require 'lib.moonloader' |
|
|
|
|
local dlstatus = require("moonloader").download_status |
|
|
|
@ -483,9 +483,9 @@ function addChatMessage(text) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
script_update = { |
|
|
|
|
version_url = "http://git.deadpoo.net/rubin/test/raw/branch/master/version", |
|
|
|
|
script_url = "http://git.deadpoo.net/rubin/test/raw/branch/master/corn-hud.lua", |
|
|
|
|
changelog_url = "http://git.deadpoo.net/rubin/test/raw/branch/master/changelog", |
|
|
|
|
version_url = "http://git.deadpoo.net/rubin/corn-hud/raw/branch/master/version", |
|
|
|
|
script_url = "http://git.deadpoo.net/rubin/corn-hud/raw/branch/master/corn-hud.lua", |
|
|
|
|
changelog_url = "http://git.deadpoo.net/rubin/corn-hud/raw/branch/master/changelog", |
|
|
|
|
address_ini = "rubin-mods-updates.ini", |
|
|
|
|
main = function() |
|
|
|
|
local name = thisScript().name |
|
|
|
@ -654,7 +654,7 @@ script_update = { |
|
|
|
|
-->> utf8(table path, incoming variables encoding, outcoming variables encoding) |
|
|
|
|
-->> table path example { "sampev", "onShowDialog" } |
|
|
|
|
-->> encoding options nil | AnsiToUtf8 | Utf8ToAnsi |
|
|
|
|
_utf8 = load([=[return function(utf8_func, in_encoding, out_encoding); if encoding == nil then; encoding = require("encoding"); encoding.default = "CP1251"; u8 = encoding.UTF8; end; if type(utf8_func) ~= "table" then; return false; end; if AnsiToUtf8 == nil or Utf8ToAnsi == nil then; AnsiToUtf8 = function(text); return u8(text); end; Utf8ToAnsi = function(text); return u8:decode(text); end; end; if _UTF8_FUNCTION_SAVE == nil then; _UTF8_FUNCTION_SAVE = {}; end; local change_var = "_G"; for s = 1, #utf8_func do; change_var = string.format('%s["%s"]', change_var, utf8_func[s]); end; if _UTF8_FUNCTION_SAVE[change_var] == nil then _UTF8_FUNCTION = function(...); local pack = table.pack(...); for i = 1, pack.n do; if type(pack[i]) == "string" and in_encoding ~= nil and (in_encoding == "AnsiToUtf8" or in_encoding == "Utf8ToAnsi") then; pack[i] = _G[in_encoding](pack[i]); end; end; local unpacked = {_UTF8_FUNCTION_SAVE[change_var](table.unpack(pack))}; for i = 1, #unpacked do; if type(unpacked[i]) == "string" and out_encoding ~= nil and (out_encoding == "AnsiToUtf8" or out_encoding == "Utf8ToAnsi") then; unpacked[i] = _G[out_encoding](unpacked[i]); end; end; return table.unpack(unpacked); end; local text = string.format("_UTF8_FUNCTION_SAVE['%s'] = %s; %s = _UTF8_FUNCTION;", change_var, change_var, change_var); load(text)(); _UTF8_FUNCTION = nil; end; return true; end]=]) |
|
|
|
|
_utf8 = load([=[return function(utf8_func, in_encoding, out_encoding); if encoding == nil then; encoding = require("encoding"); encoding.default = "CP1251"; u8 = encoding.UTF8; end; if type(utf8_func) ~= "table" then; return false; end; if AnsiToUtf8 == nil or Utf8ToAnsi == nil then; AnsiToUtf8 = function(text); return u8(text); end; Utf8ToAnsi = function(text); return u8:decode(text); end; end; if _UTF8_FUNCTION_SAVE == nil then; _UTF8_FUNCTION_SAVE = {}; end; local change_var = "_G"; for s = 1, #utf8_func do; change_var = string.format('%s["%s"]', change_var, utf8_func[s]); end; if _UTF8_FUNCTION_SAVE[change_var] == nil then; _UTF8_FUNCTION = function(...); local pack = table.pack(...); readTable = function(t, enc); for k, v in next, t do; if type(v) == 'table' then; readTable(v, enc); else; if enc ~= nil and (enc == "AnsiToUtf8" or enc == "Utf8ToAnsi") then; if type(k) == "string" then; k = _G[enc](k); end; if type(v) == "string" then; t[k] = _G[enc](v); end; end; end; end; return t; end; return table.unpack(readTable({_UTF8_FUNCTION_SAVE[change_var](table.unpack(readTable(pack, in_encoding)))}, out_encoding)); end; local text = string.format("_UTF8_FUNCTION_SAVE['%s'] = %s; %s = _UTF8_FUNCTION;", change_var, change_var, change_var); load(text)(); _UTF8_FUNCTION = nil; end; return true; end]=]) |
|
|
|
|
function utf8(...) |
|
|
|
|
pcall(_utf8(), ...) |
|
|
|
|
end |
|
|
|
|