Exemple #1
0
 public void SelectChannel(int channel)
 {
     Ssid_Id          = _selectedSsid;
     _selectedChannel = channel;
     _device.ScanChannel((byte)channel);
     _calculator = new LevelCalculator(_selectedSsid, _selectedMac);
 }
Exemple #2
0
        public static void Load()
        {
            string settingsFile = IO.workingDirectory + @"/gsettings.ini";

            if (System.IO.File.Exists(settingsFile) != false)
            {
                ConfigServer.SERVER_KEY_PASSWORD = IO.readINI("Server", "key", settingsFile);
                ConfigServer.SERVER_NAME         = IO.readINI("Server", "name", settingsFile);
                ConfigServer.SERVER_IP           = IO.readINI("Server", "ip", settingsFile);
                ConfigServer.ClientVersion       = Convert.ToInt32(IO.readINI("Server", "clientversion", settingsFile));
                ConfigServer.EXPDinar            = double.Parse(IO.readINI("Server", "expdinarrate", settingsFile));
                ConfigServer.Rates     = Convert.ToInt32(IO.readINI("Server", "rates", settingsFile));
                ConfigServer.Debug     = Convert.ToInt32(IO.readINI("Server", "debug", settingsFile));
                ConfigServer.KillEvent = Convert.ToInt32(IO.readINI("Server", "killevent", settingsFile));
                ConfigServer.CQC       = bool.Parse(IO.readINI("Channels", "CQC", settingsFile));
                ConfigServer.BG        = bool.Parse(IO.readINI("Channels", "BG", settingsFile));
                ConfigServer.AI        = bool.Parse(IO.readINI("Channels", "AI", settingsFile));
                LevelCalculator.SetRates(ConfigServer.Rates);
                string Host     = IO.readINI("Database", "host", settingsFile);
                int    Port     = Convert.ToInt32(IO.readINI("Database", "port", settingsFile));
                string Username = IO.readINI("Database", "username", settingsFile);
                string Password = IO.readINI("Database", "password", settingsFile);
                string Database = IO.readINI("Database", "database", settingsFile);

                OpenConnection();

                sClient  = new ServerClient(5010);
                Username = Password = string.Empty;
                FormCalling.frm2.Show();
            }
        }
		public string getValueByName(string name)
		{
			switch (name)
			{
				case "LEVEL":
					string a = getValueByKey("player.networkExp");
					if (a == null)
						return "0";
					return LevelCalculator.GetExactStringLevel(
						double.Parse(
							a
							)
						);
				case "BW_FKD":
					try
					{
						int kills = int.Parse(getValueByKey("player.stats.Bedwars.final_kills_bedwars"));
						int deaths = int.Parse(getValueByKey("player.stats.Bedwars.final_deaths_bedwars"));
						double rate = (double)kills / deaths;
						return rate.ToString("N1");
					} catch
					{
						return "?";
					}
				default:
					if (name.Contains("+"))
					{
						string[] namelist = name.Split("+");
						if (namelist.Length < 2)
							return null;
						StringBuilder builder = new StringBuilder();
						string[] colorlist = new string[6] { "6", "a", "c", "d", "e", "b" };
						for (int i = 0; i < namelist.Length; i++)
						{
							if (LevelHead.objlist.ContainsKey(namelist[i]))
							{
								LevelHead.objlist.TryGetValue(namelist[i], out TypeObj value);
								string b = getValue(namelist[i], value);
								if (b != null)
								{
									builder.Append(" &!");
									builder.Append(colorlist[i % 6]);
									builder.Append(b);
								} else
								{
									Console.WriteLine($"Warning: getValue({namelist[i]}) not found");
								}
							}
						}
						return builder.ToString();
					} else
					{
						return null;
					}
			}
			return null;
		}
Exemple #4
0
        public void TestMethod2()
        {
            LevelCalculator calculator = new LevelCalculator();

            using (var textStream = CreateResource())
            {
                Assert.AreEqual(1783, calculator.PassingLevelAfterSteps(-1, InputReader.ReadResource(textStream)));
            }
        }
