run time error 4 -
PinAxXx - 14.05.2015
[23:01:17] [debug] Run time error 4: "Array index out of bounds"
[23:01:17] [debug] Accessing element at index 78 past array upper bound 77
[23:01:17] [debug] AMX backtrace:
[23:01:17] [debug] #0 0028bfec in public CustomPickups () at D:\Gta-Sv-Run\gamemodes\rlrp.pwn:46139
code in gamemode
for(new h = 0; h < sizeof(BizzInfo); h++)
{
if(BizzInfo[h][bOwned] == 0)
{
format(string, sizeof(string), "{00b4ff}Biz %d \n{FFFFFF}%s \n{00b4ff}This Business is for sale \n Cost: {FFFFFF}$%s \n{00b4ff}Level: {FFFFFF}%d \n{00b4ff}Entrance Fee: {FFFFFF}$%s \n{00b4ff}to buy this Business type {FFFFFF}/buybiz",BizzInfo[h],BizzInfo[h][bMessage],FormatNumber(BizzInfo[h][bBuyPrice]),BizzInfo[h][bLevelNeeded],FormatNumber(BizzInfo[h][bEntranceCost]));
UpdateDynamic3DTextLabelText(bizer[h], COLOR_BIZ, string);
}
else if(BizzInfo[h][bOwned] == 1)
{
format(string, sizeof(string), "{00b4ff}Biz %d \n{FFFFFF}%s \n{00b4ff}Owner: {FFFFFF}%s \n{00b4ff}Level: {FFFFFF}%d \n{00b4ff}Entrance Fee: {FFFFFF}$%s \n{00b4ff}Type: {FFFFFF}/enter to enter",BizzInfo[h],BizzInfo[h][bMessage],BizzInfo[h][bOwner],BizzInfo[h][bLevelNeeded],FormatNumber(BizzInfo[h][bEntranceCost]));
UpdateDynamic3DTextLabelText(bizer[h], COLOR_BIZ, string);
}
else if(BizzInfo[h][bOwned] == 2)
{
format(string, sizeof(string), "{00b4ff}Biz %d \n{FFFFFF}%s \n{00b4ff}This Business is for sale \n{00b4ff}Owner: {FFFFFF}%s \n{00b4ff}Level: {FFFFFF}%d \n{00b4ff}Entrance Fee: {FFFFFF}$%s \n{00b4ff}Cost: {FFFFFF}$%s \n{00b4ff}Type: {FFFFFF}/buybiz to buy",BizzInfo[h],BizzInfo[h][bMessage],BizzInfo[h][bOwner],BizzInfo[h][bLevelNeeded],FormatNumber(BizzInfo[h][bEntranceCost]),FormatNumber(BizzInfo[h][bForosh]));
UpdateDynamic3DTextLabelText(bizer[h], COLOR_BIZ, string);
}
}
line 46139 = UpdateDynamic3DTextLabelText(bizer[h], COLOR_BIZ, string);
Re: run time error 4 -
Konstantinos - 14.05.2015
The size of
bizer must be equal to the size of
BizzInfo.
Re: run time error 4 -
PinAxXx - 14.05.2015
Quote:
Originally Posted by Konstantinos
The size of bizer must be equal to the size of BizzInfo.
|
How To fix it .
pls help me more.
Re: run time error 4 -
Konstantinos - 14.05.2015
That's actually pretty basic. Read more about arrays:
https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
So if you do something like this (an example):
pawn Код:
new BizzInfo[100][e_BizzInfo];
new Text3D:bizer[78];
it will loop as the size of
BizzInfo which in your case is 100 but the size of
bizer is 78 so the last valid index is 77 and it exceeds; thus causing the run time error. Use the same size or you can even do:
pawn Код:
new BizzInfo[100][e_BizzInfo];
new Text3D:bizer[sizeof (BizzInfo)];