Advertisement
RanAway

[ Pawn - utility ] logger

Oct 8th, 2024 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.87 KB | None | 0 0
  1. //---------------------------------------- Description -----------------------------------------//
  2. /*  This mod is designed to log in-game messages and actions into separate log files,           */
  3. /*  providing a detailed breakdown of specific events such as "TextMsg", "SendAudio",           */
  4. /*  "StatusIcon", "HudTextArgs", and "DeathMsg". Each message is recorded in its own            */
  5. /*  log file to ensure easy tracking and reviewing of different types of game events.           */
  6. /*                                                                                              */
  7. /*  Key Features:                                                                               */
  8. /*  - Automatically creates and organizes log files into a dedicated folder.                    */
  9. /*  - Captures specific in-game messages and actions like death messages and text prompts.      */
  10. /*  - Prevents duplicate logging by checking if a message has already been logged.              */
  11. /*                                                                                              */
  12. /*  This script ensures that relevant game events are tracked efficiently for future analysis.  */
  13. /*  It is a practical tool for admins and developers looking to monitor or analyze game logs.   */
  14.  
  15. //-------------------- Includes --------------------//
  16. #include < amxmodx >
  17.  
  18. //-------------------- Functions --------------------//
  19. new TextMsgLog[ 128 ], SendAudioLog[ 128 ], StatusIconLog[ 128 ], HudTextArgsLog[ 128 ], DeathMsgLog[ 128 ]
  20.  
  21. //-------------------- Plugin init --------------------//
  22. public plugin_init()
  23. {
  24.     register_plugin( "Logger list", "v1.0", "RanAway`" )
  25.  
  26.     //-------------------- Logs folder --------------------//
  27.     new logfile[ 128 ]
  28.     get_localinfo( "amxx_logs", logfile, charsmax( logfile ) )
  29.     formatex( logfile, charsmax( logfile ), "%s/loglist", logfile )
  30.  
  31.     //-------------------- Logs folder maker --------------------//
  32.     if( !dir_exists( logfile ) ) mkdir( logfile )
  33.  
  34.     //-------------------- Logs --------------------//
  35.     formatex( TextMsgLog, charsmax( TextMsgLog ), "%s/TextMsg.log", logfile )
  36.     formatex( DeathMsgLog, charsmax( DeathMsgLog ), "%s/DeathMsg.log", logfile )
  37.     formatex( SendAudioLog, charsmax( SendAudioLog ), "%s/SendAudio.log", logfile )
  38.     formatex( StatusIconLog, charsmax( StatusIconLog ), "%s/StatusIcon.log", logfile )
  39.     formatex( HudTextArgsLog, charsmax( HudTextArgsLog ), "%s/HudTextArgs.log", logfile )
  40.     //-------------------- Messages --------------------//
  41.     register_message( get_user_msgid( "TextMsg" ), "LogToFile" )
  42.     register_message( get_user_msgid( "DeathMsg" ), "LogToFile" )
  43.     register_message( get_user_msgid( "SendAudio" ), "LogToFile" )
  44.     register_message( get_user_msgid( "StatusIcon" ), "LogToFile" )
  45.     register_message( get_user_msgid( "HudTextArgs" ), "LogToFile" )
  46. }
  47.  
  48. //-------------------- Logs --------------------//
  49. public LogToFile( msgid )
  50. {
  51.     new logmsg[ 64 ], Line[ 255 ], checkmsg[ 255 ], File
  52.     //-------------------- TextMsg --------------------//
  53.     if( msgid == 77 ) File = fopen( TextMsgLog, "a+" ), get_msg_arg_string( 2, logmsg, charsmax( logmsg ) )
  54.     //-------------------- DeathMsg --------------------//
  55.     if( msgid == 83 ) File = fopen( DeathMsgLog, "a+" ), get_msg_arg_string( 4, logmsg, charsmax( logmsg ) )
  56.     //-------------------- SendAudio --------------------//
  57.     if( msgid == 100 ) File = fopen( SendAudioLog, "a+" ), get_msg_arg_string( 2, logmsg, charsmax( logmsg ) )
  58.     //-------------------- StatusIcon --------------------//
  59.     if( msgid == 107 ) File = fopen( StatusIconLog, "a+" ), get_msg_arg_string( 2, logmsg, charsmax( logmsg ) )
  60.     //-------------------- HudTextArgs --------------------//
  61.     if( msgid == 145 ) File = fopen( HudTextArgsLog, "a+" ), get_msg_arg_string( 1, logmsg, charsmax( logmsg ) )
  62.     //-------------------- Check if already print --------------------//
  63.     while( !feof( File ) )
  64.     {
  65.         fgets( File, Line, charsmax( Line ) )
  66.         trim( Line )
  67.         parse( Line, checkmsg, charsmax( checkmsg ) )
  68.  
  69.         if( equali( Line, logmsg ) )
  70.         {
  71.             fclose( File )
  72.             return
  73.         }
  74.     }
  75.     //-------------------- print --------------------//
  76.     fprintf( File, "%s^n", logmsg )
  77.     fclose( File )
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement