AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get a name from an id (https://forums.alliedmods.net/showthread.php?t=46007)

Martin1 10-16-2006 14:14

How to get a name from an id
 
If you have already specified a steam id in the plugin, is there anyway you can tell it to find if there is someone in the server with the id and to get the name of the person.

Rolnaaba 10-16-2006 14:19

Re: How to get a name from an id
 
Code:

/* Returns player name. */
native get_user_name(index,name[],len);

amxmodx.inc file

Silencer123 10-16-2006 14:31

Re: How to get a name from an id
 
I think he is talking about the Steam ID? *confused*
Code:
new authid[35] get_user_authid(id,authid,34) new name[32] get_user_name(id,name,31) if(equal(name,"This Name") && equal(authid,"STEAM_0:1:23456789")) {     // Name is "This Name" and Steam ID is "STEAM_0:1:23456789" }

organizedKaoS 10-16-2006 15:03

Re: How to get a name from an id
 
Quote:

Originally Posted by Silencer123 (Post 391815)
I think he is talking about the Steam ID? *confused*
Code:
new authid[35] get_user_authid(id,authid,34) new name[32] get_user_name(id,name,31) if(equal(name,"This Name") && equal(authid,"STEAM_0:1:23456789")) {     // Name is "This Name" and Steam ID is "STEAM_0:1:23456789" }

Yes and no.

equal is usually case sensitive. Using equal to compare a name with a defined name will return false unless the defined is spelled exactly the same as the used name.

This whole thing
Code:
if(equal(name,"This Name") && equal(authid,"STEAM_0:1:23456789"))
will return false if "This Name" doesn't match the name the player is using regardless if the players steamid matches the plugins defined steamid.

Assuming you are correctly retrieving a players steamid, ie. in putinserver, it should look like this:
Code:
new authid[32], name[32] get_user_authid(id,authid,31) get_user_name(id,name,31) if(equal(authid, defined_authid)) // checks if players authid matches defined authid, if it matches proceed.      {      //since we have found the player whose steamid matches the plugins defined steamid, we execute whatever code we want, in this case a client print of the name the person is using.      client_print(id, print_chat, "Hello %s: Your SteamID matches the plugins SteamID", name) }

Martin1 10-16-2006 15:32

Re: How to get a name from an id
 
I am making a sort of plugin like admin check, in which clients can check if the main admin is in the server. When clients say /adminz it checks if the id of the admin is in the server, and then finds the name of the admin

Silencer123 10-16-2006 15:36

Re: How to get a name from an id
 
Good, if you are smart enough you can change the above Code a bit to make it work that way.
;)


All times are GMT -4. The time now is 04:58.

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