SA-MP Forums Archive
Spectating - 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: Spectating (/showthread.php?tid=312411)



Spectating - spd_sahil - 21.01.2012

Okay so i was making this command to spectate players from only a certain teams.. and leave all the rest.. what kind of logic should i use ??

should i put all the players in those team in a different array or something ...

also i want to use buttons to change the player being speced.. i hardly have ideas about buttons and how this will be done..


Re: Spectating - spd_sahil - 21.01.2012

Okay This is something i worked out.. this is Untested.. can anyone check it ??



pawn Код:
new Spects[MAX_PLAYERS];
new player[MAX_PLAYERS];
new counter;
new current[MAX_PLAYERS];


public OnPlayerSpawn(playerid)
{
    if(Team[playerid] != 3) // the team not be seen in the spec
    {
        if(Spects[playerid] != 1)
        {
            player[counter+1] = playerid;
            counter++;
        }
    }
}

dcmd_start(playerid,params[]) // a command which enable the use of the spec command
{
            #pragma unused params
            counter = 0;
        for(new i;i<MAX_PLAYERS;i++)
        {
            if(IsPlayerConnected(i) && Team[i] != 3)
            {
                Spects[i] = 1;
                player[counter] = i;
                counter++;
        }
         }
}

dcmd_spec(playerid,params[])
{
    #pragma unused params
    if(Team[playerid] == 3 && WarStart == 1)
    {
        TogglePlayerSpectating(playerid,1);
            PlayerSpectatePlayer(playerid,player[0]);
            current[playerid] = 0;
        return 1;
    }
    return 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if((newkeys & KEY_RIGHT) && Team[playerid] == 3 && WarStart == 1)
    {
        if(current[playerid] < counter)
        {
            PlayerSpectatePlayer(playerid,player[current[playerid]+1]);
            current[playerid]++;
        }
        if(current[playerid] == counter)
        {
            PlayerSpectatePlayer(playerid,player[0]);
            current[playerid] = 0;
        }
    }
    if((newkeys & KEY_LEFT) && Team[playerid] == 3 && WarStart == 1)
    {
        if(current[playerid] > 0)
        {
            PlayerSpectatePlayer(playerid,player[current[playerid]-1]);
            current[playerid]--;
        }
        if(current[playerid] == 0)
        {
            PlayerSpectatePlayer(playerid,player[counter]);
            current[playerid] = counter;
        }
    }
    return 1;
}



Re: Spectating - spd_sahil - 21.01.2012

bump