Does anyone know how to fix this please?? -
Samieastwood - 16.11.2014
THIS HAPPENS WHEN SOMEONE CLICKS REGISTER & THEY CRASH TELL ME HOW TO FIX IT PLEASE
PHP код:
19:25:19] [debug] Run time error 4: "Array index out of bounds"
[19:25:19] [debug] Accessing element at index 999 past array upper bound 500
[19:25:19] [debug] AMX backtrace:
[19:25:19] [debug] #0 000760c0 in public OnPlayerStateChange (0, 1, 8) from pla.amx
[19:25:40] Unloading Leeo_Kee's vehicles.
[19:25:40] [part] Leeo_Kee has left the server (0:0)
OnPlayerStateChange Code
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate != 2) NOPTrigger[playerid] = 0;
if(IsPlayerNPC(playerid))
{
if(newstate == PLAYER_STATE_SPECTATING)
{
TogglePlayerSpectating(playerid, false);
}
return 1;
}
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
ShowSpeedo(playerid);
}
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
HideSpeedo(playerid);
}
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);
}
}
if(newstate == PLAYER_STATE_PASSENGER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 508)
{
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, "Objects loading...", 4000, 5);
SetPVarInt(playerid, "LoadingObjects", 1);
SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
SetPlayerPos(playerid, 2404.993164, -1512.187500, 898.142944);
SetPlayerFacingAngle(playerid, 0);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
Injourney[playerid] = GetPlayerVehicleID(playerid);
}
if(newstate == PLAYER_STATE_ONFOOT)
{
if(Audio_IsClientConnected(playerid))
{
Audio_Stop(playerid, stationidp[playerid]);
stationidp[playerid] = 0;
}
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 ) );
}
Re: Does anyone know how to fix this please?? -
HY - 16.11.2014
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate != 2) NOPTrigger[playerid] = 0;
if(IsPlayerNPC(playerid))
{
if(newstate == PLAYER_STATE_SPECTATING)
{
TogglePlayerSpectating(playerid, false);
}
return 1;
}
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
ShowSpeedo(playerid);
}
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
HideSpeedo(playerid);
}
if(GettingSpectated[playerid] != 499)
{
new spectator = GettingSpectated[playerid];
if(!IsPlayerConnected(spectator))
{
GettingSpectated[playerid] = 499;
Spectate[spectator] = 499;
}
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);
}
}
if(newstate == PLAYER_STATE_PASSENGER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 508)
{
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, "Objects loading...", 4000, 5);
SetPVarInt(playerid, "LoadingObjects", 1);
SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
SetPlayerPos(playerid, 2404.993164, -1512.187500, 898.142944);
SetPlayerFacingAngle(playerid, 0);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 1);
Injourney[playerid] = GetPlayerVehicleID(playerid);
}
if(newstate == PLAYER_STATE_ONFOOT)
{
if(Audio_IsClientConnected(playerid))
{
Audio_Stop(playerid, stationidp[playerid]);
stationidp[playerid] = 0;
}
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 ) );
}
I think your amount exceed 500. Try above code.
Re: Does anyone know how to fix this please?? -
Abagail - 16.11.2014
Simply check:
pawn Код:
if(IsPlayerConnected(playerid))
if they are connected.
And setting variables past MAX_PLAYERS shouldn't be an issue. If it was, it just wouldn't compile.
Re: Does anyone know how to fix this please?? -
Samieastwood - 16.11.2014
how do i check can you tell me what to do ?
Re: Does anyone know how to fix this please?? -
Samieastwood - 16.11.2014
says this now
PHP код:
19:46:05] Incoming connection: 86.25.160.28:50011
[19:46:05] [join] Samie_Kay has joined the server (0:86.25.160.28)
[19:46:14] Samie_Kay has logged in.
[19:46:14] Loading Samie_Kay's vehicles.
[19:46:14] [debug] Run time error 4: "Array index out of bounds"
[19:46:14] [debug] Accessing element at index 999 past array upper bound 499
[19:46:14] [debug] AMX backtrace:
[19:46:14] [debug] #0 00075904 in public OnPlayerStateChange (0, 8, 0) from pla.amx
Re: Does anyone know how to fix this please?? -
Samieastwood - 16.11.2014
need it fixed asap please?
Re : Does anyone know how to fix this please?? -
Dutheil - 16.11.2014
3 posts, congratulations
Re: Re : Does anyone know how to fix this please?? -
Samieastwood - 16.11.2014
what?
Re: Re : Does anyone know how to fix this please?? -
JaysonJee - 16.11.2014
i have the same problem!