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
#2

On the last one, do you check if GettingSpectated[playerid] is not 999? If not, do that to prevent it.
Reply
#3

So make it GettingSpectated[playerid] != INVAILD_PLAYER_ID?
Reply
#4

Not INVALID_PLAYER_ID but 999 instead.
pawn Код:
if(GettingSpectated[playerid] != 999)
{
    // second code here
}
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Not INVALID_PLAYER_ID but 999 instead.
pawn Код:
if(GettingSpectated[playerid] != 999)
{
    // second code here
}
doing now this

Код:
[22:21:55] [debug] Server crashed while executing UGRP.amx
[22:21:55] [debug] AMX backtrace:
[22:21:55] [debug] #0 ffffffff in public OnPlayerClickMap () from UGRP.amx
Reply
#6

help
Reply
#7

Posting OnPlayerClickMap callback would be helpful.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Posting OnPlayerClickMap callback would be helpful.
The problem I dont have this call back in the script and my plugins are streamer 2.7.1 and sscanf
Reply
#9

?
Reply
#10

NO ONE
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)