Spectating problem
#1

Hello,I made a random spectating system which those players who've been killed can spectate any players who aren't killed yet.
But there's one problem, when I've been killed by Player 1, I've to click multiple times(KEY_FIRE) to spectate other players who were still alive. Well I know it's because of this random() thingy but how can I make a system like I just have to click only once, and then I'll be able to spectate another player who're still alive, and so on..

This's my script:


pawn Код:
if (PRESSED(KEY_FIRE))
    {
    if(PlayerInfo[playerid][Latezor] == 1 && PlayerInfo[playerid][Killedzor] == 1)
    {
        for(new i; i<GetMaxPlayers(); i++)
        {
            if(IsPlayerConnected(i)) PCount++;
        }
        new Spectatethisguy = random(PCount);
        if(PlayerInfo[Spectatethisguy][Latezor] == 0 && PlayerInfo[Spectatethisguy][Killedzor] == 0)
        {
        PlayerSpectatePlayer(playerid, Spectatethisguy);
        }
    }
    }
Anyone have any idea on how to do that?
Big thanks.
Reply
#2

Search for a proper random player function.
Reply
#3

Ermm, is this a good one? :

pawn Код:
stock RandomPlayer()
{
    new randomplayer = random(MAX_PLAYERS);
    while(!IsPlayerConnected(randomplayer)) randomplayer = random(MAX_PLAYERS);
    return randomplayer;
}
Reply
#4

DEFINATELY NOT!
Don't even get me started on why that's a terrible idea!

http://pastebin.com/jvhMdwhJ
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)