how i fix this error in c# 5165

01/15/2010 00:57 bogy_king#1
how i fix this error
[Only registered and activated users can see links. Click Here To Register...]
01/15/2010 01:04 Korvacs#2
Apparently your server is trying to access something which is outside the bounds of an Item Drop array.

Example:

Code:
            ItemDrop[] _Array = new ItemDrop[10];
            [COLOR="Red"][B]Item _NewItem = _Array[30];[/B][/COLOR]
The red line would throw the same exception because there are not 30 objects inside the array, there are only 10.

Put a breakpoint in at line 713 and see what is happening on that line.
01/15/2010 01:11 bogy_king#3
Quote:
Originally Posted by Korvacs View Post
Apparently your server is trying to access something which is outside the bounds of an Item Drop array.

Example:

Code:
            ItemDrop[] _Array = new ItemDrop[10];
            [COLOR="Red"][B]Item _NewItem = _Array[30];[/B][/COLOR]
The red line would throw the same exception because there are not 30 objects inside the array, there are only 10.

Put a breakpoint in at line 713 and see what is happening on that line.
this screen in line 713 and i dont know what i diong please help me

[Only registered and activated users can see links. Click Here To Register...]
01/15/2010 01:25 Korvacs#4
Code:
                        if (From != null)
                        {
                            byte Tries = (byte)Rnd.Next(0, From.Count);
                            ItemID = (uint)From[Tries - 1];
                        }
That should be fine now.
01/15/2010 01:31 pro4never#5
Completely off topic: Congrats on getting mod Korvacs, you deserve it!
01/15/2010 02:26 bogy_king#6
Quote:
Originally Posted by Korvacs View Post
Code:
                        if (From != null)
                        {
                            byte Tries = (byte)Rnd.Next(0, From.Count);
                            ItemID = (uint)From[Tries - 1];
                        }
That should be fine now.
tnx very much but what i doing now i dont know
01/15/2010 02:44 NoFatChicks#7
Quote:
Originally Posted by bogy_king View Post
tnx very much but what i doing now i dont know
Just read what him said and then.. read ur Mob.cs lines.
01/15/2010 03:08 bogy_king#8
Quote:
Originally Posted by Korvacs View Post
Code:
                        if (From != null)
                        {
                            byte Tries = (byte)Rnd.Next(0, From.Count);
                            ItemID = (uint)From[Tries - 1];
                        }
That should be fine now.
the same problem not complete and make again see
[Only registered and activated users can see links. Click Here To Register...]
01/15/2010 09:54 Korvacs#9
Have you made any modifications to the source?
01/15/2010 10:12 ~Yuki~#10
i bet he has i dont have this error at all not even when i scatter like 5k birdmans n they drop much much items :)
01/15/2010 12:38 bogy_king#11
then how i fix it
01/15/2010 16:29 alexik#12
if u run on x64 bit try to do it to run in x32bit ..

See this thread: [Only registered and activated users can see links. Click Here To Register...]
01/16/2010 00:04 InfamousNoone#13
Quote:
Originally Posted by Korvacs View Post
Code:
                        if (From != null)
                        {
                            byte Tries = (byte)Rnd.Next(0, From.Count);
                            ItemID = (uint)From[Tries - 1];
                        }
That should be fine now.
(Bear in mind this isn't directed at you Korvacs, I'd never baby a post like this if it was lol)

The return value on Random.Next returns:
>=min, <max
Meaning it should never *logically* produce a number that wouldn't suffice as an index. HOWEVER! There are exceptions to this rule, where is the max is 0, 0 will be returned. So what if the Length of the array is 0, we can't index 0; now can we? So therefore logically From[0] would produce an exception where From.Length is 0.

So the solution would be

Code:
                
                        if (From.Length > 0)
                            ItemID = (uint)From[Rnd.Next(From.Count)];
Get rid of the whole if (From != null) scope. When would From ever equal null when we initialize it just a couple lines before our if-statement and never set it back to null.
01/16/2010 00:15 bogy_king#14
then i removed this
if (From != null)
{
byte Tries = (byte)Rnd.Next(0, From.Count);
ItemID = (uint)From[Tries - 1];
}
and put this

if (From.Length > 0)
ItemID = (uint)From[Rnd.Next(From.Count)];
01/16/2010 01:05 Korvacs#15
Quote:
Originally Posted by InfamousNoone View Post
(Bear in mind this isn't directed at you Korvacs, I'd never baby a post like this if it was lol)
Its fine, it was in the middle of the night when i posted that reply, i didnt think alot about it at the time lol :)