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

Getting the entity index of a player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wgooch
Member
Join Date: Dec 2008
Old 05-03-2009 , 18:18   Getting the entity index of a player
Reply With Quote #1

Ok really, I have absolutely no idea how I can accomplish this without aiming at the client and using GetClientAimTarget
wgooch is offline
BAILOPAN
Join Date: Jan 2004
Old 05-03-2009 , 18:32   Re: Getting the entity index of a player
Reply With Quote #2

What?
__________________
egg
BAILOPAN is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 05-03-2009 , 18:56   Re: Getting the entity index of a player
Reply With Quote #3

The client's id (that number between (including) 1 and maxplayers) is his entity index IIRC.
__________________
hello, i am pm
PM is offline
wgooch
Member
Join Date: Dec 2008
Old 05-03-2009 , 19:04   Re: Getting the entity index of a player
Reply With Quote #4

Let me revise the question. I'm looking for a way to get the entity index of a player entity, such as using GetClientAimTarget and looking at an entity but instead simply targeting the player with a command such as sm_getplayerindex yams.
wgooch is offline
paegus
Senior Member
Join Date: Nov 2004
Location: Extreme low earth orbit
Old 05-04-2009 , 10:51   Re: Getting the entity index of a player
Reply With Quote #5

take a look at some of the SourceMod functions.. sm_slay for instance...

Code:
public Action:Command_Slay(client, args) {     if (args < 1)     {         ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");         return Plugin_Handled;     }     decl String:arg[65];     GetCmdArg(1, arg, sizeof(arg));     decl String:target_name[MAX_TARGET_LENGTH];     decl target_list[MAXPLAYERS], target_count, bool:tn_is_ml;         if ((target_count = ProcessTargetString(             arg,             client,             target_list,             MAXPLAYERS,             COMMAND_FILTER_ALIVE,             target_name,             sizeof(target_name),             tn_is_ml)) <= 0)     {         ReplyToTargetError(client, target_count);         return Plugin_Handled;     }     for (new i = 0; i < target_count; i++)     {         PerformSlay(client, target_list[i]);     }         if (tn_is_ml)     {         ShowActivity2(client, "[SM] ", "%t", "Slayed target", target_name);     }     else     {         ShowActivity2(client, "[SM] ", "%t", "Slayed target", "_s", target_name);     }     return Plugin_Handled; }

...for ways to find a player's index by sending part of their name etc using the ProcessTargetString function.
__________________
Live and learn or die and teach by example.
Plugins Mine | Hidden:SourceMod

Last edited by paegus; 05-04-2009 at 10:54.
paegus is offline
wgooch
Member
Join Date: Dec 2008
Old 05-04-2009 , 19:49   Re: Getting the entity index of a player
Reply With Quote #6

I'm looking for the entity index of the player, for example, if I enter find_ent weapon_ into the console, I will get something like this
Code:
   'weapon_molotov_spawn' : '' (entindex 28) 
   'weapon_rifle_spawn' : '' (entindex 73) 
   'weapon_pipe_bomb_spawn' : '' (entindex 29) 
   'weapon_first_aid_kit_spawn' : '' (entindex 74) 
   'weapon_hunting_rifle_spawn' : '' (entindex 52) 
   'weapon_first_aid_kit_spawn' : '' (entindex 75) 
   'weapon_ammo_spawn' : '' (entindex 53)
If I type find_ent player I get something like this
Code:
   'player' : '' (entindex 1) 
   'player' : '' (entindex 2) 
   'player' : '' (entindex 3) 
   'player' : '' (entindex 4)
Those indexes seem to have no relation to their ID's so I'm stumped on how to get them, and I don't see how ProcessTargetString is going to help me get them. It allows me to target a player for finding the index, but what I need is a way to figure out a way to retrieve the index first. Please correct me I missed something with ProcessTargetString that would help me with this. I'm very new to SourceMod and still learning a lot about it!
wgooch is offline
BAILOPAN
Join Date: Jan 2004
Old 05-05-2009 , 04:39   Re: Getting the entity index of a player
Reply With Quote #7

PM said this in comment #3. Players also have a "userid" which is [2,SHRT_MAX) or something, but it's less reliable. GetClientUserId and GetClientOfUserId switch between entity indexes and userids.
__________________
egg
BAILOPAN is offline
paegus
Senior Member
Join Date: Nov 2004
Location: Extreme low earth orbit
Old 05-05-2009 , 06:22   Re: Getting the entity index of a player
Reply With Quote #8

yeah and ProcessTargetString will return a list of player entity indexes (somewhere between 1 and MaxClients) that match the search parameters passed. if only 1 client matches then you'll only get that 1 player's entity index which is what SourceMod uses for quite literally everything. which is why in any event-hooks you always see GetClientOfUserId() to get the client's entity index from the player-in-question's UserID.
__________________
Live and learn or die and teach by example.
Plugins Mine | Hidden:SourceMod

Last edited by paegus; 05-06-2009 at 03:00. Reason: generally dyslexic issues
paegus is offline
wgooch
Member
Join Date: Dec 2008
Old 05-05-2009 , 18:13   Re: Getting the entity index of a player
Reply With Quote #9

AHA! Thank you, just what I was searching for
wgooch 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 18:40.


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