SA-MP Forums Archive
Saving logs fastly - 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: Saving logs fastly (/showthread.php?tid=429935)



Saving logs fastly - Saw® - 11.04.2013

Hey ,the question is not 'how to save logs?' but what's the best way to save them instead of adding new Day,Month.... then save the time + log, every Ideas ? I heard about creating a stock that can be called everytime we want, is it 100% accurate ? thanks.


Re: Saving logs fastly - park4bmx - 11.04.2013

Creating a stock will require a timer.
Running the server under windows the timers will not be accurate as they will have some offset.
Otherwise in Linux the timer will highly acurate because of the kernel!


Re: Saving logs fastly - zDivine - 11.04.2013

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
Creating a stock will require a timer.
Running the server under windows the timers will not be accurate as they will have some offset.
Otherwise in Linux the timer will highly acurate because of the kernel!
No, creating a stock will not require a timer. I don't know what you're talking about...

Anyways, you can make a stock, such as

Код:
Log(sz_fileName[], sz_input[]) {

	new
	sz_logEntry[156],
	i_dateTime[2][3],
	File: fileHandle = fopen(sz_fileName, io_append);

	gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
	getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);

	format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
	fwrite(fileHandle, sz_logEntry);
	return fclose(fileHandle);
}
Then use:

Код:
new log[256];
format(log, sizeof(log), "Message here.");
Log("logs/test.log", log);
* This was taken from another script, as I didn't feel like writing this up myself when I could just get it form this. Hope this helps.


Re: Saving logs fastly - Saw® - 11.04.2013

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
Creating a stock will require a timer.
Running the server under windows the timers will not be accurate as they will have some offset.
Otherwise in Linux the timer will highly acurate because of the kernel!
So I have to use the manual way...using a stock will not make it more accurate.


Re: Saving logs fastly - zDivine - 11.04.2013

Quote:
Originally Posted by Saw®
Посмотреть сообщение
So I have to use the manual way...using a stock will not make it more accurate.
Check my reply, this should help you.


Re: Saving logs fastly - park4bmx - 11.04.2013

That's not a stock !

pawn Код:
stock MyFunction(VAR)
{
if(VAR == 3) return true;
return false;
}
That is,
And he was talking about time and date which I though he is checking with gettime instead of a timer


Re: Saving logs fastly - Saw® - 11.04.2013

Quote:
Originally Posted by zDivine
Посмотреть сообщение
No, creating a stock will not require a timer. I don't know what you're talking about...

Anyways, you can make a stock, such as

Код:
Log(sz_fileName[], sz_input[]) {

	new
	sz_logEntry[156],
	i_dateTime[2][3],
	File: fileHandle = fopen(sz_fileName, io_append);

	gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
	getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);

	format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
	fwrite(fileHandle, sz_logEntry);
	return fclose(fileHandle);
}
Then use:

Код:
new log[256];
format(log, sizeof(log), "Message here.");
Log("logs/test.log", log);
* This was taken from another script, as I didn't feel like writing this up myself when I could just get it form this. Hope this helps.
Nice one , but still have one question : the [256] is the Length of the string(format) or all the file (log)? cuz we don't know fo example if the Bans log will be only 256.

thanks.

NB : use [ PAWN] [/ PAWN] .


Re: Saving logs fastly - zDivine - 11.04.2013

Quote:
Originally Posted by Saw®
Посмотреть сообщение
Nice one , but still have one question : the [256] is the Length of the string(format) or all the file (log)? cuz we don't know fo example if the Bans log will be only 256.

thanks.

NB : use [ PAWN] [/ PAWN] .
The [256] is the length of the log string. Not the entire file.


Re: Saving logs fastly - park4bmx - 11.04.2013

Quote:
Originally Posted by zDivine
Посмотреть сообщение
Actually, it's "stock", not "Stock". Lol.
Not easy on a ipad
Currents everything.


Re: Saving logs fastly - Saw® - 11.04.2013

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
Not easy on a ipad
Currents everything.
Yep

Quote:
Originally Posted by zDivine
Посмотреть сообщение
The [256] is the length of the log string. Not the entire file.
Nice thanks.


thank you park4bmx & zDivine for your help