#1

Hi!

I need help with "Fread" files function.

First of all I'll show You what I've got here:

pawn Код:
// OnPlayerCommandText

// Command: "/NameSearch"
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Name Search", "Enter the account name You wanted to see if exists or not, here:", "Search", "Cancel");

// OnDialogResponse

    // Name Search
    if(dialogid == 1 && response == 1)
    {
 
    new File:players= fopen("Players.txt", io_read);
    while(fread(players, inputtext))
    {
          /*
          I've tried everything, also ******d it billion times and nothing.
          I just need a code here which is going to say if the searched name is registered (exists) or not.
          */

    }
    fclose(players);

    }
The main scripter of the server is not able to help me now, and I really need this as soon as possible, please!
Please, anybody?
Reply
#2

I'll give you my view on this, typically with an INI system you save the player data to file such as, [uL]Pottus.ini so really you only have to do if(fexists("filepath/[uL]Pottus.ini")) instead of what your trying to do. But I would recommend using SQLite instead of an INI system.

@Seif- Bad idea dude, your putting a bandaid on a fundamental design flaw which is worse than his first mistake.
Reply
#3

What you need is strfind. strfind will search through a string for what you want. fread will read the file and requires a string object so it can extract line by line what it's reading.
pawn Код:
new string[MAX_PLAYER_NAME]; // If your file has each registered name in 1 line instead of having 1 per line, then change this.
    new File:players= fopen("Players.txt", io_read);
    while(fread(players, string))
    {
        if (strfind(string, inputtext, true) != -1)
        {
            // Found it
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)