What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Need help again

zar101

New Member
Joined
Mar 28, 2010
Messages
92
Reaction score
0
HB2 crashes when i change targets and at random times in the fight..
Code:
 public static void ThreadLoop()
        {
            while (Styx.Plugins.PluginManager.Plugins.Count() == 0)
                Thread.Sleep(100);

            for (int i = 0; i < Styx.Plugins.PluginManager.Plugins.Count(); i++)
            {
                myPlugin = Styx.Plugins.PluginManager.Plugins[i];
                if (myPlugin.Plugin.PluginName == "Hotkey")
                    break;
            }
            
            while (true)
            {
               
                int Holder2 = 0;
              
                Holder2 = Convert.ToInt32(GetAsyncKeyState(Keys.C).ToString());
              
                if (Holder2 == 1 || Holder2 == -32767 || Holder2 == -32768)
                {

                      Logging.Write(Holder2.ToString());
 
                      if (!Me.CurrentTarget.Buffs.ContainsKey("Immolate") )
                      {
                          if (SpellManager.CanCastSpell("Immolate") && Me.CurrentTarget.HealthPercent > 0)
                          { SpellManager.CastSpell("Immolate");
                          Logging.Write("Immolate");
                          }
                      }
                      else
                      {
                          if (SpellManager.CanCastSpell("Conflagrate") && Me.CurrentTarget.HealthPercent > 0)
                          {  SpellManager.CastSpell("Conflagrate");
                          Logging.Write("Conflagrate");
                          }
                          if (SpellManager.CanCastSpell("Chaos Bolt") && Me.CurrentTarget.HealthPercent > 0)
                          { SpellManager.CastSpell("Chaos Bolt");
                          Logging.Write("Chaos Bolt");
                          }
                          if (SpellManager.CanCastSpell("Incinerate") && Me.CurrentTarget.HealthPercent > 0 )
                          { SpellManager.CastSpell("Incinerate");
                          Logging.Write("Incinerate");
                          }
                      }
                         
                }
                Thread.Sleep(75);
            }
           
        }
 

Attachments

How about this?

Code:
 public static void ThreadLoop()
        {
            while (Styx.Plugins.PluginManager.Plugins.Count() == 0)
                Thread.Sleep(100);

            for (int i = 0; i < Styx.Plugins.PluginManager.Plugins.Count(); i++)
            {
                myPlugin = Styx.Plugins.PluginManager.Plugins[i];
                if (myPlugin.Plugin.PluginName == "Hotkey")
                    break;
            }
            
            while (true)
            {
               
                //int Holder2 = 0;
              
                int Holder2 = Convert.ToInt32(GetAsyncKeyState(Keys.C).ToString());
              
                if (Holder2 == 1 || Holder2 == -32767 || Holder2 == -32768)
                {
                      string hold2 = Holder2.ToString;
                      Logging.Write(hold2);
 
                      if (!Me.CurrentTarget.Buffs.ContainsKey("Immolate") )
                      {
                          if (SpellManager.CanCastSpell("Immolate") && Me.CurrentTarget.HealthPercent > 0)
                          { SpellManager.CastSpell("Immolate");
                          Logging.Write("Immolate");
                          }
                      }
                      else
                      {
                          if (SpellManager.CanCastSpell("Conflagrate") && Me.CurrentTarget.HealthPercent > 0)
                          {  SpellManager.CastSpell("Conflagrate");
                          Logging.Write("Conflagrate");
                          }
                          if (SpellManager.CanCastSpell("Chaos Bolt") && Me.CurrentTarget.HealthPercent > 0)
                          { SpellManager.CastSpell("Chaos Bolt");
                          Logging.Write("Chaos Bolt");
                          }
                          if (SpellManager.CanCastSpell("Incinerate") && Me.CurrentTarget.HealthPercent > 0 )
                          { SpellManager.CastSpell("Incinerate");
                          Logging.Write("Incinerate");
                          }
                      }
                         
                }
                Thread.Sleep(75);
            }
           
        }

I can't really check the code myself; but post back and tell me if it works. :P

Cheers.
 
Last edited:
Check if CurrentTarget is null. (Or for the much faster approach; check if CurrentTargetGuid == 0)

You're crashing because you're trying to access a property on a null object.
 
I am tring it right now, asking your advice. would you think this would the best placment for the check?

