Does anyone know how to fix this please??
#1

THIS HAPPENS WHEN SOMEONE CLICKS REGISTER & THEY CRASH TELL ME HOW TO FIX IT PLEASE
PHP код:
19:25:19] [debugRun 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] [debugAMX 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(playeridnewstateoldstate)
{
    if(
newstate != 2NOPTrigger[playerid] = 0;
    if(
IsPlayerNPC(playerid))
    {
        if(
newstate == PLAYER_STATE_SPECTATING)
        {
            
TogglePlayerSpectating(playeridfalse);
        }
        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] >= || newstate == PLAYER_STATE_PASSENGER && PlayerInfo[spectator][pAdmin] >= 2)
        {
            
TogglePlayerSpectating(spectatortrue);
            new 
carid GetPlayerVehicleIDplayerid );
            
PlayerSpectateVehiclespectatorcarid );
            
SetPVarInt(spectator"SpecState"newstate);
        }
        else if(
newstate == PLAYER_STATE_ONFOOT && PlayerInfo[spectator][pAdmin] >= 2)
        {
            
TogglePlayerSpectating(spectatortrue);
               
PlayerSpectatePlayerspectatorplayerid );
               
SetPlayerInteriorspectatorGetPlayerInteriorplayerid ) );
            
SetPVarInt(spectator"SpecState"newstate);
        }
    }
    if(
newstate == PLAYER_STATE_PASSENGER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 508)
    {
        
TogglePlayerControllable(playerid0);
        
GameTextForPlayer(playerid"Objects loading..."40005);
         
SetPVarInt(playerid"LoadingObjects"1);
          
SetTimerEx("SafeLoadObjects"40000"d"playerid);
         
SetPlayerPos(playerid2404.993164, -1512.187500898.142944);
         
SetPlayerFacingAngle(playerid0);
        
SetCameraBehindPlayer(playerid);
        
SetPlayerInterior(playerid1);
        
Injourney[playerid] = GetPlayerVehicleID(playerid);
    }
    if(
newstate == PLAYER_STATE_ONFOOT)
    {
         if(
Audio_IsClientConnected(playerid))
        {
            
Audio_Stop(playeridstationidp[playerid]);
             
stationidp[playerid] = 0;
        }
        new 
spectator GettingSpectated[playerid];
        if(
PlayerInfo[spectator][pAdmin] >= 2) {
            
// Preventing possible buffer overflows with the arrays
             
TogglePlayerSpectating(spectatortrue);
            
PlayerSpectatePlayerspectatorplayerid );
            
SetPlayerInteriorspectatorGetPlayerInteriorplayerid ) );
            
SetPVarInt(spectator"SpecState"newstate);
            
SetPlayerInteriorspectatorGetPlayerInteriorplayerid ) );
            
SetPlayerVirtualWorldspectatorGetPlayerVirtualWorldplayerid ) );
        } 
Reply
#2

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.
Reply
#3

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.
Reply
#4

how do i check can you tell me what to do ?
Reply
#5

says this now
PHP код:
19:46:05Incoming connection86.25.160.28:50011
[19:46:05] [joinSamie_Kay has joined the server (0:86.25.160.28)
[
19:46:14Samie_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 
Reply
#6

need it fixed asap please?
Reply
#7

3 posts, congratulations
Reply
#8

what?
Reply
#9

i have the same problem!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)