Counter-Strike: play sound when successfully buying ammo.
This commit is contained in:
parent
d0ec99b5b1
commit
8905fa98bc
3 changed files with 29 additions and 7 deletions
|
@ -23,11 +23,11 @@ STUB!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: Finish these
|
// TODO: Finish these
|
||||||
#define SF_MOV_OPEN 1
|
#define SF_MOV_OPEN 1
|
||||||
#define SF_MOV_UNLINK 4
|
#define SF_MOV_UNLINK 4
|
||||||
#define SF_MOV_PASSABLE 8
|
#define SF_MOV_PASSABLE 8
|
||||||
#define SF_MOV_TOGGLE 32
|
#define SF_MOV_TOGGLE 32
|
||||||
#define SF_MOV_USE 256
|
#define SF_MOV_USE 256
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ class func_door:CBaseTrigger
|
||||||
int m_iStopSnd;
|
int m_iStopSnd;
|
||||||
int m_iDamage;
|
int m_iDamage;
|
||||||
int m_iLocked;
|
int m_iLocked;
|
||||||
|
|
||||||
void(void) func_door;
|
void(void) func_door;
|
||||||
virtual void(void) SetMovementDirection;
|
virtual void(void) SetMovementDirection;
|
||||||
virtual void(vector vdest, void(void) func) MoveToDestination;
|
virtual void(vector vdest, void(void) func) MoveToDestination;
|
||||||
|
|
|
@ -107,10 +107,12 @@ ammoinfo_t cs_ammoinfo[11] = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
int
|
||||||
Ammo_BuyCaliber(player pl, int cal)
|
Ammo_BuyCaliber(player pl, int cal)
|
||||||
{
|
{
|
||||||
int *ptr_ammo;
|
int *ptr_ammo;
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
while (pl.money - cs_ammoinfo[cal].price > 0) {
|
while (pl.money - cs_ammoinfo[cal].price > 0) {
|
||||||
switch (cal) {
|
switch (cal) {
|
||||||
case CALIBER_50AE:
|
case CALIBER_50AE:
|
||||||
|
@ -146,11 +148,14 @@ Ammo_BuyCaliber(player pl, int cal)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*ptr_ammo >= cs_ammoinfo[cal].a_max)
|
if (*ptr_ammo >= cs_ammoinfo[cal].a_max)
|
||||||
return;
|
break;
|
||||||
|
|
||||||
*ptr_ammo += cs_ammoinfo[cal].a_size;
|
*ptr_ammo += cs_ammoinfo[cal].a_size;
|
||||||
Money_AddMoney(pl, -cs_ammoinfo[cal].price);
|
Money_AddMoney(pl, -cs_ammoinfo[cal].price);
|
||||||
|
rv = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We want to loop through all the possible weapons in case the server
|
/* We want to loop through all the possible weapons in case the server
|
||||||
|
@ -160,6 +165,7 @@ void
|
||||||
CSEv_AmmoBuySecondary(void)
|
CSEv_AmmoBuySecondary(void)
|
||||||
{
|
{
|
||||||
int cal = 0;
|
int cal = 0;
|
||||||
|
int ps = 0;
|
||||||
player pl = (player)self;
|
player pl = (player)self;
|
||||||
|
|
||||||
for (int i = 1; i < g_weapons.length; i++) {
|
for (int i = 1; i < g_weapons.length; i++) {
|
||||||
|
@ -184,15 +190,23 @@ CSEv_AmmoBuySecondary(void)
|
||||||
cal = CALIBER_57MM;
|
cal = CALIBER_57MM;
|
||||||
break;
|
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);
|
Weapons_RefreshAmmo(pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CSEv_AmmoBuyPrimary(void)
|
CSEv_AmmoBuyPrimary(void)
|
||||||
{
|
{
|
||||||
|
int ps = 0;
|
||||||
int cal = 0;
|
int cal = 0;
|
||||||
player pl = (player)self;
|
player pl = (player)self;
|
||||||
|
|
||||||
|
@ -248,9 +262,16 @@ CSEv_AmmoBuyPrimary(void)
|
||||||
cal = CALIBER_556MMBOX;
|
cal = CALIBER_556MMBOX;
|
||||||
break;
|
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);
|
Weapons_RefreshAmmo(pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ void Game_Worldspawn(void)
|
||||||
precache_sound("player/pl_pain4.wav");
|
precache_sound("player/pl_pain4.wav");
|
||||||
Sound_Precache("buy.kevlar");
|
Sound_Precache("buy.kevlar");
|
||||||
Sound_Precache("buy.weapon");
|
Sound_Precache("buy.weapon");
|
||||||
|
Sound_Precache("buy.ammo");
|
||||||
|
|
||||||
Weapons_Init();
|
Weapons_Init();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue