Reading from file not working properly - 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: Reading from file not working properly (
/showthread.php?tid=149160)
Reading from file not working properly -
russo666 - 20.05.2010
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);
}
Re: Reading from file not working properly -
pmk1 - 20.05.2010
right hmmm what's the problem?
Re: Reading from file not working properly -
russo666 - 20.05.2010
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'.
Re: Reading from file not working properly - Zeex - 21.05.2010
That's because you close the file right after the first line read, move fclose out of the loop
Re: Reading from file not working properly -
russo666 - 21.05.2010
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!