Beispiel #1
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            string RemoveItem = getNextBlock();
            int    InvID      = Convert.ToInt32(getNextBlock());

            if (User.hasItem(RemoveItem))
            {
                string inventoryID = User.getInventoryID(RemoveItem);
                for (int I = 0; I < 5; I++)
                {
                    for (int J = 0; J < 8; J++)
                    {
                        if (User.Equipment[I, J].Contains(inventoryID))
                        {
                            User.Equipment[I, J] = "^";
                        }
                    }
                }
                User.SaveEquipment();
                User.LoadEquipment();
                User.reloadEquipment();
                DB.runQuery("DELETE FROM inventory WHERE ownerid='" + User.UserID + "' AND itemcode='" + RemoveItem + "'");
                User.Inventory = new InventoryItem[105];
                User.LoadItems();
                User.send(new Packets.PACKET_DELETE_WEAPON(User, RemoveItem));
            }
            else
            {
                User.disconnect();
            }
        }
Beispiel #2
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            string RemoveItem = getBlock(0);

            if (User.hasCostume(RemoveItem))
            {
                DB.runQuery("DELETE FROM inventory_costume WHERE ownerid='" + User.UserID + "' AND itemcode='" + RemoveItem + "'");
                User.Costume = new CostumeItem[105];
                User.LoadItems();
                User.send(new Packets.PACKET_DELETE_COSTUME(User, RemoveItem));
                User.reloadCash();
            }
            else
            {
                User.disconnect();
            }
        }
