Spectating
#1

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..
Reply
#2

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;
}
Reply
#3

bump
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)