Retrieving one line from a player file.
#1

Hello,

I have a player file created with Y_INI, however I only want to load one line from this file. The way I want to do this is with native SAMP File Functions (Found here: https://sampwiki.blast.hk/wiki/File_Functions), however I cannot make head or tail of it.

The line I want to retrieve is: "IP = ***.***.***.***"

I do not want to parse the whole file as the player isn't going to be actively online for this function, however I also don't want to use Y_INI to parse one line of information.

I have tried attempting this myself:
pawn Код:
new File:PlayerIP = fopen(LuckyGuy, io_read);
    new string[15 + 5];
    while(fread(PlayerIP, string))
    {
        if(strcmp(string, "IP = ", true)==0)
        {
            strmid(string, string, 5, 20, 15);
        }
    }

    format(LuckyGuy, sizeof(LuckyGuy), Ban_Path, string);
    if(fremove(LuckyGuy)) return SendClientMessage(playerid, COLOR_RED, "|-- Error: Account Deletion Failed!");
As you can see here I am trying to delete a ban file using the IP from within "LuckyGuys" file, which I have set this to the correct path.

pawn Код:
format(LuckyGuy, sizeof(LuckyGuy), PATH, LuckyGuy);
This is shown here by the inital LuckyGuy result back from sccanf is being formatted into string.
Reply


Messages In This Thread
Retrieving one line from a player file. - by Binx - 18.08.2013, 01:33
Re: Retrieving one line from a player file. - by Binx - 18.08.2013, 15:04
Re: Retrieving one line from a player file. - by Jefff - 18.08.2013, 18:02
Re: Retrieving one line from a player file. - by Binx - 18.08.2013, 18:17
Re: Retrieving one line from a player file. - by Jefff - 18.08.2013, 18:23
Re: Retrieving one line from a player file. - by Binx - 18.08.2013, 18:56
Re: Retrieving one line from a player file. - by avivelkayam - 18.08.2013, 19:04
Re: Retrieving one line from a player file. - by Ada32 - 18.08.2013, 19:19

Forum Jump:


Users browsing this thread: 1 Guest(s)