Exemple #5
0
        public void TestCalcLevels()
        {
            LevelCalculator calculator = new LevelCalculator();

            using (var textStream = CreateResource())
            {
                Assert.AreEqual(232, calculator.CalcLevels(InputReader.ReadResource(textStream)));
            }
        }
Exemple #6
0
 public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
 {
     try
     {
         int    OPCode      = Convert.ToInt32(getBlock(0));
         int    Period      = Convert.ToInt32(getBlock(4));
         string Code        = getBlock(1);
         int[]  convertDays = new int[6] {
             3, 7, 15, 30, 1, -1
         };
         Item Item = ItemManager.getItem(Code);
         if (Item != null)
         {
             int Price = Item.getCashPrice(Period);
             if (User.Cash - Price < 1)
             {
                 User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.NotEnoughDinar, "NULL"));
             }
             else if (LevelCalculator.getLevelforExp(User.Exp) < Item.Level && User.Rank < 3)
             {
                 User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.LevelLow, "NULL"));
             }
             else
             {
                 int InventorySlot = User.InventorySlots;
                 if (InventorySlot >= 0)
                 {
                     User.Cash -= Price;
                     DB.runQuery("UPDATE users SET cash='" + User.Cash + "' WHERE id='" + User.UserID + "'");
                     User.LoadItems();
                     User.AddOutBoxItem(Code, convertDays[Period], 1);
                     User.send(new PACKET_OUTBOX_SEND(User));
                     Log.AppendText(User.Nickname + " has bought [" + Item.Code.ToUpper() + "-" + Item.Name + "] for " + convertDays /*[Period]*/ + "days.");
                 }
                 else
                 {
                     User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.InventoryFull, "NULL"));
                 }
             }
         }
         else
         {
             User.send(new Packets.PACKET_ITEMSHOP(Packets.PACKET_ITEMSHOP.ErrorCodes.CannotBeBougth, "NULL"));
         }
     }
     catch (Exception ex)
     {
         Log.AppendError(ex.Message);
     }
 }
 void UpdateModelAttribute()
 {
     toLevelUp.levelUp             = false;
     toLevelUp.attribute           = new Attribute();
     toLevelUp.elemental           = new ElementAttribute();
     toLevelUp.name                = pName.text;
     toLevelUp.level              += LevelCalculator.CalculateGainedLevel(toLevelUp.exp, toLevelUp.level);
     toLevelUp.attribute.endurance = attEnd.GetValue();
     toLevelUp.attribute.agi       = attAgi.GetValue();
     toLevelUp.attribute.cons      = attCon.GetValue();
     toLevelUp.attribute.intel     = attInt.GetValue();
     toLevelUp.attribute.wisdom    = attWis.GetValue();
     toLevelUp.attribute.str       = attStr.GetValue();
     PlayerSession.GetInstance().SaveSession();
 }
 public void SetForLevelUp(CharacterModel model)
 {
     //TODO Badly need new recalculation on total attributes
     isNewGame = false;
     if (model.exp > 0)
     {
         bonusValue = LevelCalculator.CalculateGainedLevel(model.exp, model.level) * 3;
     }
     else
     {
         bonusValue = 15;
     }
     //pName.interactable = false;
     initialAttr = model.attribute.DeepCopy();
     pName.text  = model.name;
     toLevelUp   = model;
     LoadModelAttribute(model.attribute);
     startingValue = TotalAttributeValue();
     RecalculateRemainingValue();
 }
