Player Search - 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: Player Search (
/showthread.php?tid=591836)
Player Search -
SpriTe - 17.10.2015
Hello, I have a question, how can a player search system only on certain characters of the name.
Ex: My name on server is TestPlayer and i use command only certain characters /command player, but on server is
two players with name Test1Player and Test2Player when I use the /command player, I get a message on server is two player with this characters. I use sscanf.
Image:
http://s27.postimg.org/dd0lgtxkz/sa_mp_075.png, I use /id Mihai and show my all player with containing those characters.
When the number of players is less than 10 to show a message like:
http://s10.postimg.org/nu9u1jpqh/sa_mp_075.png
Re: Player Search -
ATGOggy - 17.10.2015
PHP код:
CMD:command(playerid, params[])
{
new name[MAX_PLAYER_NAME], bool:check, string[128];
if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, 0, "Usage: /command [name]");
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
if(!strcmp(name, pName, true))
{
check=true;
format(string, sizeof(string), "ID:%d, Name:%s.", i, pName);
SendClientMessage(playerid, 0, string);
}
}
}
if(!check) return SendClientMessage(playerid, 0, "There are no players playing with this name.");
return 1;
}