Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 12:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Index was outside the bounds of the array

Discussion on Index was outside the bounds of the array within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2010
Posts: 951
Received Thanks: 76
Index was outside the bounds of the array

Code:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Conquer.Server.LoadNewMonsters(UInt32 id) in D:\Conquer\Conquer\System\Server.cs:line 477
Code:
        public static void LoadNewMonsters(uint id)
        {
            try
            {
                Game.MsgMonster.MobCollection colletion = new Game.MsgMonster.MobCollection(id);
                if (colletion.ReadMap())
                {
                    string[] text = System.IO.File.ReadAllLines(Program.ServerConfig.DbLocation + "MonsterSpawns\\NewMonster.txt");
                    foreach (string line in text)
                    {
                        string[] data = line.Split(' ');
                        ushort MapID = (ushort)long.Parse(data[1]);// Line 477
                        if (id != MapID) continue;
                        ushort X = (ushort)long.Parse(data[2]);
                        ushort Y = (ushort)long.Parse(data[3]);
                        ushort XPlus = (ushort)long.Parse(data[4]);
                        ushort YPlus = (ushort)long.Parse(data[5]);
                        uint respawn = (uint)long.Parse(data[6]);
                        int Amount = (int)long.Parse(data[7]);
                        uint monsterID = (uint)long.Parse(data[8]);
                        Game.MsgMonster.MonsterFamily famil;
                        if (!Pool.MonsterFamilies.TryGetValue(monsterID, out famil))
                        {
                            continue;
                        }
                        if (Game.MsgMonster.MonsterRole.SpecialMonsters.Contains(famil.ID))
                            continue;
                        Game.MsgMonster.MonsterFamily Monster = famil.Copy();
                        Monster.SpawnX = X;
                        Monster.SpawnY = Y;
                        Monster.MaxSpawnX = (ushort)(X + XPlus);
                        Monster.MaxSpawnY = (ushort)(Y + YPlus);
                        Monster.MapID = MapID;
                        Monster.SpawnCount = (byte)Amount;
                        Monster.rest_secs = (int)respawn;
                        colletion.Add(Monster);
                    }
                }

                GC.Collect();
            }
            catch (Exception e) { MyConsole.WriteLine(e.ToString()); }
        }
Example of NewMonster.txt

Code:
8000 15757 144 143 50 50 5 15 2437
Can I get a laymans terms of what it means, is it the code (doubtful) or is it the .txt file that's the issue? I say doubtful it's the code because the code before is exactly the same
Code:
public static void LoadMyMonsters(uint id)
But works with no error
denominator is offline  
Old 11/12/2024, 10:06   #2
 
elite*gold: 0
Join Date: Mar 2023
Posts: 20
Received Thanks: 2
The text file is the issue.

The error specifically tells you that an array index (in this case an index to "data") was out of bounds, which means that the index was above the size of the array.

So when you are parsing the file then a certain line in it contains invalid data.

Just figure out what line is causing the issue and then either remove it or fix it.

I'm going to guess and say that you have an empty line somewhere, perhaps at the end of the file.
BarcodeReader is offline  
Thanks
1 User
Old 11/12/2024, 13:38   #3
 
pintinho12's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 943
Received Thanks: 408
For some reason, some inis and dats from TQ will sometimes have less or more columns, and it may happen to get this error or a conversion error. Just find the problem row using a try catch block or reading the file urself.
pintinho12 is offline  
Old 11/12/2024, 21:05   #4
 
elite*gold: 0
Join Date: Aug 2010
Posts: 951
Received Thanks: 76
Thanks, yeah just checked the file and half way through there was missing data
denominator is offline  
Old 11/13/2024, 00:22   #5
 
Arcо's Avatar
 
elite*gold: 0
Join Date: Oct 2009
Posts: 8,783
Received Thanks: 5,304
Layman's terms:
The basket was created to hold 5 pieces of bread.
Bread1
Bread2
Bread3
Bread4
Bread5

You tried to grab Bread6.
The basket exploded.
Arcо is offline  
Thanks
2 Users
Old 11/13/2024, 01:09   #6
 
elite*gold: 0
Join Date: Aug 2010
Posts: 951
Received Thanks: 76
Quote:
Originally Posted by Arcо View Post
Layman's terms:
The basket was created to hold 5 pieces of bread.
Bread1
Bread2
Bread3
Bread4
Bread5

You tried to grab Bread6.
Yeah that's what I had assumed, I initially thought it was the code so tried changing the number given, then after some thought assumed it was something to do with the txt that the code was reading. Turns out there was an empty line in the txt
denominator is offline  
Old 11/13/2024, 13:58   #7
 
elite*gold: 0
Join Date: Nov 2020
Posts: 64
Received Thanks: 7
Quote:
Originally Posted by Arcо View Post
Layman's terms:
The basket was created to hold 5 pieces of bread.
Bread1
Bread2
Bread3
Bread4
Bread5

You tried to grab Bread6.
The basket exploded.
hahaha this is how id explain coding to my daughter, made me laugh
TheFadedOne is offline  
Old 11/13/2024, 17:42   #8
 
Soulfly25's Avatar
 
elite*gold: 0
Join Date: Mar 2006
Posts: 599
Received Thanks: 69
Just remove this "15757" in your sample txt.
Soulfly25 is offline  
Reply


Similar Threads Similar Threads
New Act7 'Index was outside the bounds of the array.'
12/13/2019 - Nostale - 2 Replies
Hello, I'm parsing the new Act7 files, but everytime i'm getting 'Index was outside the bounds of the array.' on the factory.ImportNpcMonsters();. What could i do? Before i had mostly issues on the npc."ELEMENT"Resistences, so i disabled those from parse and i got other array issues until I didn't displayed on the whole Function. Any idea on how to fix?
MySql Execute : index was outside the bounds of the array at C#
09/20/2013 - CO2 Private Server - 33 Replies
hello guys i have no idea why i get this error : index was outside the bounds of the array while i run this code MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("Entities") .Insert("Name", eC.Name) .Insert("Owner", client.Account.Username)
Array auf Negativen Index-Zugriff checken?
04/25/2013 - C/C++ - 6 Replies
Hey, Bin grade dabei in c++ Conways Game of Life zu coden zum training, nun wollte ich den Check auf Nachbar-Zellen machen, jedoch crasht das Game zu Beginn wenn man als Start-Zelle im Check nen zu geringen Wert hat. Beispiel ums genauer zu erläutern -> int mapsize=6; //Spielfeldgröße.. 6x6 Spielfeld int map; int nachbar_oben = map; //Zelle über der Zelle an "position"
[Frage]Warum hat Maxtei No Bounds in seinen Hack eingebaut?
05/28/2010 - WarRock - 9 Replies
Hey ihr Ich hab mich schon oft gefragt warum Maxtei No Bounds in den Hack eingebaut hat. No Bounds steh ja dafür das man wenn man auserhalb der Map ist nicht stirbt oder? Bitte um Antwort ;D
how to play cabal us outside us or cabal ph outside ph???
08/05/2008 - Cabal Online - 2 Replies
help!!!help!!! pleaseeeeeeeeeeeee



All times are GMT +1. The time now is 12:37.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.