Well, this code is within the:
void CMjolnir::PrimaryAttack()
function (the name is for one of the weapons), and my code starts right under:
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
My code it´s another
if and don´t belong to any other code.
If you want to have multiple lines of code depend on an if statement, then you have to surround them with curly braces:
That´s what I did before, but it does not work.
{
m_flFreeammotime = gpGlobals->time + RANDOM_FLOAT(1, 5);// New code
if (gpGlobals->time >= m_flFreeammotime) //New code
{
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "AUTORELOAD\n");//New code
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] += 99;//Old code
}
}
Unless what you say is:
if (FBitSet(m_pPlayer->pev->flags, FL_FAKECLIENT)&& (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)/*Old Code*/
&& (m_flFreeammotime <= 0)) //New code
{ m_flFreeammotime = gpGlobals->time + RANDOM_FLOAT(1, 5); } //New code
if (gpGlobals->time >= m_flFreeammotime) //New code
{
UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "AUTORELOAD\n");//New code
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] += 99;//Old code
}
Looks easy to do a countdown part that activates something, but I swear it´s not.
EDIT: Well, doing that the code works, the
AUTORELOAD message appears, BUT it does always appear. It´s like if
m_flFreeammotime is always
0 even if the condition m_rgAmmo[m_iPrimaryAmmoType] <= 0 is not met. :/