Originally Posted by Dayrion
I've 2 connection's type : when i'm on local (OnTestServer) and when I'm not. I'm using OnTestServer in differents commands like /ban, etc..
For this:
Code:
- Config ( Core )
- base.pwn ( Global Definitions, MySQL, Server Settings )
- macros.pwn ( Global Macros for shortcuts like FUNCTION: and PUBLIC: )
- plugins.pwn ( Global Plugin Definitions )
I'm doing like this:
"../core/configuration.inc" (GM's inititialization)
"../core/MySQLConnections.inc" (Creating table, connection to mysql, etc...)
"../core/base.inc" (Macros and constants)
That's good?
Annnd..
I'm trying a new thing. It's for creating logs (from configuration.inc):
PHP Code:
new
Log_Level:Log_Server,
...;
enum Log_Level:LogType
{
NOTHING,
COMMANDS,
TCHAT,
FULL_LOG = NOTHING | COMMANDS | TCHAT
};
stock CreateServerLog(Log_Level:Log_Serv = Log_Level:FULL_LOG)
{
Log_Server = Log_Serv;
if(_:Log_Serv == NOTHING)
return print("[SERVER] Aucun log crйй."), 1;
static
string[120],
hour,
minu,
sec,
day,
month,
year;
Get@SetWorldTime(hour, minu, sec);
getdate(year, month, day);
format(string, sizeof(string), "-------- Dйbut -------- [%02i/%02i/%02i] - %02ih %02imin %02is.", day, month, year, hour, minu, sec);
WriteLogs("AllCommands.txt", string);
print("[SERVER] Logs configurйs.")
return 1;
}
stock Get@SetWorldTime(&hour = -1, &minutes = -1, &seconds = -1)
{
gettime(hour, minu, sec);
SetWorldTime(hour);
}
Log_Server is gonna be used when writing logs.
EDIT: Write logs function
PHP Code:
WriteLogs(file[70], const reason[], playerid = INVALID_PLAYER_ID)
{
if(!_:Log_Server)
return 1;
static day,
month,
hour,
minute,
seconde,
year;
static 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" Une erreur est survenue dans les logs. Merci de vйrifier ceux-ci!");
SendMessageToAdmins(RED, "[Server] "SAUMON_U"Fichier : '%s' | Contenus : '%s'", file, reason);
return 1;
}
gettime(hour, minute, seconde);
getdate(year, month, day);
if(!strcmp(file, "AllCommands.txt") && _:Log_Server == L_COMMANDS)
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") && _:Log_Server == L_TCHAT)
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 if(_:Log_Server == L_TCHAT)
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;
}
|