Command Log
#1

Hello, I'm looking for a command log, like a Chat Log, but for commands.

I made a Chat Log with this tutorial and it works perfectly.

Now, I tryed to use this tutorial to do a command log, but it doesn't work. Does anybody know how to make a command log ?


Thanks =)
Reply
#2

Nobody ?
Reply
#3

Quote:
Originally Posted by ludesert
Посмотреть сообщение
Nobody ?
What command system are you using ?
Reply
#4

Dcmd and zcmd
Reply
#5

Quote:
Originally Posted by ludesert
Посмотреть сообщение
Dcmd and zcmd
Both ? I thought Zcmd block's the OnPlayerCommandText?

Though, here's how to output zcmd commands :

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
     return Log(cmdtext); // probably do some formating to output the player name etc.
}
Reply
#6

No. But do you know how to make a command log ?
Reply
#7

Quote:
Originally Posted by ludesert
Посмотреть сообщение
No. But do you know how to make a command log ?
Yes,

pawn Код:
stock Log(Text[])
{
     new Query[130];
     format(Query, sizeof(Query), "INSERT INTO logs (id, text) VALUES (NULL, '%s');", Text);
     mysql_query(Query);
}
Besides stripping the Text for mysql injections, this is how i would do it.
Reply
#8

Is it possible to create a log of thй commands whitch were used un a txt file like that :

[day] [mounth] [hour] [minut] : player : command

?
Reply
#9

Add this on the OnPlayerCommandText

Код:
new cmd[128];
cmd = strtok(cmdtext, idx);
printf("[cmd][%s]: %s",PlayerName(playerid),cmdtext);
Reply
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
What is it with people recently assuming that people use MySQL - I've seen it in an increasing number of topics. The OP asks a perfectly normal question and doesn't mention MySQL at any point; at no point do they say they have it installed, have it set up or have any interest in using it at all; yet answers start using it.

MySQL, like ALL plugins, is non-standard. If you are going to use it at least mention that "this will require you to install a massive great library designed for huge websites on to your tiny little SA:MP server which already has perfectly good database functionality built in, just for one line of code" (or words to that effect). You cannot assume that people have any plugins installed, even common ones like sscanf should be explicitly stated.
Quote:
Originally Posted by ludesert
Посмотреть сообщение
No. But do you know how to make a command log ?
Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
Yes,

pawn Код:
stock Log(Text[])
{
     new Query[130];
     format(Query, sizeof(Query), "INSERT INTO logs (id, text) VALUES (NULL, '%s');", Text);
     mysql_query(Query);
}
Besides stripping the Text for mysql injections, this is how i would do it.
He asked me if i knew how to script and command log, and basicly that's how i would do it, i did not assume Ludesert were using mysql at all.


Anyway, this should work :
pawn Код:
// Zcmd
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    CommandLog(playerid, cmdtext);
    return 1;
}
// Strcmp
public OnPlayerCommandText(playerid, cmdtext[])
{
    CommandLog(playerid, cmdtext);
    return 1;
}

stock CommandLog(playerid, text[])
{
    new
     File:lFile = fopen("Logs/CommandLog.txt", io_append),
     logData[178],
        fyear, fmonth, fday,
        fhour, fminute, fsecond;

    getdate(fyear, fmonth, fday);
    gettime(fhour, fminute, fsecond);

    format(logData, sizeof(logData),"[%02d/%02d/%04d %02d:%02d:%02d] %s: %s \r\n", fday, fmonth, fyear, fhour, fminute, fsecond, GetName(playerid), text);
    fwrite(lFile, logData);

    fclose(lFile);
    return 1;
}

stock GetName(playerid)
{
    new pName[25];
    GetPlayerName(playerid, pName, sizeof(pName));
    return pName;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)