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.
__________________