SA-MP Forums Archive
[Help]Spectating system! - 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)
+--- Thread: [Help]Spectating system! (/showthread.php?tid=312686)



[Help]Spectating system! - Zhoom - 22.01.2012

Hello guys! Can someone tell me how to make a spectating system? Like after the players has died, and if they click FIRE, he will spectate other players randomly. Please help me guys!
Thanks.


Re: [Help]Spectating system! - Konstantinos - 22.01.2012

PlayerSpectatePlayer


Re: [Help]Spectating system! - [HK]Ryder[AN] - 22.01.2012

1.For a spectating system note that there is a spec f that comes already when you download the server package.
2.For specing when he press key use OnPlayerKeyStateChange and OnPlayerDeath when he dies.
EDIT - I was a little late


Re: [Help]Spectating system! - Zhoom - 22.01.2012

this is my script:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((newkeys & KEY_FIRE))
    {
    if(PlayerInfo[playerid][Youdead] == 1)
    {
    new ranplayer;
    ranplayer = random(500);
    SetPlayerColor(playerid,COLOR_GREY);
    while(!IsPlayerConnected(ranplayer))
    {
        ranplayer = random(500);
     }
    TogglePlayerSpectating(playerid, 1);
    PlayerSpectatePlayer(playerid, ranplayer);
    }
    }
    return 1;
}
I dont know why it doesnt works. Help please


Re: [Help]Spectating system! - Zhoom - 22.01.2012

bump! help me please


Re: [Help]Spectating system! - MP2 - 22.01.2012

You need a proper RandomPlayer() function. If you have 3 players online (ID 0 1 2) and you run that, it may take hours for it to return 0 1 or 2.


Re: [Help]Spectating system! - Zhoom - 23.01.2012

can you give me that script please? i dont know how to do it


Re: [Help]Spectating system! - Snowman12 - 23.01.2012

pawn Код:
stock RandomPlayer()
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    /* Success you have 1 player online :P */
                    return i;
                }
            }
            else return 0;
        }



Re: [Help]Spectating system! - Zhoom - 23.01.2012

i tried adding some script on "/* Success you have 1 player online :P */" and failed
can you give me the full script of it please?