21.01.2012, 14:02
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;
}