19.09.2015, 17:53
hello guys i have a problem when a player dies he will spectate a random alive player works but when the other map loads and function spectateoff called the server crash plz help
thnx and sorry for my bad english
pawn Код:
forward SpectateOn(playerid);
public SpectateOn(playerid)
{
print("SpectateOn");
for(new i=0; i<MAX_PLAYERS; i++)
{
if(Player[i][IsPlaying] && playerid != i)
{
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, i);
SetPlayerInterior(playerid, GetPlayerInterior(i));
PlayerSpectateVehicle(playerid, Player[i][VehicleID]);
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(i));
Player[playerid][SpectateID] = i;
}
}
new str[128];
if(Player[playerid][SpectateID] != -1)
{
format(str, 128, "You are now spectating %s (ID:%d).", PlayerName(Player[playerid][SpectateID]), Player[playerid][SpectateID]);
SendClientMessage(playerid, COLOR_WHITE, str);
}
return 1;
}
forward SpectateOff(playerid);
public SpectateOff(playerid)
{
print("SpectateOff");
TogglePlayerSpectating(playerid, 0);
Player[playerid][SpectateID] = -1;
SendClientMessage(playerid, COLOR_WHITE, "You stopped spectating.");
return 1;
}