Raised This Month: $ Target: $400
 0% 

How to get a name from an id


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Martin1
BANNED
Join Date: May 2006
Old 10-16-2006 , 14:14   How to get a name from an id
Reply With Quote #1

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.
Martin1 is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 10-16-2006 , 14:19   Re: How to get a name from an id
Reply With Quote #2

Code:
/* Returns player name. */
native get_user_name(index,name[],len);
amxmodx.inc file
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-16-2006 , 14:31   Re: How to get a name from an id
Reply With Quote #3

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" }
__________________
EAT YOUR VEGGIES
Silencer123 is offline
organizedKaoS
Senior Member
Join Date: Feb 2006
Old 10-16-2006 , 15:03   Re: How to get a name from an id
Reply With Quote #4

Quote:
Originally Posted by Silencer123 View Post
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) }
organizedKaoS is offline
Martin1
BANNED
Join Date: May 2006
Old 10-16-2006 , 15:32   Re: How to get a name from an id
Reply With Quote #5

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
Martin1 is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-16-2006 , 15:36   Re: How to get a name from an id
Reply With Quote #6

Good, if you are smart enough you can change the above Code a bit to make it work that way.
;)
__________________
EAT YOUR VEGGIES
Silencer123 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 04:58.


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