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

Loading a new profile?

ohcrit95

New Member
Joined
May 22, 2010
Messages
49
Reaction score
0
Hey guys,

Been workin' on a little plugin, and for some reason:

Code:
ProfileManager.LoadNew("C:\blahblahblah.xml");

Won't work for me. Maybe I'm doing something wrong with the file name? Any help is appreciated.

Thanks. :cool:
 
Code:
using System;
using System.Collections.Generic;
using System.Text;
using Styx.Plugins.PluginClass;
using System.Diagnostics;
using Styx.Helpers;
using Styx.WoWInternals;
using Styx.WoWInternals.WoWObjects;
using Styx.Logic.Profiles;
using System.Windows.Forms;

namespace SkiProfileSwitcher
{
    public class SkiProfileSwitcher : HBPlugin
    {
        #region config
        private bool _useTimer = skiProfileSwitcher.Properties.Settings.Default.useTimer; //Change profiles based on Time
        private bool _useKills = skiProfileSwitcher.Properties.Settings.Default.useKills; //Change profiles based on Kills
        private bool _useRandom = skiProfileSwitcher.Properties.Settings.Default.useRandom; //Change profiles randomly instead of linearly
        private uint _maxKills = skiProfileSwitcher.Properties.Settings.Default.maxKills; //Change profiles after this many kills
        private int _maxTime = skiProfileSwitcher.Properties.Settings.Default.maxTime; //Change profiles after this long in seconds
        private string _profile1 = skiProfileSwitcher.Properties.Settings.Default.profile1; //Profile to start with
        private string _profile2 = skiProfileSwitcher.Properties.Settings.Default.profile2; //second profile
        private string _profile3 = skiProfileSwitcher.Properties.Settings.Default.profile3; //third profile
        private string _profile4 = skiProfileSwitcher.Properties.Settings.Default.profile4; //fourth profile

        private bool _debug = skiProfileSwitcher.Properties.Settings.Default.debug;
        #endregion

        private string _logspam;
        private bool _initialized = false;
        private int _count = skiProfileSwitcher.Properties.Settings.Default.profileNum - 1;

        public override void OnButtonPress()
        {
            skiProfileSwitcher.SkiProfileSwitchGui form = new skiProfileSwitcher.SkiProfileSwitchGui();
            form.ShowDialog();
        }

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

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

        public override Version Version
        {
            get { return new Version(1, 0); }
        }

        public override string Name
        {
            get { return "skiProfileSwitcher"; }
        }

        Stopwatch _sw = new Stopwatch();
        Stopwatch _timer = new Stopwatch();

