Ejemplo n.º 1
0
        public static void StartTheServer()
        {
            try
            {
                Console.ForegroundColor = ConsoleColor.Green;
                zoneServer.Monsters     = new List <NonPlayerCharacterClass>();
                zoneServer.Vendors      = new List <VendingMachine>();
                zoneServer.Doors        = new List <Doors>();

                using (SqlWrapper sqltester = new SqlWrapper())
                {
                    if (sqltester.SQLCheck() != SqlWrapper.DBCheckCodes.DBC_ok)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Database setup not correct");
                        Console.WriteLine("Error: #" + sqltester.lasterrorcode + " - " + sqltester.lasterrormessage);
                        Console.WriteLine("Please press Enter to exit.");
                        Console.ReadLine();
                        Process.GetCurrentProcess().Kill();
                    }
                    sqltester.CheckDBs();
                }

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Loaded {0} items", ItemHandler.CacheAllItems());
                Console.WriteLine("Loaded {0} nanos", NanoHandler.CacheAllNanos());
                Console.WriteLine("Loaded {0} spawns", NonPlayerCharacterHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} vendors", VendorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} teleports", DoorHandler.CacheAllFromDB());
                Console.WriteLine("Loaded {0} statels", Statels.CacheAllStatels());

                LootHandler.CacheAllFromDB();
                Tradeskill.CacheItemNames();

                csc.AddScriptMembers();
                csc.CallMethod("Init", null);

                ThreadMgr.Start();
                zoneServer.Start();
                Console.ResetColor();
            }
            catch (MySqlException e)
            {
                Console.WriteLine("MySql Error. Server Cannot Start");
                Console.WriteLine("Exception: " + e.Message);
                string       current = DateTime.Now.ToString("HH:mm:ss");
                StreamWriter logfile = File.AppendText("ZoneEngineLog.txt");
                logfile.WriteLine(current + " " + e.Source + " MySql Error. Server Cannot Start");
                logfile.WriteLine(current + " " + e.Source + " Exception: " + e.Message);
                logfile.Close();
                zoneServer.Stop();
                ThreadMgr.Stop();
                Process.GetCurrentProcess().Kill();
            }
        }
Ejemplo n.º 2
0
        public static void TradeSkillTargetChanged(Client client, int container, int placement)
        {
            if (container != 0 && placement != 0)
            {
                TradeSkillInfos.Add(new TradeSkillInfo(client, 1, container, placement));

                AOItem it = client.Character.GetInventoryAt(placement).Item;

                TradeskillPacket.SendTarget(client.Character, Tradeskill.TargetProcessesCount(it.HighID));

                var l1 = TradeSkillInfos.Where(m => m.Cli == client && m.Location == 0).Select(m => m);
                var l2 = TradeSkillInfos.Where(m => m.Cli == client && m.Location == 1).Select(m => m);

                if (l1.Count() == 1 && l2.Count() == 1)
                {
                    TradeSkillInfo info1 = l1.ElementAt(0);
                    TradeSkillInfo info2 = l2.ElementAt(0);

                    Tradeskill ts = new Tradeskill(client, info1.Placement, info2.Placement);

                    if (ts.IsTradeSkill)
                    {
                        if (ts.ValidateRange())
                        {
                            foreach (TradeSkillSkillInfo si in ts.Skills)
                            {
                                TradeskillPacket.SendRequirement(client.Character, si);
                            }
                            TradeskillPacket.SendResult(
                                client.Character, ts.MinQL, ts.MaxQL, ts.ResultLowId, ts.ResultHighId);
                        }
                        else
                        {
                            TradeskillPacket.SendOutOfRange(client.Character, ts.sMinQl);
                        }
                    }
                    else
                    {
                        TradeskillPacket.SendNotTradeskill(client.Character);
                    }
                }
            }
            else if (container == 0 && placement == 0)
            {
                TradeSkillInfos.RemoveAll(m => (m.Cli == client) && (m.Location == 1));
            }
        }
Ejemplo n.º 3
0
        public static void TradeSkillBuildPressed(Client client, int quality)
        {
            int src =
                TradeSkillInfos.Where(m => m.Cli == client && m.Location == 0).Select(m => m).ElementAt(0).Placement;
            int tgt =
                TradeSkillInfos.Where(m => m.Cli == client && m.Location == 1).Select(m => m).ElementAt(0).Placement;

            Tradeskill ts = new Tradeskill(client, src, tgt);

            if (ts.IsTradeSkill)
            {
                ts.Quality = quality;
                ts.WindowBuild();
            }
            else
            {
                client.SendChatText("It is not possible to assemble those two items. Maybe the order was wrong?");
                client.SendChatText("No combination found!");
            }
            TradeSkillInfos.RemoveAll(m => m.Cli == client);
        }
        public static void TradeSkillBuildPressed(Client client, int quality)
        {
            int src =
                TradeSkillInfos.Where(m => m.Cli == client && m.Location == 0).Select(m => m).ElementAt(0).Placement;
            int tgt =
                TradeSkillInfos.Where(m => m.Cli == client && m.Location == 1).Select(m => m).ElementAt(0).Placement;

            Tradeskill ts = new Tradeskill(client, src, tgt);

            if (ts.IsTradeSkill)
            {
                ts.Quality = quality;
                ts.WindowBuild();
            }
            else
            {
                client.SendChatText("It is not possible to assemble those two items. Maybe the order was wrong?");
                client.SendChatText("No combination found!");
            }
            TradeSkillInfos.RemoveAll(m => m.Cli == client);
        }
        public static void TradeSkillTargetChanged(Client client, int container, int placement)
        {
            if (container != 0 && placement != 0)
            {
                TradeSkillInfos.Add(new TradeSkillInfo(client, 1, container, placement));

                AOItem it = client.Character.GetInventoryAt(placement).Item;

                TradeskillPacket.SendTarget(client.Character, Tradeskill.TargetProcessesCount(it.HighID));

                var l1 = TradeSkillInfos.Where(m => m.Cli == client && m.Location == 0).Select(m => m);
                var l2 = TradeSkillInfos.Where(m => m.Cli == client && m.Location == 1).Select(m => m);

                if (l1.Count() == 1 && l2.Count() == 1)
                {
                    TradeSkillInfo info1 = l1.ElementAt(0);
                    TradeSkillInfo info2 = l2.ElementAt(0);

                    Tradeskill ts = new Tradeskill(client, info1.Placement, info2.Placement);

                    if (ts.IsTradeSkill)
                    {
                        if (ts.ValidateRange())
                        {
                            foreach (TradeSkillSkillInfo si in ts.Skills)
                            {
                                TradeskillPacket.SendRequirement(client.Character, si);
                            }
                            TradeskillPacket.SendResult(
                                client.Character, ts.MinQL, ts.MaxQL, ts.ResultLowId, ts.ResultHighId);
                        }
                        else
                        {
                            TradeskillPacket.SendOutOfRange(client.Character, ts.sMinQl);
                        }
                    }
                    else
                    {
                        TradeskillPacket.SendNotTradeskill(client.Character);
                    }
                }
            }
            else if (container == 0 && placement == 0)
            {
                TradeSkillInfos.RemoveAll(m => (m.Cli == client) && (m.Location == 1));
            }
        }