25.01.2014, 11:01
The only way this would be possible with strfind is if you had a text file that contained the names of every single player that has registered to your server.
Should work.
pawn Код:
//OnPlayerRegister
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new str[30];
format(str, sizeof(str), "%s\r\n", name);
new File:text = fopen("Players.txt", io_append);
fwrite(text, str);
fclose(text);
//Continue..
//Example with ZCMD of how you would use it:
CMD:findplayer(playerid, params[])
{
if(!strlen(params) || strlen(params) > MAX_PLAYER_NAME) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /findplayer [part of name]");
new count = 0, File:text = fopen("Players.txt", io_read), string[50];
format(string, sizeof(string), "Player Names Containing '%s'", params);
SendClientMessage(playerid, 0x00FF00FF, string);
while(fread(text, string))
{
if(strfind(string, params, true) != -1)
{
SendClientMessage(playerid, 0xFFFF00FF, string);
count++;
}
}
if(count == 0) return SendClientMessage(playerid, 0xFF0000FF, "No matches found.");
return 1;
}