11.04.2012, 16:58
pawn Код:
CmdLog(text[], bool:write = false) {
static cmdLogData[200][384];
new time[6];
if (strlen(text)) {
for (new i; i < sizeof(cmdLogData); i++) {
if (cmdLogData[i][0] == EOS) {
getdate( time[0], time[1], time[2]);
gettime( time[3], time[4], time[5]);
format(cmdLogData[i], 384, "[%d.%02d.%02d - %02d:%02d:%02d] %s\n", time[0], time[1], time[2], time[3], time[4], time[5], text);
break;
}
}
}
if (write || strlen(cmdLogData[sizeof(cmdLogData) - 1])) {
new fileName[64];
getdate( time[0], time[1], time[2]);
gettime( time[3], time[4], time[5]);
format(fileName, 64, LOGDIR"[%d.%02d.%02d %02d-%02d-%02d] Log.txt", time[0], time[1], time[2], time[3], time[4], time[5]);
new File:file = fopen(fileName, io_write);
for (new i; i < sizeof(cmdLogData); i++) {
for( new j, len = strlen(cmdLogData[i]); j < len; j++) fputchar(file, cmdLogData[i][j], false);
cmdLogData[i][0] = EOS;
}
fclose(file);
}
return 1;
}