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

[Question] SDKtools Trace


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 09-25-2007 , 08:15   [Question] SDKtools Trace
Reply With Quote #1

How do I use TR_GetEntityIndex(Handle:hndl=INVALID_HANDLE) ; ?

I assume this can be used in some very interesting and creative ways. I'm trying to use it in a hooked weapon_fire event to find out what the player is looking at. I've tried testing it using the following code but it just prints out 0.

Code:
    new Handle:target;
    TR_GetEntityIndex(target);
    PrintToChatAll("%i",target);
Am I correct in assuming TR_GetEntityIndex will return another players index if the person shooting is looking directly at them? Also, why isn't this working as intended?
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
IceMatrix
New Member
Join Date: Sep 2007
Location: Germany
Old 09-25-2007 , 11:14   Re: [Question] SDKtools Trace
Reply With Quote #2

Not at all!!

You do a ray-trace, either with TR_TraceRay or with another ray tracing functions that returns you a handle.

After that you call TR_GetEntityIndex either with the default value (no argument) or with the handle returned by the complex ray tracing functions. TR_GetEntityIndex will return you the entity index hit by the ray (if any).

Example:
PHP Code:
decl Float:pos[3], Float:angles[3];
GetClientEyePositionclientpos );
GetClientEyeAnglesclientangles );

TR_TraceRayposanglesMASK_SOLID_BRUSHONLYRayType:RayType_Infinite );

new 
target TR_GetEntityIndex();
if( 
target >= )
{
/* hit something */
}
else
{
/* didn't hit anything */

IceMatrix is offline
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-25-2007 , 11:14   Re: [Question] SDKtools Trace
Reply With Quote #3

not done anything with trace rays in hl2. but i think it might be for if a trace line hits an entity to get the entity index that it hit need to run a trace ray first to find out if the player is looking at an entity done ^ ;)
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 09-25-2007 , 16:09   Re: [Question] SDKtools Trace
Reply With Quote #4

My plugin spray tracer use TraceRay, if you need to learn how to use it :O
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 09-25-2007 , 16:54   Re: [Question] SDKtools Trace
Reply With Quote #5

Quote:
Originally Posted by IceMatrix View Post
Not at all!!

You do a ray-trace, either with TR_TraceRay or with another ray tracing functions that returns you a handle.

After that you call TR_GetEntityIndex either with the default value (no argument) or with the handle returned by the complex ray tracing functions. TR_GetEntityIndex will return you the entity index hit by the ray (if any).

Example:
PHP Code:
decl Float:pos[3], Float:angles[3];
GetClientEyePositionclientpos );
GetClientEyeAnglesclientangles );

TR_TraceRayposanglesMASK_SOLID_BRUSHONLYRayType:RayType_Infinite );

new 
target TR_GetEntityIndex();
if( 
target >= )
{
/* hit something */
}
else
{
/* didn't hit anything */

OMG, thanks! That got me on the right path.
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
Reply



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 09:03.


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