- 231
- 48
- Версия MoonLoader
- .026-beta
Чё нахуй за пдц?
[14:52:49.401477] (script) broadcaster.lua: [INFO 14:52:49] ...mes\GTA 140K BY DAPO SHOW\moonloader\lib\broadcaster.lua:38: registered handler "brc_handler"
[14:52:49.401477] (script) broadcaster.lua: [INFO 14:52:49] ...mes\GTA 140K BY DAPO SHOW\moonloader\lib\broadcaster.lua:38: registered handler "brc_info"
[14:53:01.408410] (script) geimorg.lua: 1Я в сети: Artur_Pid
[14:53:01.515436] (script) geimorg.lua: 2Я в сети: Artur_Pid [14] 1408 -32 1000
[14:53:01.755497] (script) geimorg.lua: 2Я в сети: Artur_Pid [14] 1408 -32 1000
[14:53:01.800509] (script) geimorg.lua: 2Я в сети: Arta_Xzkov [17] 1406 -36 1000
[14:53:01.801510] (error) geimorg.lua: opcode '0AF8' call caused an unhandled exception
stack traceback:
[C]: in function 'sampAddChatMessage'
C:\Games\GTA 140K BY DAPO SHOW\moonloader\geimorg.lua:149: in function <C:\Games\GTA 140K BY DAPO SHOW\moonloader\geimorg.lua:146>
[14:53:01.801510] (script) broadcaster.lua: [INFO 14:53:01] ...mes\GTA 140K BY DAPO SHOW\moonloader\lib\broadcaster.lua:48: unregistered handler "brc_handler"
[14:53:01.801510] (script) broadcaster.lua: [INFO 14:53:01] ...mes\GTA 140K BY DAPO SHOW\moonloader\lib\broadcaster.lua:48: unregistered handler "brc_info"
[14:53:01.801510] (error) geimorg.lua: Script died due to an error. (0C1B1CE4)
Lua:
local broadcaster = import('lib/broadcaster.lua')
local encoding = require('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8
local ffi = require('ffi')
local hook = {hooks = {}}
addEventHandler('onScriptTerminate', function(scr)
if scr == script.this then
for i, hook in ipairs(hook.hooks) do
if hook.status then
hook.stop()
end
end
broadcaster.unregisterHandler('brc_handler')
broadcaster.unregisterHandler('brc_info')
end
end)
ffi.cdef [[
int VirtualProtect(void* lpAddress, unsigned long dwSize, unsigned long flNewProtect, unsigned long* lpflOldProtect);
]]
function hook.new(cast, callback, hook_addr, size)
local size, new_hook = size or 5, {}
local detour_addr = tonumber( ffi.cast('intptr_t', ffi.cast('void*', ffi.cast(cast, callback) ) ) )
local void_addr, old_prot, org_bytes = ffi.cast('void*', hook_addr),ffi.new('unsigned long[1]'),ffi.new('uint8_t[?]', size)
ffi.copy(org_bytes, void_addr, size)
local hook_bytes = ffi.new('uint8_t[?]', size, 0x90)
hook_bytes[0] = 0xE9
ffi.cast('uint32_t*', hook_bytes + 1)[0] = detour_addr - hook_addr - 5
new_hook.call, new_hook.status = ffi.cast(cast, hook_addr), false
local function set_status(bool)
new_hook.status = bool
ffi.C.VirtualProtect(void_addr, size, 0x40, old_prot) ffi.copy(void_addr, bool and hook_bytes or org_bytes, size) ffi.C.VirtualProtect(void_addr, size, old_prot[0], old_prot)
end
new_hook.stop = function() set_status(false) end new_hook.start = function() set_status(true) end new_hook.start() table.insert(hook.hooks, new_hook)
return setmetatable(new_hook, {
__call = function(self, ...) self.stop()
local res = self.call(...)
self.start()
return res
end
})
end
local online = {}
function ChatHook(HOOKED_CHAT_THIS, HOOKED_CHAT_TYPE, HOOKED_CHAT_TEXT, HOOKED_CHAT_PREFIX, HOOKED_CHAT_COLOR, HOOKED_CHAT_PCOLOR) local text = ffi.string(HOOKED_CHAT_TEXT)
local myid = select(2, sampGetPlayerIdByCharHandle(1))
local mynick = sampGetPlayerNickname( select(2, sampGetPlayerIdByCharHandle(1)))
if text:match('1Я в сети:%s+(.+)')then
online = {}
x,y,z = getCharCoordinates( 1 )
lua_thread.create(function()
wait(100)
print((('2Я в сети: %s [%d] %d %d %d'):format(mynick,myid,x,y,z)))
broadcaster.sendMessage( u8(('2Я в сети: %s [%d] %d %d %d'):format(mynick,myid,x,y,z)), 'brc_info')
end)
return false
end
local nick, coord = text:match('Я в сети:%s+(.+)%s+([0-9-]+ [0-9-]+ [0-9-]+)')
if nick ~= nil then
if #online == 0 then
table.insert(online, {[1] = nick, [2] = coord})
else
for i,k in pairs(online)do
if nick:match(k)then
status = true
end
end
if not status then
table.insert(online, nick)
end
status = false
end
_G['num'] = #online
--return false
end
sampChatHook(HOOKED_CHAT_THIS, HOOKED_CHAT_TYPE, HOOKED_CHAT_TEXT, HOOKED_CHAT_PREFIX, HOOKED_CHAT_COLOR, HOOKED_CHAT_PCOLOR)
end
function main()
while not isSampAvailable() do wait(100) end
sampChatHook = hook.new('void(__thiscall *)(void *this, uint32_t type, const char* text, const char* prefix, uint32_t color, uint32_t pcolor)', ChatHook, getModuleHandle('samp.dll') + 0x64010)
wait(300)
broadcaster.registerHandler('brc_handler', brc_handlers)
broadcaster.registerHandler('brc_info', brc_infos)
sampRegisterChatCommand('brc', function(arg)
if #arg == 0 then
return sampAddChatMessage('/brc [msg]',0xFF0000) end
res, id = sampGetPlayerIdByCharHandle( 1 )
broadcaster.sendMessage( sampGetPlayerNickname( id )..'['..id..']: {FFFFFF}'..u8(arg), 'brc_handler')
end)
sampRegisterChatCommand('fr', function()
local mynick = sampGetPlayerNickname( select(2, sampGetPlayerIdByCharHandle(1)))
broadcaster.sendMessage(u8('1Я в сети: ')..mynick, 'brc_info')
end)
sampRegisterChatCommand('c',function()
print(222, #online)
for i,k in pairs(online)do
print(89,i,k)
end
end)
while true do wait(0)
if _G['num'] == #online then
check()
_G['num'] = 0
end
end
end
function check()
if #online > 0 then
local text
for i = 1, #online do
text = text and text..'\n'..online[i][1] or online[i][1]..''
end
sampShowDialog(416,'Ник френдс', text, 'Ok', '', 2)
lua_thread.create(function()
while sampIsDialogActive( 416 ) do wait( 100 ) end
local _, button, list, _ = sampHasDialogRespond( 416 )
if button == 1 then
for i = 1, #online do
if list == i-1 then
x,y,z = string.match(online[i][2], '([0-9-]+) ([0-9-]+) ([0-9-]+)')
print(1111111, x,y,z,tostring(online[i][1]),tostring(online[i][2]))
x,y,z = tonumber(x),tonumber(y),tonumber(z)
setCharCoordinates(playerPed, x,y,z)
--sampAddChatMessage('Вы тепнулись к '..tostring(online[i][1]), -1)
end
end
end
end)
end
end
function brc_handlers(message)
sampAddChatMessage( u8:decode(message), 0x0000FF)
end
function brc_infos(message)
lua_thread.create(function()
wait(100)
print(u8:decode(tostring(message)))
sampAddChatMessage(u8:decode(message),-1)
end)
end