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

Get user ID If I have the name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghostdlr
Senior Member
Join Date: Aug 2010
Old 12-02-2012 , 17:21   Get user ID If I have the name
Reply With Quote #1

I have the player name and I need to get his ID so I can kick him with a custom reason .

server_cmd("kick #%d ^"%s^"", ....)

What function should I use?

Last edited by ghostdlr; 12-02-2012 at 17:25.
ghostdlr is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 12-02-2012 , 17:50   Re: Get user ID If I have the name
Reply With Quote #2

PHP Code:
#include <amxmodx>

stock kick_user(szName[], szReason[])
{
    new 
id get_user_index(szName)
    
    
// Player Not found
    
if(!id)    return 0
    
    
new iUserId get_user_userid(id)
    
    
server_cmd("kick #%d ^"%s^""iUserIdszReason)
    return 
1

__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-02-2012 , 20:32   Re: Get user ID If I have the name
Reply With Quote #3

Code:
server_cmd("kick ^"%s^" ^"%s^"", name, ...);
hleV is offline
xDrugz
Senior Member
Join Date: Jul 2011
Location: return 4;
Old 12-03-2012 , 04:25   Re: Get user ID If I have the name
Reply With Quote #4

Code:
public function( index )
{
	new userid = get_user_userid( index );
	
	server_cmd( "kick #%i ^"Kicked By Server Administrator^"", userid );
}
xDrugz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2012 , 20:33   Re: Get user ID If I have the name
Reply With Quote #5

Quote:
Originally Posted by xDrugz View Post
Code:
public function( index )
{
	new userid = get_user_userid( index );
	
	server_cmd( "kick #%i ^"Kicked By Server Administrator^"", userid );
}
That is not what he asked for.
__________________
fysiks is offline
n0br41ner
Senior Member
Join Date: May 2012
Location: Planet Earth
Old 12-04-2012 , 12:59   Re: Get user ID If I have the name
Reply With Quote #6

If you are getting the name of the player from an admin command, then use:
Code:
cmd_target(id,const arg[],flags = CMDTARGET_OBEY_IMMUNITY);
If not, then i do not know how to help you

EDIT: never mind just use this

Code:
/* Find player.
* Flags:
* "a" - with given name.
* "b" - with given part of name.
* "c" - with given authid.
* "d" - with given ip.
* "e" - with given team name.
* "f" - don't look in dead players.
* "g" - don't look in alive players.
* "h" - skip bots.
* "i" - skip real players.
* "j" - return index of last found player. 
* "k" - with given userid.
* "l" - ignore case sensitivity. */
native find_player(const flags[], ... );
__________________

Last edited by n0br41ner; 12-04-2012 at 13:01.
n0br41ner is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-04-2012 , 19:32   Re: Get user ID If I have the name
Reply With Quote #7

Quote:
Originally Posted by n0br41ner View Post
If you are getting the name of the player from an admin command, then use:
Code:
cmd_target(id,const arg[],flags = CMDTARGET_OBEY_IMMUNITY);
If not, then i do not know how to help you

EDIT: never mind just use this

Code:
/* Find player.
* Flags:
* "a" - with given name.
* "b" - with given part of name.
* "c" - with given authid.
* "d" - with given ip.
* "e" - with given team name.
* "f" - don't look in dead players.
* "g" - don't look in alive players.
* "h" - skip bots.
* "i" - skip real players.
* "j" - return index of last found player. 
* "k" - with given userid.
* "l" - ignore case sensitivity. */
native find_player(const flags[], ... );
I recommend using cmd_target() is most all situations because it has things built into it that make life easier, especially for beginners.
__________________
fysiks 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 16:43.


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