Hello again

After a few hours of work (looking for tutorials), I finally managed to make a little mage trainer for EA Shards.
after a few tests on "Test Center", it works!
Only a little problem...
If i run the program from Visual Studio 2017 I have no crash.
But If i open the build release with Admin right, it will insta crash the Client.exe but continue working on stealth.
using System;
using StealthAPI;
using ScriptSDK.Mobiles;
using ScriptSDK.Targets;
namespace PapangTrainer
{
class Program
{
public static PlayerMobile Me = PlayerMobile.GetPlayer();
public static bool IsBusy = false;
public static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Press [1] for Magery");
string Select = Console.ReadLine();
switch (Select)
{
case "1":
IsBusy = true;
while (IsBusy)
{
var _MageMax = Stealth.Client.GetSkillCap(Skill.Magery);
var _CurMage = Stealth.Client.GetSkillValue(Skill.Magery);
var Target = new EntityTarget(1000);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("\r " + "[magery @ " + _CurMage + "/" + _MageMax + "]");
if (Me.Mana < 25)
Medit();
if (_CurMage >= 0 && _CurMage < 34)
{
Me.Cast("Bless");
Stealth.Client.Wait(850);
Target.Action(Target.Entity);
}
else if (_CurMage >= 34 && _CurMage < 45)
{
Me.Cast("Greater Heal");
Me.Targeting.WaitForTarget(1000);
Target.Action(Target.Entity);
}
else if (_CurMage >= 45 && _CurMage < 67)
{
Me.Cast("Dispel Field");
Me.Targeting.WaitForTarget(1000);
Target.Action(Target.Entity);
}
else if (_CurMage >= 67 && _CurMage < 82)
{
Me.Cast("Invisibility");
Me.Targeting.WaitForTarget(1500);
Target.Action(Target.Entity);
}
else if (_CurMage >= 82 && _CurMage < 95)
{
Me.Cast("Mass Dispel");
Me.Targeting.WaitForTarget(2000);
Target.Action(Target.Entity);
}
else if (_CurMage >= 95 && _CurMage < 120)
{
Me.Cast("Earthquake");
Stealth.Client.Wait(1500);
}
else
{
Console.WriteLine("Magery Cap Raised ! Congratulation.");
IsBusy = false;
}
}
break;
}
}
public static void Medit()
{
do
{
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.Write("\r" + "Meditating ... MWaah !");
Stealth.Client.CancelTarget();
Stealth.Client.UseSkill(Skill.Meditation);
Stealth.Client.Wait(500);
} while (Me.Mana < Me.MaxMana);
}
}
}
Post Merge: December 21, 2017, 11:46:32 AM
If you are shocked by the code structure, all tips will be welcome, I have never done anything like this before.
My goal is to learn and share, each advice received will allow me to evolve and share my achievements on the forum.