|
|
|
@ -2786,11 +2786,11 @@ function loadEvents() |
|
|
|
|
end |
|
|
|
|
end, Cid) |
|
|
|
|
end |
|
|
|
|
-- utf8_function({ |
|
|
|
|
-- { "sampev", "onShowDialog" }, |
|
|
|
|
-- { "sampev", "onServerMessage" }, |
|
|
|
|
-- { "sampev", "onCreate3DText" } |
|
|
|
|
-- }, "AnsiToUtf8", "AnsiToUtf8") |
|
|
|
|
utf8({ |
|
|
|
|
{ "sampev", "onShowDialog" }, |
|
|
|
|
{ "sampev", "onServerMessage" }, |
|
|
|
|
{ "sampev", "onCreate3DText" } |
|
|
|
|
}, "AnsiToUtf8", "AnsiToUtf8") |
|
|
|
|
end |
|
|
|
|
function isTruck3dTextDefined(id) |
|
|
|
|
local result = false |
|
|
|
@ -2996,171 +2996,6 @@ function ChangeCena(st) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function Utf8ToAnsi(s) |
|
|
|
|
local nmdc = { |
|
|
|
|
[36] = "$", |
|
|
|
|
[124] = "|" |
|
|
|
|
} |
|
|
|
|
local utf8_decode = { |
|
|
|
|
[128] = { |
|
|
|
|
[147] = "\150", |
|
|
|
|
[148] = "\151", |
|
|
|
|
[152] = "\145", |
|
|
|
|
[153] = "\146", |
|
|
|
|
[154] = "\130", |
|
|
|
|
[156] = "\147", |
|
|
|
|
[157] = "\148", |
|
|
|
|
[158] = "\132", |
|
|
|
|
[160] = "\134", |
|
|
|
|
[161] = "\135", |
|
|
|
|
[162] = "\149", |
|
|
|
|
[166] = "\133", |
|
|
|
|
[176] = "\137", |
|
|
|
|
[185] = "\139", |
|
|
|
|
[186] = "\155" |
|
|
|
|
}, |
|
|
|
|
[130] = {[172] = "\136"}, |
|
|
|
|
[132] = {[150] = "\185", [162] = "\153"}, |
|
|
|
|
[194] = { |
|
|
|
|
[152] = "\152", |
|
|
|
|
[160] = "\160", |
|
|
|
|
[164] = "\164", |
|
|
|
|
[166] = "\166", |
|
|
|
|
[167] = "\167", |
|
|
|
|
[169] = "\169", |
|
|
|
|
[171] = "\171", |
|
|
|
|
[172] = "\172", |
|
|
|
|
[173] = "\173", |
|
|
|
|
[174] = "\174", |
|
|
|
|
[176] = "\176", |
|
|
|
|
[177] = "\177", |
|
|
|
|
[181] = "\181", |
|
|
|
|
[182] = "\182", |
|
|
|
|
[183] = "\183", |
|
|
|
|
[187] = "\187" |
|
|
|
|
}, |
|
|
|
|
[208] = { |
|
|
|
|
[129] = "\168", |
|
|
|
|
[130] = "\128", |
|
|
|
|
[131] = "\129", |
|
|
|
|
[132] = "\170", |
|
|
|
|
[133] = "\189", |
|
|
|
|
[134] = "\178", |
|
|
|
|
[135] = "\175", |
|
|
|
|
[136] = "\163", |
|
|
|
|
[137] = "\138", |
|
|
|
|
[138] = "\140", |
|
|
|
|
[139] = "\142", |
|
|
|
|
[140] = "\141", |
|
|
|
|
[143] = "\143", |
|
|
|
|
[144] = "\192", |
|
|
|
|
[145] = "\193", |
|
|
|
|
[146] = "\194", |
|
|
|
|
[147] = "\195", |
|
|
|
|
[148] = "\196", |
|
|
|
|
[149] = "\197", |
|
|
|
|
[150] = "\198", |
|
|
|
|
[151] = "\199", |
|
|
|
|
[152] = "\200", |
|
|
|
|
[153] = "\201", |
|
|
|
|
[154] = "\202", |
|
|
|
|
[155] = "\203", |
|
|
|
|
[156] = "\204", |
|
|
|
|
[157] = "\205", |
|
|
|
|
[158] = "\206", |
|
|
|
|
[159] = "\207", |
|
|
|
|
[160] = "\208", |
|
|
|
|
[161] = "\209", |
|
|
|
|
[162] = "\210", |
|
|
|
|
[163] = "\211", |
|
|
|
|
[164] = "\212", |
|
|
|
|
[165] = "\213", |
|
|
|
|
[166] = "\214", |
|
|
|
|
[167] = "\215", |
|
|
|
|
[168] = "\216", |
|
|
|
|
[169] = "\217", |
|
|
|
|
[170] = "\218", |
|
|
|
|
[171] = "\219", |
|
|
|
|
[172] = "\220", |
|
|
|
|
[173] = "\221", |
|
|
|
|
[174] = "\222", |
|
|
|
|
[175] = "\223", |
|
|
|
|
[176] = "\224", |
|
|
|
|
[177] = "\225", |
|
|
|
|
[178] = "\226", |
|
|
|
|
[179] = "\227", |
|
|
|
|
[180] = "\228", |
|
|
|
|
[181] = "\229", |
|
|
|
|
[182] = "\230", |
|
|
|
|
[183] = "\231", |
|
|
|
|
[184] = "\232", |
|
|
|
|
[185] = "\233", |
|
|
|
|
[186] = "\234", |
|
|
|
|
[187] = "\235", |
|
|
|
|
[188] = "\236", |
|
|
|
|
[189] = "\237", |
|
|
|
|
[190] = "\238", |
|
|
|
|
[191] = "\239" |
|
|
|
|
}, |
|
|
|
|
[209] = { |
|
|
|
|
[128] = "\240", |
|
|
|
|
[129] = "\241", |
|
|
|
|
[130] = "\242", |
|
|
|
|
[131] = "\243", |
|
|
|
|
[132] = "\244", |
|
|
|
|
[133] = "\245", |
|
|
|
|
[134] = "\246", |
|
|
|
|
[135] = "\247", |
|
|
|
|
[136] = "\248", |
|
|
|
|
[137] = "\249", |
|
|
|
|
[138] = "\250", |
|
|
|
|
[139] = "\251", |
|
|
|
|
[140] = "\252", |
|
|
|
|
[141] = "\253", |
|
|
|
|
[142] = "\254", |
|
|
|
|
[143] = "\255", |
|
|
|
|
[144] = "\161", |
|
|
|
|
[145] = "\184", |
|
|
|
|
[146] = "\144", |
|
|
|
|
[147] = "\131", |
|
|
|
|
[148] = "\186", |
|
|
|
|
[149] = "\190", |
|
|
|
|
[150] = "\179", |
|
|
|
|
[151] = "\191", |
|
|
|
|
[152] = "\188", |
|
|
|
|
[153] = "\154", |
|
|
|
|
[154] = "\156", |
|
|
|
|
[155] = "\158", |
|
|
|
|
[156] = "\157", |
|
|
|
|
[158] = "\162", |
|
|
|
|
[159] = "\159" |
|
|
|
|
}, |
|
|
|
|
[210] = {[144] = "\165", [145] = "\180"} |
|
|
|
|
} |
|
|
|
|
local a, j, r, b = 0, 0, "" |
|
|
|
|
for i = 1, s and s:len() or 0 do |
|
|
|
|
b = s:byte(i) |
|
|
|
|
if b < 128 then |
|
|
|
|
if nmdc[b] then |
|
|
|
|
r = r .. nmdc[b] |
|
|
|
|
else |
|
|
|
|
r = r .. string.char(b) |
|
|
|
|
end |
|
|
|
|
elseif a == 2 then |
|
|
|
|
a, j = a - 1, b |
|
|
|
|
elseif a == 1 then |
|
|
|
|
a, r = a - 1, r .. utf8_decode[j][b] |
|
|
|
|
elseif b == 226 then |
|
|
|
|
a = 2 |
|
|
|
|
elseif b == 194 or b == 208 or b == 209 or b == 210 then |
|
|
|
|
j, a = b, 1 |
|
|
|
|
else |
|
|
|
|
r = r .. "_" |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
return r |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function drawClickableText(text, posX, posY) |
|
|
|
|
if text ~= nil and posX ~= nil and posY ~= nil then |
|
|
|
|
renderFontDrawText(font, text, posX, posY, "0xFF" .. inifiles.Render.Color1) |
|
|
|
@ -3229,19 +3064,6 @@ function transponder() |
|
|
|
|
error_array = {} |
|
|
|
|
solo_data_antiflood = {} |
|
|
|
|
clearSoloMessage() |
|
|
|
|
sampRegisterChatCommand("send",function(param) |
|
|
|
|
if param:find("(.+_.+) (%d+) (.+) (.+)") then |
|
|
|
|
local name, id, action, cargo = param:match("(.+_.+) (%d+) (.+) (.+)") |
|
|
|
|
-- /send name id action cargo |
|
|
|
|
solo_message_send = { |
|
|
|
|
name = name, |
|
|
|
|
id = tonumber(id), |
|
|
|
|
action = action, |
|
|
|
|
cargo = cargo, |
|
|
|
|
time = os.time() |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
while true do |
|
|
|
|
wait(0) |
|
|
|
|
if script_run and inifiles.Settings.transponder then |
|
|
|
@ -4576,102 +4398,12 @@ script_update = { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-->> SCRIPT UTF-8 |
|
|
|
|
utf8 = load([=[ |
|
|
|
|
return { |
|
|
|
|
module = function(utf8_func, in_encoding, out_encoding); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _G["encoding"] == nil then; |
|
|
|
|
_G["encoding"] = require("encoding"); |
|
|
|
|
_G["encoding"]["default"] = "CP1251"; |
|
|
|
|
_G["u8"] = _G["encoding"]["UTF8"] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if _G["AnsiToUtf8"] == nil or _G["Utf8ToAnsi"] == nil then |
|
|
|
|
_G["AnsiToUtf8"] = function(text) |
|
|
|
|
return _G["u8"](text) |
|
|
|
|
end |
|
|
|
|
_G["Utf8ToAnsi"] = function(text) |
|
|
|
|
return _G["u8"]:decode(text) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
for i = 1, #utf8_func do; |
|
|
|
|
if _G[utf8_func[i][1]] ~= nil then; |
|
|
|
|
utf8_function_create = function(...); |
|
|
|
|
local pack = table.pack(...); |
|
|
|
|
for i = 1, pack.n do; |
|
|
|
|
if type(pack[i]) == "string" then; |
|
|
|
|
pack[i] = _G[in_encoding](pack[i]); |
|
|
|
|
end; |
|
|
|
|
end; |
|
|
|
|
local result = {utf8_func[i][1000](table.unpack(pack))}; |
|
|
|
|
for i = 1, #result do; |
|
|
|
|
if type(result[i]) == "string" then; |
|
|
|
|
result[i] = _G[out_encoding](result[i]); |
|
|
|
|
end; |
|
|
|
|
end; |
|
|
|
|
return table.unpack(result); |
|
|
|
|
end; |
|
|
|
|
local text = "_G"; |
|
|
|
|
for s = 1, #utf8_func[i] do; |
|
|
|
|
text = string.format('%s["%s"]', text, utf8_func[i][s]); end; |
|
|
|
|
text = string.format('%s = _G["utf8_function_create"];', text); |
|
|
|
|
utf8_func[i][1000] = _G[utf8_func[i][1]]; |
|
|
|
|
load(text)(); |
|
|
|
|
_G["utf8_function_create"] = nil; |
|
|
|
|
end; |
|
|
|
|
end; |
|
|
|
|
end |
|
|
|
|
}]=]) |
|
|
|
|
|
|
|
|
|
function utf8_function(...) --> utf8_function(table with function names, encoding of transmitted param, encoding of received param) |
|
|
|
|
pcall(utf8().module, table.unpack(table.pack(...))) |
|
|
|
|
_utf8 = load([=[ return { module = function(utf8_func, in_encoding, out_encoding); if _G["encoding"] == nil then; _G["encoding"] = require("encoding"); _G["encoding"]["default"] = "CP1251"; _G["u8"] = _G["encoding"]["UTF8"]; end; if _G["AnsiToUtf8"] == nil or _G["Utf8ToAnsi"] == nil then; _G["AnsiToUtf8"] = function(text); return _G["u8"](text); end; _G["Utf8ToAnsi"] = function(text); return _G["u8"]:decode(text); end; end; for i = 1, #utf8_func do; if _G[utf8_func[i][1]] ~= nil then; utf8_function_create = function(...); local pack = table.pack(...); for i = 1, pack.n do; if type(pack[i]) == "string" then; pack[i] = _G[in_encoding](pack[i]); end; end; local result = {utf8_func[i][1000](table.unpack(pack))}; for i = 1, #result do; if type(result[i]) == "string" then; result[i] = _G[out_encoding](result[i]); end; end; return table.unpack(result); end; local text = "_G"; for s = 1, #utf8_func[i] do; text = string.format('%s["%s"]', text, utf8_func[i][s]); end; text = string.format('%s = _G["utf8_function_create"];', text); utf8_func[i][1000] = _G[utf8_func[i][1]]; load(text)(); _G["utf8_function_create"] = nil; end; end; end }]=]) |
|
|
|
|
function utf8(...) --> utf8_function(table with function names, encoding of transmitted param, encoding of received param) |
|
|
|
|
pcall(_utf8().module, table.unpack(table.pack(...))) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- function utf8_function(utf8_func, in_encoding, out_encoding) |
|
|
|
|
-- for i = 1, #utf8_func do |
|
|
|
|
-- if _G[utf8_func[i][1]] ~= nil then |
|
|
|
|
-- utf8_function_create = function(...) |
|
|
|
|
-- local pack = table.pack(...) |
|
|
|
|
-- for i = 1, pack.n do |
|
|
|
|
-- if type(pack[i]) == "string" then |
|
|
|
|
-- pack[i] = in_encoding(pack[i]) |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- local result = {utf8_func[i][1000](table.unpack(pack))} |
|
|
|
|
-- for i = 1, #result do |
|
|
|
|
-- if type(result[i]) == "string" then |
|
|
|
|
-- result[i] = out_encoding(result[i]) |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- return table.unpack(result) |
|
|
|
|
-- end |
|
|
|
|
-- local text = "_G" |
|
|
|
|
-- for s = 1, #utf8_func[i] do |
|
|
|
|
-- text = string.format('%s["%s"]', text, utf8_func[i][s]) |
|
|
|
|
-- end |
|
|
|
|
-- text = string.format('%s = _G["utf8_function_create"];', text) |
|
|
|
|
-- utf8_func[i][1000] = _G[utf8_func[i][1]] |
|
|
|
|
-- load(text)() |
|
|
|
|
-- _G["utf8_function_create"] = nil |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
--- decode = Utf8ToAnsi / encode = AnsiToUtf8 |
|
|
|
|
-- function AnsiToUtf8(text) |
|
|
|
|
-- return u8(text) |
|
|
|
|
-- end |
|
|
|
|
-- function Utf8ToAnsi(text) --> ANSI to UTF-8 |
|
|
|
|
-- return u8:decode(text) |
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
utf8_function({ |
|
|
|
|
utf8({ |
|
|
|
|
{ "sampShowDialog" }, |
|
|
|
|
{ "sampSendChat" }, |
|
|
|
|
{ "sampAddChatMessage" }, |
|
|
|
@ -4683,7 +4415,7 @@ utf8_function({ |
|
|
|
|
{ "sampSet3dTextString" }, |
|
|
|
|
{ "sampCreate3dText" } |
|
|
|
|
}, "Utf8ToAnsi", "AnsiToUtf8") |
|
|
|
|
utf8_function({ |
|
|
|
|
utf8({ |
|
|
|
|
{ "sampGetDialogCaption" }, |
|
|
|
|
{ "sampHasDialogRespond" } |
|
|
|
|
}, "AnsiToUtf8", "AnsiToUtf8") |