#define ServerLog "Server/Log/%02d-%02d-%04d.txt"
public OnPlayerSpawn(playerid)
{
PrintX("Lol? (ID %d)", playerid);
}
stock PrintX(const string[], {Float,_}:...)
{
new Hour, Minute, Second;
new Year, Month, Day;
new LogFile[128], entry[128], File:Log;
gettime(Hour, Minute, Second);
getdate(Year, Month, Day);
format(LogFile, sizeof(LogFile), ServerLog, Day, Month, Year);
if(!fexist(LogFile))
{
dini_Create(LogFile);
printf("New Log File: %02d-%02d-%04d.txt", Day, Month, Year);
Log = fopen(LogFile, io_append);
format(entry, sizeof(entry), "[%02d:%02d:%02d] %s\r\n", Hour, Minute, Second, string);
fwrite(Log, entry);
fclose(Log);
}
else
{
format(entry, sizeof(entry), "[%02d:%02d:%02d] %s\r\n", Hour, Minute, Second, string);
Log = fopen(LogFile, io_append);
fwrite(Log, entry);
fclose(Log);
}
return 1;
}
[15:24:02] Lol? (ID %d) |
OnPlayerSpawn(playerid) { PrintX("Lol? (ID %d)", playerid); } stock PrintX(const format[], {Float,_}:...) { new Hour, Minute, Second; new Year, Month, Day; new LogFile[128], entry[128], File:Log; gettime(Hour, Minute, Second); getdate(Year, Month, Day); format(LogFile, sizeof(LogFile), ServerLog, Day, Month, Year); //>>>>>> RULE 64 <<<<<< if(!fexist(LogFile)) { dini_Create(LogFile); printf("New Log File: %02d-%02d-%04d.txt", Day, Month, Year); Log = fopen(LogFile, io_append); format(entry, sizeof(entry), "[%02d:%02d:%02d] %s\r\n", Hour, Minute, Second, string); fwrite(Log, entry); fclose(Log); } else { format(entry, sizeof(entry), "[%02d:%02d:%02d] %s\r\n", Hour, Minute, Second, string); Log = fopen(LogFile, io_append); fwrite(Log, entry); fclose(Log); } return 1; }
const format[]
const string[]
(64) : error 012: invalid function call, not a valid address (64) : warning 215: expression has no effect (64) : warning 215: expression has no effect (64) : warning 215: expression has no effect (64) : warning 215: expression has no effect (64) : warning 215: expression has no effect (64) : warning 215: expression has no effect (64) : error 001: expected token: ";", but found ")" (64) : error 029: invalid expression, assumed zero (64) : fatal error 107: too many error messages on one line
static stock
s_printX_str[128];
#deine printX(%1,%2) \
format(s_printX_str,128,(%1),%2); \
printX_proc()
stock printX(const str[]){
format(s_printX_str,128,"%s",str);
printX_proc();
}
stock printX_proc(){
new Hour, Minute, Second;
new Year, Month, Day;
new LogFile[128], entry[128], File:Log;
gettime(Hour, Minute, Second);
getdate(Year, Month, Day);
format(LogFile, sizeof(LogFile), ServerLog, Day, Month, Year); //>>>>>> RULE 64 <<<<<<
if(!fexist(LogFile))
{ dini_Create(LogFile);
printf("New Log File: %02d-%02d-%04d.txt", Day, Month, Year);
Log = fopen(LogFile, io_append);
format(entry, sizeof(entry), "[%02d:%02d:%02d] %s\r\n", Hour, Minute, Second, s_printX_str);
fwrite(Log, entry);
fclose(Log);
} else
{ format(entry, sizeof(entry), "[%02d:%02d:%02d] % s\r\n", Hour, Minute, Second, s_printX_str);
Log = fopen(LogFile, io_append);
fwrite(Log, entry);
fclose(Log);
}
}
Originally Posted by Remi-X
If you can't fix the errors, just don't post. And why look into sscanf? That's a really different thing, i think?
|
new printx_array[256]; //that is suppost to be above the first function
#define PrintX(%1) (format(printx_array, sizeof(printx_array), %1), print(printx_array), Log(printx_array))
public OnPlayerSpawn(playerid)
{
PrintX("Lol? (ID %d)", playerid);
}
stock Log(text[])
{
new
Hour,
Minute,
Second,
Year,
Month,
Day,
temp[256],
File:Log;
getdate(Year, Month, Day), gettime(Hour, Minute, Second);
format(temp, sizeof(temp), "Server/Log/%02d-%02d-%04d.txt", Day, Month, Year);
if(!fexist(temp)) Log = fopen(temp, io_write); else Log = fopen(temp, io_append);
format(temp, sizeof(temp), "[%02d:%02d:%02d] %s\r\n", Hour, Minute, Second, text);
fwrite(Log, temp), fclose(Log);
return true;
}