Problem /givelevelall
#1

Код:
//---------------------------------------------------------------<[Giveallevel]>----------------------------------------------------------------------//
    if(strcmp(cmd, "/givelevelall", true) == 0)
    {
        if (PlayerInfo[playerid][pAdmin] >= 6)
        {
          for(new i = 0; i < MAX_PLAYERS; i++)
      {
        if(IsPlayerConnected(i))
        {
          new playerlevel = PlayerInfo[pLevel];
                    PlayerInfo[pLevel] = playerlevel + 1;
                    format(string, sizeof(string), " Administrator %s gave up 1 level all players who are online",sendername);
                    SendClientMessage(i,COLOR_LIGHTGREEN,string);
        }
      }
          return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command !");
    }
    }
Error at line
Код:
C:\Documents and Settings\Carbon\Desktop\larp.pwn(58017) : error 033: array must be indexed (variable "-unknown-")
C:\Documents and Settings\Carbon\Desktop\larp.pwn(58018) : warning 217: loose indentation
C:\Documents and Settings\Carbon\Desktop\larp.pwn(58018) : error 033: array must be indexed (variable "PlayerInfo")
LINE:
Код:
                    PlayerInfo[pLevel] = playerlevel + 1;
Reply
#2

Can you show your Enum please ? of PlayerInfo..


And do you use 'new PlayerInfo[MAX_PLAYERS][pInfo];" ?
Reply
#3

pawn Код:
//---------------------------------------------------------------<[Giveallevel]>----------------------------------------------------------------------//
if(strcmp(cmd, "/givelevelall", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] >= 6)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                PlayerInfo[i][pLevel] ++;
                format(string, sizeof(string), " Administrator %s gave up 1 level all players who are online",sendername);
                return SendClientMessageToAll(COLOR_LIGHTGREEN, string);
            }
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by fordawinzz
Посмотреть сообщение
pawn Код:
//---------------------------------------------------------------<[Giveallevel]>----------------------------------------------------------------------//
if(strcmp(cmd, "/givelevelall", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] >= 6)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                PlayerInfo[i][pLevel] ++;
                format(string, sizeof(string), " Administrator %s gave up 1 level all players who are online",sendername);
                return SendClientMessageToAll(COLOR_LIGHTGREEN, string);
            }
        }
    }
    return 1;
}
Do you know how to use loops at all? Your code will only affect ID 0 and if the return was removed it would spam the server with a ton of messages.

@ Poster

Use this:

pawn Код:
//---------------------------------------------------------------<[Giveallevel]>----------------------------------------------------------------------//
if(strcmp(cmd, "/givelevelall", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] >= 6)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            PlayerInfo[i][pLevel]++;
        }

        new string[128];
        format(string, sizeof(string), " Administrator %s gave up 1 level all players who are online",sendername);
        SendClientMessageToAll(COLOR_LIGHTGREEN, string);
    }

    return 1;
}
Just a note, it's better to not check for a connected player if you're doing something as simple as setting a variable.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)