The function being called multiple times is normal, that's how prediction testing works. Does the weapon actually end up in an incorrect state after firing multiple times? If not, this is likely to be a problem with the viewmodel entity rather than the weapon. Are you using predicted_viewmodel?

On 12/07/2011 9:05, Priyadarshi Sharma wrote:
Hello,

I am having the issue of a weapon being fired multiple times on client
side when there is a lag between client and server (net_fakelag 100).
This is similar to the issue mentioned here :
http://www.mail-archive.com/hlcoders@list.valvesoftware.com/msg19271.html

I've tried the suggested fix but it doesn't seem to help in my case.
It only happens in the burst fire mode though, not otherwise.

Below are the relevant functions. As you can see, even checking for
IsFirstTimePredicted() doesn't solve the issue and the function is
still called multiple times on client side as evident from the
DevMsg() below. How do I go on about solving this issue?

PS - I've also tried the fix mentioned here -
http://www.mail-archive.com/hlcoders@list.valvesoftware.com/msg19344.html,
which indicates a bug with the SDK itself, but no help here too.

Code :

void MyWeapon::ItemPostFrame()
{

        // Burstfire continues for 3 shots after we press fire
        if(cBurstShots)
                BurstFire();
        else
                BaseClass::ItemPostFrame();
}

void MyWeapon::BurstFire()
{
        if (!m_iClip1)
        {
                cBurstShots = 0;
                return;
        }

        if (tNextBurst>  gpGlobals->curtime)
                return;

#ifdef CLIENT_DLL
         if ( prediction->InPrediction()&&  !prediction->IsFirstTimePredicted() 
)
                 return;
#endif

#ifdef CLIENT_DLL
        DevMsg("Time : %f cBurstShots : %d tNextBurst : %f\n",
gpGlobals->curtime, cBurstShots, tNextBurst);
#endif

        // making this NOT relative to curtime means it won't be totally
cpu/tickrate dependent
        tNextBurst += info.m_tReloadChamber;

        --cBurstShots;

        Fire();

        m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->curtime + 
0.1;

        WeaponSound( SINGLE );
        DoMuzzleFlash();
}


void MyWeapon::PrimaryAttack()
{
        if (!fBurstMode)
         {
                Fire();
                return;
        }

        cBurstShots = 3;
        tNextBurst = gpGlobals->curtime;
        SendWeaponAnim( ACT_VM_PRIMARYATTACK );
}

_______________________________________________
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

Reply via email to