Get random player
#1

How can I get random id of player that sustains this -

if(X[playerid] == 0 && playerid != LastIdChoose)

But not in the order [as in "for"]



Thanks
Reply
#2

Explain a lil more
Reply
#3

uh, I didn't get what you want. Please explain more.
Reply
#4

I need random id of player ... that his variable is == 0 and changed than the last id I got ...

I thought to use for, but I want it not in order [0,1,2,3], How can I make it ?
Reply
#5

You could create a function, or use Iter_Random (I think It's that) in ******' foreach, if you're using foreach, that is.

Here is a function that will get you a random, connected, player - though it could be done much better!

pawn Code:
stock RandomPlayer()
{
     new iPlayer = random(GetMaxPlayers());
     while(!IsPlayerConnected(iPlayer)) iPlayer = random(GetMaxPlayers());
     return iPlayer;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)