SA-MP Forums Archive
Reading Files - 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: Reading Files (/showthread.php?tid=480698)



Storing File Data in Array - Deduction - 12.12.2013

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..