Exemple #9
0
        static void Main()
        {
            DateTime current = DateTime.Now;
            string   nTime   = String.Format("{0:dd_MM_yy}", current);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Log.setup("Log_" + nTime + ".txt");

            string settingsFile = IO.workingDirectory + @"/gsettings.ini";
            string newitembin   = IO.workingDirectory + @"/out.bin";

            if (File.Exists(newitembin))
            {
                File.Delete(IO.workingDirectory + @"/items.bin");
                File.Move(IO.workingDirectory + @"/out.bin", IO.workingDirectory + @"/items.bin");
            }

            if (File.Exists(settingsFile) == false)
            {
                Application.Run(new Form10());
            }

            if (File.Exists(settingsFile) != false)
            {
                ConfigServer.SERVER_KEY_PASSWORD = IO.readINI("Server", "key", settingsFile);
                ConfigServer.SERVER_NAME         = IO.readINI("Server", "name", settingsFile);
                ConfigServer.SERVER_IP           = IO.readINI("Server", "ip", settingsFile);
                ConfigServer.ClientVersion       = Convert.ToInt32(IO.readINI("Server", "clientversion", settingsFile));
                ConfigServer.EXPDinar            = double.Parse(IO.readINI("Server", "expdinarrate", settingsFile));
                ConfigServer.Rates     = Convert.ToInt32(IO.readINI("Server", "rates", settingsFile));
                ConfigServer.Debug     = Convert.ToInt32(IO.readINI("Server", "debug", settingsFile));
                ConfigServer.KillEvent = Convert.ToInt32(IO.readINI("Server", "killevent", settingsFile));
                ConfigServer.CQC       = bool.Parse(IO.readINI("Channels", "CQC", settingsFile));
                ConfigServer.BG        = bool.Parse(IO.readINI("Channels", "BG", settingsFile));
                ConfigServer.AI        = bool.Parse(IO.readINI("Channels", "AI", settingsFile));
                LevelCalculator.SetRates(ConfigServer.Rates);
                string Host     = IO.readINI("Database", "host", settingsFile);
                int    Port     = Convert.ToInt32(IO.readINI("Database", "port", settingsFile));
                string Username = IO.readINI("Database", "username", settingsFile);
                string Password = IO.readINI("Database", "password", settingsFile);
                string Database = IO.readINI("Database", "database", settingsFile);

                OpenConnection();

                Username = Password = string.Empty;

                // check if loginserver is open!
                sClient = new ServerClient(5010);

                /* if (sClient.connect("localhost", 5010) == false)
                 * {
                 *   Application.Exit();
                 * }*/
                Application.Run(new Form2());
            }
            else
            {
                Application.Exit();
            }
        }
