Last Commands
#1

Hey,

I want to make a last commands system for my RP script so I know when people metagame etc.

I have these variables

pawn Код:
CMD1[128],
    CMD2[128],
    CMD3[128],
    CMD4[128],
    CMD5[128],
How do I easy give them the last command text like:

/pm 0 HEY HOW YOU DOING?!

Do i need to do something with OnplayerCommandText
or in each command....
Reply
#2

You can do

pawn Код:
forward OnPlayerCommandPerformed(playerid, cmdtext[], success);
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) //send it to admins or save to file.
        if(success)
        //do the same as above.
    return 1;
}
not sure if this is what you want, the way i've done it is a watchlist, if the person is on there, it sends the command that they entered to admins as " xx entered command: xx" and saves to file, if they arent, it saves to file.

like this:

Код:
[01/06/2013 | 07:42:17] Dobby entered command /rc 134
Reply
#3

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
You can do

pawn Код:
forward OnPlayerCommandPerformed(playerid, cmdtext[], success);
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) //send it to admins or save to file.
        if(success)
        //do the same as above.
    return 1;
}
not sure if this is what you want, the way i've done it is a watchlist, if the person is on there, it sends the command that they entered to admins as " xx entered command: xx" and saves to file, if they arent, it saves to file.

like this:

Код:
[01/06/2013 | 07:42:17] Dobby entered command /rc 134
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) return SendClientMessage(playerid, SERVERCOLOR, "SERVER: This command is unknown, use /help for a list of commands.");  //If the command was wrong/invalid
    if(success)
    {
        format(Player[playerid][CMD1], 129, "%s", Player[playerid][CMD2]);
        format(Player[playerid][CMD2], 129, "%s", Player[playerid][CMD3]);
        format(Player[playerid][CMD3], 129, "%s", Player[playerid][CMD4]);
        format(Player[playerid][CMD4], 129, "%s", Player[playerid][CMD5]);
        format(Player[playerid][CMD5], 129, "%s", cmdtext);
    }
    return 1;
}
Would this work?
Reply
#4

I'm not too sure, I use SendMessageToAdmins and SaveIn, I format a string, then when they enter any command, it saves. Does your code compile?


Edit:
pawn Код:
forward SaveIn(filename[],text[]);

public SaveIn(filename[],text[])
{
    new File:Lfile;
    new filepath[256];
    new string[256];
    new year,month,day;
    new hour,minute,second;

    getdate(year,month,day);
    gettime(hour,minute,second);
    format(filepath,sizeof(filepath),"PATHHERE/%s.txt",filename);//save it as %s.txd
    Lfile = fopen(filepath,io_append);
    format(string,sizeof(string),"[%02d/%02d/%02d | %02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
    fwrite(Lfile,string);
    fclose(Lfile);
    return 1;
}
Here's my OnPlayerCommand:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) SendClientMessage(playerid,bad,"Incorrect command, type /cmds to find out available commands");
    if(WatchList[playerid]  >= 1)
    {
        new string[124];
        format(string, sizeof(string),"[WATCHLIST]%s entered command %s",pName(playerid),cmdtext);
        SendMessageToAdmins(connect,string);
    }
    else if(WatchList[playerid] <= 0)
    {
        new string[124];
        format(string, sizeof(string),"%s entered command %s",pName(playerid),cmdtext);
        SaveIn("EnteredCommands",string);
    }
    return 1;
}
Understand how i've done it?
Reply
#5

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
I'm not too sure, I use SendMessageToAdmins and SaveIn, I format a string, then when they enter any command, it saves. Does your code compile?


Edit:
pawn Код:
forward SaveIn(filename[],text[]);

public SaveIn(filename[],text[])
{
    new File:Lfile;
    new filepath[256];
    new string[256];
    new year,month,day;
    new hour,minute,second;

    getdate(year,month,day);
    gettime(hour,minute,second);
    format(filepath,sizeof(filepath),"PATHHERE/%s.txt",filename);//save it as %s.txd
    Lfile = fopen(filepath,io_append);
    format(string,sizeof(string),"[%02d/%02d/%02d | %02d:%02d:%02d] %s\r\n",day,month,year,hour,minute,second,text);
    fwrite(Lfile,string);
    fclose(Lfile);
    return 1;
}
Here's my OnPlayerCommand:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success) SendClientMessage(playerid,bad,"Incorrect command, type /cmds to find out available commands");
    if(WatchList[playerid]  >= 1)
    {
        new string[124];
        format(string, sizeof(string),"[WATCHLIST]%s entered command %s",pName(playerid),cmdtext);
        SendMessageToAdmins(connect,string);
    }
    else if(WatchList[playerid] <= 0)
    {
        new string[124];
        format(string, sizeof(string),"%s entered command %s",pName(playerid),cmdtext);
        SaveIn("EnteredCommands",string);
    }
    return 1;
}
Understand how i've done it?
Yup it does compiles, but what I try to do is show the admin who is spectating a player, to see its lasts commands so we can check if they spammed, insulted, metagamed etc
Reply
#6

It works, Thanks REP+
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)