Log system - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Log system (
/showthread.php?tid=509583)
Log system -
lonalovegood1 - 27.04.2014
i want to make a log system with y_ini
i use this system ...
and i want it to make a new file and when player type for example /kick <pid> , add a log after those before
example :
1 . Admin Level (6) (John_Alien) Has Kicked Player (Mr.Adriana) for reason (No0b).
and the next line same as this line ...
2 . Admin Level (3) (ArShAm) Has Muted Player (John_Alien) for reason (Kick No0bs).
something like that ...
i can make it myself but just in one line ... is there any loop to help me make them one after another ?
Re: Log system -
IceBilizard - 27.04.2014
i don't know with y_ini but you can create normally with this
pawn Код:
forward SaveIn(filename[],text[]);
public SaveIn(filename[],text[])
{
new File:Lfile;
new filepath[256];
new string[256];
new year,month,day;
getdate(year,month,day);
format(filepath,sizeof(filepath),"%s.txt",filename);
Lfile = fopen(filepath,io_append);
format(string,sizeof(string),"[%02d/%02d/%02d] %s\r\n",day,month,year,text);
fwrite(Lfile,string);
fclose(Lfile);
return 1;
}
then you use SaveIn("Logs",string);
at commands
Re: Log system -
Kyance - 27.04.2014
You don't have to use Y_INI
pawn Код:
#include <a_samp>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
if(!fexist("/adminlogs/logs.txt"))
{
printf("WARNING: 'logs.txt' does NOT exist at the 'scriptfiles/adminlogs' folder");
print("NOTIFICATION: attempting to create 'logs.txt'");
SetTimer("CheckForFile", 5000, false);
fcreate("/adminlogs/logs.txt");
}
else
{
new string[132];
gettime(slhour, slminute, slsecond);
getdate(slyear, slmonth, slday);
new File:AdminInfo = fopen("/adminlogs/logs.txt", io_append);
if(SquadInfo)
{
format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - gamemode successfully loaded\r\n", slday, slmonth, slyear, slhour, slminute, slsecond);
SaveToLog(string);
fclose(AdminInfo);
}
}
return 1;
}
public CheckForFile()
{
new string[132];
if(fexist("/adminlogs/logs.txt"))
{
print("NOTIFICATION: 'logs.txt' has been successfully created at 'scriptfiles/adminlogs'");
gettime(slhour, slminute, slsecond);
getdate(slyear, slmonth, slday);
new File:AdminInfo = fopen("/adminlogs/logs.txt", io_append);
if(SquadInfo)
{
format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - gamemode successfully loaded\r\n", slday, slmonth, slyear, slhour, slminute, slsecond);
SaveToLog(string);
fclose(AdminInfo);
}
}
else
{
print("WARNING: could NOT create 'logs.txt' at 'scriptfiles/adminlogs' ...");
}
return 1;
}
public fcreate(filename[])
{
if (fexist(filename)){return false;}
new File:fhandle = fopen(filename,io_write);
fclose(fhandle);
return true;
}
stock SaveToLog(string[])
{
if(fexist("/adminlogs/logs.txt"))
{
new File:AdminInfo = fopen("/adminlogs/logs.txt", io_append);
if(SquadInfo)
{
fwrite(AdminInfo, string);
fclose(AdminInfo);
}
}
return 1;
}
#endif
* created as filterscript xd *