07.08.2013, 02:43
Here you're getting the spectated which I believe can return as 999, and later you're accessing PlayerInfo[spectator][pAdmin] without checking if it equals 999, there's probably more of this happening too but that's one instance of it and I'm not going to go over all your script.
A quick note for future proofing, I would set the invalid to -1 because in case your server slots increase to 1000 and the server fills up then you'll be running into problems, however player slots won't ever start from -1 so you wouldn't run into any problems in the future.
Also you could use a define instead of hardcoding and that way you wouldn't have to change all your 999's
This solution was posted by cessil in one of my old threads which I had the same problem as you.
A quick note for future proofing, I would set the invalid to -1 because in case your server slots increase to 1000 and the server fills up then you'll be running into problems, however player slots won't ever start from -1 so you wouldn't run into any problems in the future.
Also you could use a define instead of hardcoding and that way you wouldn't have to change all your 999's
pawn Код:
new spectator = GettingSpectated[playerid];
if(!IsPlayerConnected(spectator))
{
GettingSpectated[playerid] = 999;
Spectate[spectator] = 999;
}
if(newstate == PLAYER_STATE_DRIVER && PlayerInfo[spectator][pAdmin] >= 2 || newstate == PLAYER_STATE_PASSENGER && PlayerInfo[spectator][pAdmin] >= 2)
{