Jump to content

Recommended Posts

Hey y'all!

I'm actually SUPER bummed, because I've basically been working on this all day (learning c# as I go + I'm a bit slow...don't make fun of me).

I finally had it all fixed down to only throwing one error...and now the bot won't even load the plugin.

Can anyone see what's wrong? (All the log says is "Error to load plugin PATH\lootoggle.cs")

using robotManager.Helpful;
using System.Threading;
using robotManager.Products;
using wManager.Wow.Enums;
using wManager.Wow.Helpers;
using wManager.Wow.ObjectManager;
using System;
using System.Collections.Generic;
using System.IO;
using System.ComponentModel;
using robotManager;


public class Lootoggle : wManager.Plugin.IPlugin
{
    private bool _isLaunched;
    private bool _isLooting;
    private int KillTime;
    private int LootTime;
    private int timeToKill;
    private int timeToLoot;
  
    public void Initialize()
    {
        _isLaunched = true;
        _isLooting = true;
        LootoggleSettings.Load();
        timeToKill = LootoggleSettings.CurrentSetting.KillMinutes * 60 * 1000;
        timeToLoot = LootoggleSettings.CurrentSetting.LootMinutes * 60 * 1000;

        Logging.Write("[Lootoggle] Started.");
        pluginLoop();
    }

    public void Dispose()
    {
        _isLaunched = false;
        Logging.Write("[Lootoggle] Disposed.");
    }

    public void Settings()
    {
        LootoggleSettings.Load();
        LootoggleSettings.CurrentSetting.ToForm();
        LootoggleSettings.CurrentSetting.Save();
    }


    public void pluginLoop()
    {
        while (Products.IsStarted && _isLaunched)
        {
            if (_isLooting)
            {
                wManager.wManagerSetting.CurrentSetting.LootMobs = _isLooting;
                Log("Bot will loot for " + LootTime + ".");
                Thread.Sleep(timeToLoot);
                Logging.Write("Disabling looting and continuing...");
                _isLooting = !_isLooting;
            }

            if (!_isLooting)
            {
                wManager.wManagerSetting.CurrentSetting.LootMobs = _isLooting;
                Logging.Write("Bot will now stop looting and only kill for " + KillTime + ".");
                Thread.Sleep(timeToKill);
                _isLooting = !_isLooting;
            }
        }
    }
    [Serializable]
    public class LootoggleSettings : Settings
    {
        [DefaultValue(3)]
        [Category("General Settings")]
        [DisplayName("Kill Time")]
        [Description("How long (in minutes) should bot should kill shit?")]
        
        public int KillMinutes { get; set; }
    
        [DefaultValue(1)]
        [Category("General Settings")]
        [DisplayName("Loot Time")]
        [Description("How long (in minutes) should bot should loot before toggling looting back off.")]
        
        public int LootMinutes { get; set; }
        
        private LootoggleSettings()
        {
            KillMinutes = 3;
            LootMinutes = 1;
            ConfigWinForm(new System.Drawing.Point(300, 400), "Lootoggle " + Translate.Get("Settings"));
        }

        public static LootoggleSettings CurrentSetting { get; set; }
        
	/*				Save/Load Functions				*/
      public bool Save()
        {
            try
            {
                return Save(AdviserFilePathAndName("Lootoggle", ObjectManager.Me.Name + "." + Usefuls.RealmName));
            }
            catch (Exception e)
            {
                Logging.WriteError("LootoggleSettings > Save(): " + e);
                return false;
            }
        }
        
        public static bool Load()
        {
            try
            {
                if (File.Exists(AdviserFilePathAndName("Lootoggle", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
                {
                    CurrentSetting = Load<LootoggleSettings>(AdviserFilePathAndName("Lootoggle", ObjectManager.Me.Name + "." + Usefuls.RealmName));
                    return true;
                }
                CurrentSetting = new LootoggleSettings();
            }
            catch (Exception e)
            {
                Logging.WriteError("LootoggleSettings > Load(): " + e);
            }
            return false;
        }
    }
}

 

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...