SA-MP Forums Archive
Logs help - 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: Logs help (/showthread.php?tid=580214)



Logs help - Hybris - 03.07.2015

Hello I was wondering if anyone can help me out,I need my server to write logs of the admin commands which have been used by the players for example:
Nick has used /get on Travis
if anyone can provide a tutorial that would help alot


Re : Logs help - Terrorizt - 03.07.2015

Код:
new File:acmds; // Add this at the top of your script under includes so you don't have to put it everytime in every command.
Код:
CMD:get(playerid, params[])
{
    new pID, log[128], year, month, day, hour, minute, second,  Float:X, Float:Y, Float:Z;
    getdate(year, month, day);
    gettime(hour, minute, second);
    if(PlayerInfo[playerid][pAdmin] < 1 || PlayerInfo[playerid][pAdmin] > 4) return SendClientMessage(playerid, grey, "Error: You are not authorized to use this command.");
    if(sscanf(params,"i", pID)) return SendClientMessage(playerid, grey,"[Usage] /get [id]");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, grey,"Error: Player not found!");
    GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
    SetPlayerPos(pID, Float:X + 3.0 ,Float:Y,Float:Z);
    format(log, sizeof(log),"[%02d/%02d/%04d %02d:%02d:%02d] [Admin] %s has used /get on %s.\r\n",day, month, year, hour, minute, second, GetName(playerid), GetName(pID));
    acmds = fopen("acmds.log", io_append);
    fwrite(acmds, log);
    fclose(acmds);
    return 1;
}