*** Terrible Title Removed
#1

Код:
22:34:01] [death] Dan died 255
[22:34:05] [debug] Run time error 4: "Array index out of bounds"
[22:34:05] [debug]  Accessing element at index 999 past array upper bound 500
[22:34:05] [debug] AMX backtrace:
[22:34:05] [debug] #0 000661e8 in public OnPlayerStateChange () from EG-RP.amx
Happens When i die
Код:
22:31:15] [debug] Run time error 4: "Array index out of bounds"
[22:31:15] [debug]  Accessing element at index 999 past array upper bound 500
[22:31:15] [debug] AMX backtrace:
[22:31:15] [debug] #0 000661e8 in public OnPlayerStateChange () from EG-RP.amx
When ANYBODY logs into the server
Reply
#2

show me public OnPlayerStateChange
Reply
#3

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(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_ONFOOT)
    {
        if(Audio_IsClientConnected(playerid))
        {
            Audio_Stop(playerid, stationidp[playerid]);
            stationidp[playerid] = 0;
        }
This is a big part of it
Reply
#4

Bump :/
N.B: After 3 days
Reply
#5

Try changing those 999 to INVALID_PLAYER_ID (all 999)

ex : if(GettingSpectated[playerid] != INVALID_PLAYER_ID)
Reply
#6

I changed it but that time i couldn't log in
Reply
#7

Show me where you create:
Spectate[spectator] = 999;

Because if spectator is 999 it does this:
Spectate[999] and i think this is why it crash, but if you show me where you create this array I can have a better look at it.
Reply
#8

Do you mean this:
pawn Код:
}
    if(GettingSpectated[playerid] != 999)
    {
        new spectator = GettingSpectated[playerid];
        if(!IsPlayerConnected(spectator))
        {
            GettingSpectated[playerid] = 999;
            Spectate[spectator] = 999;
        }
Reply
#9

No where do you define Spectate[spectator]?
like
pawn Код:
new Spectate[SOME NUMBER];
Index out of bounds means that you somewhere are using a number inside a array that isn't exist like,
pawn Код:
new AnArray[10];
AnArray[11] = 1;
This will crash you gamemode.
Reply
#10

It doesn't crash it just show errors but if you want this it may help:
pawn Код:
new Spectate[MAX_PLAYERS];
new GettingSpectated[MAX_PLAYERS];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)