#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#define weapon_entity(%0) (get_pdata_int(%0, 43, 4))
public plugin_init()
{
RegisterHam(Ham_AddPlayerItem, "player", "add_player_item", 1);
}
public add_player_item(id, ent)
{
if (!pev_valid(ent) || !is_user_connected(id) || is_user_bot(id) || is_user_hltv(id)) return HAM_IGNORED;
new owner = pev(ent, pev_iuser1);
if (!is_user_connected(owner))
{
new weapon = weapon_entity(ent);
set_pev(ent, pev_iuser1, id);
if (weapon == CSW_M4A1)
{
cs_set_weapon_silen(ent, 1, 0);
}
}
return HAM_IGNORED;
}
#include < amxmodx >
#include < hamsandwich >
#include < cstrike >
const m_pPlayer = 41
const XO_WEAPON = 4
new szm4a1[ 33 ]
public plugin_init( ) {
register_plugin("Silencer", "1.0", "");
RegisterHam( Ham_Item_Deploy, "weapon_m4a1", "OnM4A1_Deploy", 1 );
RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_m4a1", "OnM4A1_SecondaryAttack", 1 );
}
public OnM4A1_Deploy( m4a1 ) {
new id = get_pdata_cbase( m4a1, m_pPlayer, XO_WEAPON );
if( szm4a1[ id ] )
cs_set_weapon_silen( m4a1, 1, 0 );
}
public OnM4A1_SecondaryAttack( m4a1 ) {
new id = get_pdata_cbase( m4a1, m_pPlayer, XO_WEAPON );
if( szm4a1[ id ] )
szm4a1[ id ] = false;
else
szm4a1[ id ] = true;
}