"Array out of bounds"
#1

pawn Code:
[debug] Run time error 4: "Array index out of bounds"
[debug]   Accessing element at index 4 past array upper bound 3
[debug] Backtrace:
[debug] #0  0002220c in ?? () from ExplosionDMV1.0.amx
[debug] #1  00017700 in public OnPlayerStateChange () from ExplosionDMV1.0.amx
And, OnPlayerStateChange:

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new aid = GetPlayerVehicleID(playerid);
        if(OnRekka(aid))
        {
            if(PlayerInfo[playerid][pTool] == 1)
            {
                SendClientMessage(playerid, C_ORANGE, "TEADE: Sa oled tццl, palun transpordi kaup!");
            }
            else
            {
                SendClientMessage(playerid, C_ORANGE, "TEADE: Et tццle asuda, kirjuta palun /tццle!");
            }
        }
        else if(OnAuto(aid))
        {
            if(PlayerInfo[playerid][pTool] == 1)
            {
                SendClientMessage(playerid, C_ORANGE, "TEADE: Sa oled tццl, palun transpordi kaup!");
            }
            else
            {
                SendClientMessage(playerid, C_ORANGE, "TEADE: Et tццle asuda, kirjuta palun /tццle!");
            }
        }
    }
    return 1;
}
Reply
#2

When player gets into the car, if the car is a truck (OnRekka), it sends the messages. Or else if, the car is a bobcat(OnAuto), sends some messages.
Reply
#3

pTool is 4 and you have declared PlayerInfo[MAX_PLAYERS][4], so there is only [0],[1],[2]and [3] (you reserved memory for 4 fields in that array)
extend your array to 5, so PlayerInfo[playerid][ptool] is valid

this is only a solution when ptool is 4 and is supposed to be 4
Reply
#4

new PlayerInfo[MAX_PLAYERS][pInfo];

So how should I change this?
Reply
#5

Show the enum pinfo
Reply
#6

where is pInfo declared/initialized?
a workaround would be using pInfo+1
but i'd rather not do that since it's confusing
Reply
#7

pawn Code:
enum pInfo
{
    pLogitud,
    pRegatud,
    pScore,
    pRaha,
    pAdmin,
    pHoiatus,
    pVargatase,
    pVtasemeni,
    pRekkatase,
    pRtasemeni,
    pIpod,
    pKanep,
    pIp,
    // NEED EI SALVESTU ENAM ДRA.
    pPearaha,
    pRooviraha,
    pVangis,
    pKasiinos,
    pAutopa,
    pJumal,
    pMuted,
    pTool,
    pLaheb,
    pTuleb,
    pRob
}

new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#8

Vini... you do that...
i didn't get into that enum stuff yet
Reply
#9

OnPlayerStateChange code looks correct.

But ,maybe , it is incorrect :

pawn Code:
pIp,
where appears these errors?
pawn Code:
[debug] Run time error 4: "Array index out of bounds"
[debug]   Accessing element at index 4 past array upper bound 3
[debug] Backtrace:
[debug] #0  0002220c in ?? () from ExplosionDMV1.0.amx
[debug] #1  00017700 in public OnPlayerStateChange () from ExplosionDMV1.0.amx
Reply
#10

Post these functions, OnRekka(aid), OnAuto(aid) And also the declarations of any arrays used in those funcs.

If indeed they use arrays that is...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)