View Full Version : [Question] SDKtools Trace
SamuraiBarbi
09-25-2007, 08:15
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.
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
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:
decl Float:pos[3], Float:angles[3];
GetClientEyePosition( client, pos );
GetClientEyeAngles( client, angles );
TR_TraceRay( pos, angles, MASK_SOLID_BRUSHONLY, RayType:RayType_Infinite );
new target = TR_GetEntityIndex();
if( target >= 0 )
{
/* hit something */
}
else
{
/* didn't hit anything */
}
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 ^ ;)
My plugin spray tracer use TraceRay, if you need to learn how to use it :O
SamuraiBarbi
09-25-2007, 16:54
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:
decl Float:pos[3], Float:angles[3];
GetClientEyePosition( client, pos );
GetClientEyeAngles( client, angles );
TR_TraceRay( pos, angles, MASK_SOLID_BRUSHONLY, RayType:RayType_Infinite );
new target = TR_GetEntityIndex();
if( target >= 0 )
{
/* hit something */
}
else
{
/* didn't hit anything */
}
OMG, thanks! That got me on the right path.
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.