addEventHandler("onReceivePacket", function(id, bs)
if id == 220 then
raknetBitStreamIgnoreBits(bs, 8)
local cefPacketID = raknetBitStreamReadInt8(bs)
if cefPacketID == 17 then
raknetBitStreamIgnoreBits(bs, 32)
local length = raknetBitStreamReadInt16(bs)
local encoded = raknetBitStreamReadInt8(bs)
local cmd = (encoded ~= 0) and raknetBitStreamDecodeString(bs, length + encoded) or raknetBitStreamReadString(bs, length)
local eventCall, dataCall = string.match(cmd, "window%.executeEvent%('([%w.]+)', `(.*)`%)")
if eventCall == "event.inventory.playerInventory" and sampIsLocalPlayerSpawned() and sampGetGamestate() == 3 then -- Проверка на спавн нужна при инициализации цефа, т.к триггерится на собственный инвентарь
local action = tonumber(dataCall:match('"action":(%d+)'))
if action == 0 then
local modified = dataCall:gsub('"amount":(%d+),.-"text":"([^"]*)"', function(amount, oldText)
local newText = number_separator(amount)
return '"amount":' .. amount .. ',"text":"' .. newText .. '"'
end)
if modified then
local final = string.format(
"window.executeEvent('event.inventory.playerInventory', `%s`);",
modified
)
if connect_timer ~= nil and connect_timer - os.clock() <= -2 then -- Дополнительная проверка на таймер, так-как все равно может обойти проверку спавна сверху
evalanon(final)
elseif connect_timer == nil then
connect_timer = os.clock() -- Если нажали перезагрузку (CTRL + R), и сбросили connect_timer
end
end
end
end
end
end
end)
addEventHandler('onSendPacket', function(id, bs)
lua_thread.create(function()
if id == 220 then
local id = raknetBitStreamReadInt8(bs)
local packettype = raknetBitStreamReadInt8(bs)
local strlen = raknetBitStreamReadInt16(bs)
local text = raknetBitStreamReadString(bs, strlen)
if packettype ~= 0 and packettype ~= 1 and #text > 2 then
if text:find('onSvelteAppVersion') then -- Инициализация CEF
while not sampIsLocalPlayerSpawned() do wait(100) end
connect_timer = os.clock()
end
end
end
end)
end)
function evalanon(code)
evalcef(("(() => {%s})()"):format(code))
end
function number_separator(n)
local left, num, right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
end