01.08.2010, 06:43
Foreach is faster and simpler than a regular loop. Indent your code properly and the issue is easily visible.
pawn Код:
public Spectator()
{
foreach (Player, i)
{
if(PlayerInfo[i][pAdmin] >= 1 && Specing[i] == 1)
{
SetPlayerColor(i,COLOR_SPEC);
TogglePlayerControllable(i, 0);
new targetid = Spectate[i];
if(IsPlayerConnected(targetid))
{
TogglePlayerSpectating(i, 1);
if(PlayerInfo[i][pAdmin] >= 1)
{
if(IsPlayerInAnyVehicle(targetid))
{
new carid = GetPlayerVehicleID(targetid);
PlayerSpectateVehicle(i, carid);
}
else
{
PlayerSpectatePlayer(i, targetid);
}
if(GetPlayerInterior(targetid) != GetPlayerInterior(i))
{
SetPlayerInterior(i,0);
}
}
}
if(Spectate[i] == 254)
{
TogglePlayerControllable(i, 1);
SetPlayerInterior(i,Unspec[i][sPint]);
PlayerInfo[i][pInt] = Unspec[i][sPint];
PlayerInfo[i][pLocal] = Unspec[i][sLocal];
SetPlayerPos(i, Unspec[i][sPx], Unspec[i][sPy], Unspec[i][sPz]);
Spectate[i] = 255;
}
if(Spectate[i] == 256)
{
SetPlayerToTeamColor(i);
Spectate[i] = 255;
}
if(Spectate[i] == 257)
{
Spectate[i] = 254;
}
}
}
}