[HELP] Read files
#1

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
Reply
#2

Oh.. cmon guys.. you know that -
Reply
#3

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
Reply
#4

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;
    }
Reply
#5

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
Reply
#6

but add this when you are done reading:

pawn Код:
fclose(mF);
Reply
#7

^^ tnhx guys
Reply
#8

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

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

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
Reply
#10

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;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)