Raised This Month: $ Target: $400
 0% 

Solved Detecting If A Weapon Is Silenced


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-13-2015 , 11:38   Re: [HELP] Detecting If A Weapon Is Silenced
Reply With Quote #5

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_silenget_pdata_cbaseinvoker 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 *amxcell *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;

__________________

Last edited by Bugsy; 12-13-2015 at 11:50.
Bugsy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode