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

[suggestion] shutdown timer plugin and inkeeper logout

Togarda

New Member
Joined
Mar 31, 2010
Messages
96
Reaction score
3
Hello everybody,

at first thank you for everthing you do to hb and your users.

Last evening my head was warming up and dumped out some ideas for HB.

The first idea was: "The shutdown timer":
- put in the date, time, the level or the runtime
- make little form with
- Button for "Start Timer" and "Stop Timer"

My second idea was: "The inkeeper logout":
- it works together with the shutdown timer means
- when the timer ends the bot go to the next inkeeper that means:
- when it is not still in the megamesh someone must put in all the inkeepers coordinates
- when the bot in the hood of the inkeeper he log out

So Iam a coder... even with C# but i'm not clear with the styx lib. So I ask for the plugins when someone have time and lust to code it. Propably someone can send me the lib and i will try it more
it think this will help me.
I hope i have inspirated someone ;)

im german so i can english very well but et geht noch nit so schnell

with friendly greetings

Togarda
 
there is a ExitTime out here

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Styx.Helpers;
using Styx.Plugins.PluginClass;
using Styx.Combat.CombatRoutine;
using Styx.WoWInternals;
using Styx;

namespace PluginLogoutAfterNMinutes
{
    public class FormLogOutAfter : Form
    {
        #region Designer
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.btnOK = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.nmcExitTime = new System.Windows.Forms.NumericUpDown();
            this.label2 = new System.Windows.Forms.Label();
            this.btnCancel = new System.Windows.Forms.Button();
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.lblExitAt = new System.Windows.Forms.ToolStripStatusLabel();
            this.lblTimeRemaining = new System.Windows.Forms.ToolStripStatusLabel();
            this.tmrUpdateTimeRemaining = new System.Windows.Forms.Timer(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.nmcExitTime)).BeginInit();
            this.statusStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // btnOK
            // 
            this.btnOK.Location = new System.Drawing.Point(190, 8);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new System.Drawing.Size(75, 23);
            this.btnOK.TabIndex = 0;
            this.btnOK.Text = "OK";
            this.btnOK.UseVisualStyleBackColor = true;
            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(13, 13);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(35, 13);
            this.label1.TabIndex = 1;
            this.label1.Text = "Exit in";
            // 
            // nmcExitTime
            // 
            this.nmcExitTime.Increment = new decimal(new int[] {
            10,
            0,
            0,
            0});
            this.nmcExitTime.Location = new System.Drawing.Point(54, 11);
            this.nmcExitTime.Maximum = new decimal(new int[] {
            12000,
            0,
            0,
            0});
            this.nmcExitTime.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.nmcExitTime.Name = "nmcExitTime";
            this.nmcExitTime.Size = new System.Drawing.Size(80, 20);
            this.nmcExitTime.TabIndex = 2;
            this.nmcExitTime.Value = new decimal(new int[] {
            10,
            0,
            0,
            0});
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(140, 13);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(44, 13);
            this.label2.TabIndex = 3;
            this.label2.Text = "Minutes";
            // 
            // btnCancel
            // 
            this.btnCancel.Location = new System.Drawing.Point(271, 8);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(75, 23);
            this.btnCancel.TabIndex = 4;
            this.btnCancel.Text = "Cancel";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // statusStrip1
            // 
            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.lblExitAt,
            this.lblTimeRemaining});
            this.statusStrip1.Location = new System.Drawing.Point(0, 41);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(364, 22);
            this.statusStrip1.TabIndex = 5;
            this.statusStrip1.Text = "statusStrip1";
            // 
            // lblExitAt
            // 
            this.lblExitAt.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
                        | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)
                        | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom)));
            this.lblExitAt.Name = "lblExitAt";
            this.lblExitAt.Size = new System.Drawing.Size(4, 17);
            // 
            // lblTimeRemaining
            // 
            this.lblTimeRemaining.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Top)
                        | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right)
                        | System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom)));
            this.lblTimeRemaining.Name = "lblTimeRemaining";
            this.lblTimeRemaining.Size = new System.Drawing.Size(4, 17);
            // 
            // tmrUpdateTimeRemaining
            // 
            this.tmrUpdateTimeRemaining.Interval = 1000;
            this.tmrUpdateTimeRemaining.Tick += new System.EventHandler(this.tmrUpdateTimeRemaining_Tick);
            // 
            // FormLogOutAfter
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(364, 63);
            this.Controls.Add(this.statusStrip1);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.nmcExitTime);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.btnOK);
            this.Name = "FormLogOutAfter";
            this.Text = "Exit Timer";
            ((System.ComponentModel.ISupportInitialize)(this.nmcExitTime)).EndInit();
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button btnOK;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.NumericUpDown nmcExitTime;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Button btnCancel;
        private System.Windows.Forms.StatusStrip statusStrip1;
        private System.Windows.Forms.ToolStripStatusLabel lblExitAt;
        private System.Windows.Forms.Timer tmrUpdateTimeRemaining;
        private System.Windows.Forms.ToolStripStatusLabel lblTimeRemaining;

        #endregion

        public FormLogOutAfter()
        {
            InitializeComponent();
        }

        public void Pulse()
        {

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            _exitAt = DateTime.Now.Add(TimeSpan.FromMinutes((double)nmcExitTime.Value));
            lblExitAt.Text = "HB will exit at " + _exitAt.ToShortDateString() + " - " + _exitAt.ToShortTimeString();
            tmrUpdateTimeRemaining.Enabled = true;
            tmrUpdateTimeRemaining.Start();
        }

        private DateTime _exitAt;
        private void tmrUpdateTimeRemaining_Tick(object sender, EventArgs e)
        {
            var now = DateTime.Now;
            if (now > _exitAt)
            {
                tmrUpdateTimeRemaining.Enabled = false;
                tmrUpdateTimeRemaining.Stop();
                //if (Global.Honorbuddy != null)
                //{
                //    Global.Honorbuddy.Stop();
                //}
                lblExitAt.Text = "Exiting WoW...";
                int id = ObjectManager.Wow.ProcessId;
                Lua.DoString("ForceQuit()");
                int tickCount = Environment.TickCount;
                while (Environment.TickCount - tickCount < 10000 && Process.GetProcessesByName("Wow").Where(proc => proc.Id == id).ToList().Count > 0)
                    Thread.Sleep(200);

                Process process;
                if ((process = Process.GetProcessesByName("Wow").Where(proc => proc.Id == id).FirstOrDefault()) != null)
                    process.Kill();

                Application.Exit();
                return;
            }
            TimeSpan remaining = _exitAt.Subtract(DateTime.Now);
            lblTimeRemaining.Text = remaining + " remaining";
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            tmrUpdateTimeRemaining.Stop();
            tmrUpdateTimeRemaining.Enabled = false;
            lblExitAt.Text = "Canceled";
            lblTimeRemaining.Text = "";
        }
    }

    public class ExitTimer : HBPlugin
    {
        public override void Pulse()
        {
            if (_curForm.Visible)
                _curForm.Pulse();
        }

        private readonly FormLogOutAfter _curForm = new FormLogOutAfter();

        public override string Name { get { return "Exit Timer"; } }

        public override string Author { get { return "MaiN"; } }

        private readonly Version _version = new Version(1, 0, 0, 0);
        public override Version Version { get { return _version; } }

        public override string ButtonText { get { return "Open"; } }

        public override bool WantButton { get { return true; } }

        public override void OnButtonPress()
        {
            if (!_curForm.Visible)
                _curForm.Show();
        }
    }
}

Though maybe not as advanced as you want it to be :P

Credits to MaiN for making it :)
 
Last edited:
Nar all main's work all credit am keeping as his i just simply updated it for beta.
 
Back
Top