"Array out of bounds" -
Dan. - 27.04.2012
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;
}
Re: "Array out of bounds" -
Dan. - 27.04.2012
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.
Re: "Array out of bounds" -
Falco-Ger - 27.04.2012
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
Re: "Array out of bounds" -
Dan. - 27.04.2012
new PlayerInfo[MAX_PLAYERS][pInfo];
So how should I change this?
Re: "Array out of bounds" -
ViniBorn - 27.04.2012
Show the enum pinfo
Re: "Array out of bounds" -
Falco-Ger - 27.04.2012
where is pInfo declared/initialized?
a workaround would be using pInfo+1
but i'd rather not do that since it's confusing
Re: "Array out of bounds" -
Dan. - 27.04.2012
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];
Re: "Array out of bounds" -
Falco-Ger - 27.04.2012
Vini... you do that...
i didn't get into that enum stuff yet
Re: "Array out of bounds" -
ViniBorn - 27.04.2012
OnPlayerStateChange code looks correct.
But ,maybe , it is incorrect :
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
Re: "Array out of bounds" -
iggy1 - 27.04.2012
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...