Skip to content
View in the app

A better way to browse. Learn more.

WRobot

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Changing Botbase

Featured Replies

Hello, I'm trying to change my Botbase(in Plugin) from Party bot to another. I found somethink like this:

        Products.DisposeProduct();
        Products.LoadProducts("Automaton");

After this trying additional Products.ProductRestart(); etc but it dosen't work. Bot stopped or freezed? Any1 know how to do this?

Hello, i tried this also by a plugin but i have figured out that it's abit difficult.

You need to create your own thread because if you dispose product your plugin also stop working(maybe there's another method to do it but i haven't found it yet).

Here's an example how do you create your own thread:

    public static bool _isLaunched1;
    public static bool AllowAbort;
    Dictionary<string, Thread> threadDict = new Dictionary<string, Thread>();



    public void Initialize()
    {
	MemoryBool(true);
        Thread th1 = new Thread(() => Thread1());
        th1.Name = Convert.ToString(TableID);
        th1.Start();
        threadDict.Add("Thread1", th1);
	Logging.Write("Thread started.");
    }



    public void Dispose()
    {
        if (!MemoryBool())
        {
            Logging.Write("Abort thread.");
            SwitchProduct(StartedRotationName());
            if (AllowAbort)
            {
                threadDict["Thread1"].Abort();
            }
        }
    }



    public void Settings()
    {

    }



    public void Thread1()
    {
        Logging.Write("Initialize thread.");
        _isLaunched1 = true;
        var timer = new Timer(1500);
        timer.ForceReady();
        while (_isLaunched1)
        {
            try
            {
                if (Conditions.ProductIsStartedNotInPause 
                    && timer.IsReady 
                    //&& !ObjectManager.Me.IsDead //optional
		    )
                {
                    Pulse1();
                    timer.Reset();
                }
            }
            catch
            {
            }
            Thread.Sleep(65);
        }
    }



    //may change address if not available or use System.Runtime.Caching.MemoryCache or write settings
    public bool MemoryBool()
    {
        if (Memory.WowMemory.Memory.ReadInt32((uint) GetWoWBase() + 0x7322CA) == 1)
        {
            return true;
        }
        return false;
    }



    public void Pulse1();
    {
	Logging.Write("Tick");
    }

 

 

and the key to switch products:

    //Need own thread to work
    //=> Products.ProductStop();/Products.DisposeProduct(); aborts the main thread and method has nothing to continue
    public void SwitchProduct(string name)
    {
        if (Products.ProductName != name && Products.IsStarted)
        {
            Logging.Write("Switch to " + name);
            MemoryBool(true);
            Products.ProductStop();
            Products.LoadProducts(name);
            Logging.Write("stop & load product");
            Thread.Sleep(200);
            Products.ProductStart();
            Logging.Write("product start & abort old");
            MemoryBool(false);
            Thread.Sleep(1500);
            threadDict["Thread1"].Abort(); //abort of current thread
        }
    }

 

 

if you need support, feel free to pm me

ah forget the complicated code, i've found a better way to do it

for e.g:

    public void Initialize()
    {
	Logging.Write("Plugin started.");
        Thread.Sleep(7000);
        SwitchProduct("Grinder");
    }



    public void Dispose()
    {
    	Logging.Write("Disposed");
    }



    public void Settings()
    {
	
    }



    public void SwitchProduct(string name)
    {
        if (Products.ProductName != name && Products.IsStarted)
        {
            var t = Task.Run(async delegate
            {
                await Task.Delay(500);
                Logging.Write("Switch to " + name);
                Products.ProductStop();
                Products.LoadProducts(name);
                Logging.Write("stop & load product");
                Thread.Sleep(200);
                Products.ProductStart();
                Logging.Write("product start");
                Thread.Sleep(1500);
            });
            t.Wait();
        }
    }

I think it's better ;)

Edit: using System.Threading.Tasks; is also needed

9 hours ago, reapler said:

ah forget the complicated code, i've found a better way to do it

for e.g:


    public void Initialize()
    {
	Logging.Write("Plugin started.");
        Thread.Sleep(7000);
        SwitchProduct("Grinder");
    }



    public void Dispose()
    {
    	Logging.Write("Disposed");
    }



    public void Settings()
    {
	
    }



    public void SwitchProduct(string name)
    {
        if (Products.ProductName != name && Products.IsStarted)
        {
            var t = Task.Run(async delegate
            {
                await Task.Delay(500);
                Logging.Write("Switch to " + name);
                Products.ProductStop();
                Products.LoadProducts(name);
                Logging.Write("stop & load product");
                Thread.Sleep(200);
                Products.ProductStart();
                Logging.Write("product start");
                Thread.Sleep(1500);
            });
            t.Wait();
        }
    }

I think it's better ;)

Edit: using System.Threading.Tasks; is also needed

@reaperl

as a novice at this, would you say its best to run most plugins as async or on other threads?

@Jasabi For plugins there's no best. It depends on the situation. Most of the time you won't need it anyway for plugins because it's not so complex and stucks don't happen that often while running.

I think also that every plugin run anyway on it's own thread. For e.g. if you use async with a method it will run independent (it doesn't block the main thread on its own processing) so other stuff can continue and the second one what you have mention is multithreading.

The both are "almost" the same but with multithreading you have your seperate thread which can execute its own code.

  • 5 years later...

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.