OnPlayerStateChange Crashdetect problem!
#1

I have a problem every time i login the server crash because of the OnPlayerStateChange

Crashdetect code:
Код:
[20:48:58] [debug] Run time error 4: "Array index out of bounds"
[20:48:58] [debug]  Accessing element at index 999 past array upper bound 500
[20:48:58] [debug] AMX backtrace:
[20:48:58] [debug] #0 0007cdac in public OnPlayerStateChange (0x00000000, 0x00000001, 0x00000008) from UGRP.amx
[20:49:06] [debug] Server crashed while executing UGRP.amx
The code that doing it:
Код:
if(GettingSpectated[playerid] != 999)
	{
	    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)
	    {
	        TogglePlayerSpectating(spectator, true);
			new carid = GetPlayerVehicleID( playerid );
			PlayerSpectateVehicle( spectator, carid );
			SetPVarInt(spectator, "SpecState", newstate);
	    }
	    else if(newstate == PLAYER_STATE_ONFOOT && PlayerInfo[spectator][pAdmin] >= 2)
	    {
	        TogglePlayerSpectating(spectator, true);
		   	PlayerSpectatePlayer( spectator, playerid );
		   	SetPlayerInterior( spectator, GetPlayerInterior( playerid ) );
			SetPVarInt(spectator, "SpecState", newstate);
	    }
	}
or this

Код:
new spectator = GettingSpectated[playerid];
	    if(PlayerInfo[spectator][pAdmin] >= 2) {
	        // Preventing possible buffer overflows with the arrays
	 		TogglePlayerSpectating(spectator, true);
			PlayerSpectatePlayer( spectator, playerid );
			SetPlayerInterior( spectator, GetPlayerInterior( playerid ) );
			SetPVarInt(spectator, "SpecState", newstate);
			SetPlayerInterior( spectator, GetPlayerInterior( playerid ) );
			SetPlayerVirtualWorld( spectator, GetPlayerVirtualWorld( playerid ) );
		}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)