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

Check to see if current bot is active?

AutomaticCoding

New Member
Joined
Dec 20, 2011
Messages
1,091
Reaction score
1
I need to add:

if(InBG) {
if(bot.isOff) {
bot.start();
}
}

How do I check if the bot is active? I worked out how to start/stop it, just not check if its' already on.
 
Last edited:
If you're writing a plugin, as I suspect, you can know if the bot is running just because it's executing the plugin's Pulse overridden method. If the bot is not running, Pulse won't be executed. Thus, in definitive, you don't need to know it. If you want though to execute code when you (re)start the bot, or when you stop it, you can use the BotEvents adding a method OnBotStarted/OnBotStopped (or OnBotStart/OnBotStop, kinda similar but different times).

Also, you can create a stopwatch and let it reset/start in the Pulse method, and then checking whenever the milliseconds passed are more than 10000 in a while(true) loop, outside Pulse.
 
Last edited:
TreeRoot.IsRunning (indicates wether the bot is active or stopped)
 
If you're writing a plugin, as I suspect, you can know if the bot is running just because it's executing the plugin's Pulse overridden method. If the bot is not running, Pulse won't be executed. Thus, in definitive, you don't need to know it. If you want though to execute code when you (re)start the bot, or when you stop it, you can use the BotEvents adding a method OnBotStarted/OnBotStopped (or OnBotStart/OnBotStop, kinda similar but different times).

Also, you can create a stopwatch and let it reset/start in the Pulse method, and then checking whenever the milliseconds passed are more than 10000 in a while(true) loop, outside Pulse.

Really? If I do something like:

public void pulse() {
Styx.StyxInstance.Lua.DoString(String.Format("DEFAULT_CHAT_FRAME:AddMessage(\"We're still running! Number {0}\");"));
}

with no for/while loops, it will start when I start the bot, then, when I stop the bot continue to go.
 
I'm not sure 100%, but public void pulse() should be different than public override void Pulse() ... btw just debug log something like Logging.WriteDebug("Still alive {0}", System.currentTimeMillis()) . If it prints it out only once, it means that you've got a cycle blocking the code, or you're not using threads to execute methods that require time to process (if they can be processed parallely ofc).
 
Last edited:
Back
Top