Use this in with zcmd?
#1

How can i use this with zcmd so when someone type a command it will show admin what he typed. Need i use any callback or something ? ZCMD callback?

pawn Код:
new string[256];
    format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
            {
                SendClientMessage(i, ANY_COLOR, string);
            }
        }
    }
Reply
#2

Put it at the top of OnPlayerCommandText like this:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){
    new string[256];
    format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
            {
                SendClientMessage(i, ANY_COLOR, string);
            }
        }
    }
Reply
#3

Quote:
Originally Posted by Badger(new)
Посмотреть сообщение
Put it at the top of OnPlayerCommandText like this:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){
    new string[256];
    format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
            {
                SendClientMessage(i, ANY_COLOR, string);
            }
        }
    }
No, he is using ZCMD - that would be incorrect.

Use this:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    new string[256];
    format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
            {
                SendClientMessage(i, ANY_COLOR, string);
            }
        }
    }
   return 1;
}
Reply
#4

Quote:
Originally Posted by Badger(new)
Посмотреть сообщение
Put it at the top of OnPlayerCommandText like this:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){
    new string[256];
    format(string, sizeof(string), "**** %s (%d) has typed: %s", pNameL(playerid),playerid,cmdtext);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
            {
                SendClientMessage(i, ANY_COLOR, string);
            }
        }
    }
What about this?

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    new string[256];
    format(string, sizeof(string), "**** %s (%d) typed: %s", pNameL(playerid),playerid,cmdtext);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
            {
                SendClientMessage(i, ANY_COLOR, string);
            }
        }
    }
    if(!success)
    {
        return  SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
    }
    return 1;
}
Reply
#5

Yeah, that should work correctly, but I would do this:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success)
    {
        new string[256];
        format(string, sizeof(string), "**** %s (%d) typed: %s", pNameL(playerid),playerid,cmdtext);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
                {
                    SendClientMessage(i, ANY_COLOR, string);
                }
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
    }
    return 1;
}
It's a little bit more code, but it will only send a message to the admins if the command exists in the GM. If it doesn't, it'll just send the player an error message.
Reply
#6

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Yeah, that should work correctly, but I would do this:

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success)
    {
        new string[256];
        format(string, sizeof(string), "**** %s (%d) typed: %s", pNameL(playerid),playerid,cmdtext);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if( (PlayerInfo[i][AdminLevel] > PlayerInfo[playerid][AdminLevel]) && (PlayerInfo[i][AdminLevel] > 2) && (i != playerid) )
                {
                    SendClientMessage(i, ANY_COLOR, string);
                }
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
    }
    return 1;
}
It's a little bit more code, but it will only send a message to the admins if the command exists in the GM. If it doesn't, it'll just send the player an error message.
I just want all to see the unknow cmd like "Type /cmds to display available commands."

Thank you.
Reply
#7

Nice cell sizes guys..

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
        return SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
    return 1;
}
Reply
#8

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Nice cell sizes guys..

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(!success)
        return SendClientMessage(playerid, COLOR_WHITE, "Type /cmds to display available commands.");
    return 1;
}
I wasn't optimizing the code, just giving 'em what he wanted. If it were my code though, the size would of been changed.
Reply
#9

I don't believe he wants a unefficient cell size.. :'p
Reply
#10

Don't use 256 cell strings in command, text, etc.

Maximum chat string is 128...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)