Exemple #10
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            try
            {
                if (User.Room != null)
                {
                    return;
                }
                int    RoomID   = Convert.ToInt32(getNextBlock());
                string Password = getNextBlock();
                int    Side     = Convert.ToInt32(getBlock(2));//FreeWar > 0 Derb/ 1 NIU/ 2 Random

                virtualRoom Room = RoomManager.getRoom(User.Channel, RoomID);

                if (Room != null)
                {
                    bool LevelLimit = true;
                    switch (Room.LevelLimit)
                    {
                    case 0: { LevelLimit = false; break; }

                    case 1: { if (LevelCalculator.getLevelforExp(User.Exp) <= 4)
                              {
                                  LevelLimit = false;
                              }
                              break; }

                    case 2: { if (LevelCalculator.getLevelforExp(User.Exp) > 5)
                              {
                                  LevelLimit = false;
                              }
                              break; }

                    case 3: { if (LevelCalculator.getLevelforExp(User.Exp) > 13)
                              {
                                  LevelLimit = false;
                              }
                              break; }

                    case 4: { if (LevelCalculator.getLevelforExp(User.Exp) > 23)
                              {
                                  LevelLimit = false;
                              }
                              break; }

                    case 5: { if (LevelCalculator.getLevelforExp(User.Exp) > 33)
                              {
                                  LevelLimit = false;
                              }
                              break; }
                    }

                    bool canJoinPing = false;
                    switch (Room.Ping)
                    {
                    case 0: if (User.Ping < 150)
                        {
                            canJoinPing = true;
                        }
                        else
                        {
                            canJoinPing = false;
                        } break;

                    case 1: if (User.Ping < 250)
                        {
                            canJoinPing = true;
                        }
                        else
                        {
                            canJoinPing = false;
                        } break;

                    case 2: canJoinPing = true; break;
                    }

                    if ((Room.Players.Count >= Room.MaxPlayers || Room.RoomType == 1 && (User.ClanRank == -1 || User.ClanRank == 9) || (Room.RoomType == 1 && (Room.getSideCount(0) > 0 && Room.getSideCount(1) > 0 && Room.isMyClan(User) == false)) || Room.RoomType == 1 && User.ClanID == -1 || canJoinPing == false && User.Rank < 2 || Room.UserLimit || Room.isJoinAble() == false || User.pingOK == false) && User.Rank < 2)
                    {
                        User.send(new PACKET_JOIN_ROOM(PACKET_JOIN_ROOM.ErrorCodes.GenericError));
                    }
                    else if (Password != "NULL" && (Password != Room.Password))
                    {
                        User.send(new PACKET_JOIN_ROOM(PACKET_JOIN_ROOM.ErrorCodes.InvalidPassword));
                    }
                    else if (LevelLimit == true)
                    {
                        User.send(new PACKET_JOIN_ROOM(PACKET_JOIN_ROOM.ErrorCodes.BadLevel));
                    }
                    else if (User.Premium == 0 && Room.PremiumOnly == 1)
                    {
                        User.send(new PACKET_JOIN_ROOM(PACKET_JOIN_ROOM.ErrorCodes.OnlyPremium));
                    }
                    else
                    {
                        if (User.Room != null)
                        {
                            return;
                        }
                        if (Room.joinUser(User, Side) == true)
                        {
                            ArrayList tempPlayers = new ArrayList();
                            User.isReady      = false;
                            User.isSpawned    = false;
                            User.BackedToRoom = false;
                            User.Health       = 0;
                            foreach (virtualUser RoomUser in Room.Players)
                            {
                                if (RoomUser.Equals(User) == false)
                                {
                                    tempPlayers.Add(RoomUser);
                                }
                            }
                            User.send(new PACKET_ROOM_UDP(User, tempPlayers));

                            foreach (virtualUser tempSpectator in Room.Spectators)
                            {
                                User.send(new PACKET_ROOM_UDP_SPECTATE(tempSpectator));
                            }

                            // User.send(new PACKET_JOIN_ROOM(User, Room));

                            tempPlayers.Clear();
                            tempPlayers.Add(User);

                            foreach (virtualUser RoomUser in Room.Players)
                            {
                                RoomUser.send(new PACKET_ROOM_UDP(RoomUser, tempPlayers));
                            }

                            foreach (virtualUser SpectatorUser in Room.Spectators)
                            {
                                SpectatorUser.send(new PACKET_ROOM_UDP(SpectatorUser, tempPlayers));
                            }

                            /* Send out changed Room Data */
                            foreach (virtualUser _User in UserManager.getUsersInChannel(Room.Channel, false))
                            {
                                if (_User.Page == Math.Floor(Convert.ToDecimal(Room.ID / 14)))
                                {
                                    _User.send(new PACKET_ROOMLIST_UPDATE(Room));
                                }
                            }
                        }
                        else
                        {
                            User.send(new PACKET_JOIN_ROOM(PACKET_JOIN_ROOM.ErrorCodes.GenericError));
                        }
                    }
                }
                else
                {
                    User.send(new PACKET_JOIN_ROOM(PACKET_JOIN_ROOM.ErrorCodes.GenericError));
                }
            }
            catch { User.send(new PACKET_JOIN_ROOM(PACKET_JOIN_ROOM.ErrorCodes.GenericError)); }
        }
Exemple #11
0
 public static void ShowStats(Character character)
 {
     GTA.UI.TextElement elmnt = new GTA.UI.TextElement("~w~Level: ~g~" + LevelCalculator.GetPlayerLevel(character.Xp) + " ~b~\\|/ ~w~XP to next level: ~g~" + LevelCalculator.GetXpToNextLevel(character.Xp),
                                                       new PointF(GTA.UI.Screen.Width - 250, GTA.UI.Screen.Height - 20), 0.4f, Color.White, GTA.UI.Font.ChaletLondon);
     elmnt.Draw();
 }
