-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakLua.lua
31 lines (23 loc) · 892 Bytes
/
RakLua.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local RakLuaDll = require "RakLuaDll"
addEventHandler("onScriptTerminate", function(scr) if scr == script.this then RakLuaDll.destroyHandlers() end end)
local events = {
["onSendRpc"] = RakLuaEvents.OUTGOING_RPC,
["onSendPacket"] = RakLuaEvents.OUTGOING_PACKET,
["onReceiveRpc"] = RakLuaEvents.INCOMING_RPC,
["onReceivePacket"] = RakLuaEvents.INCOMING_PACKET
}
local addEventHandler_orig = addEventHandler
local function hookAddEventHandler(event, func)
if events[event] then
RakLuaDll.registerHandler(events[event], func)
else
addEventHandler_orig(event, func)
end
end
local function defineSampLuaCompatibility()
RakLuaDll.defineGlobals()
addEventHandler = hookAddEventHandler
isSampfuncsLoaded = function() return true end
end
RakLuaDll.defineSampLuaCompatibility = defineSampLuaCompatibility
return RakLuaDll