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



random spec? - jamesbond007 - 11.05.2011

i already tried these both ways and i can't get a player spectate a random person after he dies by gravity. please help me .. :/

pawn Код:
if(killerid != INVALID_PLAYER_ID)
    {
        new count[MAX_PLAYERS];
        for (new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                count[i]++;
            }
        }
        SendDeathMessage(killerid, playerid, reason);
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, random(sizeof(count)));
    }
pawn Код:
if(killerid != INVALID_PLAYER_ID)
    {
        new count;
        for (new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                count++;
            }
        }
        SendDeathMessage(killerid, playerid, reason);
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, random(sizeof(count)));
    }



Re: random spec? - netanelbb - 11.05.2011

i have the same problem :/


Re: random spec? - jamesbond007 - 11.05.2011

bump


Re: random spec? - Jefff - 11.05.2011

pawn Код:
if(killerid != INVALID_PLAYER_ID)
{
    new Players[MAX_PLAYERS],count;
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && i != playerid)
        {
            Players[count] = i;
            count++;
        }
    }
    SendDeathMessage(killerid, playerid, reason);
    if(count)
    {
        TogglePlayerSpectating(playerid, 1);
        PlayerSpectatePlayer(playerid, Players[random(count)]);
    }
}