View Single Post
Author Message
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 04-06-2012 , 14:28   Only attacker call
Reply With Quote #1

I need to do that only those who are the attacker, run the following call:

PHP Code:
ShowHPInfo (clientaimTarget); 
I've tried other ways but still can not, can someone help?

PHP Code:
public Event_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
GetConVarBool(g_cvar_enable))
    {
        new 
String:weapon[64];
        new 
client GetClientOfUserId(GetEventInt(event"userid"));
        new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
        
GetEventString(event"weapon"weaponsizeof(weapon));

        if( 
StrEqual(weapon,"smokegrenade") )
        {
            return;    
        }

        if( 
StrEqual(weapon,"hegrenade") )
        {
            return;    
        }

        if( 
StrEqual(weapon,"flashbang") )
        {
            return;    
        }

        if ((
attacker 0) && (attacker != client))
        {
            
CreateTimer(HUD_INTERVALLTimer_DisplayHud0TIMER_FLAG_NO_MAPCHANGE);
        }
    }
}

public 
Action:Timer_DisplayHud(Handle:timer) {
    
    
decl Float:pos[3];
    
    for (new 
client=1client<=MaxClients; ++client) {
        
        if(!
g_bClientShowDisplay[client]){
            continue;
        }

        if (
IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client)) {

            new 
aimTarget GetClientAimHullTarget(clientpos);

            
ShowHPInfo(clientaimTarget);
        }
    }
    
    return 
Plugin_Continue;
}

public 
ShowHPInfo(client, &attackertarget) {
    
    if(
GetClientTeam(client) == CS_TEAM_CT) {
        return;
    }
    
    if (!
GetConVarBool(g_cvar_enable)) {
        return;
    }
    
    if(
g_bDontOverRideHealthDisplay[client]){
        return;
    }
    
    new 
String:targetname[MAX_TARGET_LENGTH];
    new 
bool:success GetEntityName(target,targetname,sizeof(targetname));
    
    if(
success){
        
        new 
String:health[MAX_HEALTH_LENGTH];
        
GetEntityHealthString(targethealth);
        
        new 
String:showstring[MAX_SHOWSTRING_LENGTH];
        
g_bClearedDisplay[client] = false;
        
Format(showstring,MAX_SHOWSTRING_LENGTH,"%s %s",targetname,health);
                
        if(!
StrEqual(showstring,g_szOldShowString[client],false) || ((GetGameTime() - g_iUpdateHintTimeout[client]) > 4.0)){
                    
            
PrintHintText(client,showstring);
            
strcopy(g_szOldShowString[client],MAX_SHOWSTRING_LENGTH,showstring);
            
g_iUpdateHintTimeout[client] = GetGameTime();
        }
    }
    else if(!
g_bClearedDisplay[client]) {
        
        
g_bClearedDisplay[client] = true;
        
        
PrintHintText(client,HINTBOX_BLANK);
        
        
strcopy(g_szOldShowString[client],sizeof(g_szOldShowString[]),HINTBOX_BLANK);
    }

Thanks.
__________________
My Plugins | VIEW HERE | I accept private requests, send me a PM.
Buy respawn | Uber Recall | Grenade drop | Damage Supperssor
Meet the Medic | Disguise Expert | Crazy Jet

CZSBrasil TEAM

Last edited by rodrigo286; 04-06-2012 at 14:30.
rodrigo286 is offline