• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Need help again

    Discussion in 'Archives' started by zar101, Jul 10, 2010.

    1. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      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);
                  }
                 
              }
       

      Attached Files:

    2. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      Just a bump
       
    3. Lt.Leon

      Lt.Leon New Member

      Joined:
      May 19, 2010
      Messages:
      1,022
      Likes Received:
      4
      Trophy Points:
      0
      Noticed your using 1.9.4.5. Try 1.9.5
       
    4. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      Did, same problem
       
    5. ohcrit95

      ohcrit95 New Member

      Joined:
      May 22, 2010
      Messages:
      49
      Likes Received:
      0
      Trophy Points:
      0
      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: Jul 15, 2010
    6. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      No change still crashes.
       
    7. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      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.
       
    8. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      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: Jul 19, 2010
    9. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      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");
                              }
       
    10. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      Welp its still crashing HB.. Do you think i am not doing enough target checking or?
       
    11. ski

      ski Well-Known Member

      Joined:
      Feb 12, 2010
      Messages:
      3,720
      Likes Received:
      48
      Trophy Points:
      48
      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.
       
    12. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      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);
      	}
      }
       
    13. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      That's not valid C# ;)

      Should be:

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

      ski Well-Known Member

      Joined:
      Feb 12, 2010
      Messages:
      3,720
      Likes Received:
      48
      Trophy Points:
      48
      Yeah that :(
       
    15. zar101

      zar101 New Member

      Joined:
      Mar 28, 2010
      Messages:
      92
      Likes Received:
      0
      Trophy Points:
      0
      Going to try it out right now.. THanks again!!! for all yalls help!!
       

    Share This Page