You are using it incorrectly. You must pass the weapon entity to the cs_get/set_weapon_silen() function.
PHP Code:
const m_pActiveItem = 373;
if ( cs_get_weapon_silen( get_pdata_cbase( invoker , m_pActiveItem ) ) )
You should also review the function details to make sure it will work as you want. Specifically, are you checking this condition only when it is the M4A1 or USP? You should also see an error in your log based on the code you posted.
Code:
Note
Only the USP and M4A1 can return 1 as they are the only guns in the
game that have a silenced fire mode.
Note
This native does not check that the provided entity is actually a
weapon entity. It will return incorrect values for non-weapon entities.
Return
1 if the weapon is in silenced mode, 0 otherwise
Error
If an invalid entity index or a client index is provided,
an error will be thrown.
Here you can see it will only work for those two weapons.
PHP Code:
static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) // cs_get_weapon_silenced(index); = 1 param
{
// Is weapon silenced? Does only work on M4A1 and USP.
// params[1] = weapon index
// Valid entity should be within range
CHECK_NONPLAYER(params[1]);
// Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]);
int weapontype = *((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
switch (weapontype) {
case CSW_M4A1:
if (*silencemode & M4A1_SILENCED)
return 1;
case CSW_USP:
if (*silencemode & USP_SILENCED)
return 1;
}
// All else return 0.
return 0;
}
__________________