Serach users from ini files
#8

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.

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;
}
Should work.
Reply


Messages In This Thread
Serach users from ini files - by GuyYahood1 - 25.01.2014, 10:41
Re : Serach users from ini files - by MCZOFT - 25.01.2014, 10:45
Re: Serach users from ini files - by GuyYahood1 - 25.01.2014, 10:47
Re : Serach users from ini files - by MCZOFT - 25.01.2014, 10:51
Re: Serach users from ini files - by Threshold - 25.01.2014, 10:53
Re: Serach users from ini files - by Shetch - 25.01.2014, 10:53
Re: Serach users from ini files - by GuyYahood1 - 25.01.2014, 10:58
Re: Serach users from ini files - by Threshold - 25.01.2014, 11:01
Re: Serach users from ini files - by GuyYahood1 - 25.01.2014, 11:04

Forum Jump:


Users browsing this thread: 1 Guest(s)