AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Detecting If A Weapon Is Silenced (https://forums.alliedmods.net/showthread.php?t=276002)

hellmonja 12-12-2015 11:39

Detecting If A Weapon Is Silenced
 
Well, like the title says, is there a way to detect if a weapon is silenced? or has the silencer attached to it?...

siriusmd99 12-12-2015 11:54

Re: [HELP] Detecting If A Weapon Is Silenced
 
Quote:

Originally Posted by hellmonja (Post 2371705)
Well, like the title says, is there a way to detect if a weapon is silenced? or has the silencer attached to it?...

https://forums.alliedmods.net/showthread.php?p=891661

Are u banned on google search ?

HamletEagle 12-12-2015 11:58

Re: [HELP] Detecting If A Weapon Is Silenced
 
http://amxmodx.org/api/cstrike/cs_get_weapon_silen

hellmonja 12-13-2015 01:41

Re: [HELP] Detecting If A Weapon Is Silenced
 
Hey thanks! I'm doing this:

PHP Code:

    if (cs_get_weapon_silen(CSW_MAKAROV))
    {
        
set_weapon_anim(invokerSHOOT_SILEN)
        
emit_sound(invokerCHAN_WEAPONFIRE_SOUNDVOL_NORMATTN_NORM0PITCH_NORM)
    }
    else
    {
        
set_weapon_anim(invokerSHOOT_ANIM)
        
emit_sound(invokerCHAN_WEAPONFIRE_SOUNDVOL_NORMATTN_NORM0PITCH_NORM)
    } 

but it doesn't seem to work. I'm trying to replace the shooting anim and sound on an extra weapon when it's silenced. but what happens with this is, the both anim and sound just don't work...

Bugsy 12-13-2015 11:38

Re: [HELP] Detecting If A Weapon Is Silenced
 
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;




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

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