From 5867e3398fdcfc9065c9dbc9f053746b7dbb32bc Mon Sep 17 00:00:00 2001 From: Steve Dudenhoeffer Date: Fri, 10 Sep 2004 13:57:10 +0000 Subject: [PATCH] Added client_spawn(id) & client_changeteam(id,newteam,oldteam) forwards --- dlls/ns/ns/CPlayer.cpp | 15 ++++++++++++++- dlls/ns/ns/CPlayer.h | 2 ++ dlls/ns/ns/hookedfunctions.cpp | 12 ++++++++---- dlls/ns/ns/ns.h | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dlls/ns/ns/CPlayer.cpp b/dlls/ns/ns/CPlayer.cpp index 9e5aebc7..09e57d43 100755 --- a/dlls/ns/ns/CPlayer.cpp +++ b/dlls/ns/ns/CPlayer.cpp @@ -9,10 +9,18 @@ void CPlayer::PreThink() Connect(); bot=true; } + if (olddeadflag && pev->deadflag == 0 && SpawnForward != -1) + MF_ExecuteForward(SpawnForward,index); + + if (oldteam != pev->team && TeamForward != -1) + MF_ExecuteForward(TeamForward,index,pev->team,oldteam); + int tClass = GetClass(); if (tClass != iclass) ChangeClass(tClass); oldimpulse=pev->impulse; + olddeadflag = pev->deadflag; + oldteam = pev->team; } void CPlayer::PreThink_Post() { @@ -34,7 +42,8 @@ void CPlayer::PostThink_Post() } void CPlayer::ChangeClass(int newclass) { - MF_ExecuteForward(ChangeclassForward, index, newclass, iclass, oldimpulse); + if (ChangeclassForward != -1) + MF_ExecuteForward(ChangeclassForward, index, newclass, iclass, oldimpulse); iclass=newclass; } @@ -75,6 +84,7 @@ void CPlayer::Connect() { connected=true; bot=false; + Reset(); } void CPlayer::Disconnect() @@ -95,4 +105,7 @@ void CPlayer::Reset() this->body=0; this->fov=0.0; this->foved=false; + olddeadflag=0; + oldteam=0; + } \ No newline at end of file diff --git a/dlls/ns/ns/CPlayer.h b/dlls/ns/ns/CPlayer.h index db30581a..90e92458 100755 --- a/dlls/ns/ns/CPlayer.h +++ b/dlls/ns/ns/CPlayer.h @@ -19,6 +19,8 @@ public: edict_t *edict; entvars_t *pev; int oldimpulse; // Store the previous impulse. + int olddeadflag; + int oldteam; int index; bool connected; diff --git a/dlls/ns/ns/hookedfunctions.cpp b/dlls/ns/ns/hookedfunctions.cpp index 5f40cecd..b24c5b93 100755 --- a/dlls/ns/ns/hookedfunctions.cpp +++ b/dlls/ns/ns/hookedfunctions.cpp @@ -10,9 +10,10 @@ CPlayer g_player[33]; edict_t *player_edicts[33]; int gmsgHudText2=0; -int ChangeclassForward = 0; -int BuiltForward = 0; - +int ChangeclassForward = -1; +int BuiltForward = -1; +int SpawnForward = -1; +int TeamForward = -1; // Index of last entity hooked in CreateNamedEntity int iCreateEntityIndex; BOOL iscombat; @@ -41,6 +42,8 @@ void OnPluginsLoaded() // No sense in this if it's combat.. if (!iscombat) BuiltForward = MF_RegisterForward("client_built", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); + SpawnForward = MF_RegisterForward("client_spawn",ET_IGNORE,FP_CELL/*id*/,FP_DONE); + TeamForward = MF_RegisterForward("client_changeteam",ET_IGNORE,FP_CELL/*id*/,FP_CELL/*new team*/,FP_CELL/*old team*/,FP_DONE); } @@ -272,7 +275,8 @@ void AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...) iForward = 1; } // ns2amx_built.execute(index,iCreateEntityIndex,iForward,iType); - MF_ExecuteForward(BuiltForward, index, iCreateEntityIndex, iForward, iType); + if (BuiltForward != -1) + MF_ExecuteForward(BuiltForward, index, iCreateEntityIndex, iForward, iType); iCreateEntityIndex=0; } } diff --git a/dlls/ns/ns/ns.h b/dlls/ns/ns/ns.h index 06bfd8fb..416b86e1 100755 --- a/dlls/ns/ns/ns.h +++ b/dlls/ns/ns/ns.h @@ -23,7 +23,8 @@ extern int gmsgHudText2; extern AMX_NATIVE_INFO ns_misc_natives[]; extern AMX_NATIVE_INFO ns_pdata_natives[]; - +extern int SpawnForward; +extern int TeamForward; extern int ChangeclassForward; extern int BuiltForward;