Loop trough all players except one - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Loop trough all players except one (
/showthread.php?tid=213051)
Loop trough all players except one -
BlackWolf120 - 18.01.2011
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.
Re: Loop trough all players except one -
iggy1 - 18.01.2011
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
}
}
Re: Loop trough all players except one -
Patrik356b - 18.01.2011
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
}
}
Re: Loop trough all players except one -
BlackWolf120 - 18.01.2011
thx guys
![Cheesy](images/smilies/biggrin.png)
im gonna try it out