AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block Attack2 in defined weapons. (https://forums.alliedmods.net/showthread.php?t=133448)

Gadzislaw007 07-25-2010 15:31

Block Attack2 in defined weapons.
 
Code:


#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>

       

public plugin_init() {
        register_forward(FM_CmdStart,"Attack")
        register_plugin("Sample", "1.0", "Gadzik :*")
}

public Attack(player, handle, seed)
{
        if(!is_user_alive(player)) return FMRES_IGNORED
        new weapon = get_user_weapon(player)
        new button = get_uc(handle,UC_Buttons)
        if(weapon == CSW_SCOUT)       
                {
                        return FMRES_IGNORED
                }
                else       
                {
                if(button & IN_ATTACK2) {
                        button &= ~IN_ATTACK2
                        set_uc(handle,UC_Buttons,button)
                                                }
                                        }
}

Well, another question.
I want to block every weapon zoom (or other attack2 function) but scout.
It still blocks every weapon, scout too.
So what's wrong here?

ConnorMcLeod 07-25-2010 15:38

Re: Block Attack2 in defined weapons.
 
Look at this snipet : http://forums.alliedmods.net/showthr...19#post1238819

Register only weapons you want.
You can filter weapon type using cs_get_weapon_id or pdata m_iId (43 extra offset 4).

grimvh2 07-25-2010 16:22

Re: Block Attack2 in defined weapons.
 
hook it with ham?

Gadzislaw007 07-25-2010 16:27

Re: Block Attack2 in defined weapons.
 
I can't really get the pdata functions. Gonna study on it.

Gadzislaw007 07-25-2010 17:13

Re: Block Attack2 in defined weapons.
 
I've tried, but something went wrong.
I think I'm too stupid for this.

Code:


#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

// weapons offsets
#define m_weapon 4
#define m_player 41
#define m_id 43
#define m_Attack2 47


public init()
{
new szWeaponName[20]
        for(new i=CSW_P228; i<=CSW_P90; i++)
    {
        if( get_weaponname(i, szWeaponName, charsmax(szWeaponName)) )
        {
            RegisterHam(Ham_Item_Deploy, szWeaponName, "GG", true)
        }
    }

}

public GG(r_Weapon)
{
        new iId = get_pdata_int(r_Weapon, m_id, m_weapon)
        if(iId == CSW_AUG)
        {
                    set_pdata_float(r_Weapon, m_Attack2, 99999.0, m_weapon)
        }



}

What have I done wrong?

nikhilgupta345 07-25-2010 20:58

Re: Block Attack2 in defined weapons.
 
Adding 1 to I in the for function, at least what I think, wont change the weapon. Also it's public plugin_init not public init :/

Oh, and post the error log?

Gadzislaw007 07-26-2010 03:49

Re: Block Attack2 in defined weapons.
 
Quote:

Originally Posted by nikhilgupta345 (Post 1251506)
Also it's public plugin_init not public init :/

Just retyping mistake (I just copied the part of plug)...


Quote:

Originally Posted by nikhilgupta345 (Post 1251506)
Oh, and post the error log?

Argh... No errors? I can't see any. Logs are clear ;p.

xPaw 07-26-2010 06:04

Re: Block Attack2 in defined weapons.
 
Should work
Code:
const m_pPlayer               = 41; const m_flNextSecondaryAttack = 47; public plugin_init( )     RegisterHam( Ham_Item_Deploy, "weapon_aug", "FwdHamItemDeploy", 1 ); public FwdHamItemDeploy( const iEntity ) {     if( mama[ get_pdata_cbase( iEntity, m_pPlayer, 4 ) ] )         set_pdata_float( iEntity, m_flNextSecondaryAttack, 9999.0, 4 ); }

Gadzislaw007 07-26-2010 08:15

Re: Block Attack2 in defined weapons.
 
And what if I would like to set blocking by a value attached to id.
For example:
I define
new mama[33]
and then
if (mama[id])
then user's attack2 is blocked.
Is this possible by this way or I have to use other, more complicated function?

xPaw 07-26-2010 08:19

Re: Block Attack2 in defined weapons.
 
edited above


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

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