Skip to content

Commit

Permalink
Enhance CSPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyShorokhov committed Sep 1, 2021
1 parent 9a7707a commit 098104f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ void CCSPlayer::Reset()
m_iWeaponInfiniteIds = 0;
m_bCanShootOverride = false;
m_bGameForcingRespawn = false;
m_iNickChangesBeforeSpawn = -1;
}

void CCSPlayer::OnSpawn()
Expand All @@ -562,3 +563,18 @@ void CCSPlayer::OnKilled()
}
#endif
}

EXT_FUNC void CCSPlayer::OnRoundRespawn()
{
m_iNickChangesBeforeSpawn = 0;
}

EXT_FUNC bool CCSPlayer::CanChangeNickname()
{
return (max_alive_name_changes.value >= 0 && m_iNickChangesBeforeSpawn > max_alive_name_changes.value);
}

EXT_FUNC void CCSPlayer::OnNicknameChanged()
{
m_iNickChangesBeforeSpawn++;
}
7 changes: 6 additions & 1 deletion regamedll/public/regamedll/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class CCSPlayer: public CCSMonster {
m_iWeaponInfiniteAmmo(0),
m_iWeaponInfiniteIds(0),
m_bCanShootOverride(false),
m_bGameForcingRespawn(false)
m_bGameForcingRespawn(false),
m_iNickChangesBeforeSpawn(-1)
{
m_szModel[0] = '\0';
}
Expand Down Expand Up @@ -101,6 +102,9 @@ class CCSPlayer: public CCSMonster {

void OnSpawn();
void OnKilled();
void OnRoundRespawn();
bool CanChangeNickname();
void OnNicknameChanged();

CBasePlayer *BasePlayer() const;

Expand All @@ -125,6 +129,7 @@ class CCSPlayer: public CCSMonster {
int m_iWeaponInfiniteIds;
bool m_bCanShootOverride;
bool m_bGameForcingRespawn;
int m_iNickChangesBeforeSpawn;
};

// Inlines
Expand Down

0 comments on commit 098104f

Please sign in to comment.