private void SellMedic() { uint tottal = 0; try { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("medics").Where("Name", PName.Text).Execute(); MySqlReader r = new MySqlReader(cmd); if (r.Read()) { tottal = r.ReadUInt32("Count"); } if (tottal > 0) { tottal = --tottal; PTottal.Clear(); PTottal.Text = tottal.ToString(); MySqlCommand CMD = new MySqlCommand(MySqlCommandType.UPDATE); CMD.Update("medics") .Set("Count", tottal); CMD.Where("Name", PName.Text).Execute(); MessageBox.Show("تم بيع واحد"); SaveSold(); SellCom = true; } else { MessageBox.Show("الدواء غير متوفر"); } } catch (Exception ep) { MessageBox.Show(ep.ToString()); } }
public AccountTable(string username) { if (username == null) { return; } this.Username = username; this.Password = ""; this.IP = ""; this.State = Enums.AccountState.Default; this.EntityID = 0; using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("accounts").Where("Username", username)) using (var reader = new MySqlReader(cmd)) { if (reader.Read()) { exists = true; this.Password = reader.ReadString("Password"); this.IP = reader.ReadString("Ip"); this.EntityID = reader.ReadUInt32("EntityID"); this.State = (Enums.AccountState)reader.ReadInt32("State"); using (var cmd2 = new MySqlCommand(MySqlCommandType.SELECT).Select("characters").Where("UID", EntityID)) using (var reader2 = new MySqlReader(cmd2)) { if (reader2.Read()) { Name = reader2.ReadString("Name"); Rank = (ushort)Entity.RankExperiences.Where(i => i.Value >= reader2.ReadUInt32("Experience")).FirstOrDefault().Key; byte[] Battles = reader2.ReadBlob("Battles"); var battles = new List <Battle>(); if (Battles.Length > 0) { using (var stream = new System.IO.MemoryStream(Battles)) using (var rdr = new System.IO.BinaryReader(stream)) { int count = rdr.ReadInt32(); for (int i = 0; i < count; i++) { Battle battle = new Battle { GameMode = (Enums.GameMode)rdr.ReadByte(), Won = rdr.ReadBoolean(), Kills = rdr.ReadUInt16(), Deaths = rdr.ReadUInt16() }; battles.Add(battle); } } } TotalDeaths = (uint)battles.Sum(i => i.Deaths); TotalKills = (uint)battles.Sum(i => i.Kills); } } } } }
public static void LoadServer(bool KnowConfig) { Time32 Start = Time32.Now; RandomSeed = Convert.ToInt32(DateTime.Now.Ticks.ToString().Remove(DateTime.Now.Ticks.ToString().Length / 2)); Console.Title = "Conquord Is Loading..."; Kernel.Random = new FastRandom(RandomSeed); if (!KnowConfig) { ConquordDBName = "test"; ConquordDBPass = "******"; ConquordIP = "149.202.128.35"; } System.Console.ForegroundColor = ConsoleColor.DarkGray; IntPtr hWnd = FindWindow(null, Console.Title); System.Console.WriteLine(@" ` ______ __ ` ` "); System.Console.WriteLine(@" / ____/___ ____ ____ ___ ______ _________/ / "); System.Console.WriteLine(@" ` / / / __ \/ __ \/ __ `/ / / / __ \/ ___/ __ / ` ` _ "); System.Console.WriteLine(@" _/ /___/ /_/ / / / / /_/ / /_/ / /_/ / / / /_/ / | | "); System.Console.WriteLine(@" ` \____/\____/_/ /_/\__, /\__,_/\____/_/ \__,_/ ` ___| | "); System.Console.WriteLine(@" ` /_/ ` ` ( .' "); System.Console.WriteLine(@" __ ... _____ Michael Nashaat _____ ... __ ) ( "); System.Console.WriteLine(); System.Console.WriteLine(@" Copyright (c) Conquord Project 2015-2016. "); Console.BackgroundColor = ConsoleColor.Black; System.Console.ForegroundColor = ConsoleColor.DarkGray; Database.DataHolder.CreateConnection(ConquordDBName, ConquordDBPass); Database.EntityTable.EntityUID = new Counter(0); new MySqlCommand(MySqlCommandType.UPDATE).Update("entities").Set("Online", 0).Execute(); using (MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT)) { cmd.Select("configuration"); using (MySqlReader r = new MySqlReader(cmd)) { if (r.Read()) { if (!KnowConfig) { ConquordIP = r.ReadString("ConquordIP"); GamePort = 5816; AuthPort = r.ReadUInt16("ConquordPort"); } Database.EntityTable.EntityUID = new Counter(r.ReadUInt32("EntityID")); if (Database.EntityTable.EntityUID.Now == 0) { Database.EntityTable.EntityUID.Now = 1; } Union.UnionCounter = new Counter(r.ReadUInt32("UnionID")); Kernel.ServerKingdom = (r.ReadUInt32("ServerKingdom")); if (r.ReadByte("LastDailySignReset") != DateTime.Now.Month) { MsgSignIn.Reset(); } Game.ConquerStructures.Society.Guild.GuildCounter = new Conquord.Counter(r.ReadUInt32("GuildID")); Network.GamePackets.ConquerItem.ItemUID = new Conquord.Counter(r.ReadUInt32("ItemUID")); Constants.ExtraExperienceRate = r.ReadUInt32("ExperienceRate"); Constants.ExtraSpellRate = r.ReadUInt32("SpellExperienceRate"); Constants.ExtraProficiencyRate = r.ReadUInt32("ProficiencyExperienceRate"); Constants.MoneyDropRate = r.ReadUInt32("MoneyDropRate"); Constants.ConquerPointsDropRate = r.ReadUInt32("ConquerPointsDropRate"); Constants.ItemDropRate = r.ReadUInt32("ItemDropRate"); Constants.ItemDropQualityRates = r.ReadString("ItemDropQualityString").Split('~'); Database.EntityVariableTable.Load(0, out Vars); } } } using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration")) cmd.Set("LastDailySignReset", DateTime.Now.Month).Execute(); Database.JiangHu.LoadStatus(); Database.JiangHu.LoadJiangHu(); Console.WriteLine("JiangHu Loaded."); Way2Heroes.Load(); QuestInfo.Load(); AuctionBase.Load(); Database.DataHolder.ReadStats(); Conquord.Soul.SoulProtection.Load(); Database.PerfectionTable.Load(); Console.WriteLine("Perfection Loaded."); Database.LotteryTable.Load(); Database.ConquerItemTable.ClearNulledItems(); Database.ConquerItemInformation.Load(); Console.WriteLine("Items Loaded."); Database.GameUpdetess.LoadRates(); Database.MonsterInformation.Load(); Database.IPBan.Load(); Database.SpellTable.Load(); Database.ShopFile.Load(); Database.HonorShop.Load(); Database.RacePointShop.Load(); Database.ChampionShop.Load(); Database.EShopFile.Load(); Database.EShopV2File.Load(); Console.WriteLine("Shops Loaded."); Database.MapsTable.Load(); Database.Flowers.LoadFlowers(); Database.Flowers.SaveFlowers(); Console.WriteLine("Flowers Systems Loaded."); Database.NobilityTable.Load(); Database.ArenaTable.Load(); Database.TeamArenaTable.Load(); Database.GuildTable.Load(); Database.ChiTable.LoadAllChi(); Console.WriteLine("Social Systems Loaded."); Refinery.LoadItems(); StorageManager.Load(); UnionTable.Load(); Console.WriteLine("Union Loaded."); World = new World(); World.Init(); Database.Statue.Load(); Console.WriteLine("Tops And Quests Loaded."); Database.PoketTables.LoadTables(); Database.InnerPowerTable.LoadDBInformation(); Database.InnerPowerTable.Load(); Console.WriteLine("InnerPower Loaded."); Map.CreateTimerFactories(); Database.SignInTable.Load(); Database.DMaps.Load(); Console.WriteLine("Maps Loaded."); Game.Screen.CreateTimerFactories(); World.CreateTournaments(); Game.GuildWar.Initiate(); Game.ClanWar.Initiate(); Game.Tournaments.SkillTournament.LoadSkillTop8(); Game.Tournaments.TeamTournament.LoadTeamTop8(); Clan.LoadClans(); Game.EliteGuildWar.EliteGwint(); Console.WriteLine("Guilds and Clans loaded."); Booths.Load(); Console.WriteLine("Booths Loaded."); Database.FloorItemTable.Load(); Database.ReincarnationTable.Load(); new MsgUserAbilityScore().GetRankingList(); new MsgEquipRefineRank().UpdateRanking(); PrestigeRank.LoadRanking(); Console.WriteLine("Ranks Loaded."); BruteForceProtection.CreatePoll(); Console.WriteLine("Protection System On."); { Client.GameClient gc = new Client.GameClient(new ClientWrapper()); gc.Account = new AccountTable("NONE"); gc.Socket.Alive = false; gc.Entity = new Entity(EntityFlag.Player, false) { Name = "NONE" }; Npcs.GetDialog(new NpcRequest(), gc, true); } #region OpenSocket Network.Cryptography.AuthCryptography.PrepareAuthCryptography(); AuthServer = new ServerSocket(); AuthServer.OnClientConnect += AuthServer_OnClientConnect; AuthServer.OnClientReceive += AuthServer_OnClientReceive; AuthServer.OnClientDisconnect += AuthServer_OnClientDisconnect; AuthServer.Enable(AuthPort, "0.0.0.0"); GameServer = new ServerSocket(); GameServer.OnClientConnect += GameServer_OnClientConnect; GameServer.OnClientReceive += GameServer_OnClientReceive; GameServer.OnClientDisconnect += GameServer_OnClientDisconnect; GameServer.Enable(GamePort, "0.0.0.0"); #endregion Console.WriteLine("Server loaded iN : " + (Time32.Now - Start) + " MilliSeconds."); ConquordHandler += ConquordConsole_CloseEvent; Native.SetConsoleCtrlHandler(ConquordHandler, true); GC.Collect(); WorkConsole(); }