Gamemode by include
#26

Quote:
Originally Posted by Dayrion
View Post
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(hourminusec);
    
getdate(yearmonthday);
    
format(stringsizeof(string), "-------- Dйbut -------- [%02i/%02i/%02i] - %02ih %02imin %02is."daymonthyearhourminusec);
    
WriteLogs("AllCommands.txt"string);
    print(
"[SERVER] Logs configurйs.")
    return 
1;
}
stock Get@SetWorldTime(&hour = -1, &minutes = -1, &seconds = -1)
{
    
gettime(hourminusec);
    
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"false0) == -1format(filesizeof(file), "%s.txt"file);
    new 
File:pos=fopen(fileio_append);
    if(!
pos)
    {
        
printf("[Server] Write Logs Error | Reason : pos=fopen Error | File : '%s' | Reason: '%s'"filereason);
        
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'"filereason);
        return 
1;
    } 
    
    
gettime(hourminuteseconde);
    
getdate(yearmonthday);
    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++, daymonthyearhourminutesecondeplayerid != INVALID_PLAYER_ID GetName(playeridtrue) : "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'"daymonthyearhourminutesecondeplayerid != INVALID_PLAYER_ID GetName(playeridtrue) : "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'"daymonthyearhourminutesecondeplayerid != INVALID_PLAYER_ID GetName(playeridtrue) : "ALL"reason);
    
fwrite(pos,stringW);
    
fclose(pos);
    return 
1;

Don't do logs in that way, just... don't...
Maddinat0r made an excepcional plugin for logging: https://sampforum.blast.hk/showthread.php?tid=603175
Reply


Messages In This Thread
Gamemode by include - by Dayrion - 22.02.2017, 12:48
Re: Gamemode by include - by jlalt - 22.02.2017, 12:53
Re: Gamemode by include - by Dayrion - 22.02.2017, 13:17
Re: Gamemode by include - by jlalt - 22.02.2017, 13:25
Re: Gamemode by include - by Dayrion - 22.02.2017, 14:52
Re: Gamemode by include - by jlalt - 22.02.2017, 14:57
Re: Gamemode by include - by PrO.GameR - 22.02.2017, 19:44
Re: Gamemode by include - by iKarim - 23.02.2017, 06:13
Re: Gamemode by include - by Sew_Sumi - 23.02.2017, 06:20
Re: Gamemode by include - by Yashas - 23.02.2017, 06:52
Re: Gamemode by include - by iKarim - 23.02.2017, 19:41
Re: Gamemode by include - by Dayrion - 23.02.2017, 23:47
Re: Gamemode by include - by Sew_Sumi - 24.02.2017, 00:50
Re: Gamemode by include - by iKarim - 24.02.2017, 05:17
Re: Gamemode by include - by DRIFT_HUNTER - 24.02.2017, 05:24
Re: Gamemode by include - by Sew_Sumi - 24.02.2017, 05:35
Re: Gamemode by include - by Gammix - 24.02.2017, 07:34
Re: Gamemode by include - by Dayrion - 24.02.2017, 10:21
Re: Gamemode by include - by DRIFT_HUNTER - 24.02.2017, 14:28
Re: Gamemode by include - by patrickgtr - 24.02.2017, 14:32
Re: Gamemode by include - by iKarim - 24.02.2017, 14:59
Re: Gamemode by include - by Dayrion - 01.03.2017, 22:27
Re: Gamemode by include - by azzerking - 01.03.2017, 23:41
Re: Gamemode by include - by Dayrion - 02.03.2017, 12:52
Re: Gamemode by include - by azzerking - 02.03.2017, 18:00
Re: Gamemode by include - by renatog - 02.03.2017, 19:50
Re: Gamemode by include - by Dayrion - 02.03.2017, 20:15
Re: Gamemode by include - by renatog - 02.03.2017, 20:58
Re: Gamemode by include - by Mauzen - 03.03.2017, 03:46
Re: Gamemode by include - by Y_Less - 03.03.2017, 10:25
Re: Gamemode by include - by RyderX - 03.03.2017, 10:49

Forum Jump:


Users browsing this thread: 8 Guest(s)