SA-MP Forums Archive
How do I do this? - 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: How do I do this? (/showthread.php?tid=559067)



How do I do this? - _Application_ - 20.01.2015

I created a code as a player kills player other he watch it (spectate), but how do I do that I can scroll through the players mouse

I mean watch another player with the possibility (forward backward)


sorry my bad english


Re: How do I do this? - nezo2001 - 20.01.2015

PHP код:
new SpectatedPlayer[MAX_PLAYERS]; 
PHP код:
forward SpectateNext(playerid);
public 
SpectateNext(playerid)
{
        
SpectatedPlayer[playerid]++;
        for(new 
i=SpectatedPlayer[playerid]; i<MAX_PLAYERSi++)
        {
                if(!
IsPlayerConnected(i)) continue;
                if(
IsPlayerInAnyVehicle(i))
                {
                        
PlayerSpectateVehicle(playeridGetPlayerVehicleID(i));
                }
                else
                {
                        
PlayerSpectatePlayer(playeridi);
                }
                
SpectatedPlayer[playerid] = i;
                break;
        }
        new 
str[128];
        
format(str128"Spectate: ON (%s (%d) )"PlayerName(SpectatedPlayer[playerid]), SpectatedPlayer[playerid]);
        
SendClientMessage(playeridCOLOR_REDstr);
}

forward SpectatePrevious(playerid);
public 
SpectatePrevious(playerid)
{
    
SpectatedPlayer[playerid]--;
        for(new 
i=SpectatedPlayer[playerid]; i>-1i--)
        {
                if(!
IsPlayerConnected(i)) continue;
                if(
IsPlayerInAnyVehicle(i))
                {
                        
PlayerSpectateVehicle(playeridGetPlayerVehicleID(i));
                }
                else
                {
                        
PlayerSpectatePlayer(playeridi);
                }
                
SpectatedPlayer[playerid] = i;
                break;
        }
        new 
str[128];
        
format(str128"Spectate: ON (%s (%d) )"PlayerName(SpectatedPlayer[playerid]), SpectatedPlayer[playerid]);
        
SendClientMessage(playeridCOLOR_REDstr);

Scripted by Axey
If there any missing part just tell me....