/admin command getting errors?
#1

pawn Код:
CMD:admins(playerid, params[])
{
    if(!IsPlayerConnected(3)) return 1;

    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
    SendClientMessage(playerid, 0x1FFFFFF, "Administrators online:");
    foreach(Player, i)
    {
        new level[128], string[128];

        if(PlayerInfo[i][pAdmin] > 0)
        {
            switch(PlayerInfo[i][pAdmin])
            {
                case 1: level = ""adminlevel1" (1)";
                case 2: level = ""adminlevel2" (2)";
                case 3: level = ""adminlevel3" (3)";
                case 4: level = ""adminlevel4" (4)";
                case 5: level = ""adminlevel5" (5)";
            }
            format(string, sizeof(string), "%s %s", level, PlayerName(i)); // here are the errors
            SendClientMessage(playerid, 0xFFF84FFFF, string);
        }
    }
    return 1;
}
Код:
C:\Users\Mustafa\Desktop\Servers\Gta server\ForYou\gamemodes\TDMNIEUW.pwn(1065) : error 012: invalid function call, not a valid address
C:\Users\Mustafa\Desktop\Servers\Gta server\ForYou\gamemodes\TDMNIEUW.pwn(1065) : warning 215: expression has no effect
C:\Users\Mustafa\Desktop\Servers\Gta server\ForYou\gamemodes\TDMNIEUW.pwn(1065) : error 001: expected token: ";", but found ")"
C:\Users\Mustafa\Desktop\Servers\Gta server\ForYou\gamemodes\TDMNIEUW.pwn(1065) : error 029: invalid expression, assumed zero
C:\Users\Mustafa\Desktop\Servers\Gta server\ForYou\gamemodes\TDMNIEUW.pwn(1065) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

I think the problem is on the switch function used.
pawn Код:
switch(PlayerInfo[i][pAdmin])
            {
                case 1: level = "adminlevel1";
                case 2: level = "adminlevel2";
                case 3: level = "adminlevel3";
                case 4: level = "adminlevel4";
                case 5: level = "adminlevel5";
            }
Reply
#3

pawn Код:
GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
Here you're grabbing the person who uses /admins, and in the string, your getting all admins names,
Where it says GetPalyerName(playerid,.......,......);
Change playerid, to i.

Fixed Version.

pawn Код:
CMD:admins(playerid, params[])
{
    if(!IsPlayerConnected(3)) return 1;
    foreach(Player, i)
    {
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(i,PlayerName,sizeof(PlayerName));
        SendClientMessage(playerid, 0x1FFFFFF, "Administrators online:");
        new level[128], string[128];
        if(PlayerInfo[i][pAdmin] > 0)
        {
            switch(PlayerInfo[i][pAdmin])
            {
                case 1: level = ""adminlevel1" (1)";
                case 2: level = ""adminlevel2" (2)";
                case 3: level = ""adminlevel3" (3)";
                case 4: level = ""adminlevel4" (4)";
                case 5: level = ""adminlevel5" (5)";
            }
            format(string, sizeof(string), "%s %s", level, PlayerName(i));
            SendClientMessage(playerid, 0xFFF84FFFF, string);
        }
    }
    return 1;
}
Does it work?
Reply
#4

Didnt work
Reply
#5

Try this,
pawn Код:
CMD:admins(playerid, params[])
{
    if(!IsPlayerConnected(3)) return 1;
    foreach(Player, i)
    {
        SendClientMessage(playerid, 0x1FFFFFF, "Administrators online:");
        new level[128], string[128];
        if(PlayerInfo[i][pAdmin] > 0)
        {
            if(PlayerInfo[i][pAdmin]>= 1 && PlayerInfo[i][pAdmin]>= 5)
            {
                if(PlayerInfo[i][pAdmin] == 1) { level = "(1)"; }
                else if(PlayerInfo[i][pAdmin] == 2) { level = "(2)"; }
                else if(PlayerInfo[i][pAdmin] == 3) { level = "(3)"; }
                else if(PlayerInfo[i][pAdmin] == 4) { level = "(4)"; }
                else if(PlayerInfo[i][pAdmin] == 5) { level = "(5)"; }
                new PlayerName[MAX_PLAYER_NAME];
                GetPlayerName(i,PlayerName,sizeof(PlayerName));
                format(string, sizeof(string), "%s %s", level, PlayerName);
                SendClientMessage(playerid, 0xFFF84FFFF, string);
            }
        }
    }
    return 1;
}
I re-coded some. Does that work?
Reply
#6

Edit: fixed
Reply
#7

It won't allow you to use this character
pawn Код:
"\"
You'll need to remove that.
Reply
#8

Oke thanks...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)