Beispiel #3
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            int UserID = Convert.ToInt32(getBlock(1));

            if (BanManager.isBlocked(UserID) == false)
            {
                string   LoginName   = getBlock(3);
                int      AccessLevel = Convert.ToInt32(getBlock(8));
                string[] UserData    = DB.runReadRow("SELECT id, username, nickname, exp, dinar, kills, deaths, premium, premiumExpire, cash, rank, coupons, todaycoupon, pc, clanID, clanrank, loginevent, logineventcheck, online, password, salt, country, infinity FROM users WHERE id='" + UserID + "' AND username='******'");
                string[] Event       = DB.runReadRow("SELECT userid, eventid FROM users_events WHERE userid='" + UserID + "'");

                if (UserData.Length > 0)
                {
                    if (Event.Length > 0)
                    {
                        if (Event[1] == "5")
                        {
                            User.ReceivedRandomBox = true;
                        }
                    }
                    User.UserID          = Convert.ToInt32(UserData[0]);
                    User.Username        = UserData[1];
                    User.Nickname        = UserData[2];
                    User.Exp             = Convert.ToInt32(UserData[3]);
                    User.Dinar           = Convert.ToInt32(UserData[4]);
                    User.Kills           = Convert.ToInt32(UserData[5]);
                    User.Deaths          = Convert.ToInt32(UserData[6]);
                    User.Premium         = Convert.ToInt32(UserData[7]);
                    User.PremiumExpire   = long.Parse(UserData[8]);
                    User.Cash            = Convert.ToInt32(UserData[9]);
                    User.Rank            = Convert.ToInt32(UserData[10]);
                    User.Coupons         = Convert.ToInt32(UserData[11]);
                    User.TodayCoupon     = Convert.ToInt32(UserData[12]);
                    User.PCItem          = (Convert.ToInt32(UserData[13]) == 1) ? true : false;
                    User.PCItem1         = (Convert.ToInt32(UserData[13]) == 2) ? true : false;
                    User.PCItem2         = (Convert.ToInt32(UserData[13]) == 3) ? true : false;
                    User.ClanID          = Convert.ToInt32(UserData[14]);
                    User.Country         = UserData[21];
                    User.InfinityPremium = int.Parse(UserData[22]);

                    User.LoginCountry = Structure.LookupModule.getCountry(User.IPAddr);

                    if (User.Country == "")
                    {
                        DB.runQuery("UPDATE users SET country='" + User.LoginCountry.getCode() + "' WHERE id='" + User.UserID + "'");

                        DB.runQuery("UPDATE countrys SET count=count+1 WHERE code='" + User.LoginCountry.getCode() + "'");
                    }

                    string[] HeadshotData = DB.runReadRow("SELECT headshots FROM users WHERE id='" + User.UserID + "'");

                    User.Headshots = Convert.ToInt32(HeadshotData[0]);

                    if (User.Rank > 4)
                    {
                        User.Nickname = "[GM]" + User.Nickname;
                    }
                    else if (User.Rank > 2)
                    {
                        User.Nickname = "[MOD]" + User.Nickname;
                    }
                    else if (User.Rank == 2)
                    {
                        User.Nickname = "[ESL]" + User.Nickname;
                    }

                    DB.runQuery("UPDATE users SET lasthwid='" + User.HWID + "' WHERE id='" + User.UserID + "'");
                    if (User.ClanID != -1)
                    {
                        User.ClanRank = Convert.ToInt32(UserData[15]);
                    }
                    User.LoginEvent      = Convert.ToInt32(UserData[16]);
                    User.LoginEventCheck = Convert.ToInt32(UserData[17]);
                    if (Convert.ToInt32(UserData[18]) == 1)
                    {
                        Log.AppendError(User.Nickname + " tried to double login!");
                        DB.runQuery("UPDATE users SET online='0' WHERE id='" + User.UserID + "'");
                        User.disconnect();
                    }

                    for (int I = 0; I < User.EndGameWord.Length; I++)
                    {
                        User.EndGameWord[I] = "/";
                    }

                    if (User.Rank > 1)
                    {
                        User.MaxSlots = 80;
                    }

                    if (Structure.Debug > 1 && User.Rank < 3)
                    {
                        User.send(new PACKET_CHAT(User, PACKET_CHAT.ChatType.Notice1, "NOTA: Stiamo facendo modifiche al server, attendere prego", User.SessionID, User.Nickname));
                        return;
                    }

                    User.uniqID      = Convert.ToInt32(getBlock(5)); // 1
                    User.uniqID2     = Convert.ToInt32(getBlock(6)); // 0
                    User.uniqIDisCRC = Convert.ToInt32(getBlock(7)); // 910
                    string LastJoin = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    DB.runQuery("UPDATE users SET lasthwid='" + User.HWID + "', lastjoin='" + LastJoin + "' WHERE id='" + User.UserID + "'");



                    DateTime current   = DateTime.Now;
                    int      StartTime = Convert.ToInt32(String.Format("{0:yyMMddHH}", current));

                    string[] Skin = DB.runReadRow("SELECT class_0,class_1,class_2,class_3,class_4 FROM users_costumes WHERE ownerid='" + User.UserID + "'");
                    if (Skin.Length > 0)
                    {
                        User.CostumeE = Skin[0];
                        User.CostumeM = Skin[1];
                        User.CostumeS = Skin[2];
                        User.CostumeA = Skin[3];
                        User.CostumeH = Skin[4];
                    }
                    else
                    {
                        DB.runQuery("INSERT INTO users_costumes(ownerid) VALUES ('" + User.UserID + "')");
                    }

                    if (User.ClanID != -1)
                    {
                        string[] Clan = DB.runReadRow("SELECT clanname, iconid FROM clans WHERE id='" + User.ClanID + "'");
                        if (Clan.Length > 0)
                        {
                            User.Clan       = ClanManager.getClan(User.ClanID);
                            User.ClanName   = Clan[0];
                            User.ClanIconID = Convert.ToInt32(Clan[1]);
                        }
                        string[] checkClanUser = DB.runReadRow("SELECT * FROM users WHERE clanrank='2' AND clanid='" + User.ClanID + "'");
                        if (checkClanUser.Length == 0)
                        {
                            DB.runQuery("UPDATE users SET clanrank='-1', clanid='-1' WHERE clanid='" + User.ClanID + "'");
                            DB.runQuery("DELETE FROM clans WHERE id='" + User.ClanID + "'");
                        }
                    }
                    else
                    {
                        DB.runQuery("UPDATE users SET clanID='-1', clanRank='1' WHERE id='" + User.UserID + "'");
                    }

                    bool isEventMessage = false;

                    for (int i = 0; i < 5; i++)
                    {
                        User.cCodes6th[i] = "^";
                    }

                    User.LoadItems();

                    int[] checkItemIDs = DB.runReadColumn("SELECT id FROM inventory WHERE ownerid='" + UserID.ToString() + "' AND deleted='0'", 0, null);
                    for (int I = 0; I < checkItemIDs.Length; I++)
                    {
                        string[] itemData = DB.runReadRow("SELECT expiredate, itemcode FROM inventory WHERE id=" + checkItemIDs[I].ToString());
                        if (Convert.ToInt32(itemData[0]) < StartTime)
                        {
                            int InvItems = 0;
                            foreach (InventoryItem _InvItem in User.Inventory)
                            {
                                if (_InvItem != null)
                                {
                                    InvItems++;
                                }
                            }
                            if (InvItems > User.MaxSlots)
                            {
                                DB.runQuery("DELETE FROM inventory WHERE ownerid='" + UserID.ToString() + "'");
                                User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Room_ToAll, "SYSTEM >> Your inventory's was resetted due too many items!", 999, "NULL"));
                                User.Inventory = new InventoryItem[105];
                            }

                            string itemID = User.getInventoryID(itemData[1]);

                            DB.runQuery("DELETE FROM inventory WHERE ownerid='" + UserID.ToString() + "' AND itemcode='" + itemData[1] + "'");
                            User.LeftItems.Add(itemData[1]);
                            User.ExpiredWeapon = true;
                        }
                    }

                    int[] checkCostumeIDs = DB.runReadColumn("SELECT id FROM inventory_costume WHERE ownerid='" + UserID.ToString() + "' AND deleted='0'", 0, null);
                    for (int I = 0; I < checkCostumeIDs.Length; I++)
                    {
                        string[] itemData = DB.runReadRow("SELECT expiredate, itemcode FROM inventory_costume WHERE id=" + checkCostumeIDs[I].ToString());
                        if (Convert.ToInt32(itemData[0]) < StartTime)
                        {
                            int InvItems = 0;
                            foreach (CostumeItem _InvItem in User.Costume)
                            {
                                if (_InvItem != null)
                                {
                                    InvItems++;
                                }
                            }
                            if (InvItems > User.MaxSlots)
                            {
                                DB.runQuery("DELETE FROM inventory_costume WHERE ownerid='" + UserID.ToString() + "'");
                                User.send(new PACKET_CHAT("SYSTEM", PACKET_CHAT.ChatType.Room_ToAll, "SYSTEM >> Your costume's was resetted due too many items!", 999, "NULL"));
                                User.Costume = new CostumeItem[105];
                            }
                            DB.runQuery("DELETE FROM inventory_costume WHERE ownerid='" + UserID.ToString() + "' AND itemcode='" + itemData[1] + "'");
                            User.LeftItems.Add(itemData[1]);
                            User.ExpiredWeapon = true;
                        }
                    }


                    // Check for expired weapons

                    if (User.ExpiredWeapon == true)
                    {
                        User.LoadEquipment();
                        int ItemCount = User.LeftItems.Count;
                        foreach (string sItem in User.LeftItems)
                        {
                            string inventoryID = User.getInventoryID(sItem);
                            for (int Class = 0; Class < 5; Class++)
                            {
                                for (int Slot = 0; Slot < 8; Slot++)
                                {
                                    if (User.Equipment[Class, Slot].Contains(inventoryID))
                                    {
                                        User.Equipment[Class, Slot] = "^";
                                    }
                                }
                            }
                        }
                        User.SaveEquipment();
                        User.send(new PACKET_EXPIRE_ITEM(User));
                        User.reloadEquipment(ItemCount);
                        User.Inventory = new InventoryItem[105];
                        User.LoadItems();
                    }

                    User.CheckForFirstLogin();

                    /*Login Event*/
                    int  EventID      = 6;
                    bool EventEnabled = false;
                    if (User.CheckForEvent(EventID) == false && EventEnabled)
                    {
                        int InvItems = User.InventorySlots;

                        if (InvItems > 0)
                        {
                            User.AddOutBoxItem("CB09", -1, 1);
                            DB.runQuery("INSERT INTO users_events (eventid, userid) VALUES ('" + EventID + "','" + User.UserID + "')");
                        }
                        else
                        {
                            User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.InventoryFull, "NULL"));
                        }
                    }
                    User.PremiumTimeLeft();
                    User.LoadRetails();
                    User.KillEventLoad2();

                    User.send(new PACKET_CLIENT_PACKET(0)); // Welcome sound
                    UserManager.addUser(User);
                    if (isEventMessage == true)
                    {
                        User.send(new PACKET_MESSAGE_BOX("Check_your_inventory!_:)"));
                    }
                    User.send(new PACKET_CREDITS(User));
                    User.send(new PACKET_CHARACTER_INFO(User));
                    User.send(new PACKET_PING(User));
                    User.reloadCash();
                }
            }
            else
            {
                User.send(new PACKET_CHARACTER_INFO(73030));
                User.disconnect();
            }
        }
