UpdateClientData (pre hooked) and check for each bpammo slot if m_rgAmmo[SLOT] != m_rgAmmoLast[SLOT]
376 -> 407 - m_rgAmmo[MAX_AMMO_SLOTS]
408 -> 439 - m_rgAmmoLast[MAX_AMMO_SLOTS]
PHP Code:
// Called from UpdateClientData
// makes sure the client has all the necessary ammo info, if values have changed
void CBasePlayer::SendAmmoUpdate(void)
{
for (int i=0; i < MAX_AMMO_SLOTS;i++)
{
if (m_rgAmmo[i] != m_rgAmmoLast[i])
{
m_rgAmmoLast[i] = m_rgAmmo[i];
ASSERT( m_rgAmmo[i] >= 0 );
ASSERT( m_rgAmmo[i] < 255 );
// send "Ammo" update message
MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev );
WRITE_BYTE( i );
WRITE_BYTE( max( min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte
MESSAGE_END();
}
}
}
You could filter with active item to be more efficient.
You can still use the registered event instead of message AmmoX that will no crash and be less consuming ;), this way you won't be able to block the actual message from being sent but that better than a 0.1 task IMO.
__________________