[Include] rLogs | Server logs
#1

rLogs | Server Logs

Scripted by Rock

With this include you can save anything from your server in a log with just one line of code!
Base syntax of this functions is:
pawn Код:
WriteInLog( const Log_File[ ], Log_Com[ ], Log_Par[ ], va_args< > )
And yes, if you see "va_args< >" it uses y_va from ******.

Params:
  • Log_File[ ] - Name of the .log file // it can be .txt too
  • Log_Com[ ] - Your comment about the log, it could be anything
  • Log_Par[ ] - Text (Bla: %s, Bla2, %i...etc)
  • va_args< > - Arguments for %s, %i..etc

Another function that is implemented(I know, a big word for such a small script) is "DeleteLog" whitch says it all.
pawn Код:
DeleteLog( "NameOfLog.log" )
Example of WriteInLog:
pawn Код:
WriteInLog( "LogThis.log", "My Comment about this", "Name: %s, Money: %i, Health: %f", "Rock", 500, 100.00 );
In "LogThis.log" it will appear:
Код:
COMMENT: My Comment about this
(20/2/2013)[04:35:37] Name: Rock, Money: 500, Health: 100.000000
You will also have a test script inside the folder you will download(I hope you will)

Download:
Solidfiles - Direct Download

IMPORTANT:
If you want to use this you will need y_va which you can get from here.

If any bugs occur tell me and I will update as fast as I can.
Reply
#2

Ohh..I was working on a script like this..
Anyway, good job.
Reply
#3

Quote:
Originally Posted by rVar
Посмотреть сообщение
Ohh..I was working on a script like this..
Anyway, good job.
I didn't know, you can release your script too and see whose better
Reply
#4

Might be very useful for my server, good job will be testing it later.
Reply
#5

Nice.
For Beginers~!
Reply
#6

nice work. i might use this
Reply
#7

Meh, it wouldn't really take much effort to make a better one. But good for a newbies. =) GJ!
Reply
#8

I like this, especially the use of y_va, you could log all admin (any, actually) used commands with this !
Example of usage:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!IsPlayerAdmin(playerid)) return 1;
new player_name[24]; GetPlayerName(playerid, player_name, sizeof(player_name));
WriteInLog( "LogThis.log", "", "%s used %s !", player_name, cmdtext );
return 1;
}
Reply
#9

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
I like this, especially the use of y_va, you could log all admin (any, actually) used commands with this !
Example of usage:
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(!IsPlayerAdmin(playerid)) return 1;
new player_name[24]; GetPlayerName(playerid, player_name, sizeof(player_name));
WriteInLog( "LogThis.log", "", "%s used %s !", player_name, cmdtext );
return 1;
}
Yes, you could log anything you want.
I'm glad you find it useful and.

I think I should make "Comment" param optional.
Reply
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
You know you can just do "printf" and the text will be formatted and logged, right?
Honestly no.
If I do that what the file name will be?

With this you can set the file name and you can add a "Comment"
Look at the source code:
pawn Код:
#include <  a_samp  >
#include < YSI\y_va >

#if defined _ServerLogs_included
    #endinput
#endif

#define _ServerLogs_included

#define LogExist fexist

stock WriteInLog( const Log_File[ ], Log_Com[ ], Log_Par[ ], va_args< > )
{
    if( !LogExist( Log_File ) )
    {
        new
            File:File_Rk = fopen( Log_File, io_write )
        ;
        fclose( File_Rk );
    }
   
    new
        rGz_iSTRG[ 300 ],   rYear,      rHour,
        rQz_iSTRG[ 100 ],   rMonth,     rMinute,
        rYz_iSTRG[ 300 ],   rDay,       rSecond,
        rTz_iSTRG[ 300 ]
    ;
   
    va_format( rTz_iSTRG, sizeof( rTz_iSTRG ), Log_Par, va_start< 3 > );
   
    getdate( rYear, rMonth, rDay );
    gettime( rHour, rMinute, rSecond );
    format( rQz_iSTRG, 100,  "COMMENT: %s\r\n", Log_Com );
    format( rGz_iSTRG, 300, "(%d/%d/%d)[%02d:%02d:%d] %s\r\n\n", rDay, rMonth, rYear, rHour, rMinute , rSecond, rTz_iSTRG );
   
    strcat( rQz_iSTRG, rGz_iSTRG );
    strcat( rYz_iSTRG, rQz_iSTRG );
   
    new File:File_r = fopen( Log_File, io_append );
    fwrite( File_r, rYz_iSTRG );
    fclose( File_r );

    return 1;
}

stock DeleteLog( const Log_File[ ] )
{
    if( !LogExist( Log_File ) )
    {
        printf("This log doesn't exist.");
        return 0;
    }
    fremove( Log_File );

    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)