AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   find_player SteamID||Name (https://forums.alliedmods.net/showthread.php?t=9655)

Damocles 01-26-2005 11:10

find_player SteamID||Name
 
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.

Twilight Suzuka 01-26-2005 15:22

theres a stock in the AMXMISC include for this called cmd_target

BlueRaja 01-26-2005 18:14

http://forums.alliedmods.net/showthread.php?t=7986

Damocles 01-27-2005 06:38

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 02-03-2005 16:07

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.

XxAvalanchexX 02-03-2005 19:12

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.


All times are GMT -4. The time now is 19:29.

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