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

Only attacker call


Post New Thread Reply   
 
Thread Tools Display Modes
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
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 04-06-2012 , 17:44   Re: Only attacker call
Reply With Quote #2

are you looking for something like - http://forums.alliedmods.net/showthread.php?p=763425
__________________
View my Plugins | Donate
TnTSCS is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 04-06-2012 , 17:53   Re: Only attacker call
Reply With Quote #3

This script does not work anymore, so I made mine, but I'm having problems in this part, I have only the attacker see the HUD.

And my shows, the life of the player is attacked.

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 17:59.
rodrigo286 is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 04-06-2012 , 18:03   Re: Only attacker call
Reply With Quote #4

If it would not work it would not be running on > 800 Servers, mine included.
Where is the problem?

To answer your question, use your code like so.
PHP Code:
CreateTimer(HUD_INTERVALLTimer_DisplayHudGetClientSerial(attacker), TIMER_FLAG_NO_MAPCHANGE); 
Then in the timercallback retrieve the client of the serial and only display the message to him.
PHP Code:
public Action:Timer_DisplayHud(Handle:timerany:serial
Yours sincerely
Impact
__________________

Last edited by Impact123; 04-06-2012 at 18:12.
Impact123 is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 04-06-2012 , 18:57   Re: Only attacker call
Reply With Quote #5

Compiled 100%

But HP does not appear, I did something wrong?

PHP Code:
GetClientAimHullTarget(client,Float:resultPos[3]) {
    
    
//Hull trace calculation by berni all credits for this goes to him!
    
    
decl Float:pos[3];
    
GetClientAimTargetPos(clientpos);
    
    
decl Float:vEyePosition[3];
    
GetClientEyePosition(clientvEyePosition);
    
    
decl Float:m_vecMins[3], Float:m_vecMaxs[3];
    
//GetEntPropVector(entity, Prop_Send, "m_vecMins", m_vecMins);
    //GetEntPropVector(entity, Prop_Send, "m_vecMaxs", m_vecMaxs);
    
m_vecMins[0] = m_vecMins[1] = m_vecMins[2] = 0.0;
    
m_vecMaxs[0] = m_vecMaxs[1] = 1.0;
    
m_vecMaxs[2] = 1.0;
    
    new 
Handle:trace TR_TraceHullFilterEx(vEyePositionposm_vecMinsm_vecMaxsTRACE_FILTER,TraceEntityFilter,client);
    
    
TR_GetEndPosition(resultPostrace);
    
    if(
TR_DidHit(trace)){
        
        new 
entity TR_GetEntityIndex(trace);
        
        
CloseHandle(trace);
        
        return 
entity;
    }
    
    
CloseHandle(trace);
    
    return -
1;
}

public 
Event_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
GetConVarBool(g_cvar_enable))
    {
        new 
String:weapon[64];
        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;    
        }

        
CreateTimer(HUD_INTERVALLTimer_DisplayHudGetClientSerial(attacker), TIMER_FLAG_NO_MAPCHANGE);  

    }
}

public 
Action:Timer_DisplayHud(Handle:timerany:serial) {
    
    
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(clienttarget) {
    
    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 tem (%s) de vida restante.",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
rodrigo286 is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 04-06-2012 , 23:01   Re: Only attacker call
Reply With Quote #6

Quote:
Originally Posted by rodrigo286 View Post
Compiled 100%

But HP does not appear, I did something wrong?
I quote myself
Quote:
Then in the timercallback retrieve the client of the serial and only display the message to him.
Yours sincerely
Impact
__________________
Impact123 is offline
rodrigo286
Veteran Member
Join Date: Sep 2010
Location: Brazil, São Paulo
Old 04-07-2012 , 06:19   Re: Only attacker call
Reply With Quote #7

#EDIT

Thanks for all, 100% work.
__________________
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-08-2012 at 13:09.
rodrigo286 is offline
Reply


Thread Tools
Display Modes

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 05:08.


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