Hi Tan,
You can override the Equip( CBaseCombatCharacter *pOwner ) function to
handle the first pickup of a weapon. This gets called when a player obtains
the weapon either by touching it or when they are given it programmatically
using GiveNamedItem().
Also, why do you need to keep track of the silenced status at the player
object when it really only relates to the gun? If you kept the silenced
state local to the gun itself and not to the player then just un-set the
silencer boolean on the weapon object when the player drops the gun to the
ground then the next player that picks it up will have an un-silenced USP.
It might be a better design to do it that way and it will probably prevent a
few bugs along the way... such as if a player picks up a gun and you don't
set the player's silenced flag to false, any gun they could pick up could be
silenced regardless of it has a silencer or not. Unless I'm just totally
missing the real reason why you're holding the silencer flag on the player.
I hope that helps.
-Cale
On Fri, Jul 11, 2008 at 4:22 AM, Tan Theodore <[EMAIL PROTECTED]>
wrote:
>
> 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. Sorry if this is double-posted.
> Something's screwy with my router.
> _________________________________________________________________
> Check out Barclays Premier League exclusive video clips here!
> http://fc.sg.msn.com/index.aspx
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders