whats this called?
#1

hmm i made a vaariable like class[max_players] for teams ..
ok i want to get their teams,.. now how do i find that when noone is in team 2 ? i could do it like this ..
pawn Код:
for(new i; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                    else if(class[i] != 2)
                {
                        //blah         
                                                   }
            }
        }
i tried taht but it didnt work .. what if i use this .. if(class[max_players] for all the players ... but that will tell me taht it is out of bounds , and what if i use if(class[499] != 2 )? will this work ?
Reply
#2

pawn Код:
new count = 0;

for(new i; i<MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        if(class[i] != 2) // You can't have an else if statement on it's own, or an else statement for that matter
        {
            //blah        
        }
        else count++; // You could do an else here, after a previous if statement, counting people in team 2
    }
}

// Now if count = 0 nobody is in team 2
Hope that helps.
Reply
#3

Yea,that might help, but i used the [499] lol, it worked..
Reply
#4

Quote:
Originally Posted by Rocky Balboa
Посмотреть сообщение
Yea,that might help, but i used the [499] lol, it worked..
Well then you'd be checking the class of playerid 499 only! If that's what you want, there's no need for a loop at all. You would just make a single if statement
Reply
#5

well i am using a timer for this funciton , but the timer goes crazy ...and spams shit..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)