Exemple #12
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            string unknownObj = getNextBlock();
            string WeaponID   = getBlock(1);
            int    Period     = Convert.ToInt32(getBlock(4));

            int[] convertDays = new int[6] {
                3, 7, 15, 30, 1, -1
            };

            Item Item = ItemManager.getItem(WeaponID);

            if (Item != null)
            {
                if (Item.Buyable && Item.getPrice(Period) >= 0)
                {
                    if (Item.Premium && User.Premium <= 0)
                    {
                        User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.PremiumOnly, unknownObj));
                    }
                    else if (LevelCalculator.getLevelforExp(User.Exp) < Item.Level && User.Rank < 2)
                    {
                        User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.LevelLow, unknownObj));
                    }
                    else
                    {
                        int DinarResult = User.Dinar - Item.getPrice(Period);
                        if (DinarResult >= 0)
                        {
                            int InventorySlot = User.InventorySlots;
                            if (InventorySlot > 0)
                            {
                                User.AddItem(WeaponID, convertDays[Period], 1);
                                User.Dinar = DinarResult;
                                DB.runQuery("UPDATE users SET dinar='" + DinarResult + "' WHERE id=" + User.UserID);
                                User.Inventory = new InventoryItem[105];
                                User.LoadItems();
                                User.send(new PACKET_ITEMSHOP(User));
                                Log.AppendText(User.Nickname + " has bought [" + Item.Code.ToUpper() + "-" + Item.Name + "] for " + convertDays[Period] + "days.");
                            }
                            else
                            {
                                User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.InventoryFull, unknownObj));
                            }
                        }
                        else
                        {
                            User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.NotEnoughDinar, unknownObj));
                        }
                    }
                }
                else
                {
                    User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.CannotBeBougth, unknownObj));
                }
            }
            else
            {
                User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.CannotBeBougth, unknownObj));
            }
        }
Exemple #13
0
 public static int GenerateDrugAmount(Drug drug)
 {
     return(GetRandomNumber(0, (drug.BaseAmount * LevelCalculator.GetPlayerLevel(DatabaseHandler.character.Xp))));
 }
 public void GetExperience(int ex)
 {
     exp += ex;
     //TODO Calculating exp needed for next level
     levelUp = LevelCalculator.CalculateLevelUp(exp, level);
 }
Exemple #15
0
        public PACKET_CHARACTER_INFO(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            newPacket(25088);
            addBlock(1);
            addBlock("ReBornWarRock");
            addBlock(User.SessionID);   // SessionID UDP
            addBlock(User.UserID);      // UserID
            addBlock(User.SessionID);   // SessionIDz UDP
            addBlock(User.Nickname);    // Nickname
            //Clan
            addBlock(User.ClanID);
            addBlock(User.ClanIconID);
            addBlock(User.ClanName);
            addBlock(-1);
            addBlock(User.ClanRank);
            //END Clan

            addBlock(0); // Premium Type

            // Level & Exp
            addBlock(LevelCalculator.getLevelforExp(User.Exp)); // Level for EXP
            addBlock(User.Exp);                                 // Exp
            addBlock(-1);                                       // Unknown
            addBlock(0);
            addBlock(User.Dinar);
            addBlock(User.Kills);  // Kills
            addBlock(User.Deaths); // Deaths
            addBlock(0);
            addBlock(0);
            addBlock(0);
            addBlock(0);
            addBlock(0);
            addBlock(User.getSlots()); //Slots Enabled

            // Player Equipment //
            for (int Class = 0; Class < 5; Class++)
            {
                StringBuilder ClassBuilder = new StringBuilder();

                for (int Slot = 0; Slot < 8; Slot++)
                {
                    ClassBuilder.Append(User.Equipment[Class, Slot]);
                    if (Slot != 7)
                    {
                        ClassBuilder.Append(",");
                    }
                }
                addBlock(ClassBuilder.ToString());
            }

            addBlock(User.rebuildWeaponList());

            addBlock(User.MaxSlots);

            addBlock(User.CostumeE);
            addBlock(User.CostumeM);
            addBlock(User.CostumeS);
            addBlock(User.CostumeA);
            addBlock(User.CostumeH);

            // Costume Inventory //

            addBlock(User.rebuildCostumeList());
            addBlock(User.Premium);
            addBlock(1);
            addBlock(-1);
            addBlock(0);
            addBlock(0);
            addBlock(0);
            addBlock(1);
        }
