sscanf playername - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf playername (
/showthread.php?tid=615619)
sscanf playername -
MerryDeer - 24.08.2016
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
Re: sscanf playername -
Shinja - 24.08.2016
PHP код:
sscanf(playername, "r", playerid);
Re: sscanf playername -
MerryDeer - 24.08.2016
But it's bad for names, you have always write first part of name
Re: sscanf playername -
Stinged - 24.08.2016
I once gave you the solution on a topic you created.
http://forum.sa-mp.com/showpost.php?...15&postcount=5
Re: sscanf playername -
MerryDeer - 24.08.2016
Oh i remember but this by not work using id..
Re: sscanf playername -
Stinged - 24.08.2016
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.
Re: sscanf playername -
MerryDeer - 24.08.2016
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);
}
Re: sscanf playername -
Stinged - 24.08.2016
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.
Re: sscanf playername -
SickAttack - 24.08.2016
Use "r" or "u" with sscanf, it's is good for player names.
Re: sscanf playername -
Shinja - 24.08.2016
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