Annoying Unknown Error

10/10/2011 02:12 killersub#1
Alright sorry for my massive posting but I have been testing out different sources amd understand how they are coded, a little better. I just need this one to figure out InGame how everything works but ofc I get errors.

I get an error on the 'public static void Load(GameClient GC)'

Here's the line of the error:

Code:
if (DateTime.Now > GC.MyChar.canload.AddSeconds(3) && GC.MyChar.cannload == false)
This is the error:

Code:
Object reference not set to an instance of an object
This is the first ProjectX source originally released here, that I'm currently using btw.

EDIT:
Now at times it wont give me any error now the client closes halfway loading without any error.
10/10/2011 03:02 pro4never#2
The error is very general. It's saying that an object has not been set to any value.


For example if I told you "is player X over level 130" you can't check that if I haven't given you the information about who player x is.


Breakpoint it, check the line where the error is happening and find what is null then make sure you assign it before checking it.
10/10/2011 03:29 killersub#3
Quote:
Originally Posted by pro4never View Post
The error is very general. It's saying that an object has not been set to any value.


For example if I told you "is player X over level 130" you can't check that if I haven't given you the information about who player x is.


Breakpoint it, check the line where the error is happening and find what is null then make sure you assign it before checking it.
I wouldn't have posted if I haven't tried all of that,sir.

The result is inevitable, client comes to a stop then closes rapidly.

The breakpoint did not help me because I got nothing out of it, btw the values is assigned to a 'new DateTime()' so that can't be it.

There must be some sort of hidden error, idk.
10/10/2011 04:08 pro4never#4
GC is not null, mychar is not null and canload is a valid, initiated datetime value?
10/10/2011 07:21 BaussHacker#5
canload is null if I'm correct. Initialize it in the constructor of the character class.
10/10/2011 16:46 killersub#6
Quote:
Originally Posted by pro4never View Post
GC is not null, mychar is not null and canload is a valid, initiated datetime value?
Correct everything is assigned to a value. But for some reason it tells me GC in the parameters of the 'Load' void is null, when it cant be because it's the ClientState and it can't ne null ?

Quote:
Originally Posted by BaussHacker View Post
canload is null if I'm correct. Initialize it in the constructor of the character class.
sorry I'm still kinda new to some of this.

'public bool canload == false'

Has a value assigned to it already, has it not?
10/10/2011 17:59 Spirited#7
canload must be null.
also, == is a Boolean expression.
= is an assignment.

[Only registered and activated users can see links. Click Here To Register...]
10/10/2011 19:08 BaussHacker#8
Argh, I don't have the source. Haven't got it since I released it, I will download it and take a look and get back to you :)
10/11/2011 00:34 killersub#9
Quote:
Originally Posted by Fаng View Post
canload must be null.
also, == is a Boolean expression.
= is an assignment.

[Only registered and activated users can see links. Click Here To Register...]
Sorry to break it to you sir, But I already have the basic knowledge to know the difference between "==" and "=".

this is "CANLOAD":
Code:
public DateTime canload = new DateTime();
this is "CANNLOAD":
Code:
public bool cannload = false;
Quote:
Originally Posted by BaussHacker View Post
Argh, I don't have the source. Haven't got it since I released it, I will download it and take a look and get back to you :)
I would so much appreciate it.

Any questions you have, please ask ahead.
10/11/2011 00:44 BaussHacker#10
Before I look at it try change:
public DateTime canload = new DateTime();

to:
public DateTime canload = DateTime.Now;


You can also try catching ArgumentNullException or what it's named.
10/11/2011 03:36 killersub#11
Quote:
Originally Posted by BaussHacker View Post
Before I look at it try change:
public DateTime canload = new DateTime();

to:
public DateTime canload = DateTime.Now;


You can also try catching ArgumentNullException or what it's named.
Will do.

will get back to you ASAP.

EDIT:

The error seems to occur when the client finishes creating the Account and the server sends the "Load" void to the client, that it when the
Quote:
Object reference not set to an instance of an object
error pops up in the same line. And when I try to login again the client crashes.
10/11/2011 12:39 pwerty#12
breakpoint. Check for null values in Client/entity
10/11/2011 12:57 BaussHacker#13
Replace it with:
Code:
        public static void Load(Character C)
        {
            if (C.cannload == true)
            {
                if (DateTime.Now > C.canload.AddSeconds(3))
                {
                    C.CanBackup = DateTime.Now;

                    C.Loc.PreviousMap = 1002;
                    C.Loc.PreviousX = 400;
                    C.Loc.PreviousY = 400;

                    C.cannload = false;
                    C.CTT.Stop();
                    C.IsLoaded = true;
                    C.Teleport(C.Loc.Map, C.Loc.X, C.Loc.Y);
                }
            }
        }
Find the constructor for Character and replace it with:
Code:
            CTT = new System.Timers.Timer(5000.0);
            CTT.Start();
            CTT.Elapsed += delegate { Timer32.Timer.Load(this); };
Now find C.Loaded = true; in (Database.cs)
Code:
public static Game.Character LoadCharacter(string Name, ref string Account)
Put this under:
Code:
C.cannload = true;
Really bad way, but it should work. I can see a lot other shit mistakes I made back then and something like this should not even be in use.
10/11/2011 20:59 killersub#14
Quote:
Originally Posted by BaussHacker View Post
Replace it with:
Code:
        public static void Load(Character C)
        {
            if (C.cannload == true)
            {
                if (DateTime.Now > C.canload.AddSeconds(3))
                {
                    C.CanBackup = DateTime.Now;

                    C.Loc.PreviousMap = 1002;
                    C.Loc.PreviousX = 400;
                    C.Loc.PreviousY = 400;

                    C.cannload = false;
                    C.CTT.Stop();
                    C.IsLoaded = true;
                    C.Teleport(C.Loc.Map, C.Loc.X, C.Loc.Y);
                }
            }
        }
Find the constructor for Character and replace it with:
Code:
            CTT = new System.Timers.Timer(5000.0);
            CTT.Start();
            CTT.Elapsed += delegate { Timer32.Timer.Load(this); };
Now find C.Loaded = true; in (Database.cs)
Code:
public static Game.Character LoadCharacter(string Name, ref string Account)
Put this under:
Code:
C.cannload = true;
Really bad way, but it should work. I can see a lot other shit mistakes I made back then and something like this should not even be in use.
smart fix, but still there is an error.

Quote:
Object reference not set to an instance of an object
Error line (Character.cs) "TELEPORT VOID"

Code:
MyClient.AddSend(Packets.GeneralData(EntityID, Map, X, Y, 86));
10/11/2011 21:14 BaussHacker#15
Might be Loc or Map that's empty.

Could be MyClient as well.