Reading Files
#1

So basicly I am trying to make a system where people can become friends and they will always be friends even when they log off and come back on.

What I see is the issue is that I do not understand how to do this type of thing.
So basicly what I have done is have it search a file for the player to see how many friends the player has.
Then I do another search for another file for the player to collect the data and store all the players friends in an array.
But I don't know how to do this.
The names save as: Deduction|TestUser|So_On|AndSo_On|

This is my current script to load the players, yes it might look wrong but I have no idea how to do it.

pawn Код:
stock LoadUserConnection(playerid)
{
    new string[128], string2[128], name[100];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, '_', ' ');
    format(string, sizeof(string), "/Users/%s.ini", name);
    format(string2, sizeof(string2), "/Users/%s#.ini", name);
    new File: file2 = fopen(string2, io_read);
    if (file2)
    {
            fread(file2, friendly[playerid]);
    }
    else
    {
        print("File Writing Error!");
        SendClientMessage(playerid, COLOR_RED, "File: Error Found!");
    }
    fclose(file2);
    new File: file = fopen(string, io_read);
    new c = friendly[playerid];
    if (file)
    {
            fread(file, string);
            new tmp[c][100];
            explode(tmp, string, "|");
            for(new i = 0; i < c; i ++)
            {
                PlayerInfo[playerid][pFriend][i] = tmp[i];
                print(tmp[i]);
            }
    }
    else
    {
        print("File Writing Error!");
        SendClientMessage(playerid, COLOR_RED, "File: Error Found!");
    }
    fclose(file);
    return 1;
}
Please help me..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)