Reading from file not working properly
#1

I really don't know what i'm doing wrong. Can anyone help me please? Thanks!

pawn Код:
new File:hFile=fopen("ler.txt",io_read);
        new l;
        while(fread(hFile,string))
        {
            l++;
            if(l==1)
            {
                //format(string,sizeof(string),"%s",string);
                SendClientMessage(playerid,amarelo,string);
            }
            else
            {
                //format(string,sizeof(string),"%s",string);
                SendClientMessage(playerid,azul,string);
            }
            fclose(hFile);
        }
Reply
#2

right hmmm what's the problem?
Reply
#3

Yeah, sorry about that.

The problem is. I'm using a command for reading the file, so when i execute the command it only shows the first line on the chat.

Eg: file.txt contains words in this format:

file.txt:
Word
Word2
Word3

On the chat it only 'prints' the word 'Word'.
Reply
#4

That's because you close the file right after the first line read, move fclose out of the loop
Reply
#5

Quote:
Originally Posted by Zeex
That's because you close the file right after the first line read, move fclose out of the loop
Oh man, thank you so much! God bless you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)