Raised This Month: $ Target: $400
 0% 

Check if it is a player (aiming)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 11-13-2010 , 18:00   Check if it is a player (aiming)
Reply With Quote #1

I am hooking a knife attack with ham:

PHP Code:
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_knife""BlockKnife")
 
RegisterHam(Ham_Weapon_SecondaryAttack"weapon_knife""BlockKnife"
This is what I have:

PHP Code:
public BlockKnife(id)
{
    if(
cached_status && !get_user_aiming (id) == PLAYER)
        return 
HAM_SUPERCEDE;
        
    return 
HAM_IGNORED;

So I want to enable knife attacks only on players, this can be a friend or an enemy.

I tested it like that now but I am getting weird errors:

PHP Code:
public BlockKnife(id)
{
    if(
cached_status)
        if(!
is_aiming_at_player(id))
            return 
HAM_SUPERCEDE;
        
    return 
HAM_IGNORED;
}

stock bool:is_aiming_at_player(index)
{
    new 
targettempclassname[32];
    
    
get_user_aiming(indextargettemp);
    
    
pev(targetpev_classnameclassname31);
    
    if ( 
equal(classname"player") ) 
        return 
true;
        
    return 
false;


Last edited by bibu; 11-13-2010 at 19:06.
bibu is offline
 



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:28.


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