Skip to content

Commit b618dcf

Browse files
authored
Move weapon command health check (#41)
1 parent bdefe5b commit b618dcf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/commands.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ WeaponMapEntry_t WeaponMap[] = {
7979

8080
void ParseWeaponCommand(CCSPlayerController *pController, const char *pszWeaponName)
8181
{
82-
if (!pController || !pController->m_hPawn() || pController->m_hPawn()->m_iHealth() <= 0)
83-
{
84-
ClientPrint(pController, HUD_PRINTTALK, CHAT_PREFIX"You can only buy weapons when alive.");
82+
if (!pController || !pController->m_hPawn())
8583
return;
86-
}
8784

8885
CCSPlayerPawn* pPawn = (CCSPlayerPawn*)pController->GetPawn();
8986

@@ -93,6 +90,10 @@ void ParseWeaponCommand(CCSPlayerController *pController, const char *pszWeaponN
9390

9491
if (!V_stricmp(pszWeaponName, weaponEntry.command))
9592
{
93+
if (pController->m_hPawn()->m_iHealth() <= 0) {
94+
ClientPrint(pController, HUD_PRINTTALK, CHAT_PREFIX"You can only buy weapons when alive.");
95+
return;
96+
}
9697
CCSPlayer_ItemServices *pItemServices = pPawn->m_pItemServices;
9798
int money = pController->m_pInGameMoneyServices->m_iAccount;
9899
if (money >= weaponEntry.iPrice)

0 commit comments

Comments
 (0)