Array Index out of Bounds error in include
#1

Dear Members,

I was coding an include for someone. Everytime i use a stock function from the include in a .pwn file. It gives me error in each function used.

The error is:
Код:
C:\Users\ABC\Desktop\boombox.inc(75) : error 032: array index out of bounds (variable "BoomBox")
You can download the source code from here.

Note: Each time a stock is called from the include in any script. I get this error. That means if i call 2 functions then two same errors are shown.

Is there anything which i am doing wrong? I am not that good at coding includes. Kinda a newbie you can say. I know what to do when this error comes and even why. But why am i seeing it here? I hope somebody can help me.

Regards,
Ballu Miaa
Reply
#2

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Dear Members,

I was coding an include for someone. Everytime i use a stock function from the include in a .pwn file. It gives me error in each function used.

The error is:
Код:
C:\Users\ABC\Desktop\boombox.inc(75) : error 032: array index out of bounds (variable "BoomBox")
You can download the source code from here.

Note: Each time a stock is called from the include in any script. I get this error. That means if i call 2 functions then two same errors are shown.

Is there anything which i am doing wrong? I am not that good at coding includes. Kinda a newbie you can say. I know what to do when this error comes and even why. But why am i seeing it here? I hope somebody can help me.

Regards,
Ballu Miaa
might be you have used your boombox variable in a huge manner [ that doesnt mean that you have used every where] ,it might be cuz you have proceeded the number to limit of the array size, recheck your include Cuz the errors you get in include is the same as errors you get in pawno so just check once and tell me
Reply
#3

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
might be you have used your boombox variable in a huge manner [ that doesnt mean that you have used every where] ,it might be cuz you have proceeded the number to limit of the array size, recheck your include Cuz the errors you get in include is the same as errors you get in pawno so just check once and tell me
Nothing worked out. Its the correct syntax for arrays along with an enum. Everything seems fine. I am still wondering if something i've done or wrong or not. I converted this inc into an FS and same thing. Well i do it this way and everything works all the time.
Reply
#4

I also spotted this problem. Let me explain you why this happens.

for example
pawn Код:
new players[MAX_PLAYERS];
now I have define a global variable above.
if i type this on player connected

pawn Код:
players[MAX_PLAYERS] ++;
It will give me a error of index out of bound. The correct way is.

pawn Код:
players[playerid] ++;
Conclusion : You don't have to reach the limit of array or get out of the array bounds.

If this still don't help you. Give us your BoomBox variable. Where ever you typed.
Reply
#5

Quote:
Originally Posted by Champ
Посмотреть сообщение
I also spotted this problem. Let me explain you why this happens.

for example
pawn Код:
new players[MAX_PLAYERS];
now I have define a global variable above.
if i type this on player connected

pawn Код:
players[MAX_PLAYERS] ++;
It will give me a error of index out of bound. The correct way is.

pawn Код:
players[playerid] ++;
Conclusion : You don't have to reach the limit of array or get out of the array bounds.

If this still don't help you. Give us your BoomBox variable. Where ever you typed.
Well bro thanks for trying to help but i already know all that and am using the array the correct way. Well if you wanna help. Check the source.

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Reply
#6

Sorry bro,
There is a error in downloading. Please reupload.

and has your problem fixed or not ?
Reply
#7

the download is not working
Reply
#8

Uhh i am sorry . Here's the pastebin.

Note: I am redoing the include in an FS the same way i coded that include with different names of all variables. So i first did CreateBoombox function only the same way and now it works fine. Without any warning or error. Thats wierd.
Reply
#9

if it is fixed then don't leak your include
Reply
#10

Hello, Ballu Miaa, I guess I found the problem you're facing :P, I see no arrays but I saw your enumerator[/b] I believe Enumerator won't accept -1 only for normal variables, so I'm guessing you need to make it -1 when the player joins, I suggest you using y_hooks



Untested No Error Code
pawn Код:
Problem Solved, He requested me to remove the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)