[HELP]ZCMD, I guess.
#1

Here's my CMD, it works but every time returns "unknown command".
pawn Код:
COMMAND:admins(playerid)
{
    new string[64];
    new name[MAX_PLAYER_NAME];

    for(new i; i < MAX_PLAYERS+1; i++)
    {
        if(PlayerInfo[i][isAdmin] == 1)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string, sizeof(string), "%d LVL ADMIN: %s", PlayerInfo[i][AdminLvl], name);
            SendClientMessage(playerid, COLOR_YELLOW, string);
        }
    }
    return 1;
}
I mean, when I write CMD In-Game it shows like this:
pawn Код:
4 LVL ADMIN: Nickname
5 LVL ADMIN: nickname
SERVER: Unknown command
Reply
#2

Try this

pawn Код:
COMMAND:admins(playerid)
{
    new string[64];
    new name[MAX_PLAYER_NAME];

    for(new i; i < MAX_PLAYERS+1; i++)
    {
        if(PlayerInfo[i][isAdmin] == 1)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string, sizeof(string), "%d LVL ADMIN: %s", PlayerInfo[i][AdminLvl], name);
            SendClientMessage(playerid, COLOR_YELLOW, string);
        }
    }
                             <---- Insert 1 row here
    return 1;
}
Reply
#3

Still, the same.
Reply
#4

Don't you need params?
Код:
COMMAND:admins(playerid, params[])
{
    new string[64];
    new name[MAX_PLAYER_NAME];

    for(new i; i < MAX_PLAYERS+1; i++)
    {
        if(PlayerInfo[i][isAdmin] == 1)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string, sizeof(string), "%d LVL ADMIN: %s", PlayerInfo[i][AdminLvl], name);
            SendClientMessage(playerid, COLOR_YELLOW, string);
        }
    }
                             <---- Insert 1 row here
    return 1;
}
If you get a warning about "symbol is never used - params", put #pragma unused params somewhere above the loop.

Hope this helps
Reply
#5

nah, still the same. Everything works fine with commands without loops. And the ones with the loops gives "unknown command"
Reply
#6

Hmm, not sure if it'll make a difference, but why the MAX_PLAYERS+1;?
Try
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
Reply
#7

have you tried using your for loop without +1?
pawn Код:
for(new i; i < MAX_PLAYERS; i++)
{
    // code here
}
Reply
#8

pawn Код:
COMMAND:admins(playerid, params[])
{
    new string[64];
    new name[MAX_PLAYER_NAME];

    for(new i; i < MAX_PLAYERS+1; i++)
    {
        if(PlayerInfo[i][isAdmin] == 1)
        {
            GetPlayerName(i, name, sizeof(name));
            format(string, sizeof(string), "%d LVL ADMIN: %s", PlayerInfo[i][AdminLvl], name);
            SendClientMessage(playerid, COLOR_YELLOW, string);
        }
<----------- insert else return SendClientMessage(playerid,COLOR,"You are not an admin");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)