Raised This Month: $51 Target: $400
 12% 

Get player ID from entityIndex


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dakex
Junior Member
Join Date: Mar 2019
Old 11-10-2019 , 12:37   Get player ID from entityIndex
Reply With Quote #1

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.
Dakex is offline
Dakex
Junior Member
Join Date: Mar 2019
Old 11-10-2019 , 13:08   Re: Get player ID from entityIndex
Reply With Quote #2

Okay, Thank you very much. So My code is valid also?
Dakex is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 11-10-2019 , 13:11   Re: Get player ID from entityIndex
Reply With Quote #3

You already wrote an identical topic in which the answer was already given to you. Why have you decided to post again and use tracerays now instead for the exact same thing?
__________________
Silvers is offline
Dakex
Junior Member
Join Date: Mar 2019
Old 11-10-2019 , 13:17   Re: Get player ID from entityIndex
Reply With Quote #4

Indeed, I am still in faze where I learn things. But I found out, that I may be able to use this code in much more ways. For example (soccer) mode with TR_hulltrace or how it is called, so I find this way much better for me.
Dakex is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:14.


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