SA-MP Forums Archive
Spectate other player after death. - 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: Spectate other player after death. (/showthread.php?tid=461758)



Spectate other player after death. - Thunderz01 - 03.09.2013

As my title above, I would like to script like this :

When you're lose or death because shooted by enemy, the camera should spectate the enemy for 5 second or until spawn back.
Someone can make script for this??


Re: Spectate other player after death. - Konstantinos - 03.09.2013

That should work.
pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
    if( killerid != INVALID_PLAYER_ID ) // if killer is valid player
    {
        TogglePlayerSpectating( playerid, 1 ); // toggle the spectate to enabled for playerid
        PlayerSpectatePlayer( playerid, killerid ); // spectate the killer
        SetTimerEx( "OnPlayerStopSpectate", 5000, false, "i", playerid ); // set a timer that in 5 seconds it will stop spectating
    }
    return 1;
}

forward OnPlayerStopSpectate( playerid );
public OnPlayerStopSpectate( playerid ) // This will be called after 5 seconds the timer has been set
{
    TogglePlayerSpectating( playerid, 0 ); // Toggling the spectate to disabled, player re-spawns automatically
}