Reading lines from file - 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 lines from file (
/showthread.php?tid=144262)
Reading lines from file -
potato - 26.04.2010
Hi!
I have a quite large file with text, each text line is devided by \n or simply enter.
How can I read a random line from the file?
Re: Reading lines from file -
dice7 - 26.04.2010
Read the file with fread() n-times, so you move the pointer down
pawn Code:
new
rand = random(20),
i = 0;
while (i < rand)
{
fread(file, string);
i++;
}