Skip to content

Commit

Permalink
Move weapon command health check (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarukon authored Oct 16, 2023
1 parent bdefe5b commit b618dcf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ WeaponMapEntry_t WeaponMap[] = {

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

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

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

if (!V_stricmp(pszWeaponName, weaponEntry.command))
{
if (pController->m_hPawn()->m_iHealth() <= 0) {
ClientPrint(pController, HUD_PRINTTALK, CHAT_PREFIX"You can only buy weapons when alive.");
return;
}
CCSPlayer_ItemServices *pItemServices = pPawn->m_pItemServices;
int money = pController->m_pInGameMoneyServices->m_iAccount;
if (money >= weaponEntry.iPrice)
Expand Down

0 comments on commit b618dcf

Please sign in to comment.