View Single Post
V952
Member
Join Date: Jan 2012
Location: Odessa, Ukraine
Old 04-08-2013 , 10:36   Re: help for use getclientaimtarget
Reply With Quote

Don't use GetClientAimTarget, because it traces through walls/brushes (like wallhack) etc. Use TR_TraceRay* natives.
Here is some snippet i use:
Code:
stock TraceClientViewEntity(this)
{
 Float:m_vecOrigin[3];
 Float:m_angRotation[3];
 GetClientEyePosition(this, m_vecOrigin);
 GetClientEyeAngles(this, m_angRotation);
 new Handle:tr = TR_TraceRayFilterEx(m_vecOrigin, m_angRotation, MASK_VISIBLE, RayType_Infinite, TRDontHitSelf, this);
 new pEntity = -1;
 if (TR_DidHit(tr))
 {
  pEntity = TR_GetEntityIndex(tr);
  CloseHandle(tr);
  return pEntity;
 }
 CloseHandle(tr);
 return -1;
}
public bool:TRDontHitSelf(entity, mask, any:data)
{
 if (entity == data) return false;
 return true;
}
I recomend you to use TR_TraceRayFilter unlike TR_TraceRay, cause the ray can hit your character's model and return itself.
If you'd call it like this:
Code:
new target = TraceClientViewEntity(this);
if (target < 1 || target > MaxClients) return;
if (!IsValidEdict(target)) return;
decl String:m_iszNetworkId[32];
GetClientAuthString(target, m_iszNetworkId, sizeof(m_iszNetworkId));
PrintToChat(client, "SteamId=%s", m_iszNetworkId);
You'll got player's SteamId.
__________________
HL2DM Real-Life Server: 195.138.78.198:27015

Last edited by V952; 04-08-2013 at 10:41. Reason: Forgot to implement entity validation
V952 is offline
Send a message via Skype™ to V952