I'm having a bit of a problem that I just can't find a solution for.
Well, as you can see I'm trying to access an entity passed to the function, but calling any function of the entity whatsoever crashes the game.Code:#define _RETAIL #define GAME_DLL #define WIN32_LEAN_AND_MEAN #include <GMLuaModule.h> #include <cbase.h> ILuaInterface *gLua = NULL; GMOD_MODULE(Start, Close) LUA_FUNCTION(EntityTest) { if(gLua->GetType(1) != GLua::TYPE_ENTITY) {gLua->TypeError("Entity",1);} edict_t *pEdict = (edict_t *)gLua->GetUserData(1); if(!pEdict || pEdict->IsFree()) {return 0;} IServerUnknown *pUnkn = pEdict->GetUnknown(); if(!pUnkn) {return 0;} CBaseEntity *pEnt = pUnkn->GetBaseEntity(); if(!pEnt) {return 0;} float hp = pEnt->GetHealth(); // Crashes the game gLua->Push(hp); return 1; } [...]
I've tried different approaches, but nothing has worked so far.
Perhaps I'm missing something, I'd be grateful for any ideas.

Register
Events
Popular
More
Post #1




Informative x 1
Friendly x 1