        public override void Pulse()
        {
            if (!_initialized)
            {
                _sw.Stop();
                _sw.Reset();
                _sw.Start();

                if (_debug) { Slog("[SkiProfileSwitch] Initial profile switch to: " + _profile1); }
                SwitchProfile(_profile1);
                _initialized = true;
                if (_debug) { Slog("[SkiProfileSwitch] Initialized."); }
            }

            if (_debug) { Slog("[SkiProfileSwitch] sw Elasped:" + _sw.ElapsedMilliseconds); }

            if (!Styx.WoWInternals.ObjectManager.Me.Combat && _sw.ElapsedMilliseconds > 30000)
            {
                _useTimer = skiProfileSwitcher.Properties.Settings.Default.useTimer; //Change profiles based on Time
                _useKills = skiProfileSwitcher.Properties.Settings.Default.useKills; //Change profiles based on Kills
                _useRandom = skiProfileSwitcher.Properties.Settings.Default.useRandom; //Change profiles randomly instead of linearly
                _maxKills = skiProfileSwitcher.Properties.Settings.Default.maxKills; //Change profiles after this many kills
                _maxTime = skiProfileSwitcher.Properties.Settings.Default.maxTime; //Change profiles after this long in seconds
                _profile1 = skiProfileSwitcher.Properties.Settings.Default.profile1; //Profile to start with
                _profile2 = skiProfileSwitcher.Properties.Settings.Default.profile2; //second profile
                _profile3 = skiProfileSwitcher.Properties.Settings.Default.profile3; //third profile
                _profile4 = skiProfileSwitcher.Properties.Settings.Default.profile4; //fourth profile

                string[] profiles = { _profile1.ToLower(), _profile2.ToLower(), _profile3.ToLower(), _profile4.ToLower() };

                if (_useTimer && !_timer.IsRunning)
                {
                    if (_debug) { Slog("[SkiProfileSwitch] Timer Started"); }
                    _timer.Stop();
                    _timer.Reset();
                    _timer.Start();
                }

                if (_useRandom)
                {
                    //random profile selection here
                }

                else
                {
                    if (_debug) { Slog("[SkiProfileSwitch] Current Elapsed Time: " + _timer.Elapsed); }
                    if (_debug) { Slog("[SkiProfileSwitch] Current kills = " + Styx.Helpers.InfoPanel.MobsKilled); }
                    if (_debug) { Slog("[SkiProfileSwitch] Max kills = " + _maxKills); }

                    if (CheckKills(_maxKills) || CheckTime(_maxTime))
                    {
                        if (_debug) { Slog("[SkiProfileSwitch] CheckKills = " + CheckKills(_maxKills).ToString()); }
                        if (_debug) { Slog("[SkiProfileSwitch] CheckTime = " + CheckTime(_maxTime).ToString()); }
                        if (_debug) { Slog("[SkiProfileSwitch] Current Profile Path = " + GetCurrentProfilePath()); }
                        if (_debug) { Slog("[SkiProfileSwitch] First Profile Path = " + _profile1); }

                        if (CheckTime(_maxTime))
                        {
                            _timer.Stop();
                            _timer.Reset();
                            _timer.Start();
                        }
                        for (int i = 0; i <= _count; i++)
                        {
                            if (_debug) { Slog("[SkiProfileSwitch] In For Loop, i = " + i); }
                            if (_debug) { Slog("[SkiProfileSwitch] Profile: " + profiles[i]); }
                            if (profiles[i] == GetCurrentProfilePath())
                            {
                                if (_debug) { Slog("[SkiProfileSwitch] Profiles[" + i + "] equals current profile path (" + GetCurrentProfilePath() + ")"); }
                                if (i < _count)
                                {
                                    if (profiles[i + 1] != "")
                                    {
                                        Slog("[SkiProfileSwitch] Switching to profile at index" + (i + 1) + " - " + profiles[i + 1]);
                                        SwitchProfile(profiles[i + 1]);
                                        Styx.Helpers.InfoPanel.Reset();
                                        break;
                                    }

                                }

                                else if (i == _count)
                                {
                                    if (profiles[0] != "")
                                    {
                                        Slog("[SkiProfileSwitch] Switching to profile at index 0 - " + profiles[0]);
                                        SwitchProfile(profiles[0]);
                                        Styx.Helpers.InfoPanel.Reset();
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                _sw.Stop();
                _sw.Reset();
                _sw.Start();
            }
        }

        private void SwitchProfile(string _path)
        {
            ProfileManager.LoadNew(_path);
        }

        private bool CheckKills(uint _kills)
        {
            if (!_useKills)
            {
                return false;
            }
            else if (Styx.Helpers.InfoPanel.MobsKilled >= _kills)
            {
                return true;
            }

            else return false;
        }

        private bool CheckTime(int time)
        {
            if (!_useTimer)
            {
                return false;
            }
            else if ((time * 1000 * 60) <= _timer.ElapsedMilliseconds)
            {
                return true;
            }

            else return false;
        }

        private string GetCurrentProfilePath()
        {
            return StyxSettings.HBSettings.LastUsedPath.ToLower();
        }

        public void Slog(string msg)
        {
            if (msg != _logspam)
            {
                Logging.Write(msg);
                _logspam = msg;
            }
        }
    }
}

Code:
ProfileManager.LoadNew(_path);

Where _path is a string. Don't forget to escape char your slashes/quotes if need be.
 
Ah. Thank-you so much. I had no idea what an escape key was; did a little Google research, and I found what I was doing wrong.

Many thanks to you, oh-wise-one. :P

Mitch.
 
Back
Top