AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [Question] SDKtools Trace (https://forums.alliedmods.net/showthread.php?t=61253)

SamuraiBarbi 09-25-2007 08:15

[Question] SDKtools Trace
 
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?

IceMatrix 09-25-2007 11:14

Re: [Question] SDKtools Trace
 
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 */



dubbeh 09-25-2007 11:14

Re: [Question] SDKtools Trace
 
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 ^ ;)

Nican 09-25-2007 16:09

Re: [Question] SDKtools Trace
 
My plugin spray tracer use TraceRay, if you need to learn how to use it :O

SamuraiBarbi 09-25-2007 16:54

Re: [Question] SDKtools Trace
 
Quote:

Originally Posted by IceMatrix (Post 535454)
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.


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

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