SA-MP Forums Archive
*** Terrible Title Removed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: *** Terrible Title Removed (/showthread.php?tid=384921)



*** Terrible Title Removed - Red_Dragon. - 13.10.2012

Код:
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


Re: Server log errors ! - Kirollos - 13.10.2012

show me public OnPlayerStateChange


Re: Server log errors ! - Red_Dragon. - 14.10.2012

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


Re: Server log errors ! - Red_Dragon. - 17.10.2012

Bump :/
N.B: After 3 days


Re : Server log errors ! - yusei - 17.10.2012

Try changing those 999 to INVALID_PLAYER_ID (all 999)

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


Re: Server log errors ! - Red_Dragon. - 18.10.2012

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


Re: Server log errors ! - Roel - 18.10.2012

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.


Re: Server log errors ! - Red_Dragon. - 18.10.2012

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



Re: Server log errors ! - Roel - 18.10.2012

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.


Re: Server log errors ! - Red_Dragon. - 18.10.2012

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];