I've created a USP with a silencer but I would like to prevent the USP to be
equipped with the silencer if the player swaps weapon/throws it. I've tried
doing this:
void CUSP::SecondaryAttack( void )
{
m_pPlayer->m_iSilencing = 1; //equipping silencer now
if (m_pPlayer->m_iSilencing == 1) //if it's being equipped now
{
if (m_iSilenced == 0) //if sliencer is not attached
{
m_pPlayer->m_iSilencing = 1; //start equipping
SendWeaponAnim( USP_ADD_SILENCER ); //play anim
m_flTimeWeaponIdle = m_flNextPrimaryAttack = m_flNextSecondaryAttack =
UTIL_WeaponTimeBase() + 3.2;
m_pPlayer->m_iSilencing = 0; //stop equipping
m_iSilenced = 1; //silencer attached
}
else //if silencer is attached
{
m_pPlayer->m_iSilencing = 1; //unequipping now
SendWeaponAnim( USP_REMOVE_SILENCER ); //play anim
m_flTimeWeaponIdle = m_flNextPrimaryAttack = m_flNextSecondaryAttack =
UTIL_WeaponTimeBase() + 3.2;
m_pPlayer->m_iSilencing = 0; //stop equipping
m_iSilenced = 0; //no silencer attached
}
}
else if (m_pPlayer->m_iSilencing == 0) //if it's not being equipped
{
m_iSilenced = m_iSilenced; // get the value of previous silencer status
return;
}
}
void CUSP::Holster( )
{
if (m_pPlayer->m_iSilencing == 1) //if holstered while silencing
{
m_iSilenced = m_iSilenced; //get the previous value.
}
else
{
}
}
Player.h
.
.
.
int m_iSilencing; //is the silencer being fitted for the USP.45?
weapon.h
.
.
.
int m_iSilenced; //is the USP.45 silenced?
I've tried all morning to make this work but to no avail. Any suggestions? I
even tried looking at the reload function but it's very indepth and I was
wondering if there is a simpler way.
_________________________________________________________________
NEW! Get Windows Live FREE.
http://www.get.live.com/wl/all
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders