Raised This Month: $ Target: $400
 0% 

Block Attack2 in defined weapons.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-25-2010 , 15:31   Block Attack2 in defined weapons.
Reply With Quote #1

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?

Last edited by Gadzislaw007; 07-25-2010 at 15:33. Reason: mistake in code
Gadzislaw007 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-25-2010 , 15:38   Re: Block Attack2 in defined weapons.
Reply With Quote #2

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).
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
grimvh2
Veteran Member
Join Date: Nov 2007
Location: Fishdot Nation
Old 07-25-2010 , 16:22   Re: Block Attack2 in defined weapons.
Reply With Quote #3

hook it with ham?
__________________
I am out of order!
grimvh2 is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-25-2010 , 16:27   Re: Block Attack2 in defined weapons.
Reply With Quote #4

I can't really get the pdata functions. Gonna study on it.
Gadzislaw007 is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-25-2010 , 17:13   Re: Block Attack2 in defined weapons.
Reply With Quote #5

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?
Gadzislaw007 is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-25-2010 , 20:58   Re: Block Attack2 in defined weapons.
Reply With Quote #6

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?

Last edited by nikhilgupta345; 07-26-2010 at 00:23.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-26-2010 , 03:49   Re: Block Attack2 in defined weapons.
Reply With Quote #7

Quote:
Originally Posted by nikhilgupta345 View Post
Also it's public plugin_init not public init :/
Just retyping mistake (I just copied the part of plug)...


Quote:
Originally Posted by nikhilgupta345 View Post
Oh, and post the error log?
Argh... No errors? I can't see any. Logs are clear ;p.
Gadzislaw007 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-26-2010 , 06:04   Re: Block Attack2 in defined weapons.
Reply With Quote #8

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 ); }
__________________

Last edited by xPaw; 07-26-2010 at 08:18.
xPaw is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-26-2010 , 08:15   Re: Block Attack2 in defined weapons.
Reply With Quote #9

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?
Gadzislaw007 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-26-2010 , 08:19   Re: Block Attack2 in defined weapons.
Reply With Quote #10

edited above
__________________
xPaw is offline
Reply



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 00:18.


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