Marrub 4 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)
281 281
 	luaL_getmetatable(g_L, "PLAYER_s");
282 282
 	lua_setmetatable(g_L, -2);
283 283
 
284
-	player->ply = pPlayer;
285 284
 	player->pev = pPlayer->pev;
286 285
 
287 286
 	return player;
288 287
 }
289 288
 
289
+struct PLAYER_s *PLAYER_New(entvars_t *pev)
290
+{
291
+	struct PLAYER_s *player = (struct PLAYER_s *)lua_newuserdata(g_L, sizeof(struct PLAYER_s));
292
+	luaL_getmetatable(g_L, "PLAYER_s");
293
+	lua_setmetatable(g_L, -2);
294
+
295
+	player->pev = pev;
296
+
297
+	return player;
298
+}
299
+
290 300
 static struct PLAYER_s *PLAYER_Get(lua_State *L)
291 301
 {
292 302
 	struct PLAYER_s *player;

+ 3
- 2
dlls/gslua.h View File

@@ -9,12 +9,12 @@
9 9
 struct gsLuaRun_s
10 10
 {
11 11
 	BOOL	LRUN_CHLR_PLAYER_SPAWN = TRUE,
12
-			LRUN_CHLR_PLAYER_THINK = TRUE;
12
+			LRUN_CHLR_PLAYER_THINK = TRUE,
13
+			LRUN_CHLR_PLAYER_KILLED = TRUE;
13 14
 };
14 15
 
15 16
 struct PLAYER_s
16 17
 {
17
-	CBasePlayer *ply;
18 18
 	entvars_t *pev;
19 19
 };
20 20
 
@@ -23,6 +23,7 @@ extern BOOL g_bLuaInitialized;
23 23
 extern struct gsLuaRun_s g_gsLuaRun;
24 24
 
25 25
 struct PLAYER_s *PLAYER_New(CBasePlayer *pPlayer);
26
+struct PLAYER_s *PLAYER_New(entvars_t *pev);
26 27
 
27 28
 void LuaInit(void);
28 29
 void LuaQuit(void);

+ 17
- 0
dlls/singleplay_gamerules.cpp View File

@@ -196,6 +196,23 @@ int CHalfLifeRules :: IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKill
196 196
 //=========================================================
197 197
 void CHalfLifeRules :: PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor )
198 198
 {
199
+	if(g_gsLuaRun.LRUN_CHLR_PLAYER_KILLED)
200
+	{
201
+		BOOL bRun;
202
+		bRun = LuaGet("GAME", LUA_TTABLE, FALSE, FALSE);
203
+		if(bRun) bRun = LuaGet("PlayerKilled", LUA_TFUNCTION, TRUE, FALSE);
204
+		if(bRun)
205
+		{
206
+			PLAYER_New(pVictim);
207
+			PLAYER_New(pKiller);
208
+			PLAYER_New(pInflictor);
209
+			LuaCall("GAME.PlayerKilled");
210
+		}
211
+		else
212
+		{
213
+			g_gsLuaRun.LRUN_CHLR_PLAYER_KILLED = FALSE;
214
+		}
215
+	}
199 216
 }
200 217
 
201 218
 //=========================================================

Loading…
Cancel
Save