AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Totally block M4A1's secondary attack. (https://forums.alliedmods.net/showthread.php?t=93922)

xbatista 06-04-2009 11:18

Totally block M4A1's secondary attack.
 
I've tryied to block it,but it sooo buggy, maybe someone can give a code that will block attack2 button(silence).
P.S. Tryied with cmd_start, animations playing pressing attack and attack2,and other bugs... :mrgreen:

So can someone give perfect code of blocking attack2 of m4a1?

Bugsy 06-04-2009 11:53

Re: Totally block M4A1's secondary attack.
 
I don't think you can block the animations as they are client-side.

PHP Code:

register_forwardFM_CmdStart "fw_CmdStart" );

public 
fw_CmdStartClient Handle )
{
    static 
ButtonsButtons get_ucHandle UC_Buttons );

    if( ( 
get_user_weaponClient ) == CSW_M4A1 ) && ( Buttons IN_ATTACK2 ) )
    {
        
Buttons &= ~IN_ATTACK2;
        
set_ucHandle UC_Buttons Buttons );
        
        return 
FMRES_SUPERCEDE;
    }
    
    return 
FMRES_IGNORED;


You can also try this method which will block the animation. It will allow the first one but then all others are blocked. If you set this on the weapon entity before the player uses attack2 then the first will be blocked. I've got to run to work now, if you can't figure out how to do it, I will write it for you later tonight.

PHP Code:

RegisterHamHam_Weapon_SecondaryAttack"weapon_m4a1""fwBlock" );

public 
fwBlock(ent
{
    
set_pdata_floatent 47 9999.0 );



xbatista 06-04-2009 12:16

Re: Totally block M4A1's secondary attack.
 
I'm confused, I'll wait:wink:

Arkshine 06-04-2009 12:18

Re: Totally block M4A1's secondary attack.
 
@Bugsy, using the offset, you should use Item_Deploy.

Bugsy 06-04-2009 22:36

Re: Totally block M4A1's secondary attack.
 
Thanks ark

I had to add a hook on primary attack post because apparently using primary attack resets the offset value.

Tested and working
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

public plugin_init() 
{
    
RegisterHamHam_Item_Deploy "weapon_m4a1" "fw_Ham_BlockSilencer" );
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_m4a1""fw_Ham_BlockSilencer" );
}

public 
fw_Ham_BlockSilenceriEnt )
{
    
set_pdata_floatiEnt 47 9999.0 );



xbatista 06-05-2009 01:14

Re: Totally block M4A1's secondary attack.
 
Thanks will try when I get back home

xbatista 06-05-2009 05:31

Re: Totally block M4A1's secondary attack.
 
Omg thats does nothing :))))))))))))))))
no effect, m4a1 still can silence

xPaw 06-05-2009 05:39

Re: Totally block M4A1's secondary attack.
 
try set_pdata_float( iEnt , 48 , 9999.0 );
not sure about offset

or Ham_Weapon_PrimaryAttack -> Ham_Weapon_SecondaryAttack, tshi will fix when you getting silencer and you again can attack

Arkshine 06-05-2009 05:47

Re: Totally block M4A1's secondary attack.
 
48 is m_flTimeWeaponIdle.

try :

Code:
    #include <amxmodx>     #include <hamsandwich>     #include <fakemeta>     const m_flNextSecondaryAttack = 47;         public plugin_init()     {         register_plugin( "Block M4A1 Secondary Attack", "1.0", "Amxx Community" );                 RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_m4a1", "Event_BlockSecondaryAttack" , 1 );         RegisterHam( Ham_Item_Deploy , "weapon_m4a1" , "Event_BlockSecondaryAttack", 1 );     }     public Event_BlockSecondaryAttack ( const Entity )     {         set_pdata_float( Entity , m_flNextSecondaryAttack , 9999.0, 4 );     }

xbatista 06-05-2009 05:47

Re: Totally block M4A1's secondary attack.
 
okeyews


All times are GMT -4. The time now is 14:02.

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