Hardly tested
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <hamsandwich>
new const Version[] = "0.1";
enum WeaponSlots
{
Slot1 = 1,
Slot2
}
public plugin_init()
{
register_plugin( "Drop BP Ammo with Weapon" , Version , "bugsy" );
register_forward( FM_SetModel , "SetModel" );
RegisterHam( Ham_AddPlayerItem , "player" , "AddPlayerItem" );
}
public SetModel( iEntity , const szModel[] )
{
new szClassname[ 32 ] , iWeaponEntID , iWeaponSlot , iBPAmmo;
pev( iEntity , pev_classname , szClassname , charsmax( szClassname ) );
if ( equal ( szClassname , "weaponbox" ) )
{
if ( pev_valid( ( iWeaponEntID = GetWeaponEntityFromWeaponbox( iEntity , iWeaponSlot ) ) ) )
{
if ( ( iBPAmmo = cs_get_user_bpammo( pev( iEntity , pev_owner ) , cs_get_weapon_id( iWeaponEntID ) ) ) )
set_pev( iWeaponEntID , pev_iuser2 , iBPAmmo );
}
}
}
public AddPlayerItem( iPlayer , iEntity )
{
new iBPAmmo = pev( iEntity , pev_iuser2 );
if ( iBPAmmo )
cs_set_user_bpammo( iPlayer , cs_get_weapon_id( iEntity ) , iBPAmmo );
}
GetWeaponEntityFromWeaponbox( iWeaponBox , &iWeaponSlot )
{
new const m_rgpPlayerItems_Weaponbox[ 6 ] = { 34 , 35 , ... };
new iWeaponEntID;
for ( new WeaponSlots:iSlot = Slot1 ; iSlot <= Slot2 ; iSlot++ )
{
if ( ( iWeaponEntID = get_pdata_cbase( iWeaponBox , m_rgpPlayerItems_Weaponbox[ 0 ] + _:iSlot ) ) > 0 )
{
iWeaponSlot = _:iSlot;
break;
}
}
return ( iWeaponEntID > 0 ) ? iWeaponEntID : 0;
}
__________________