each player has a separate log backup - 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: each player has a separate log backup (
/showthread.php?tid=537875)
each player has a separate log backup -
Slicebook - 18.09.2014
how to save the log for each player?
I mean:
1. If the player has no log folder create one
2. Save the player commands their own log folder
Some simple ideas can anyone?
Re: each player has a separate log backup -
SilentSoul - 18.09.2014
pawn Код:
forward OnPlayerCommandPerformed(playerid, cmdtext[], success);
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
if(success)
{
new playerfile[24],string[64];
format(playerfile,sizeof(playerfile),"Logs/%s.txt",GetPlayerNameEx(playerid));
format(string,sizeof(string),"[COMMAND] - /%s\r\n",cmdtext);
new File:ftw=fopen(playerfile, io_append);
if(ftw)
{
fwrite(ftw, string);
}
fclose(ftw);
}
return 1;
}
stock GetPlayerNameEx(playerid)
{
new pName[25];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}
That's outdated way, you should use something like y_ini for file functions would be better i just wanted to give you the basic idea.
Source:
https://sampwiki.blast.hk/wiki/Fopen
EDIT:
https://sampforum.blast.hk/showthread.php?tid=244223 - that's y_ini tutorial if you're interested to make a better and a faster version of this code.
Re: each player has a separate log backup -
Stinged - 18.09.2014
Quote:
Originally Posted by SilentSoul
That's outdated way, you should use something like y_ini for file functions would be better i just wanted to give you the basic idea.
EDIT: https://sampforum.blast.hk/showthread.php?tid=244223 - that's y_ini tutorial if you're interested to make a better and a faster version of this code.
|
Don't forward OnPlayerCommandPerformed as it already is forwarded in zcmd (or y_command).
Y_INI is indeed faster, but it is used for saving settings. You can't save logs in Y_INI.
INIs:
Код:
Int = value
String = string
That's not how to save logs.
The correct way is the code you posted with the file functions, not with Y_INI.
Re: each player has a separate log backup -
Slicebook - 18.09.2014
Quote:
Originally Posted by SilentSoul
pawn Код:
forward OnPlayerCommandPerformed(playerid, cmdtext[], success); public OnPlayerCommandPerformed(playerid, cmdtext[], success) { if(success) { new playerfile[24],string[64]; format(playerfile,sizeof(playerfile),"Logs/%s.txt",GetPlayerNameEx(playerid)); format(string,sizeof(string),"[COMMAND] - /%s\r\n",cmdtext); new File:ftw=fopen(playerfile, io_append); if(ftw) { fwrite(ftw, string); } fclose(ftw); } return 1; } stock GetPlayerNameEx(playerid) { new pName[25]; GetPlayerName(playerid, pName, sizeof(pName)); return pName; }
That's outdated way, you should use something like y_ini for file functions would be better i just wanted to give you the basic idea.
Source: https://sampwiki.blast.hk/wiki/Fopen
EDIT: https://sampforum.blast.hk/showthread.php?tid=244223 - that's y_ini tutorial if you're interested to make a better and a faster version of this code.
|
Thanks! +