05.09.2012, 10:21
The Gogger
Advanced log creating and saving
by Gangs a.k.a CreativityLacker
Functions:
Code
Advanced log creating and saving
by Gangs a.k.a CreativityLacker
Functions:
pawn Код:
forward CreateLog(logname[]);
forward WriteInLog(logname[], string[]);
pawn Код:
/*
The Gogger - Advanced log creating, writing and saving
by Gangs a.k.a CreativityLacker
Don't remove credits from here
This is the BETA version
Please report any bugs at the topc
*/
#include <file>
#include <a_samp>
forward CreateLog(logname[]);
forward WriteInLog(logname[], string[]);
public CreateLog(logname[])
{
new date[3];
getdate(date[0], date[1], date[2]);
new string[120];
format(string, sizeof(string), "Logs/%s.txt", logname); // Change this to the location you want your logs at
new File:log = fopen(string, io_append);
format(string, sizeof(string), "[%02d-%02d-%04d] Started logging in LOG '%s' ", date[2], date[1], date[0], logname);
fwrite(log, string);
fclose(log);
format(string, sizeof(string), "\r\n[%02d-%02d-%04d] Started logging in LOG '%s'", date[2], date[1], date[0], logname);
printf(string);
return 1;
}
public WriteInLog(logname[], string[])
{
new location[120];
format(location, sizeof(location),"Logs/%s.txt", logname); // Change this to the location you want your logs at
if(fexist(location))
{
new File:log = fopen(location, io_append);
fwrite(log, string);
fclose(log);
}
else return printf("[LOG ERROR]A log wasn't found!");
return 1;
}
Download link :
http://www.mediafire.com/download.php?c0jb6vdxad4rz49
http://www.mediafire.com/download.php?c0jb6vdxad4rz49
Test script :
Output results after this code:
Console:
File (scriptfiles/Logs/TestLog.txt):
pawn Код:
#include <a_samp>
#include <Gogger>
main()
{
print("\n----------------------------------");
print(" Testing Log creator");
print("----------------------------------\n");
}
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
CreateLog("TestLog");
return 1;
}
public OnPlayerConnect(playerid)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
new string[40];
format(string, sizeof(string), "\r\n%s connected to the server", name);
WriteInLog("TestLog", string);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new name[24];
GetPlayerName(playerid, name, sizeof(name));
new string[40];
format(string, sizeof(string), "\r\n%s disconnected from the server", name);
WriteInLog("TestLog", string);
printf(string);
return 1;
}
Console:
Quote:
[16:00:45] Number of vehicle models: 0 [16:01:09] Incoming connection: 127.0.0.1:63878 [16:01:09] [join] Futre has joined the server (0:127.0.0.1) [16:01:14] Futre disconnected from the server [16:01:14] [part] Futre has left the server (0:1) |
Quote:
[05-09-2012] Started logging in LOG 'TestLog' Futre connected to the server Futre disconnected from the server |
Please report any bugs, I'll try to fix 'em ASAP