each player has a separate log backup
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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! +
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)