Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
#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; };
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");
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