Raised This Month: $ Target: $400
 0% 

Traceline problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bcKq
Member
Join Date: Dec 2012
Location: Tczew, Poland
Old 11-07-2013 , 11:58   Traceline problem
Reply With Quote #1

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?
__________________
This is my signature.
bcKq is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 11-07-2013 , 16:22   Re: Traceline problem
Reply With Quote #2

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
        
    
}


Last edited by akcaliberg; 11-07-2013 at 16:22.
akcaliberg is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-08-2013 , 00:49   Re: Traceline problem
Reply With Quote #3

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.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-08-2013 at 00:50.
ConnorMcLeod is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 11-08-2013 , 04:36   Re: Traceline problem
Reply With Quote #4

Why useless ? What if the attacker is not a player ?
akcaliberg is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-08-2013 , 12:28   Re: Traceline problem
Reply With Quote #5

Quote:
Originally Posted by akcaliberg View Post
Why useless ? What if the attacker is not a player ?
Check on victim is not needed.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bcKq
Member
Join Date: Dec 2012
Location: Tczew, Poland
Old 11-08-2013 , 07:51   Re: Traceline problem
Reply With Quote #6

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
__________________
This is my signature.
bcKq 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 23:23.


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