Code:
 if (Holder == 1 || Holder == -32767 || Holder == -32768)
                {
                    if ([B]Me.GotTarget && Me.CurrentTarget.CurrentTargetGuid == 0[/B])
                    {
                        if (Me.ManaPercent > 10)
                        {
                            if (!Me.CurrentTarget.Buffs.ContainsKey("Corruption")) { SpellManager.CastSpell("Corruption"); }
                            if (!Me.CurrentTarget.Buffs.ContainsKey("Curse of Agony")) { SpellManager.CastSpell("Curse of Agony"); }
                            if (!Me.CurrentTarget.Buffs.ContainsKey("Haunt")) { SpellManager.CastSpell("Haunt"); }
                            if (!Me.CurrentTarget.Buffs.ContainsKey("Unstable Affiction")) { SpellManager.CastSpell("Unstable Affiction"); }
                            if (Me.CurrentTarget.HealthPercent > 25)
                            { SpellManager.CastSpell("Shadow Bolt"); }
                            else
                            { SpellManager.CastSpell("Drain Soul"); }
                        }
                        else
                        {
                            SpellManager.CastSpell("Life Tap");
                        }
                    }


BTW thank you for the help
 
Last edited:
I changed the spell check to make sure it was not another reason it was makiing it crash..

Code:
  if (Holder == 1 || Holder == -32767 || Holder == -32768)
                {
                    if (Me.GotTarget && Me.CurrentTarget.CurrentTargetGuid == 0)
                    {
                        
                        Logging.Write(Convert.ToString(Me.CurrentTarget.CurrentTargetGuid));
                       

                        if (Me.ManaPercent > 10)
                        {
                            if (!Me.CurrentTarget.Buffs.ContainsKey("Corruption"))
                            { SpellManager.CastSpell("Corruption"); }
                            else
                            {
                                if (!Me.CurrentTarget.Buffs.ContainsKey("Curse of Agony"))
                                { SpellManager.CastSpell("Curse of Agony"); }
                                else
                                {
                                    if (!Me.CurrentTarget.Buffs.ContainsKey("Haunt"))
                                    { SpellManager.CastSpell("Haunt"); }
                                    else
                                    {
                                        if (!Me.CurrentTarget.Buffs.ContainsKey("Unstable Affliction"))
                                        { SpellManager.CastSpell("Unstable Affliction"); }
                                        else
                                        {
                                            if (Me.CurrentTarget.HealthPercent > 25)
                                            { SpellManager.CastSpell("Shadow Bolt"); }
                                            else
                                            { SpellManager.CastSpell("Drain Soul"); }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            SpellManager.CastSpell("Life Tap");
                        }
 
Welp its still crashing HB.. Do you think i am not doing enough target checking or?
 
Try:

Code:
  if (Me.GotTarget && !Me.CurrentTarget.CurrentTargetGuid == 0)

instead. Your code above is checking to see if the current guid is 0, it should be checking to see that it isn't 0 to proceed.
 
Code:
public static void ThreadLoop()
{
	while (Styx.Plugins.PluginManager.Plugins.Count() == 0)
		Thread.Sleep(100);

	for (int i = 0; i < Styx.Plugins.PluginManager.Plugins.Count(); i++)
	{
		myPlugin = Styx.Plugins.PluginManager.Plugins[i];
		if (myPlugin.Plugin.PluginName == "Hotkey")
			break;
	}

	while (true)
	{
		if ((GetAsyncKeyState(Keys.C) & 1) != 0)
		{					  
			if (Me.CurrentTargetGuid != 0)
			{						
				if (!Me.CurrentTarget.Buffs.ContainsKey("Immolate") )
				{
					if (SpellManager.CanCastSpell("Immolate") && Me.CurrentTarget.HealthPercent > 0)
					{ 
						SpellManager.CastSpell("Immolate");
						Logging.Write("Immolate");
					}
				}
				else
				{
					if (SpellManager.CanCastSpell("Conflagrate") && Me.CurrentTarget.HealthPercent > 0)
					{  
						SpellManager.CastSpell("Conflagrate");
						Logging.Write("Conflagrate");
					}
					if (SpellManager.CanCastSpell("Chaos Bolt") && Me.CurrentTarget.HealthPercent > 0)
					{ 
						SpellManager.CastSpell("Chaos Bolt");
						Logging.Write("Chaos Bolt");
					}
					if (SpellManager.CanCastSpell("Incinerate") && Me.CurrentTarget.HealthPercent > 0 )
					{ 
						SpellManager.CastSpell("Incinerate");
						Logging.Write("Incinerate");
					}
				}
			}
		}
		Thread.Sleep(100);
	}
}
 
Try:

Code:
  if (Me.GotTarget && !Me.CurrentTarget.CurrentTargetGuid == 0)

instead. Your code above is checking to see if the current guid is 0, it should be checking to see that it isn't 0 to proceed.

That's not valid C# ;)

Should be:

Code:
if (Me.GotTarget && Me.CurrentTargetGuid != 0)
 
Going to try it out right now.. THanks again!!! for all yalls help!!
 
Back
Top