SA-MP Forums Archive
random spectate? - 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: random spectate? (/showthread.php?tid=87885)



random spectate? - hipy - 22.07.2009

Random is 1 of the most weirdest things so far lol
and as duffy said

Quote:

(22:21:46) (Duffy) functions in scripts that are "random" are probably the most clever things ever created
(22:22:04) (Duffy) because computers are so systematic and mathematical its amazing how they can select something at random



But i want to do a randomw spectat( so you could be spectating a random player ) anybody any idea how you do this?


Re: random spectate? - hipy - 22.07.2009

anybody


Re: random spectate? - Limex - 22.07.2009

Код:
stock GetRandomPlayer()
{
  new yplayer[MAX_PLAYERS+1];
  for (new y = 0; y != MAX_PLAYERS; y ++) {
    if (IsPlayerConnected(y)) {
      yplayer[0] ++;
      yplayer[yplayer[0]] = y;
    }
  }
  return yplayer[random(yplayer[0])+1];
}
I take no credit for this, but it is a function that I have stored.


Re: random spectate? - James_Alex - 22.07.2009

EDIT:already fixed
sorry for this post


Re: random spectate? - hipy - 22.07.2009

line new yplayer[MAX_SLOTS+1]; gives lots of erros like it doesnt know max_slots

How do i get this to work:S a define doesnt work either for max slots