16.11.2014, 18:39
THIS HAPPENS WHEN SOMEONE CLICKS REGISTER & THEY CRASH TELL ME HOW TO FIX IT PLEASE
OnPlayerStateChange Code
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)
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 ) );
}