FB/SS Exeption

10/05/2011 19:43 C#Storm#1
Hi , i saw that Pro4Never2 is getting same error as me, but i'm gonna ask help with a different way.

Here's Exeption , it happens when i try to hit a player with fastblade or SS(not sure exactly when it happens)

Quote:
System.NullReferenceException: Object reference not set to an instance of an object.
to COEmulator.Features.SkillsClass.SkillUse.GetMobTar gets (UInt32 Single) in
C: \ COEmulator \ Features \ skills.ca: line 232
to COEmulator.Features.SkillsClass.SkillUse.GetTarget s (UInt32 Single) in
C: \COEmulator \ Features \ skills.ca: line 147
this is the void of GetMobTargets

PHP Code:
 void GetMobTargets(uint Single)
            {
                if (
Info.ExtraEff == ExtraEffect.Ride || Info.ExtraEff == ExtraEffect.UnMount) return;
                if (
Info.Targetting == TargetType.Single)
                {
                    if (
World.H_Mobs.Contains(User.Loc.Map))
                    {
                        
Mob M = (Mob)((Hashtable)(World.H_Mobs[User.Loc.Map]))[Single];
                        if (
!= null && M.Alive)
                            
MobTargets.Add(MGetDamage(M));
                    }
                }
                else
                {
                    
bool RangeFromChar true;
                    if (
Info.Targetting == TargetType.FromSingle)
                    {
                        
Mob M = (Mob)((Hashtable)(World.H_Mobs[User.Loc.Map]))[Single];
                        if (
!= null && M.Alive)
                        {
                            
MobTargets.Add(MGetDamage(M));
                            
AimX M.Loc.X;
                            
AimY M.Loc.Y;
                            
RangeFromChar false;
                        }
                    }
                    else if (
Info.Targetting != TargetType.Sector && Info.Targetting != TargetType.Linear && Info.Targetting != TargetType.Range && Info.Targetting != TargetType.FromPoint)
                    {
                        
AimX User.Loc.X;
                        
AimY User.Loc.Y;
                        
RangeFromChar true;
                    }
                    else
                        
RangeFromChar false;
                    
Hashtable MapMobs = (Hashtable)World.H_Mobs[User.Loc.Map];
                    if (
MapMobs != null)
                        foreach (
Mob M in MapMobs.Values)
                        {
                            if (
M.Alive)
                            {
                                if ((!
RangeFromChar && MyMath.PointDistance(AimXAimYM.Loc.XM.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.XUser.Loc.YM.Loc.XM.Loc.Y) <= Info.MaxDist)
                                    if (
Info.Targetting == TargetType.Sector && InSector(M.Loc.XM.Loc.Y) || Info.Targetting != TargetType.Sector)
                                        if (
Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.XUser.Loc.YAimXAimY) == MyMath.PointDirecton(User.Loc.XUser.Loc.YM.Loc.XM.Loc.Y) || Info.Targetting != TargetType.Linear)
                                            if (
User.PKMode == PKMode.PK || !M.NeedsPKMode && !MobTargets.Contains(M))
                                                
MobTargets.Add(MGetDamage(M));
                            }
                        }
                }
            } 
and this is bored from saying things i don't understand

PHP Code:
 public void GetTargets(uint Single)
            {
                try
                {
                    
GetMobTargets(Single);
                    
GetPlayerTargets(Single);
                    
GetNPCTargets(Single);
                    
GetMiscTargets(Single);
                }
                catch (
Exception Exc) { Program.WriteLine(Exc); }
            } 
what do you think is going on?

PS: don't do it for me, i'm here to learn , i need an explanation of what's wrong and how to fix it
10/05/2011 19:50 BaussHacker#2
Line 232 and line 147.

Nothing else.
10/06/2011 13:42 C#Storm#3
yes i trynna ask for: what's going on there , i know how to read exeptions, it's coded by you btw
10/06/2011 15:03 BaussHacker#4
I need the lines...
10/06/2011 15:40 C#Storm#5
Quote:
public void GetTargets(uint Single)
{
try
{
GetMobTargets(Single);//line 147
GetPlayerTargets(Single);
GetNPCTargets(Single);
GetMiscTargets(Single);
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
Quote:
void GetMobTargets(uint Single)
{
if (Info.ExtraEff == ExtraEffect.Ride || Info.ExtraEff == ExtraEffect.UnMount) return;
if (Info.Targetting == TargetType.Single)
{
if (World.H_Mobs.Contains(User.Loc.Map))
{
Mob M = (Mob)((Hashtable)(World.H_Mobs[User.Loc.Map]))[Single];
if (M != null && M.Alive)
MobTargets.Add(M, GetDamage(M));
}
}
else
{
bool RangeFromChar = true;
if (Info.Targetting == TargetType.FromSingle)
{
Mob M = (Mob)((Hashtable)(World.H_Mobs[User.Loc.Map]))[Single];//line232
if (M != null && M.Alive)
{
MobTargets.Add(M, GetDamage(M));
AimX = M.Loc.X;
AimY = M.Loc.Y;
RangeFromChar = false;
}
}
else if (Info.Targetting != TargetType.Sector && Info.Targetting != TargetType.Linear && Info.Targetting != TargetType.Range && Info.Targetting != TargetType.FromPoint)
{
AimX = User.Loc.X;
AimY = User.Loc.Y;
RangeFromChar = true;
}
else
RangeFromChar = false;
Hashtable MapMobs = (Hashtable)World.H_Mobs[User.Loc.Map];
if (MapMobs != null)
foreach (Mob M in MapMobs.Values)
{
if (M.Alive)
{
if ((!RangeFromChar && MyMath.PointDistance(AimX, AimY, M.Loc.X, M.Loc.Y) <= Info.MaxDist) || MyMath.PointDistance(User.Loc.X, User.Loc.Y, M.Loc.X, M.Loc.Y) <= Info.MaxDist)
if (Info.Targetting == TargetType.Sector && InSector(M.Loc.X, M.Loc.Y) || Info.Targetting != TargetType.Sector)
if (Info.Targetting == TargetType.Linear && MyMath.PointDirecton(User.Loc.X, User.Loc.Y, AimX, AimY) == MyMath.PointDirecton(User.Loc.X, User.Loc.Y, M.Loc.X, M.Loc.Y) || Info.Targetting != TargetType.Linear)
if (User.PKMode == PKMode.PK || !M.NeedsPKMode && !MobTargets.Contains(M))
MobTargets.Add(M, GetDamage(M));
}
}
}
}

RED LINES are 147 and 232
10/06/2011 16:13 pwerty#6
System.NullReferenceException: Object reference not set to an instance of an object.

meh.
10/06/2011 16:23 BaussHacker#7
Mob M is null.
10/06/2011 18:41 ryuchetval#8
nah it shouldn't give error on that line if mob is null...
either hashtable is null or user is null...logging off while attacking could cause this...
10/06/2011 19:09 BaussHacker#9
Quote:
Originally Posted by ryuchetval View Post
nah it shouldn't give error on that line if mob is null...
either hashtable is null or user is null...logging off while attacking could cause this...
This ^

I was overlooking the code.