SA-MP Forums Archive
[HELP] Read 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Read files (/showthread.php?tid=88784)



[HELP] Read files - jonybomb - 28.07.2009

I was reading the tuturial from wiki: https://sampwiki.blast.hk/wiki/File_Functions

and I want to learn how to do 1 command to read any file, but the tuturial is a little confused, someone can help me or show other tuturial more enlightening?

tnhx


Re: [HELP] Read files - jonybomb - 30.07.2009

Oh.. cmon guys.. you know that -


Re: [HELP] Read files - James_Alex - 30.07.2009

fread(the file, the value);
example
pawn Код:
new File:mF;
mF = fopen("thefile.txt", io_read);
new str[100];
while(fread(mF, str))
{
// bla bla...
}
now the str got the file value

and plz next time do not double post
wait unitil someone answer u


Re: [HELP] Read files - jonybomb - 30.07.2009

Like that?

pawn Код:
if (strcmp("/chuvaole", cmdtext, true, 10) == 0)
{
new File:mF;
mF = fopen("thefile.txt", io_read);
new str[100];
while(fread(mF, str))
{
// bla bla...
}
        return 1;
    }



Re: [HELP] Read files - James_Alex - 30.07.2009

Quote:
Originally Posted by jonybomb
Like that?

pawn Код:
if (strcmp("/chuvaole", cmdtext, true, 10) == 0)
{
new File:mF;
mF = fopen("thefile.txt", io_read);
new str[100];
while(fread(mF, str))
{
// bla bla...
}
        return 1;
    }
yes


Re: [HELP] Read files - MadeMan - 30.07.2009

but add this when you are done reading:

pawn Код:
fclose(mF);



Re: [HELP] Read files - jonybomb - 30.07.2009

^^ tnhx guys


Re: [HELP] Read files - James_Alex - 30.07.2009

Quote:
Originally Posted by MadeMan
but add this when you are done reading:

pawn Код:
fclose(mF);
ah really sorry
i missed that
thx


Re: [HELP] Read files - jonybomb - 30.07.2009

Hey, what is wrong?

pawn Код:
if (strcmp("/news", cmdtext, true, 10) == 0)
    {
        new File:mF;
        mF = fopen("news.txt", io_read);
        new str[100];
        while(fread(mF, str))
        {
            // bla bla...
        }
        fclose(mF);
        return 1;
    }
i have the file in scriptfiles, i do /news and nothing happens


Re: [HELP] Read files - arnutisz - 30.07.2009

Because you have to insert code:
pawn Код:
if (strcmp("/news", cmdtext, true, 10) == 0)
    {
        new File:mF;
        mF = fopen("news.txt", io_read);
        new str[100];
        while(fread(mF, str))
        {
            // Insert code in here
        }
        fclose(mF);
        return 1;
    }