Beispiel #4
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            try
            {
                int    OPCode = Convert.ToInt32(getNextBlock());
                string Value  = getNextBlock();
                switch (OPCode)
                {
                case 200:
                {
                    //Login packet
                    if (Convert.ToInt32(Value) != 13)
                    {
                        User.disconnect();
                        return;
                    }
                    else
                    {
                        Log.AppendText("Passed TrinityGuard Check");
                    }
                    break;
                }

                case 207:
                {
                    Log.AppendError("Tried to modify asm!");
                    User.disconnect();
                    break;
                }

                case 209:
                {
                    Log.AppendError("Running some illegal program!");
                    User.disconnect();
                    break;
                }

                case 210:
                {
                    Log.AppendError("IntegritY check has failed!");
                    User.disconnect();
                    break;
                }

                case 211:
                {
                    Log.AppendError("DirectX hook has failed!");
                    User.disconnect();
                    break;
                }

                default:
                {
                    Log.AppendError("Received unknown TrinityGuard function: " + getAllBlocks());
                    User.disconnect();
                    break;
                }
                }
            }
            catch { }
        }
Beispiel #5
0
        public override void Handle(ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser User)
        {
            try
            {
                //3777520 30258 0 DA08 3000 3
                bool   isDinar    = (getBlock(0) == "0" ? true : false);
                string Item       = getBlock(1);
                int    PriceToPay = Convert.ToInt32(getBlock(2));
                int    Bets       = Convert.ToInt32(getBlock(3));
                int    ItemWon    = 1;
                if (isDinar && User.Dinar - PriceToPay >= 0 || isDinar == false && User.Cash - PriceToPay >= 0)
                {
                    string[] amountData   = DB.runReadRow("SELECT amount FROM luckyshot WHERE itemcode='" + Item + "'");
                    string[] isInDatabase = DB.runReadRow("SELECT * FROM luckyshot WHERE itemcode='" + Item + "'");
                    if (isInDatabase.Length <= 0)
                    {
                        User.disconnect();
                    }
                    int ItemAmount      = Convert.ToInt32(amountData[0]);
                    int PercentageToWin = Bets;
                    if (amountData[0] == "0")
                    {
                        return;
                    }
                    Random random = new Random();
                    switch (Bets)
                    {
                    case 1: Bets = 1; PercentageToWin = 10; break;

                    case 2: Bets = 1; PercentageToWin = 10; break;

                    case 3: Bets = 3; PercentageToWin = 9; break;

                    case 4: Bets = 3; PercentageToWin = 9; break;

                    case 5: Bets = 7; PercentageToWin = 8; break;

                    case 6: Bets = 7; PercentageToWin = 8; break;

                    case 7: Bets = 15; PercentageToWin = 7; break;

                    case 8: Bets = 15; PercentageToWin = 7; break;

                    case 9: Bets = 30; PercentageToWin = 6; break;

                    case 10: Bets = 30; PercentageToWin = 5; break;
                    }
                    int win = random.Next(0, PercentageToWin);
                    if (win > 1)
                    {
                        int weapon2 = random.Next(5);
                        Item    = WeaponsOnLoose[weapon2];
                        ItemWon = 0;
                    }
                    if (ItemWon == 1)
                    {
                        ItemAmount -= 1;
                        foreach (ReBornWarRock_PServer.GameServer.Virtual_Objects.User.virtualUser _Players in Managers.UserManager.getAllUsers())
                        {
                            _Players.send(new PACKET_LUCKY_SHOT(Item, ItemAmount));
                        }
                        DB.runQuery("UPDATE luckyshot SET amount=" + ItemAmount + " WHERE itemcode='" + Item + "'");
                    }
                    int InventorySlot = User.InventorySlots;
                    if (InventorySlot > 0)
                    {
                        User.AddItem(Item, Bets, 1);

                        if (isDinar)
                        {
                            User.Dinar -= PriceToPay;
                            DB.runQuery("UPDATE users SET dinar='" + User.Dinar + "' WHERE id='" + User.UserID + "'");
                        }
                        else
                        {
                            User.Cash -= PriceToPay;
                            User.reloadCash();
                            DB.runQuery("UPDATE users SET cash='" + User.Cash + "' WHERE id='" + User.UserID + "'");
                        }
                        User.LoadItems();
                        User.send(new Packets.PACKET_LUCKY_SHOT(User, Bets, Item, ItemWon, isDinar));
                    }
                    else
                    {
                        User.send(new PACKET_ITEMSHOP(PACKET_ITEMSHOP.ErrorCodes.InventoryFull, "NULL"));
                    }
                }
                else
                {
                    User.send(new PACKET_LUCKY_SHOT(PACKET_LUCKY_SHOT.ErrorCode.NotEnoughDinar));
                }
            }
            catch (Exception ex)
            {
                Log.AppendError(ex.Message);
            }
        }
Beispiel #6
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);
            }
        }