I have this code which checks if I am aiming at player or not.
HTML Code:
public int IsAimingAtPlayer(int client)
{
float fangles[3];
float fposition[3];
GetClientEyeAngles(client, fangles);
GetClientEyePosition(client, fposition);
TR_TraceRay(fposition, fangles, MASK_SOLID, RayType:RayType_EndPoint);
if(TR_DidHit(INVALID_HANDLE)) {
int entityIndex = TR_GetEntityIndex(INVALID_HANDLE);
if(IsValidEdict(entityIndex)) {
char entityName[256];
GetEdictClassname(entityIndex, entityName, sizeof(entityName));
if(StrContains(entityName, "info_player_terrorist") || StrContains(entityName, "info_player_counterterrorist")) {
PrintToConsole(client, "You aimed at player.");
return //here should go playerID.
}
}
}
}
it has
HTML Code:
int entityIndex = TR_GetEntityIndex(INVALID_HANDLE);
how can I transfer entityIndex to playerID ? This function should return the player I am aiming at.