Raised This Month: $51 Target: $400
 12% 

[Hook]CAK47::SecondaryAttack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bogdyuttzu
Senior Member
Join Date: Dec 2009
Location: Romania
Old 01-06-2012 , 00:43   [Hook]CAK47::SecondaryAttack
Reply With Quote #1

I see in CSSDK CAK47::SecondaryAttack but the function is empty. Its posible to hook the function with ham? Ham_Weapon_SecondaryAttack or with orpheu?

Last edited by bogdyuttzu; 01-06-2012 at 01:32.
bogdyuttzu is offline
Send a message via Yahoo to bogdyuttzu
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 01-06-2012 , 00:57   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #2

Code:
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_ak47", "speed_ak47", 1)
StickP0le is offline
bogdyuttzu
Senior Member
Join Date: Dec 2009
Location: Romania
Old 01-06-2012 , 01:09   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #3

I don't want primary attack....
bogdyuttzu is offline
Send a message via Yahoo to bogdyuttzu
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-06-2012 , 01:23   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #4

Doesn't work with ham, i think the function doesn't exist but i'm not sure.

You can use Ham_Item_PostFrame and check hold keys, look at this plugin : http://forums.alliedmods.net/showthread.php?p=1158121
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bogdyuttzu
Senior Member
Join Date: Dec 2009
Location: Romania
Old 01-06-2012 , 03:10   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #5

The function exist but is empty.
bogdyuttzu is offline
Send a message via Yahoo to bogdyuttzu
jim_yang
Veteran Member
Join Date: Aug 2006
Old 01-06-2012 , 05:59   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #6

Yes, the function exist means it can be hooked at least, no matter it is empty or not.
But if the function is never called, then there is no effect when you hook it.
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 01-06-2012 , 06:33   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #7

The thing you can do is to verify if the player press the secondaryattack button and get the ak47, then do something.
__________________
You can do anything you set your mind to, man.

Devil259 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-06-2012 , 12:01   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #8

Tested and works :

PHP Code:
/*    Formatright © 2011, ConnorMcLeod

    This plugin is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this plugin; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

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

#define VERSION "0.0.3"
#define PLUGIN "Weapons SecondaryAttack Enabler"

const XO_WEAPON 4
const m_pPlayer 41
const m_flNextSecondaryAttack 47

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")

    const 
bitNeedToEnableWeapons 1<<CSW_XM1014 1<<CSW_C4 1<<CSW_MAC10 1<<CSW_ELITE 1<<CSW_UMP45 1<<CSW_GALIL 1<<CSW_MP5NAVY 1<<CSW_M249 1<<CSW_M3 1<<CSW_TMP 1<<CSW_AK47 1<<CSW_P90
    
new szWeaponName[32]
    for(new 
iId CSW_P228iId<=CSW_P90iId++)
    {
        if( 
bitNeedToEnableWeapons 1<<iId )
        {
            
get_weaponname(iIdszWeaponNamecharsmax(szWeaponName))
            
RegisterHam(Ham_Item_PostFrameszWeaponName"CBasePlayerWeapon_ItemPostFrame"0)
        }
    }
}

public 
CBasePlayerWeapon_ItemPostFrameiEnt )
{
    static 
idbutton

    
if(    (button pev
                            
(id get_pdata_cbase(iEntm_pPlayerXO_WEAPON),
                            
pev_button))
            & 
IN_ATTACK2
    
&&    get_pdata_float(iEntm_flNextSecondaryAttackXO_WEAPON) <= 0.0    )
    {
        
ExecuteHamB(Ham_Weapon_SecondaryAttackiEnt)
        
// in the hooking plugin you may remove IN_ATTACK from button if you have executed something so PrimaryAttack won't be executed in the same frame
        // you can also set m_flNextAttack > 0.0 so ItemPostFrame will be ignored

        
set_pev(idpev_buttonbutton & ~IN_ATTACK2)
    }

+ Your code in the following plugin :

PHP Code:
#include <amxmodx>
#include <hamsandwich>

#define VERSION "0.0.1"
#define PLUGIN ""

const XO_WEAPON 4
const m_pPlayer 41

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_ak47""CAK47_SecondaryAttack")
}

public 
CAK47_SecondaryAttackiEnt )
{
    new 
id get_pdata_cbase(iEntm_pPlayerXO_WEAPON)
    
client_print(idprint_center"AK SecondaryAttack !!")


Plugin example :

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"
#define PLUGIN "FlashLight On Secondary Attack"

const XO_WEAPON 4
const m_pPlayer 41
const m_flNextSecondaryAttack 47

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")

    const 
bitFreeSecondaryAttackWeapons 1<<CSW_XM1014 1<<CSW_C4 1<<CSW_MAC10 1<<CSW_ELITE 1<<CSW_UMP45 1<<CSW_GALIL 1<<CSW_MP5NAVY 1<<CSW_M249 1<<CSW_M3 1<<CSW_TMP 1<<CSW_AK47 1<<CSW_P90
    
new szWeaponName[32]
    for(new 
iId CSW_P228iId<=CSW_P90iId++)
    {
        if( 
bitFreeSecondaryAttackWeapons 1<<iId )
        {
            
get_weaponname(iIdszWeaponNamecharsmax(szWeaponName))
            
RegisterHam(Ham_Weapon_SecondaryAttackszWeaponName"MWeaponsWeapons_SecondaryAttack"0)
        }
    }
}

public 
MWeaponsWeapons_SecondaryAttackiWeapon )
{
    new 
id get_pdata_cbase(iWeaponm_pPlayerXO_WEAPON)
    
set_pev(idpev_impulse100)
    
set_pdata_float(iWeaponm_flNextSecondaryAttack0.4)

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-07-2012 at 17:19.
ConnorMcLeod is offline
bogdyuttzu
Senior Member
Join Date: Dec 2009
Location: Romania
Old 01-07-2012 , 02:22   Re: [Hook]CAK47::SecondaryAttack
Reply With Quote #9

Thanks Connor

Last edited by bogdyuttzu; 01-07-2012 at 02:22.
bogdyuttzu is offline
Send a message via Yahoo to bogdyuttzu
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 06:36.


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