Counter-Strike: play sound when successfully buying ammo.

This commit is contained in:
Marco Cawthorne 2020-04-23 01:28:28 +02:00
parent d0ec99b5b1
commit 8905fa98bc
3 changed files with 29 additions and 7 deletions

View file

@ -23,11 +23,11 @@ STUB!
*/
// TODO: Finish these
#define SF_MOV_OPEN 1
#define SF_MOV_OPEN 1
#define SF_MOV_UNLINK 4
#define SF_MOV_PASSABLE 8
#define SF_MOV_TOGGLE 32
#define SF_MOV_USE 256
#define SF_MOV_USE 256
enum
{
@ -54,7 +54,7 @@ class func_door:CBaseTrigger
int m_iStopSnd;
int m_iDamage;
int m_iLocked;
void(void) func_door;
virtual void(void) SetMovementDirection;
virtual void(vector vdest, void(void) func) MoveToDestination;

View file

@ -107,10 +107,12 @@ ammoinfo_t cs_ammoinfo[11] = {
}
};
void
int
Ammo_BuyCaliber(player pl, int cal)
{
int *ptr_ammo;
int rv = 0;
while (pl.money - cs_ammoinfo[cal].price > 0) {
switch (cal) {
case CALIBER_50AE:
@ -146,11 +148,14 @@ Ammo_BuyCaliber(player pl, int cal)
}
if (*ptr_ammo >= cs_ammoinfo[cal].a_max)
return;
break;
*ptr_ammo += cs_ammoinfo[cal].a_size;
Money_AddMoney(pl, -cs_ammoinfo[cal].price);
rv = 1;
}
return rv;
}
/* We want to loop through all the possible weapons in case the server
@ -160,6 +165,7 @@ void
CSEv_AmmoBuySecondary(void)
{
int cal = 0;
int ps = 0;
player pl = (player)self;
for (int i = 1; i < g_weapons.length; i++) {
@ -184,15 +190,23 @@ CSEv_AmmoBuySecondary(void)
cal = CALIBER_57MM;
break;
}
Ammo_BuyCaliber(pl, cal);
if (Ammo_BuyCaliber(pl, cal) == 1) {
ps = 1;
}
}
}
if (ps) {
Sound_Play(pl, CHAN_ITEM, "buy.ammo");
}
Weapons_RefreshAmmo(pl);
}
void
CSEv_AmmoBuyPrimary(void)
{
int ps = 0;
int cal = 0;
player pl = (player)self;
@ -248,9 +262,16 @@ CSEv_AmmoBuyPrimary(void)
cal = CALIBER_556MMBOX;
break;
}
Ammo_BuyCaliber(pl, cal);
if (Ammo_BuyCaliber(pl, cal) == 1) {
ps = 1;
}
}
}
if (ps) {
Sound_Play(pl, CHAN_ITEM, "buy.ammo");
}
Weapons_RefreshAmmo(pl);
}

View file

@ -41,6 +41,7 @@ void Game_Worldspawn(void)
precache_sound("player/pl_pain4.wav");
Sound_Precache("buy.kevlar");
Sound_Precache("buy.weapon");
Sound_Precache("buy.ammo");
Weapons_Init();