Exemple #16
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            try
            {
                int OPCode = Convert.ToInt32(getNextBlock());
                if (OPCode == 1113) // Item Shop Open
                {
                    User.reloadCash();
                    User.reloadOutBox();
                    User.reloadEquipment();
                    User.rebuildCostumeList();
                }
                else if (OPCode == 1111)
                {
                    string ItemCode = getBlock(4);
                    if (!User.hasItem(ItemCode))
                    {
                        User.disconnect();
                    }
                    if (ItemCode == "CB01")// Change Nick
                    {
                        string   NewNickname   = getBlock(5);
                        string[] checkUsedNick = DB.runReadRow("SELECT * FROM users WHERE nickname='" + NewNickname + "'");
                        if (checkUsedNick.Length == 0)
                        {
                            switch (User.Rank)
                            {
                            case 2: NewNickname = "[D]" + NewNickname; break;

                            case 3: NewNickname = "[MOD]" + NewNickname; break;

                            case 4: NewNickname = "[MOD]" + NewNickname; break;

                            case 5: NewNickname = "[GM]" + NewNickname; break;

                            case 6: NewNickname = "[GM]" + NewNickname; break;
                            }
                            Log.AppendText("---" + User.Nickname + " is now known as: " + NewNickname + "---");
                            User.Nickname = NewNickname;
                            User.send(new PACKET_CHANGE_NICKNAME(User, User.Nickname));
                            DB.runQuery("DELETE FROM inventory WHERE ownerid = '" + User.UserID + "' AND itemcode = 'CB01'");
                            DB.runQuery("UPDATE users SET nickname='" + NewNickname + "' WHERE id='" + User.UserID + "'");
                            User.Inventory = new InventoryItem[105];
                            User.send(new PACKET_DELETE_WEAPON(User, "CB01"));
                            User.LoadItems();
                            User.reloadCash();
                        }
                        else
                        {
                            User.send(new PACKET_CHANGE_NICKNAME());
                        }
                    }
                    else if (ItemCode == "CB03")
                    {
                        User.Kills  = 0;
                        User.Deaths = 0;
                        DB.runQuery("UPDATE users SET kills='0', deaths='0' WHERE id='" + User.UserID + "'");
                        DB.runQuery("DELETE FROM inventory WHERE ownerid='" + User.UserID + "' AND itemcode='CB03'");
                        User.Inventory = new InventoryItem[105];
                        User.LoadItems();
                        User.send(new PACKET_KILLDEATH_USE(User));
                    }
                    else if (ItemCode == "CZ99" || ItemCode == "CB09" || ItemCode == "CB27" || ItemCode == "CC36" || ItemCode == "CC37" || ItemCode == "CC56" || ItemCode == "CC57")
                    {
                        //if (ItemCode == "CB09" && User.hasItem("CB08") == false) return;
                        DB.runQuery("DELETE FROM inventory WHERE ownerid = '" + User.UserID + "' AND itemcode = '" + ItemCode + "'");
                        int    Rand = new Random().Next(0, 5);
                        string Code = null;
                        int    Days = 1;

                        if (ItemCode == "CB09")
                        {
                            if (Rand == 0)
                            {
                                Code = "DU04"; Days = 7;
                            }
                            else if (Rand == 1)
                            {
                                Code = "DF48"; Days = 15;
                            }
                            else if (Rand == 2)
                            {
                                Code = "CD02"; Days = 15;
                            }
                            else if (Rand == 3)
                            {
                                Code = "CD01"; Days = 15;
                            }
                            else if (Rand == 4)
                            {
                                Code = "DF35"; Days = 30;
                            }
                            else if (Rand == 5)
                            {
                                Code = "DC33"; Days = 30;
                            }
                        }
                        else if (ItemCode == "CB27")
                        {
                            if (Rand == 0)
                            {
                                Code = "DF06"; Days = 15;
                            }
                            else if (Rand == 1)
                            {
                                Code = "DF07"; Days = 15;
                            }
                            else if (Rand == 2)
                            {
                                Code = "DG08"; Days = 15;
                            }
                            else if (Rand == 3)
                            {
                                Code = "DC04"; Days = 15;
                            }
                            else if (Rand == 4)
                            {
                                Code = "DT02"; Days = 15;
                            }
                            else if (Rand == 5)
                            {
                                Code = "DG01"; Days = 15;
                            }
                        }
                        else if (ItemCode == "CC36")
                        {
                            if (Rand == 0)
                            {
                                Code = "DU04"; Days = 7;
                            }
                            else if (Rand == 1)
                            {
                                Code = "DF48"; Days = 15;
                            }
                            else if (Rand == 2)
                            {
                                Code = "CD02"; Days = 15;
                            }
                            else if (Rand == 3)
                            {
                                Code = "CD01"; Days = 15;
                            }
                            else if (Rand == 4)
                            {
                                Code = "DF35"; Days = 30;
                            }
                            else if (Rand == 5)
                            {
                                Code = "DC33"; Days = 30;
                            }
                        }
                        else if (ItemCode == "CC37")
                        {
                            if (Rand == 0)
                            {
                                Code = "DU04"; Days = 7;
                            }
                            else if (Rand == 1)
                            {
                                Code = "DF48"; Days = 15;
                            }
                            else if (Rand == 2)
                            {
                                Code = "CD02"; Days = 15;
                            }
                            else if (Rand == 3)
                            {
                                Code = "CD01"; Days = 15;
                            }
                            else if (Rand == 4)
                            {
                                Code = "DF35"; Days = 30;
                            }
                            else if (Rand == 5)
                            {
                                Code = "DC33"; Days = 30;
                            }
                        }
                        else if (ItemCode == "CZ99")
                        {
                            int[]    tableIDs = DB.runReadColumn("SELECT id FROM random_box_items;", 0, null);
                            int      id       = new Random().Next(1, tableIDs.Length);
                            string[] Data     = DB.runReadRow("SELECT * FROM `random_box_items` WHERE id=" + tableIDs[id]);
                            Code = Data[1];
                            Days = int.Parse(Data[2]);
                        }
                        else if (ItemCode == "CC56")
                        {
                            if (Rand == 0)
                            {
                                Code = "DU04"; Days = 7;
                            }
                            else if (Rand == 1)
                            {
                                Code = "DF48"; Days = 15;
                            }
                            else if (Rand == 2)
                            {
                                Code = "CD02"; Days = 15;
                            }
                            else if (Rand == 3)
                            {
                                Code = "CD01"; Days = 15;
                            }
                            else if (Rand == 4)
                            {
                                Code = "DF35"; Days = 30;
                            }
                            else if (Rand == 5)
                            {
                                Code = "DC33"; Days = 30;
                            }
                        }
                        else if (ItemCode == "CC57")
                        {
                            if (Rand == 0)
                            {
                                Code = "DU04"; Days = 7;
                            }
                            else if (Rand == 1)
                            {
                                Code = "DF48"; Days = 7;
                            }
                            else if (Rand == 2)
                            {
                                Code = "CD02"; Days = 15;
                            }
                            else if (Rand == 3)
                            {
                                Code = "CD01"; Days = 15;
                            }
                            else if (Rand == 4)
                            {
                                Code = "DF35"; Days = 30;
                            }
                            else if (Rand == 5)
                            {
                                Code = "DC33"; Days = 30;
                            }
                        }
                        User.AddOutBoxItem(Code, Days, 1);
                        User.Inventory = new InventoryItem[105];
                        User.LoadItems();
                        User.send(new PACKET_RANDOM_BOX(User, Code, Days));
                    }
                    else
                    {
                        Log.AppendError(" - Unknown ItemCode, blocks: " + string.Join(" ", getAllBlocks()));
                    }
                }
                else if (OPCode == 1110) // Buy with cash
                {
                    //1110 1110 2 3 0 750 DA03 0
                    int    Period      = Convert.ToInt32(getBlock(3));
                    int    CashToPay   = Convert.ToInt32(getBlock(5));
                    string ItemCode    = getBlock(6);
                    int    EACount     = 0;
                    int[]  convertDays = new int[6] {
                        3, 7, 15, 30, 1, -1
                    };

                    Item Item = ItemManager.getItem(ItemCode);
                    if (Item != null)
                    {
                        if (Item.Code == "CZ83" || Item.Code == "CZ84" || Item.Code == "CZ85")
                        {
                            if (Period == 0)
                            {
                                EACount = 1;
                            }
                            if (Period == 1)
                            {
                                EACount = 10;
                            }
                            if (Period == 2)
                            {
                                EACount = 30;
                            }
                        }
                        int Price = Item.getCashPrice(Period);
                        if (User.Cash < Price)
                        {
                            User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.NotEnoughDinar, "NULL"));
                        }
                        else if (LevelCalculator.getLevelforExp(User.Exp) < Item.Level && User.Rank < 2)
                        {
                            User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.LevelLow, "NULL"));
                        }
                        else if (User.Cash > Price && Item.Buyable == true && Price >= 0)
                        {
                            int InventorySlot = User.InventorySlots;
                            if (InventorySlot > 0)
                            {
                                #region military
                                string[] military = { "CR39", "CR09", "CR11" };
                                foreach (string x in military)
                                {
                                    if (ItemCode == x)
                                    {
                                        User.AddOutBoxItem(ItemCode, -1, 1); break;
                                    }
                                    ;
                                }
                                #endregion

                                #region SendItem
                                switch (ItemCode)
                                {
                                case "CB01":
                                {
                                    User.AddOutBoxItem(ItemCode, -1, 1);
                                    break;
                                }

                                case "CB03":
                                {
                                    User.AddOutBoxItem(ItemCode, -1, 1);
                                    break;
                                }

                                case "CB09":
                                {
                                    User.AddOutBoxItem(ItemCode, -1, 1);
                                    break;
                                }

                                case "CZ83":
                                {
                                    User.AddOutBoxItem(ItemCode, -1, EACount);
                                    break;
                                }

                                case "CZ84":
                                {
                                    User.AddOutBoxItem(ItemCode, -1, EACount);
                                    break;
                                }

                                case "CZ85":
                                {
                                    User.AddOutBoxItem(ItemCode, -1, EACount);
                                    break;
                                }

                                default:
                                {
                                    User.AddOutBoxItem(ItemCode, convertDays[Period], EACount);
                                    //User.AddItem(ItemCode, convertDays[Period]);
                                    break;
                                }
                                }
                                #endregion
                                User.Cash     -= Price;
                                User.Inventory = new InventoryItem[105];
                                DB.runQuery("UPDATE users SET cash='" + User.Cash + "' WHERE id='" + User.UserID + "'");
                                User.LoadItems();
                                User.send(new PACKET_OUTBOX_SEND(User));
                                Log.AppendText(User.Nickname + " has bought [" + Item.Code.ToUpper() + "-" + Item.Name + "] for " + convertDays[Period] + "days.");
                            }
                            else
                            {
                                User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.InventoryFull, "NULL"));
                            }
                        }
                        else
                        {
                            User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.CannotBeBougth, "NULL"));
                        }
                    }
                    else
                    {
                        if (ItemCode == "CB02" || ItemCode == "CB53" || ItemCode == "CB54")
                        {
                            User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Whisper, "SYSTEM >> This item is available only on Webshop!", User.SessionID, User.Nickname));
                        }
                        Log.AppendError(User.Nickname + " tried to buy: " + ItemCode + " but is not available yet.");
                        User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.CannotBeBougth, "NULL"));
                    }
                }
                else
                {
                    Log.AppendText("New Cash ErrCode: " + OPCode);
                    Log.AppendText(string.Join(" ", getAllBlocks()));
                }
            }
            catch (Exception ex)
            {
                Log.AppendError("MySQL Error: " + ex.Message);
            }
        }