Browse Source

why not

master
Marrub 5 years ago
parent
commit
bf75fbf690
3 changed files with 31 additions and 3 deletions
  1. +11
    -1
      dlls/gslua.cpp
  2. +3
    -2
      dlls/gslua.h
  3. +17
    -0
      dlls/singleplay_gamerules.cpp

+ 11
- 1
dlls/gslua.cpp View File

@@ -281,12 +281,22 @@ struct PLAYER_s *PLAYER_New(CBasePlayer *pPlayer)
luaL_getmetatable(g_L, "PLAYER_s");
lua_setmetatable(g_L, -2);

player->ply = pPlayer;
player->pev = pPlayer->pev;

return player;
}

struct PLAYER_s *PLAYER_New(entvars_t *pev)
{
struct PLAYER_s *player = (struct PLAYER_s *)lua_newuserdata(g_L, sizeof(struct PLAYER_s));
luaL_getmetatable(g_L, "PLAYER_s");
lua_setmetatable(g_L, -2);

player->pev = pev;

return player;
}

static struct PLAYER_s *PLAYER_Get(lua_State *L)
{
struct PLAYER_s *player;


+ 3
- 2
dlls/gslua.h View File

@@ -9,12 +9,12 @@
struct gsLuaRun_s
{
BOOL LRUN_CHLR_PLAYER_SPAWN = TRUE,
LRUN_CHLR_PLAYER_THINK = TRUE;
LRUN_CHLR_PLAYER_THINK = TRUE,
LRUN_CHLR_PLAYER_KILLED = TRUE;
};

struct PLAYER_s
{
CBasePlayer *ply;
entvars_t *pev;
};

@@ -23,6 +23,7 @@ extern BOOL g_bLuaInitialized;
extern struct gsLuaRun_s g_gsLuaRun;

struct PLAYER_s *PLAYER_New(CBasePlayer *pPlayer);
struct PLAYER_s *PLAYER_New(entvars_t *pev);

void LuaInit(void);
void LuaQuit(void);


+ 17
- 0
dlls/singleplay_gamerules.cpp View File

@@ -196,6 +196,23 @@ int CHalfLifeRules :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKill
//=========================================================
void CHalfLifeRules :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
{
if(g_gsLuaRun.LRUN_CHLR_PLAYER_KILLED)
{
BOOL bRun;
bRun = LuaGet("GAME", LUA_TTABLE, FALSE, FALSE);
if(bRun) bRun = LuaGet("PlayerKilled", LUA_TFUNCTION, TRUE, FALSE);
if(bRun)
{
PLAYER_New(pVictim);
PLAYER_New(pKiller);
PLAYER_New(pInflictor);
LuaCall("GAME.PlayerKilled");
}
else
{
g_gsLuaRun.LRUN_CHLR_PLAYER_KILLED = FALSE;
}
}
}

//=========================================================


Loading…
Cancel
Save