Register for your free account! | Forgot your password?

You last visited: Today at 04:28

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

Advertisement



[help]bit of help

Discussion on [help]bit of help within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
coreymills's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 555
Received Thanks: 99
[help]bit of help

Error:
Quote:
System.NullReferenceException: Object reference not set to an instance of an object.
at NewestCOServer.PacketHandling.Teleport.Handle(Game Client GC, Byte[] Data) in C:\Users\Corey\Downloads\BetaCo\PacketHandling\Tel eport.cs:line 22
at NewestCOServer.PacketHandler.Handle(GameClient GC, Byte[] PData) in C:\Users\Corey\Downloads\BetaCo\PacketHandler.cs:l ine 758
PacketHandler.cs Line 758:
Code:
PacketHandling.Teleport.Handle(GC, Data);
Teleport.cs Line 22:
Code:
[COLOR="Red"]foreach (Game.Item I in GC.MyChar.Inventory)[/COLOR]//error line
                {
                    if (I != null)
                    {
                        GC.AddSend(Packets.AddItem(I, 0));
                    }
                }
coreymills is offline  
Old 12/21/2010, 07:44   #2
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
One of the 3 things is null. GC, MyChar or Inventory. If I had to take a guess, I'd say MyChar. Why it's null though, I can't offer and support.
InfamousNoone is offline  
Old 12/21/2010, 12:29   #3
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,225
Received Thanks: 868
Make sure the character is not null. add the line
Code:
if (GC.MyChar != null)
{
[COLOR="Lime"]//the foreach code.[/COLOR]
}
_DreadNought_ is offline  
Old 12/21/2010, 15:46   #4
 
coreymills's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 555
Received Thanks: 99
nope its still giving the same error
coreymills is offline  
Old 12/21/2010, 15:57   #5


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Learn how to debug your code using breakpoints.
Korvacs is offline  
Old 12/21/2010, 15:58   #6
 
elite*gold: 0
Join Date: Feb 2009
Posts: 262
Received Thanks: 161
if(GC.MyChar.Inventory.Count > 0)
{
....
}
teroareboss1 is offline  
Old 12/21/2010, 16:52   #7
 
coreymills's Avatar
 
elite*gold: 0
Join Date: Mar 2008
Posts: 555
Received Thanks: 99
Quote:
Originally Posted by Korvacs View Post
Learn how to debug your code using breakpoints.
i recently converted my source to mysql it was the betaco ini source and i'm still learning to code but i was working at that problem for 2 days
coreymills is offline  
Old 12/22/2010, 16:48   #8
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
Go to telport.cs and remove these lines
Quote:
foreach (Game.Item I in GC.MyChar.Inventory)//error line
{
if (I != null)
{
GC.AddSend(Packets.AddItem(I, 0));
}
}
you dont need it any more cus you are not updating/converting you are just copy pasting the load/save/sql commands
but trust me thats not gonna work delete the whole source and start learning/building your own Pserver
Ps.Dont waste your time with those sources and start learning how to do your own **** :xD
{ Angelius } is offline  
Old 12/22/2010, 20:00   #9
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
As already stated, something is null.

Your character, your inventory or the client itself (which should never happen as it would need to NOT be null for this to trigger).

Place a breakpoint on this line and when it hits it you will be able to see what the value/structure for all these things are. Find the one that is null and there's your problem. Then backtrack it to ensure this doesn't happen again.
pro4never is offline  
Reply




All times are GMT +1. The time now is 04:28.


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.