Raised This Month: $ Target: $400
 0% 

array index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bone
Member
Join Date: Mar 2005
Location: Under your bed
Old 04-14-2005 , 18:01   array index out of bounds
Reply With Quote #1

I am trying edit Ava's plugin so the new ATMS in mecklenburg work, the code i put in was

Code:
 new bankposX[3] = { -2504, 680, 275 };  new bankposY[3] = { 1072,-430, -430 };  new bankposZ[3] = { -400, -345, -345 };  new bankposA[3] = { 585, -778, 292 };  new bankposB[3] = { -2135, 2642, -344 };  new bankposC[3] = { -3605, 2645, -1179 };

Code:
        }         new origin[3], checkorigin[3], validpos;         get_user_origin(id,origin);         // check if player is near an ATM         for(new i=0;i<sizeof(bankposX);i++) {             checkorigin[0] = bankposX[i];             checkorigin[1] = bankposY[i];             checkorigin[2] = bankposZ[i];                         checkorigin[3] = bankposA[i];                         checkorigin[4] = bankposB[i];                         checkorigin[5] = bankposC[i];             if(get_distance(origin,checkorigin) <= 48) {                 validpos = 1;             }         }

and i get array index out of bounds which is somehow being caused by the new backposA,B and C arrays, can someone please help my problem. thanks
__________________
the shirt covered her face, she screamed and clawed, so billy stomped on the bitch until he broke in her jaw.
Bone is offline
Send a message via MSN to Bone
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-14-2005 , 18:19   Re: array index out of bounds
Reply With Quote #2

Quote:
Originally Posted by Bone
I am trying edit Ava's plugin so the new ATMS in mecklenburg work, the code i put in was

Code:
//[...]     new checkorigin[3] // [...]     checkorigin[3] = bankposA[i];     checkorigin[4] = bankposB[i];     checkorigin[5] = bankposC[i]; // [...]

and i get array index out of bounds which is somehow being caused by the new backposA,B and C arrays, can someone please help my problem. thanks
(look at indexes..)
xeroblood is offline
Send a message via MSN to xeroblood
Bone
Member
Join Date: Mar 2005
Location: Under your bed
Old 04-14-2005 , 19:12  
Reply With Quote #3

what?

what do you mean
__________________
the shirt covered her face, she screamed and clawed, so billy stomped on the bitch until he broke in her jaw.
Bone is offline
Send a message via MSN to Bone
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-14-2005 , 21:16  
Reply With Quote #4

Edit:

x Removed by me
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-14-2005 , 22:13  
Reply With Quote #5

v3x, do you even understand what you tell people?!

Creating an array with 5 dimensions and then using a function to compare vectors (3 dimensions) is supposed to work?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-14-2005 , 22:26  
Reply With Quote #6

Oh, I misread it.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-14-2005 , 23:12  
Reply With Quote #7

Quote:
Originally Posted by Bone
what?

what do you mean
What I meant was that you tried to access an index of the array that is out-of-bounds.. fortunately, that is exactly what the compiler tells you!!

If you declare an array of 3 values, then you can only access the array with 3 indexes (namely: 0, 1, 2)

But what you did is create an array of 3, and then tried accessing 6 indexes (namely: 0, 1, 2, 3, 4, 5).. look here in your code:

Code:
 new origin[3], checkorigin[3], validpos; //[...]             checkorigin[0] = bankposX[i];             checkorigin[1] = bankposY[i];             checkorigin[2] = bankposZ[i];             checkorigin[3] = bankposA[i];             checkorigin[4] = bankposB[i];             checkorigin[5] = bankposC[i];

The 'checkorigin' is only an array of 3, but you are trying to access 6 indexes..

Solution: make two different arrays of 3, or make the one array an array of 6..

I hope that helps..
xeroblood is offline
Send a message via MSN to xeroblood
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-15-2005 , 10:24  
Reply With Quote #8

A better solution would be to make some sort of system for which to lay your own NPC's, instead of hard coding coordinates, and then loading the saved NPC's on server start.

Also, it would be really cool if the NPC's moved, if you could set their model in game, tell them what to say in game, make them allsay and do and be different things, and if they were hooked into a working inventory mod.

http://forums.alliedmods.net/showthread.php?t=5037
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Bone
Member
Join Date: Mar 2005
Location: Under your bed
Old 04-15-2005 , 11:00  
Reply With Quote #9

ok i made neworigin and origin 6 like

Code:
new origin[6], checkorigin[6], validpos; //[...]             checkorigin[0] = bankposX[i];             checkorigin[1] = bankposY[i];             checkorigin[2] = bankposZ[i];             checkorigin[3] = bankposA[i];             checkorigin[4] = bankposB[i];             checkorigin[5] = bankposC[i];

but it says array sizes must match AND array index is out of bounds ....
__________________
the shirt covered her face, she screamed and clawed, so billy stomped on the bitch until he broke in her jaw.
Bone is offline
Send a message via MSN to Bone
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-15-2005 , 11:14  
Reply With Quote #10

You'll need to post more of your code so we can see whats going on..
xeroblood is offline
Send a message via MSN to xeroblood
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode