Loop trough all players except one
#1

hi,
how could i do a loop through all players in the server but exclude a certain player.
E.g. there is a moneyrush and the first player that finds the moneybag gets specated by all the other players on the server but hes the only one that wont be in spectating mode?

regards.
Reply
#2

Small example,
pawn Код:
new
    exeption = someplayerid;// you would need to store the ignored players id in a var.

for(new i; i < MAX_PLAYERS; i++)//im not advising using this type of loop you should look at foreach.
{
    if(exeption == i)continue;
    else
    {
        //do stuff
    }
}
Reply
#3

make a player loop, assign the excluded player to a variable, and you get something like this:

pawn Код:
// When the player find the moneybag do this:
finder = playerid

//- Other part of script -//
for(new i=0; i < MAX_PLAYERS; i++)
{
    if(finder != i)
    {
        // Do something here
    }
}
Reply
#4

thx guys
im gonna try it out
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)