PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < engine >
enum AmmoTypes
{
AMMO_CLIP,
AMMO_BACKPACK
};
new const g_iWeaponAmmo[ ][ AmmoTypes ] =
{
{ 0, 0 }, // NULL
{ 13, 52 },
{ 0, 0 }, // SHIELD
{ 10, 90 },
{ 0, 1} ,
{ 7, 32 },
{ 0, 0 }, // C4
{ 30, 100 },
{ 30, 90 },
{ 0, 1 },
{ 30, 120 },
{ 20, 100 },
{ 25, 100 },
{ 30, 90 },
{ 35, 90 },
{ 25, 90 },
{ 12, 100 },
{ 20, 120 },
{ 10, 30 },
{ 30, 120 },
{ 100, 200 },
{ 8, 32 },
{ 30, 90 },
{ 30, 120 },
{ 20, 90 },
{ 0, 2 },
{ 7, 35 },
{ 30, 90 },
{ 30, 90 },
{ 0, 0 }, // KNIFE
{ 50, 100 }
};
new g_iMaxPlayers;
public plugin_init( )
{
register_plugin( "Ammo From Kill", "0.1", "Exolent" );
register_event( "DeathMsg", "EventDeathMsg", "a" );
g_iMaxPlayers = get_maxplayers( );
}
public EventDeathMsg( )
{
new iKiller = read_data( 1 );
if( !( 1 <= iKiller <= g_iMaxPlayers )
|| !is_user_alive( iKiller ) )
{
return;
}
new iVictim = read_data( 2 );
if( iVictim == iKiller
|| cs_get_user_team( iVictim ) == cs_get_user_team( iKiller ) )
{
return;
}
static szWeaponName[ 32 ];
read_data( 4, szWeaponName, 31 );
if( equal( szWeaponName, "grenade" ) )
{
return;
}
new iWeaponId = get_user_weapon( iKiller );
if( !( 1 <= iWeaponId < sizeof( g_iWeaponAmmo ) )
|| ( 1 << iWeaponId ) & ( ( 1 << 2 ) | ( 1 << CSW_C4 ) | ( 1 << CSW_KNIFE ) ) )
{
return;
}
get_weaponname( iWeaponId, szWeaponName, 31 );
new iWeaponEntity = find_ent_by_owner( -1, szWeaponName, iKiller );
if( is_valid_ent( iWeaponEntity ) )
{
cs_set_weapon_ammo( iWeaponEntity, g_iWeaponAmmo[ iWeaponId ][ AMMO_CLIP ] );
}
cs_set_user_bpammo( iKiller, iWeaponId, g_iWeaponAmmo[ iWeaponId ][ AMMO_BACKPACK ] );
}