#include "CNetMessageRegistration.hpp" | |
#include "CNetMessage.hpp" | |
#include "gm/Lua.hpp" | |
#include "gm/CStateManager.hpp" | |
using namespace GarrysMod::Lua; | |
template <class T, int (T::*F)(CLuaInterface& Lua)> | |
int LuaBindThunk(lua_State* L) | |
{ | |
// TODO: Get instance from userdata | |
T* obj = nullptr; | |
return (obj->*F)(g_StateManager.GetInterface(L)); | |
} | |
class SVC_Print; | |
CMessageClassRegistration<SVC_Print> Registration("svc_Print"); | |
class SVC_Print : public CNetMessage | |
{ | |
SVC_Print() { m_bReliable = false; m_text = nullptr; }; | |
public: | |
void* m_pMessageHandler; | |
const char* m_text; | |
bool WriteHook(bf_write& buffer) | |
{ | |
Msg("Hi there everything!\n"); | |
return Registration.CallOriginalWrite(this, buffer); | |
} | |
int LuaGetText(CLuaInterface& Lua) | |
{ | |
return 0; | |
} | |
static void InitializeLua(CLuaInterface& Lua) | |
{ | |
Msg("svc_Print is being added to Lua!\n"); | |
Registration.Attach(); | |
Lua.SetGlobal("GetText", &LuaBindThunk<SVC_Print, &SVC_Print::LuaGetText>(Lua.GetLuaState())); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment