Raised This Month: $ Target: $400
 0% 

find_player SteamID||Name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Damocles
Member
Join Date: Jan 2005
Old 01-26-2005 , 11:10   find_player SteamID||Name
Reply With Quote #1

Hey guys n gals

Just writing my first plugin that executes a function on a client and finds the client either by part of their name or their steam id.

Is there a better way to figure out whether an admin has entered a steamid or a players name than the way i've written it ....

(sure there is because if you see my NOTE, theres a flaw)

Code:
    read_argv(1,target,31)     // If the first characters of the target = 'STEAM:'     // NOTE this will have issues if someone plays with 'Steam' as part of their name...     if (equal("STEAM:", target, 6) {                  // Admin entered a steamid for the target                  uid = find_player("chl", target)                  ......         }         else {                  // Else admin entered part of the targets name                  uid = find_player("bhl", target)                  ......         }

Thanks for any help

Damo.
Damocles is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 01-26-2005 , 15:22  
Reply With Quote #2

theres a stock in the AMXMISC include for this called cmd_target
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
BlueRaja
Senior Member
Join Date: Nov 2004
Old 01-26-2005 , 18:14  
Reply With Quote #3

http://forums.alliedmods.net/showthread.php?t=7986
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
Damocles
Member
Join Date: Jan 2005
Old 01-27-2005 , 06:38  
Reply With Quote #4

ta for that BlueRaja

Ive taken a look at the code but where does the code distinguish between an entered players name and steamid

I followed the code down to this bit

Code:
else { //szVictim is a single player         iPlayersTemp[0] = cmd_target(id,szVictim, Flags&(MUST_BE_ALIVE|CANT_BE_BOT))         //^^Will handle OBEY_IMMUNITY and ALLOW_SELF later on         iPlayersNumTemp = (iPlayersTemp[0]?1:0)            //Only set iPlayersNumTemp to 1 if cmd_target was successful        }

so will cmd_target find a player based on their name OR steamid ??

The doc for cmd_target isnt the greatest work of literary art :/

Quote:
cmd_target - Locates a player id by specific parameters.

Syntax:
cmd_target ( id, const arg[], flags = 1 )
does that mean arg[] can be a steamid or a player name (i notice your code doesnt seem to allow for part of a name to be entered...or am i reading the code wrong - sorry if i am)

Ive only just started looking at small so im piecing things together

Thanks for any reply
Damocles is offline
Damocles
Member
Join Date: Jan 2005
Old 02-03-2005 , 16:07  
Reply With Quote #5

ok this is getting to me now.

Im using cmd_target in my code and it does find players....but not all the time. I play using this handle.. -=F.L.1=- Damocles. When i try and execute a command on myself, typing the command and any of the following doesnt work:

cmd damo
cmd Damocles
cmd ocles

It just keeps telling me it cant find the player ???

is cmd_target the best code to use...because as far as i can tell, it doesnt work right...or at least aswell as find_player does with some arguements telling it to match substrings.
Damocles is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-03-2005 , 19:12  
Reply With Quote #6

Is the most recent snip of code you've posted the current? Anyway, read the entire documentation:

Quote:
cmd_target - Locates a player id by specific parameters.

Syntax:
cmd_target ( id, const arg[], flags = 1 )

Type:
Stock

Notes:
id is the player who called the command.
arg is the argument the player input.

Flags:
1 - obey immunity
2 - allow yourself
4 - must be alive
8 - can't be bot
I'm not sure if the bitwise operator works with integers, if they are different from (1<<X) values. Try setting your flags parameter as 12.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Reply


Thread Tools
Display Modes

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 19:29.


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