HOW TO DO a special printf?
#1

Hi scripters,

I need to create a function that executes the same function of the printf,
but that besides writing in console and server_log.txt also writes in a file in the scriptfiles...

I want register all in this file in the scriptfiles
format strings and substitute printf for print for each printf that I have in my gamemode will be very hard
with this function I would simply substitute the functions printf for this new function using a CTRL+H

Thanks for replys! :P

Reply
#2

Why did you make two topics...

Edit:It just got deleted.
Reply
#3

sorry,
it was a mistake in my broswer
Reply
#4

So you want to store all your printf's into your scriptfiles folder?
Reply
#5

Yes, basically I need a new printf that has an additional function: writing in a logfile in the scriptfiles...
Reply
#6

Soemthing like that (edit if needed..)
pawn Код:
new
  File:logfile,
  logstring[128]
;

#define logprint(%0); \
{\
  format(logstring,sizeof logstring,%0);\
  print(logstring);\
  logfile=fopen("logfile.log",io_append);\
  fwrite(logfile,logstring);\
  fwrite(logfile,"\r\n");\
  fclose(logfile);\
}
pawn Код:
logprint("%s = %d", "0rb", 1337);
Reply
#7

isn't there a server log for that
Reply
#8

Thanks Orb!

I also found other way of doing that, based on SendFormatMessage by ******:

pawn Код:
#define lprintf(%1,%2) do{new sendfstring[128];format(sendfstring,128,(%1),%2);lprint(sendfstring);}while(FALSE)

stock lprint(const str[])
{
    print(str);
    new hour,minute,second;
    new str2[255],File:log=fopen("Log.txt",io_append);
    gettime(hour,minute,second);
    format(str2,sizeof(str2),"[%d:%d:%d] [PRINT] %s\r\n",hour,minute,second,str);
    fwrite(log,str2);
    fclose(log);
}
The effect is the same, but I don't know which is the best...

Anyway, thanks for reply.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)