06.02.2017, 07:25
Quote:
|
Well....Here I'm once again....
To ask one of the another things.....I got in my mind while I was about to sleep....xD So it was that is there any way to save a player logs....I mean right now if a player use any command or do whatever it prints on "SERVER CONSOLE" so is there anyway possible to make those log appear in either a MySQL table or either something which would create a file or so which will save every log of that particular player?? |
Like this:
PHP код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
WriteLogs("AllTchat.txt", cmdtext, playerid); // saving every command like "/ufckingcuntasshole"
if(!success) ErrorMsg(playerid, _, "The command '%s' doesn't exist.", cmdtext);
else if(success)
WriteLogs("AllCommands.txt", cmdtext, playerid); // if the command is right, I save it in an another file
return 1;
}
PHP код:
public OnPlayerText(playerid, text[])
{
WriteLogs("AllTchat.txt", text, playerid);
...
PHP код:
WriteLogs(file[70], const reason[], playerid = INVALID_PLAYER_ID)
{
static day,
month,
hour,
minute,
seconde,
year;
new stringW[190];
if(strfind(file, ".txt", false, 0) == -1)
format(file, sizeof(file), "%s.txt", file);
new File:pos=fopen(file, io_append);
if(!pos)
{
printf("[Server] Write Logs Error | Reason : pos=fopen Error | File : '%s' | Reason: '%s'", file, reason);
SendMessageToAdmins(RED, "[Server] "SAUMON_U" An error occurred in the logs. Please check them!");
SendMessageToAdmins(RED, "[Server] "SAUMON_U"File : '%s' | Include : '%s'", file, reason);
return 1;
}
gettime(hour, minute, seconde);
getdate(year, month, day);
if(!strcmp(file, "AllCommands.txt"))
format(stringW,sizeof(stringW),"\r\n[%i] [%02i/%02i/%02i] %02i:%02i:%02i %s | '%s'", CmdID++, day, month, year, hour, minute, seconde, playerid != INVALID_PLAYER_ID ? GetName(playerid, true) : "ALL", reason);
else if(!strcmp(file, "AllTchat.txt"))
format(stringW,sizeof(stringW),"\r\n[%02i/%02i/%02i] %02i:%02i:%02i %s (Player #%i) » '%s'", day, month, year, hour, minute, seconde, playerid != INVALID_PLAYER_ID ? GetName(playerid, true) : "ALL", p_NameOff{playerid}, reason);
else
format(stringW,sizeof(stringW),"\r\n[%02i/%02i/%02i] %02i:%02i:%02i %s | '%s'", day, month, year, hour, minute, seconde, playerid != INVALID_PLAYER_ID ? GetName(playerid, true) : "ALL", reason);
fwrite(pos,stringW);
fclose(pos);
return 1;
}


