Timestamp and Question about files
#1

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

It might just be easier to invoke PHP's date() or MySQL's FROM_UNIXTIME(), though both require callbacks.
Reply
#3

But u can give me the code in pawn format?
Reply
#4

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).
Reply
#5

I thoguth is there any option to read from the end without reading whole text because i talk about big files. Anyway, thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)