Here's what i've done, is not using bpammo insteand of ammo, but when you no more having bullets is settings directly the bullets as bpamoo and empty the bpammo, test to see by yourself how is working.
You can easily add a hudmessage and remove the clip using the bugsy method (HideWeaponMessage) by yourself and manage how you want.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <engine>
public plugin_init()
{
new szWeaponName[20];
for( new i = 1; i < 31; i++ )
{
get_weaponname( i, szWeaponName, charsmax(szWeaponName) );
if( szWeaponName[0] != EOS )
{
RegisterHam( Ham_Weapon_PrimaryAttack, szWeaponName, "ham_WpPrimaryAttack_PostFunc", true );
}
}
}
public ham_WpPrimaryAttack_PostFunc( const Entity )
{
new OwnerOfWeaponIndex = pev( Entity, pev_owner );
new Bullets,Ammo;
new WeaponId = get_user_weapon( OwnerOfWeaponIndex, Bullets, Ammo );
if( Bullets <= 1 )
{
give_user_weapon( OwnerOfWeaponIndex, WeaponId, Ammo--, 0 );
}
}
give_user_weapon( index , iWeaponTypeID , iClip=0 , iBPAmmo=0 , szWeapon[]="" , maxchars=0 )
{
if ( !( CSW_P228 <= iWeaponTypeID <= CSW_P90 ) || ( iClip < 0 ) || ( iBPAmmo < 0 ) || !is_user_alive( index ) )
return -1;
new szWeaponName[ 20 ] , iWeaponEntity , bool:bIsGrenade;
const GrenadeBits = ( ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_C4 ) );
if ( ( bIsGrenade = bool:!!( GrenadeBits & ( 1 << iWeaponTypeID ) ) ) )
iClip = clamp( iClip ? iClip : iBPAmmo , 1 );
get_weaponname( iWeaponTypeID , szWeaponName , charsmax( szWeaponName ) );
if ( ( iWeaponEntity = user_has_weapon( index , iWeaponTypeID ) ? find_ent_by_owner( -1 , szWeaponName , index ) : give_item( index , szWeaponName ) ) > 0 )
{
if ( iWeaponTypeID != CSW_KNIFE )
{
if ( iClip && !bIsGrenade )
cs_set_weapon_ammo( iWeaponEntity , iClip );
if ( iWeaponTypeID == CSW_C4 )
cs_set_user_plant( index , 1 , 1 );
else
cs_set_user_bpammo( index , iWeaponTypeID , bIsGrenade ? iClip : iBPAmmo );
}
if ( maxchars )
copy( szWeapon , maxchars , szWeaponName[7] );
}
return iWeaponEntity;
}
__________________