#define GMMODULE
#include <Windows.h>
#include <cdll_int.h>
#include <Lua/Interface.h>
#include <icliententitylist.h>
#include <cbase.h>
int IsDormant_L(lua_State* state)
{
GarrysMod::Lua::UserData* pudPlayer = (GarrysMod::Lua::UserData*)LUA->GetUserdata(1);
static CreateInterfaceFn ClientFactory = (CreateInterfaceFn)GetProcAddress(GetModuleHandle("client.dll"), "CreateInterface");
static IClientEntityList* pEntityList = (IClientEntityList*)ClientFactory(VCLIENTENTITYLIST_INTERFACE_VERSION, 0);
C_BaseEntity* pPlayer = pEntityList->GetClientEntity((int)pudPlayer->data)->GetBaseEntity(); //hint, one is on this line
if(!pPlayer)
{
LUA->PushBool(true);
}
LUA->PushBool(pPlayer->IsDormant());
return 1;
};
GMOD_MODULE_OPEN()
{
LUA->PushSpecial( GarrysMod::Lua::SPECIAL_GLOB );
LUA->PushCFunction(IsDormant_L);
LUA->SetField(-2, "IsDormant");
LUA->Pop();
return 0;
};
GMOD_MODULE_CLOSE()
{
return 0;
};