Problem /givelevelall
#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


Messages In This Thread
Problem /givelevelall - by carbonzero - 12.06.2012, 13:15
Re: Problem /givelevelall - by -CaRRoT - 12.06.2012, 13:40
Re: Problem /givelevelall - by fordawinzz - 12.06.2012, 13:47
Re: Problem /givelevelall - by SuperViper - 12.06.2012, 14:44

Forum Jump:


Users browsing this thread: 2 Guest(s)