Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Run-time error 9: Subscript out of range


Kaejer
 Share

Recommended Posts

Hey again, well I actually hit something that I have no idea how to debug. I made 2 resource trees next to each other on a map and the server crashed and reported Run-time error 9: Subscript out of range.

Here is the line of code it pointed to:
```
ResourceCache(mapnum).ResourceData(Resource_Count).cur_health = Resource(Map(mapnum).Tile(x, y).Data1).health
```
Any idea on how to fix it? I do have a decent amount of resources if there's a max somewhere for that on an entire game. Actually, switching it from 100 to 500 max, it still gives the same error.

Worst case scenario I could just delete the map, I suppose.

Figured it out. I had to edit this code in server and client:
```
Public Const TILE_TYPE_RESOURCE As Byte = 7
```
EDIT: Nevermind, all it did was allow it to run and then it crashed when I tried to make a resource again.
Link to comment
Share on other sites

I do believe this has to do with you changing something in the data storage, but not having converted over the files or everything else accordingly. It's trying to read memory where it doesn't exist, or assign it so it just throws up this error, at least in my experience.
Link to comment
Share on other sites

Zerohero: I don't have any custom code that deals with resources or skills. The only code that I have that really deals with any data is something that changes sprites based on HP, but it's been in there for a while with no errors.

Joyce: I'm not sure where I could have done that, but how would I find out if that's the case?

I dunno if this matters to the error, but when I came back the one time the map didn't have either of the resources I had placed earlier.

EDIT: I edited this line of code:
```
Public Const TILE_TYPE_RESOURCE As Byte = 7
```and made it 70 instead of 7 the first time and it worked. This time I switched it back to 7 and it worked again. I don't feel like making another resource to see if it'll crash again unless anyone has any ideas on how to fix it.
Link to comment
Share on other sites

@Kaejer:

> and made it 70 instead of 7 the first time and it worked. This time I switched it back to 7 and it worked again. I don't feel like making another resource to see if it'll crash again unless anyone has any ideas on how to fix it.

I think this error occurs when you put down a resource without selecting a resource number (i.e., you place a resource tile down without clicking "OK" on the popup box). It's probably just a quick fix in the source code, or even just making the selection box vbModal.

If you want, you could go create a test map, try to replicate it, and then send the map to me via PM. I made a tool to fix it back when this error was popping up every other week.
Link to comment
Share on other sites

Ok now all of the sudden I can't replicate the bug. Before all I did was put down 2 resources and it exploded. Now I can't get it to crash. If I have the problem again I'll pm you with a map that contains the error (which appears to be temporary some how?)
Link to comment
Share on other sites

It's a very random and elusive error that can usually be fixed by deleting your maps, I haven't a proper clue how, where or why it appears. But it does when you do something you shouldn't.

But glad to know it's sorted. :]
Link to comment
Share on other sites

  • 2 months later...
Nvm.. I forgot to remove the layer I orginally wanted to add but couldn't, over-reacted, freaked.. (I've done 2 all nighters in the past 3 days working on my project).. I'm shattered, sorry for the hassle.. But omg, did I REALLY just do that.. LOOOOOOOOOOOOOOOOOOOOOOOOOOOOL!!!!1 ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...