sscanf playername
#1

Hi,

Код:
SSCANF:playername(string[])
{
	new
		name[MAX_PLAYER_NAME];
	foreach (new playerid : Player)
	{
		GetPlayerName(playerid, name, sizeof (name));
		//if (!strcmp(name, string, true)) // Exact match.
		if (strfind(name, string, true) != -1) // Far less accurate.
		{
			return playerid;
		}
	}
	return INVALID_PLAYER_ID;
}
If want if string is number then no search by name, instantly retunr that number if player connected
Reply
#2

PHP код:
sscanf(playername"r"playerid); 
Reply
#3

But it's bad for names, you have always write first part of name
Reply
#4

I once gave you the solution on a topic you created.
http://forum.sa-mp.com/showpost.php?...15&postcount=5
Reply
#5

Oh i remember but this by not work using id..
Reply
#6

Quote:
Originally Posted by MerryDeer
Посмотреть сообщение
Oh i remember but this by not work using id..
Are you sure you're actually using mine? Because it does check if it's a integer.
Reply
#7

Yes i use, but i think another way but i don't know it's right

I check if that string is numeric

IsNumeric(string)
(
if( IsPlayerConnected(strval(string))
{
return strval(string);
}
Reply
#8

I already do that (But with sscanf, which is faster)

Anyway, wait about 2 minutes, I'll go and test it out.
I'll edit this reply when I do.
Reply
#9

Use "r" or "u" with sscanf, it's is good for player names.
Reply
#10

Quote:
Originally Posted by Shinja
Посмотреть сообщение
PHP код:
sscanf(playername"r"playerid); 
Indeed i already told him about "r", i don't know what he want to do
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)