Timestamp and Question about 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)
+--- Thread: Timestamp and Question about files (
/showthread.php?tid=494227)
Timestamp and Question about files -
shaPP - 12.02.2014
Hello there, i have two questions:
Firstly i made a ban system based on unix timestamp and i need a code to convert unix to date ex: from 1392210805 to 02/12/2014 - 13:13:13. I tryed this include but it seems to be a bit buggy, posted error got with it on it's topic:
https://sampforum.blast.hk/showthread.php?tid=347605
Second i want to know if there is a way to read a file from end to begin.
Re: Timestamp and Question about files -
Vince - 12.02.2014
It might just be easier to invoke PHP's date() or MySQL's FROM_UNIXTIME(), though both require callbacks.
Re: Timestamp and Question about files -
shaPP - 12.02.2014
But u can give me the code in pawn format?
Re: Timestamp and Question about files -
MP2 - 12.02.2014
You'd have to use HTTP() and host the php script on a web server.
As for reading a file, fread() reads one line at a time. It returns true/1 when there is a line to read, so you can use a while() loop like so:
pawn Код:
new File:fileHandle = fopen("file.txt", io_read);
if(fileHandle) // If opened sucessfully
{
new dest[256];
new lineCount;
while(fread(fileHandle, dest))
{
print(dest); // Print out that line
lineCount ++;
}
printf("File has %i lines.", lineCount);
}
That will print the entire file to the console (as an example).
Re: Timestamp and Question about files -
shaPP - 12.02.2014
I thoguth is there any option to read from the end without reading whole text because i talk about big files. Anyway, thanks.