Jump to content

How to stop event?


79135

Recommended Posts

How to stop the event, event start again and again even the char running.

using System;
using System.Threading;
using robotManager.Helpful;
using robotManager.Products;
using wManager.Plugin;
using wManager.Wow.Helpers;
using System.Collections.Generic;
using System.Linq;
using robotManager.FiniteStateMachine;
using wManager;
using wManager.Wow.Bot.States;
using wManager.Wow.Enums;
using wManager.Wow.ObjectManager;
using robotManager;
using MemoryRobot;
using Memory = wManager.Wow.Memory;
using Timer = robotManager.Helpful.Timer;
using Math = robotManager.Helpful.Math;
using System.Windows.Forms;


public class Main : IPlugin
{
    private bool _isLaunched;

    public void Initialize()
    {
        _isLaunched = true;

        back:

        Thread.Sleep(5000);
        Logging.Write("begin");

        if (!MovementManager.InMovement)
        {
            robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) =>
            {
                Logging.Write("event still work");

                robotManager.Products.Products.InPause = true;
                Thread.Sleep(1000);
                robotManager.Products.Products.InPause = false;
            };
            goto back;
        }
    }
    public void Dispose()
    { }
    public void Settings()
    { }
}

Link to comment
Share on other sites

You can Subscribe to the events inside the Initialize() Method like the following (be sure to Unsubscribe from the event on Dispose):

** Code is not tested **

public void Initialize()
{
	wManager.Events.FightEvents.OnFightEnd += FightEventsOnFightEnd;	// Subscribe to the Event
	_isLaunched = true;
	// ...
}

public void Dispose()
{
 	wManager.Events.FightEvents.OnFightEnd -= FightEventsOnFightEnd;	// Unsubscribe from the Event
	_isLaunched = false;
	// ...
}

private void FightEventsOnFightEnd (ulong guid)
{
	Random _rand = new Random();
    Logging.WriteDebug("FightEventsOnFightEnd()");
  	// Wait some random time
  	Thread.Sleep(_rand.Next(2000, 5000));
}


 

Link to comment
Share on other sites

57 minutes ago, Apexx said:

You can Subscribe to the events inside the Initialize() Method like the following (be sure to Unsubscribe from the event on Dispose):

** Code is not tested **


public void Initialize()
{
	wManager.Events.FightEvents.OnFightEnd += FightEventsOnFightEnd;	// Subscribe to the Event
	_isLaunched = true;
	// ...
}

public void Dispose()
{
 	wManager.Events.FightEvents.OnFightEnd -= FightEventsOnFightEnd;	// Unsubscribe from the Event
	_isLaunched = false;
	// ...
}

private void FightEventsOnFightEnd (ulong guid)
{
	Random _rand = new Random();
    Logging.WriteDebug("FightEventsOnFightEnd()");
  	// Wait some random time
  	Thread.Sleep(_rand.Next(2000, 5000));
}


 

I need only the event: robotManager.Events.FiniteStateMachineEvents.OnRunState += (engine, state, cancelable) =>. I use the plugin for running in ghost.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...