|
|
@ -6,11 +6,6 @@ local inicfg = require "inicfg" |
|
|
|
local dlstatus = require("moonloader").download_status |
|
|
|
local dlstatus = require("moonloader").download_status |
|
|
|
local vkeys = require "lib.vkeys" |
|
|
|
local vkeys = require "lib.vkeys" |
|
|
|
local ffi = require("ffi") |
|
|
|
local ffi = require("ffi") |
|
|
|
|
|
|
|
|
|
|
|
-- local encoding = require "encoding" |
|
|
|
|
|
|
|
-- encoding.default = "CP1251" |
|
|
|
|
|
|
|
-- local u8 = encoding.UTF8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ffi.cdef [[ bool SetCursorPos(int X, int Y); ]] |
|
|
|
ffi.cdef [[ bool SetCursorPos(int X, int Y); ]] |
|
|
|
|
|
|
|
|
|
|
|
function try(f, catch_f) |
|
|
|
function try(f, catch_f) |
|
|
@ -2210,7 +2205,8 @@ function loadEvents() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function sampev.onServerMessage(color, message) |
|
|
|
-- function sampev.onServerMessage(color, message) |
|
|
|
|
|
|
|
_G["sampev"]["onServerMessage"] = function(color, message) |
|
|
|
if message == " У вас бан чата!" then |
|
|
|
if message == " У вас бан чата!" then |
|
|
|
delay.chatMon = 0 |
|
|
|
delay.chatMon = 0 |
|
|
|
delay.chat = 0 |
|
|
|
delay.chat = 0 |
|
|
@ -2568,7 +2564,8 @@ function loadEvents() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function sampev.onShowDialog(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext) |
|
|
|
--function sampev.onShowDialog(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext) |
|
|
|
|
|
|
|
_G["sampev"]["onShowDialog"] = function(DdialogId, Dstyle, Dtitle, Dbutton1, Dbutton2, Dtext) |
|
|
|
if Dstyle == 0 and string.find(Dtext, "{00AB06}Дальнобойщик{CECECE}") and string.find(Dtext, "{00AB06}Механик{CECECE}") then |
|
|
|
if Dstyle == 0 and string.find(Dtext, "{00AB06}Дальнобойщик{CECECE}") and string.find(Dtext, "{00AB06}Механик{CECECE}") then |
|
|
|
local Skill, SkillP, Rank, RankP = string.match( Dtext, ".+{00AB06}Дальнобойщик{CECECE}.*Скилл: (%d+)\tОпыт: .+ (%d+%.%d+)%%.*{CECECE}Ранг: (%d+) \tОпыт: .+ (%d+%.%d+)%%") |
|
|
|
local Skill, SkillP, Rank, RankP = string.match( Dtext, ".+{00AB06}Дальнобойщик{CECECE}.*Скилл: (%d+)\tОпыт: .+ (%d+%.%d+)%%.*{CECECE}Ранг: (%d+) \tОпыт: .+ (%d+%.%d+)%%") |
|
|
|
if Skill ~= nil then |
|
|
|
if Skill ~= nil then |
|
|
@ -2682,7 +2679,8 @@ function loadEvents() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function sampev.onCreate3DText(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text) -- f3d1 |
|
|
|
--function sampev.onCreate3DText(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text) -- f3d1 |
|
|
|
|
|
|
|
_G["sampev"]["onCreate3DText"] = function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, text) |
|
|
|
lua_thread.create( |
|
|
|
lua_thread.create( |
|
|
|
function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textt) |
|
|
|
function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textt) |
|
|
|
for k, v in pairs(find_3dText) do |
|
|
|
for k, v in pairs(find_3dText) do |
|
|
@ -2786,12 +2784,14 @@ function loadEvents() |
|
|
|
end |
|
|
|
end |
|
|
|
end, Cid) |
|
|
|
end, Cid) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
wait(100) |
|
|
|
utf8({ |
|
|
|
utf8({ |
|
|
|
{ "sampev", "onShowDialog" }, |
|
|
|
{ "sampev", "onShowDialog" }, |
|
|
|
{ "sampev", "onServerMessage" }, |
|
|
|
{ "sampev", "onServerMessage" }, |
|
|
|
{ "sampev", "onCreate3DText" } |
|
|
|
{ "sampev", "onCreate3DText" } |
|
|
|
}, "AnsiToUtf8", "AnsiToUtf8") |
|
|
|
}, "AnsiToUtf8", "AnsiToUtf8") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function isTruck3dTextDefined(id) |
|
|
|
function isTruck3dTextDefined(id) |
|
|
|
local result = false |
|
|
|
local result = false |
|
|
|
local delete = {} |
|
|
|
local delete = {} |
|
|
@ -4397,10 +4397,107 @@ script_update = { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-->> SCRIPT UTF-8 |
|
|
|
-->> 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 }]=]) |
|
|
|
_utf8 = load([=[return { |
|
|
|
function utf8(...) --> utf8_function(table with function names, encoding of transmitted param, encoding of received param) |
|
|
|
module = function(utf8_func, in_encoding, out_encoding); |
|
|
|
pcall(_utf8().module, table.unpack(table.pack(...))) |
|
|
|
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; |
|
|
|
|
|
|
|
if _G["_UTF8_FUNCTION_SAVE"] == nil then; |
|
|
|
|
|
|
|
_G["_UTF8_FUNCTION_SAVE"] = {}; |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
for i = 1, #utf8_func do; |
|
|
|
|
|
|
|
local change_var = "_G"; |
|
|
|
|
|
|
|
for s = 1, #utf8_func[i] do; |
|
|
|
|
|
|
|
change_var = string.format('%s["%s"]', change_var, utf8_func[i][s]); |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
if _G["_UTF8_FUNCTION_SAVE"][change_var] == nil then |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_G["new_function"] = 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 unpacked = {_G["_UTF8_FUNCTION_SAVE"][change_var](table.unpack(pack))}; |
|
|
|
|
|
|
|
for i = 1, #unpacked do; |
|
|
|
|
|
|
|
if type(unpacked[i]) == "string" then; |
|
|
|
|
|
|
|
unpacked[i] = _G[out_encoding](unpacked[i]); |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
return table.unpack(unpacked); |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
local text = string.format('return { a = function() _G["_UTF8_FUNCTION_SAVE"]["%s"] = %s; %s = _G["new_function"]; end; }', change_var, change_var, change_var); |
|
|
|
|
|
|
|
sampfuncsLog(text); |
|
|
|
|
|
|
|
aa = load(text) |
|
|
|
|
|
|
|
pcall(aa().a) |
|
|
|
|
|
|
|
_G["new_function"] = nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
}]=]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- function utf8(...) --> utf8_function(table with function names, encoding of transmitted param, encoding of received param) |
|
|
|
|
|
|
|
-- local pack = table.pack(...); |
|
|
|
|
|
|
|
-- pcall(_utf8().module, table.unpack(pack)) |
|
|
|
|
|
|
|
-- end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utf8 = 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; |
|
|
|
|
|
|
|
if _G["_UTF8_FUNCTION_SAVE"] == nil then; |
|
|
|
|
|
|
|
_G["_UTF8_FUNCTION_SAVE"] = {}; |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
for i = 1, #utf8_func do; |
|
|
|
|
|
|
|
local change_var = "_G"; |
|
|
|
|
|
|
|
for s = 1, #utf8_func[i] do; |
|
|
|
|
|
|
|
change_var = string.format('%s["%s"]', change_var, utf8_func[i][s]); |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
if _G["_UTF8_FUNCTION_SAVE"][change_var] == nil then |
|
|
|
|
|
|
|
_G["new_function"] = 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 unpacked = {_G["_UTF8_FUNCTION_SAVE"][change_var](table.unpack(pack))}; |
|
|
|
|
|
|
|
for i = 1, #unpacked do; |
|
|
|
|
|
|
|
if type(unpacked[i]) == "string" then; |
|
|
|
|
|
|
|
unpacked[i] = _G[out_encoding](unpacked[i]); |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
return table.unpack(unpacked); |
|
|
|
|
|
|
|
end; |
|
|
|
|
|
|
|
local text = string.format("_G['_UTF8_FUNCTION_SAVE']['%s'] = %s; %s = _G['new_function'];", change_var, change_var, change_var); |
|
|
|
|
|
|
|
sampfuncsLog(text); |
|
|
|
|
|
|
|
load(text)(); |
|
|
|
|
|
|
|
_G["new_function"] = nil; |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end; |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
utf8({ |
|
|
|
utf8({ |
|
|
|