SA-MP Forums Archive
Question about commands! - 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: Question about commands! (/showthread.php?tid=325802)



Question about commands! - Twisted_Insane - 14.03.2012

'Sup y'all?

Since I'm on a trip and haven't got anything from my script, I won't be able to show you anything, lol! I just wanted to ask the following:

How am I able to script something which lets all server moderators with level 2 ( + ) to see, which commands a player just typed? It doesn't matter if the player is a member or even an admin, I just want that from level 2 + , they'd be able to see which commands just got from any player performed!


Re: Question about commands! - [KHK]Khalid - 14.03.2012

it would be something like that
pawn Код:
//somewhere
forward SendMessageToAdmins(color, const string[]);

public SendMessageToAdmins(color, const string[])
{
    for(new player=0;player<MAX_PLAYERS;player++)
    {
        if(IsPlayerConnected(player))
        {
            if(IsPlayerAdmin(player))  // i got no idea about your script so this must be changed
            {
                SendClientMessage(player, color, string);
            }
        }
    return 1;
}
stock SendCMDToAdmins(playerid, command[])
{
    new string[128];
    GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), "<%s> has used the command: /%s", string, command);
    return SendMessageToAdmins(some color here, string); // change "some color here" to any color you want
}
and now you can use SendCMDToAdmins simply like that
pawn Код:
// example
if(strcmp("/kill", cmdtext, true) == 0)
{
    SetPlayerHealth(playerid, -9.9999);
    SendCMDToAdmins(playerid, "/kill"); // this would send a message to admins that (the player who typed /kill) has used the command: /kill   
    return 1;
}



Re: Question about commands! - Psymetrix - 14.03.2012

You could insert SendCMDToAdmins directly under OnPlayerCommandText. It would save adding it to every command you create.


Re: Question about commands! - Twisted_Insane - 14.03.2012

@both of you

Lol yes, I totally forgot that I already have the function "SendMessageToAdmins" included! The only new thing would be "SendCMDToAdmins"...

@Psymetrix

I don't get you, could you post an example?


Re: Question about commands! - Psymetrix - 14.03.2012

Public OnPlayerCommandText(playerid, cmdtext[])
{
SendCMDToAdmins(playerid, cmdtext);
return 0;
}

Though, if you use zcmd you will have use one of the callbacks it offers. Not sure what one.


Re: Question about commands! - Twisted_Insane - 14.03.2012

I am using ZCMD, of course, so what's this callback for, if I may ask? Maybe you mean "OnPlayerText"?


Re: Question about commands! - Psymetrix - 14.03.2012

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if (success) SendCMDToAdmins(playerid, cmdtext);
}
I'm not sure if this is the right callback. Try it and see.