[Problem] Error with warehouse

09/16/2010 03:54 iLikeSkittles#1
Can anyone explain why i have this error please :confused:

[Only registered and activated users can see links. Click Here To Register...]

Line 679 in Packets.cs

Line 87 in Warehouse.cs

Inside SendWarehouse

Line 638 in PacketHandler.cs

Inside Handle
09/16/2010 09:31 -Fáng-#2
How did you get that error? Did you fill up the WH all the way?
I didn't look at your code because I'm a bit hand-tied right now but tell me how you got that problem.
09/16/2010 09:45 Ian*#3
Quote:
System.NullReferenceException: Object reference not set to an instance of an object
That's the error, basically what it means is you're trying to send data to something that's just not there. Or at least you didn't tell it what to send data to.

Just skimmed through your code, anyways I think it's because you set warehouse as a null object then try to reassign it.

Why is it null anyways?

Code:
ArrayList Warehouse = null;
In your Inside Warehouse spoiler.
09/16/2010 10:05 Korvacs#4
Code:
ArrayList Warehouse = null;
Should read:

Code:
ArrayList Warehouse = new ArrayList();
Even though the warehouse may remain empty this is correct because it will be an empty arraylist, so Warehouse.Count will return 0.
09/16/2010 10:19 -Fáng-#5
Quote:
Originally Posted by Korvacs View Post
Code:
ArrayList Warehouse = null;
Should read:

Code:
ArrayList Warehouse = new ArrayList();
Even though the warehouse may remain empty this is correct because it will be an empty arraylist, so Warehouse.Count will return 0.
Sorry =s I just got out of the shower. Good job Korvacs =]
The array list is where the items are stored. Won't do much if it's equal to null xP
09/17/2010 04:35 salem rey#6
So anyone can fix this problem?
09/17/2010 04:56 -Fáng-#7
Quote:
Originally Posted by salem rey View Post
So anyone can fix this problem?
Korvacs fixed it o.o
The warehouse was being assigned to a null reference instead of an array.
09/17/2010 05:34 Ian*#8
Hang on let me get a spoon...

Code:
 public static COPacket SendWarehouse(Game.Character C, ushort NPC)
        {
[B]            ArrayList Warehouse = null;[/B]
            switch (NPC)
            {
then backspace the word "null".

replace null with "new ArrayList();"
make it look like this, exactly like this.

Code:
 public static COPacket SendWarehouse(Game.Character C, ushort NPC)
        {
[B]            ArrayList Warehouse = new ArrayList();[/B]
            switch (NPC)
            {
Basically what was going wrong was you were trying to use a null value (null basically means there is nothing there).

so instead of making a null array list, you want to create a new array list object to use for each client instance.
09/17/2010 05:36 salem rey#9
did he relesae the fix guide? please if it is release give me a link or teach me how? please
09/17/2010 05:42 Ian*#10
Quote:
Originally Posted by Korvacs View Post
Code:
ArrayList Warehouse = null;
Should read:

Code:
ArrayList Warehouse = new ArrayList();
Even though the warehouse may remain empty this is correct because it will be an empty arraylist, so Warehouse.Count will return 0.
Read this.

Quote:
Originally Posted by Ian* View Post
Hang on let me get a spoon...

Code:
 public static COPacket SendWarehouse(Game.Character C, ushort NPC)
        {
[B]            ArrayList Warehouse = null;[/B]
            switch (NPC)
            {
then backspace the word "null".

replace null with "new ArrayList();"
make it look like this, exactly like this.

Code:
 public static COPacket SendWarehouse(Game.Character C, ushort NPC)
        {
[B]            ArrayList Warehouse = new ArrayList();[/B]
            switch (NPC)
            {
Basically what was going wrong was you were trying to use a null value (null basically means there is nothing there).

so instead of making a null array list, you want to create a new array list object to use for each client instance.
And if you still don't get it read this.

ITS REALLY EASY.... JUST CHANGE ONE WORD AND UR DONE YOU DONT NEED A WHOLE GUIDE TO FIGURE THIS OUT.

kthx
09/17/2010 05:50 salem rey#11
i did it but still i got error i see this in my source

In my packet.cs

public static COPacket SendWarehouse(Game.Character C, ushort NPC)
{
ArrayList Warehouse = new ArrayList();
switch (NPC)
{
case 8: { Warehouse = C.Warehouses.TCWarehouse; break; }
case 10012: { Warehouse = C.Warehouses.PCWarehouse; break; }
case 10028: { Warehouse = C.Warehouses.ACWarehouse; break; }
case 10011: { Warehouse = C.Warehouses.DCWarehouse; break; }
case 10027: { Warehouse = C.Warehouses.BIWarehouse; break; }
case 44: { Warehouse = C.Warehouses.MAWarehouse; break; }
case 4101: { Warehouse = C.Warehouses.SCWarehouse; break; }
default: return new COPacket(new byte[0]);
}


In my Warehouse.cs

ArrayList Warehouse = null;
switch (NPC)
{
case 8: { Warehouse = GC.MyChar.Warehouses.TCWarehouse; break; }
case 10012: { Warehouse = GC.MyChar.Warehouses.PCWarehouse; break; }
case 10028: { Warehouse = GC.MyChar.Warehouses.ACWarehouse; break; }
case 10011: { Warehouse = GC.MyChar.Warehouses.DCWarehouse; break; }
case 10027: { Warehouse = GC.MyChar.Warehouses.BIWarehouse; break; }
case 44: { Warehouse = GC.MyChar.Warehouses.MAWarehouse; break; }
case 4101: { Warehouse = GC.MyChar.Warehouses.SCWarehouse; break; }
}
09/17/2010 06:03 -Fáng-#12
If you don't have the error then what's the problem.. you said you want to add a new warehouse. So do it? My friend that can't code can do it ... :facepalm: I don't mean to sound mean... but all you have to do is go to the definitions, copy them, and paste them to make a new Warehouse... and make a new NPC in Stone City and assign it's id to the warehouse...
09/17/2010 06:12 salem rey#13
i have then i try korvacs fix but still i still facing problem when i open my VIP and click stone city a error pop up in my source, can anyone help me here?


aha i fix it now but the problem is the old accounts cannot log in... you must make new account,.. what is the problem?
09/17/2010 07:28 -Fáng-#14
Quote:
Originally Posted by salem rey View Post
i have then i try korvacs fix but still i still facing problem when i open my VIP and click stone city a error pop up in my source, can anyone help me here?


aha i fix it now but the problem is the old accounts cannot log in... you must make new account,.. what is the problem?
Please read what I said... =[
Korvac's fix isn't for you because you don't have that problem. You're not trying hard enough. Look at the code in front of you. Right click what you don't understand and say "follow to definition" or whatever it is. :facepalm: Please don't just respond with "idk"- say what you tried to do and we might help.
09/17/2010 08:33 Ian*#15
Quote:
Originally Posted by salem rey View Post
i have then i try korvacs fix but still i still facing problem when i open my VIP and click stone city a error pop up in my source, can anyone help me here?


aha i fix it now but the problem is the old accounts cannot log in... you must make new account,.. what is the problem?
Google how to use break points in visual studios.

Set breakpoints within your switch, try depositing an item in your warehouse, see which line the error occurs on, and then let us know exactly where the exception is thrown.