Raised This Month: $32 Target: $400
 8% 

Give zoom with ham


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-21-2015 , 12:42   Give zoom with ham
Reply With Quote #1

Hi everybody, well I use a weapon for zombie called ak gold and this weapon uses a zoom with FM_CmdStart, my question is if its possible to do with Ham_Weapon_SecondaryAttack? if it possible can you give an example pls?

this is the code:

PHP Code:
public fw_CmdStartiduc_handleseed )
{
    if( !
g_HasAk[id] || !is_user_aliveid ) || get_user_weaponid ) != CSW_AK47 
        return
    
    if( ( 
get_ucuc_handleUC_Buttons ) & IN_ATTACK2 ) && !( pevidpev_oldbuttons ) & IN_ATTACK2 ) )
    {
        if ( 
g_hasZoom[id] )
        {
                
g_hasZoomid ] = false
                cs_set_user_zoom
idCS_RESET_ZOOM)
        }
        else
        {
                
g_hasZoomid ] = true
                cs_set_user_zoom
idCS_SET_AUGSG552_ZOOM)
                
emit_soundidCHAN_ITEM"weapons/zoom.wav"0.202.400100 )
        }
    }

I did this but not working..

PHP Code:
public plugin_init() 
{  
    
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_ak47""fw_SecondaryAttack"1)
}

public 
fw_SecondaryAttack(weapon)
{
     static 
id
     id 
get_pdata_cbase(weaponm_pPlayer4)

     if(!
pev_valid(id) || !g_HasAk[id]) return;
    
        if (
g_hasZoom[id])
        {
                
g_hasZoom[id] = false
                cs_set_user_zoom
idCS_RESET_ZOOM0)
        }
        else
        {
                
g_hasZoom[id] = true
                cs_set_user_zoom
(idCS_SET_AUGSG552_ZOOM0)
                
emit_sound(idCHAN_ITEM"weapons/zoom.wav"0.202.400100)
        }


Last edited by wicho; 03-21-2015 at 12:46.
wicho is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-21-2015 , 12:44   Re: Give zoom with ham
Reply With Quote #2

Your second public is wrong named, it should be "Ham_KnifeAttack_Post". Also, if this is for ak47, change from "weapon_knife" to "weapon_ak47".
__________________
HamletEagle is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-21-2015 , 12:46   Re: Give zoom with ham
Reply With Quote #3

i edited but same dont work..
wicho is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 03-21-2015 , 12:56   Re: Give zoom with ham
Reply With Quote #4

Why not use zoom from cstrike.inc ?
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-21-2015 , 13:05   Re: Give zoom with ham
Reply With Quote #5

the zoom uses cstrike check the code or what u mean?
wicho is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-21-2015 , 13:37   Re: Give zoom with ham
Reply With Quote #6

It's possible but it takes a little work: https://forums.alliedmods.net/showthread.php?t=175578
__________________
Bugsy is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-21-2015 , 21:56   Re: Give zoom with ham
Reply With Quote #7

So its better with fov? bugsy can u give and example of this pls?
wicho is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 03-21-2015 , 22:03   Re: Give zoom with ham
Reply With Quote #8

AK47 doesn't have a hookable secondary attack.
The least CPU expensive method would probably be to use Ham_Item_PreFrame and check the weapon's owner's keys.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 03-21-2015 at 22:07.
hornet is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-21-2015 , 22:36   Re: Give zoom with ham
Reply With Quote #9

like this?

PHP Code:
public plugin_init() 
{  
    
RegisterHam(Ham_Item_PostFrame"weapon_ak47""AK47_PostFrame")
}

public 
AK47_PostFrame(iEnt
{
    static 
id id get_pdata_cbase(iEntm_pPlayer4

    if(!
pev_valid(id) || !g_HasAk[id]) 
        return
    
    if( ( 
pevidpev_button ) & IN_ATTACK2 ) && !( pevidpev_oldbuttons ) & IN_ATTACK2 ) )
    {
        if ( 
g_hasZoom[id] )
        {
                
g_hasZoomid ] = false
                cs_set_user_zoom
idCS_RESET_ZOOM)
        }
        else
        {
                
g_hasZoomid ] = true
                cs_set_user_zoom
idCS_SET_AUGSG552_ZOOM)
                
emit_soundidCHAN_ITEM"weapons/zoom.wav"0.202.400100 )
        }
    }


Last edited by wicho; 03-21-2015 at 23:14.
wicho is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 03-22-2015 , 03:21   Re: Give zoom with ham
Reply With Quote #10

delay would be more approciate, but this might work too.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
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 11:03.


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