[Tutorial] [BASIC]How to make a command not work without enough players.
#4

Quote:
Originally Posted by [XST]O_x
Посмотреть сообщение
pawn Код:
GetPlayersOnServer()
{
    new count;
    for(new x=0; x< MAX_PLAYERS; x++)
    {
        if(IsPlayerConnected(x))
        {
            count++;
        }
    }
    return count;
}
I don't see how this is going to work. You're not giving 'count' any value, and then you're actually doing:
count = count+1 (count++), but count doesn't have any value, it contains junk.
Just assign a value to count while defining it:
pawn Код:
new count = 0;
It will still work... Initialising the variable is common practice but not a necessity in Pawn.
Reply


Messages In This Thread
[BASIC]How to make a command not work without enough players. - by RandomDude - 20.04.2013, 13:16
Re: [BASIC]How to make a command not work without enough players. - by Isolated - 20.04.2013, 16:40
Re: [BASIC]How to make a command not work without enough players. - by [XST]O_x - 20.04.2013, 16:54
Re: [BASIC]How to make a command not work without enough players. - by Ash. - 20.04.2013, 17:15
Re: [BASIC]How to make a command not work without enough players. - by RandomDude - 20.04.2013, 17:36

Forum Jump:


Users browsing this thread: 1 Guest(s)