AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Traceline problem (https://forums.alliedmods.net/showthread.php?t=229423)

bcKq 11-07-2013 11:58

Traceline problem
 
Hey, I've got this code
PHP Code:

public TraceLine(Float:vecStart[3], Float:vecEnd[3], ignoreMidtrace)
{
    if( !
is_user_connected(id) )
    {
        return;
    }
    
    new 
trafienie get_tr2(traceTR_iHitgroup);    
    if(
trafienie == HIT_HEAD)
    {
        
g_bHeadShot[id] = true;
        
client_print(idprint_chat"Strzal w Glowe");
    }


but it does client_print if I AIM on the head of enemy, not when I HIT him.
How can I do that it registers only when I hit someone in the head?

akcaliberg 11-07-2013 16:22

Re: Traceline problem
 
PHP Code:

public plugin_init() {
    
RegisterHam(Ham_TakeDamage,"player","HamPlayerTakeDamagePost",1)
}
public 
HamPlayerTakeDamagePost(victiminflictorattackerFloat:damagedmgbits) {
    if(
is_user_connected(victim
    && 
is_user_connected(attacker
    && 
victim != attacker
    
&& get_pdata_int(victim,75) == HIT_HEAD ) {
        
        
// here your codes
        
    
}



ConnorMcLeod 11-08-2013 00:49

Re: Traceline problem
 
Don't hook FM_TraceLine, it was something done in plugins few years ago when no other tools were avalaible.

Hook TraceAttack or TakeDamage (previous post contain useless check), depending on your needs.

akcaliberg 11-08-2013 04:36

Re: Traceline problem
 
Why useless ? What if the attacker is not a player ?

bcKq 11-08-2013 07:51

Re: Traceline problem
 
Ah, I used traceline for a bool that I later used in TakeDamage. I didn't know you can get hitzone from takedamage. That will be useful, thank you :)

ConnorMcLeod 11-08-2013 12:28

Re: Traceline problem
 
Quote:

Originally Posted by akcaliberg (Post 2058239)
Why useless ? What if the attacker is not a player ?

Check on victim is not needed.


All times are GMT -4. The time now is 23:23.

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