SA-MP Forums Archive
How to get 1 player with foreach - 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: How to get 1 player with foreach (/showthread.php?tid=193651)



How to get 1 player with foreach - Kitten - 26.11.2010

Solved


Re: How to get 1 player with foreach - Retardedwolf - 26.11.2010

SetPlayerColor ( i, COLOR_TEAM_BLUE );


Re: How to get 1 player with foreach - Cameltoe - 26.11.2010

Quote:
Originally Posted by Kitten
Посмотреть сообщение
How would i get 1 player to be set there color to blue like

using foreach was the best i think

for example

pawn Код:
foreach(Player,i)
{
    how would i do it to get 1 player to set there color to blue
    SetPlayerColor(playerid,COLOR_TEAM_BLUE);
}
Try to explain a bit better.

Trying to make an random dude blue?


Re: How to get 1 player with foreach - Kitten - 26.11.2010

Solved


Re: How to get 1 player with foreach - The_Moddler - 26.11.2010

pawn Код:
stock SelectPlayer()
{
    new ID;
    Start:
    ID = random(MAX_PLAYERS);
    goto Check;
    Check:
    if(!IsPlayerConnected(id)) goto Start;
    else return ID;
}

SetPlayerColor(SelectPlayer(), COLOR_TEAM_BLUE);



Re: How to get 1 player with foreach - Retardedwolf - 27.11.2010

Iter_Random(Player);


Re: How to get 1 player with foreach - Kitten - 27.11.2010

Solved


Re: How to get 1 player with foreach - Retardedwolf - 27.11.2010

No, just SPC?

SetPlayerColor ( Iter_Random ( Player ), COLOR_TEAM_BLUE );


Re: How to get 1 player with foreach - Cameltoe - 27.11.2010

Quote:
Originally Posted by Kitten
Посмотреть сообщение
so like this?
pawn Код:
foreach(Player,i)
{
    Iter_Random(Player);
    SetPlayerColor(Player,COLOR_TEAM_BLUE)
}
pawn Код:
stock RandomBlue()
{
    new Random = Iter_Random(Player);
    SetPlayerColor(Random, COLOR_TEAM_BLUE)
}



Re: How to get 1 player with foreach - The_Moddler - 27.11.2010

pawn Код:
new ID = Iter_Random(Player);
SetPlayerColor(ID, COLOR_TEAM_BLUE)
Edit: Emm.. late.. also, you can make a stock to get a random player id:

pawn Код:
stock RandomPlayer()
{
    return Iter_Random(Player);
}