コード例 #1
0
ファイル: houseface.cs プロジェクト: JVirant/DOLSharp
        public void OnCommand(GameClient client, string[] args)
        {
            int housenumber = 0;

            if (args.Length > 1)
            {
                try
                {
                    housenumber = int.Parse(args[1]);
                }
                catch
                {
                    DisplaySyntax(client);
                    return;
                }
            }
            else
            {
                HouseMgr.GetHouseNumberByPlayer(client.Player);
            }

            if (housenumber == 0)
            {
                DisplayMessage(client, "No house found.");
                return;
            }

            House house = HouseMgr.GetHouse(housenumber);

            ushort direction = client.Player.GetHeading(house.Position);

            client.Player.Heading = direction;
            client.Out.SendPlayerJump(true);
            DisplayMessage(client, "You face house " + housenumber);
        }
コード例 #2
0
        /// <summary>
        /// Check all items that belong to this ownerid and fix the OwnerLot if needed
        /// </summary>
        public virtual bool CheckInventory()
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

            if (house == null)
            {
                return(false);
            }

            bool isFixed = false;

            String sqlWhere = String.Format("OwnerID = '{0}' and SlotPosition >= {1} and SlotPosition <= {2} and OwnerLot = 0", house.OwnerID, FirstDBSlot, LastDBSlot);

            var items = GameServer.Database.SelectObjects <InventoryItem>(sqlWhere);

            foreach (InventoryItem item in items)
            {
                item.OwnerLot = (ushort)HouseNumber;
                GameServer.Database.SaveObject(item);
                MarketCache.AddItem(item);
                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: Fixed OwnerLot for item '{0}' on CM for lot {1}", item.Name, HouseNumber);
                }
                isFixed = true;
            }

            return(isFixed);
        }
コード例 #3
0
        /// <summary>
        /// Not Livelike but looks better - adds the owners guild emblem to the consignment merchants cloak
        /// </summary>
        public virtual void SetEmblem()
        {
            if (Inventory == null)
            {
                return;
            }

            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                return;
            }

            if (house.DatabaseItem.GuildHouse)
            {
                var guild  = GameServer.Database.SelectObject <DBGuild>("GuildName = '" + house.DatabaseItem.GuildName + "'");
                int emblem = guild.Emblem;

                InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak);
                if (cloak != null)
                {
                    cloak.Emblem = emblem;
                    BroadcastLivingEquipmentUpdate();
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Check all items that belong to this ownerid and fix the OwnerLot if needed
        /// </summary>
        public virtual bool CheckInventory()
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

            if (house == null)
            {
                return(false);
            }

            bool isFixed = false;

            var items = DOLDB <InventoryItem> .SelectObjects(DB.Column(nameof(InventoryItem.OwnerID)).IsEqualTo(house.OwnerID).And(DB.Column(nameof(InventoryItem.SlotPosition)).IsGreaterOrEqualTo(FirstDBSlot)).And(DB.Column(nameof(InventoryItem.SlotPosition)).IsLessOrEqualTo(LastDBSlot)).And(DB.Column(nameof(InventoryItem.OwnerLot)).IsEqualTo(0)));

            foreach (InventoryItem item in items)
            {
                item.OwnerLot = (ushort)HouseNumber;
                MarketCache.AddItem(item);
                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: Fixed OwnerLot for item '{0}' on CM for lot {1}", item.Name, HouseNumber);
                }
                isFixed = true;
            }
            GameServer.Database.SaveObject(items);

            return(isFixed);
        }
コード例 #5
0
        public override bool AddToWorld()
        {
            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                log.ErrorFormat("CM: Can't find house #{0}!", HouseNumber);
                return(false);
            }

            SetInventoryTemplate();

            var houseCM = DOLDB <HouseConsignmentMerchant> .SelectObject(DB.Column(nameof(HouseConsignmentMerchant.HouseNumber)).IsEqualTo(HouseNumber));

            if (houseCM != null)
            {
                TotalMoney = houseCM.Money;
            }
            else
            {
                log.ErrorFormat("CM: Can't find HouseConsignmentMerchant entry for CM on lot {0}!", HouseNumber);
                return(false);
            }

            base.AddToWorld();

            house.ConsignmentMerchant = this;
            SetEmblem();

            CheckInventory();

            return(true);
        }
コード例 #6
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int    unk1        = packet.ReadByte();
            int    unk2        = packet.ReadByte();
            ushort houseNumber = packet.ReadShort();

            // house is null, return
            var house = HouseMgr.GetHouse(houseNumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // player has no owner permissions and isn't a GM or admin, return
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // build the packet
            client.Out.SendHouseUsersPermissions(house);
        }
コード例 #7
0
        /// <summary>
        /// Not Livelike but looks better - adds the owners guild emblem to the consignment merchants cloak
        /// </summary>
        public virtual void SetEmblem()
        {
            if (Inventory == null)
            {
                return;
            }

            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                return;
            }

            if (house.DatabaseItem.GuildHouse)
            {
                var guild = DOLDB <DBGuild> .SelectObject(DB.Column(nameof(DBGuild.GuildName)).IsEqualTo(house.DatabaseItem.GuildName));

                int emblem = guild.Emblem;

                InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak);
                if (cloak != null)
                {
                    cloak.Emblem = emblem;
                    BroadcastLivingEquipmentUpdate();
                }
            }
        }
コード例 #8
0
ファイル: ConsignmentMerchant.cs プロジェクト: mywebext/DOL
        /// <summary>
        /// Not Livelike but looks better - adds the owners guild emblem to the consignment merchants cloak
        /// </summary>
        public virtual void SetEmblem()
        {
            if (Inventory == null)
            {
                return;
            }

            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                return;
            }

            if (house.DatabaseItem.GuildHouse)
            {
                var guild  = GameServer.Database.SelectObjects <DBGuild>("`GuildName` = @GuildName", new QueryParameter("@GuildName", house.DatabaseItem.GuildName)).FirstOrDefault();
                int emblem = guild.Emblem;

                InventoryItem cloak = Inventory.GetItem(eInventorySlot.Cloak);
                if (cloak != null)
                {
                    cloak.Emblem = emblem;
                    BroadcastLivingEquipmentUpdate();
                }
            }
        }
コード例 #9
0
ファイル: ConsignmentMerchant.cs プロジェクト: mywebext/DOL
        /// <summary>
        /// Check all items that belong to this ownerid and fix the OwnerLot if needed
        /// </summary>
        public virtual bool CheckInventory()
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

            if (house == null)
            {
                return(false);
            }

            bool isFixed = false;

            var items = GameServer.Database.SelectObjects <InventoryItem>("`OwnerID` = @OwnerID AND `SlotPosition` >= @SlotPositionMin AND `SlotPosition` <= @SlotPositionMax AND `OwnerLot` = @OwnerLot", new[] { new QueryParameter("@OwnerID", house.OwnerID), new QueryParameter("@SlotPositionMin", FirstDBSlot), new QueryParameter("@SlotPositionMax", LastDBSlot), new QueryParameter("@OwnerLot", 0) });

            foreach (InventoryItem item in items)
            {
                item.OwnerLot = (ushort)HouseNumber;
                MarketCache.AddItem(item);
                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: Fixed OwnerLot for item '{0}' on CM for lot {1}", item.Name, HouseNumber);
                }
                isFixed = true;
            }
            GameServer.Database.SaveObject(items);

            return(isFixed);
        }
コード例 #10
0
        public override bool AddToWorld()
        {
            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                log.ErrorFormat("CM: Can't find house #{0}!", HouseNumber);
                return(false);
            }

            SetInventoryTemplate();

            var houseCM = GameServer.Database.SelectObject <HouseConsignmentMerchant>("HouseNumber = '" + HouseNumber + "'");

            if (houseCM != null)
            {
                TotalMoney = houseCM.Money;
            }
            else
            {
                log.ErrorFormat("CM: Can't find HouseConsignmentMerchant entry for CM on lot {0}!", HouseNumber);
                return(false);
            }

            base.AddToWorld();

            house.ConsignmentMerchant = this;
            SetEmblem();

            CheckInventory();

            return(true);
        }
コード例 #11
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            packet.ReadShort(); // pid
            ushort housenumber = packet.ReadShort();

            // house is null, return
            var house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // player has no owner permissions and isn't a GM or admin, return
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // send out the house permissions
            using (var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HousingPermissions)))
            {
                pak.WriteByte(HousingConstants.MaxPermissionLevel); // number of permissions ?
                pak.WriteByte(0x00);                                // unknown
                pak.WriteShort((ushort)house.HouseNumber);

                foreach (var entry in house.PermissionLevels)
                {
                    var level      = entry.Key;
                    var permission = entry.Value;

                    pak.WriteByte((byte)level);
                    pak.WriteByte(permission.CanEnterHouse ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.Vault1);
                    pak.WriteByte(permission.Vault2);
                    pak.WriteByte(permission.Vault3);
                    pak.WriteByte(permission.Vault4);
                    pak.WriteByte(permission.CanChangeExternalAppearance ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.ChangeInterior);
                    pak.WriteByte(permission.ChangeGarden);
                    pak.WriteByte(permission.CanBanish ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.CanUseMerchants ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.CanUseTools ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.CanBindInHouse ? (byte)1 : (byte)0);
                    pak.WriteByte(permission.ConsignmentMerchant);
                    pak.WriteByte(permission.CanPayRent ? (byte)1 : (byte)0);
                    pak.WriteByte(0x00); // ??
                }

                client.Out.SendTCP(pak);
            }
        }
コード例 #12
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            // player is null, return

            // active consignment merchant is null, return
            if (!(client.Player?.ActiveInventoryObject is GameConsignmentMerchant conMerchant))
            {
                return;
            }

            // current house is null, return
            House house = HouseMgr.GetHouse(conMerchant.HouseNumber);

            if (house == null)
            {
                return;
            }

            // make sure player has permissions to withdraw from the consignment merchant
            if (!house.CanUseConsignmentMerchant(client.Player, ConsignmentPermissions.Withdraw))
            {
                client.Player.Out.SendMessage("You don't have permission to withdraw money from this merchant!", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                return;
            }

            lock (conMerchant.LockObject())
            {
                long totalConMoney = conMerchant.TotalMoney;

                if (totalConMoney > 0)
                {
                    if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
                    {
                        client.Player.Out.SendMessage($"You withdraw {totalConMoney} BountyPoints from your Merchant.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                        client.Player.BountyPoints += totalConMoney;
                        client.Player.Out.SendUpdatePoints();
                    }
                    else
                    {
                        ChatUtil.SendMerchantMessage(client, "GameMerchant.OnPlayerWithdraw", Money.GetString(totalConMoney));
                        client.Player.AddMoney(totalConMoney);
                        InventoryLogging.LogInventoryAction(conMerchant, client.Player, eInventoryActionType.Merchant, totalConMoney);
                    }

                    conMerchant.TotalMoney -= totalConMoney;

                    if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                    {
                        Log.Debug($"CM: [{client.Player.Name}:{client.Account.Name}] withdraws {totalConMoney} from CM on lot {conMerchant.HouseNumber}.");
                    }

                    client.Out.SendConsignmentMerchantMoney(conMerchant.TotalMoney);
                }
            }
        }
コード例 #13
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int level = packet.ReadByte();

            packet.ReadByte(); // unk1
            ushort housenumber = packet.ReadShort();

            // make sure permission level is within bounds
            if (level < HousingConstants.MinPermissionLevel || level > HousingConstants.MaxPermissionLevel)
            {
                return;
            }

            // house is null, return
            var house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // player has no owner permissions and isn't a GM or admin, return
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // read in the permission values
            DBHousePermissions permission = house.PermissionLevels[level];

            permission.CanEnterHouse = packet.ReadByte() != 0;
            permission.Vault1        = (byte)packet.ReadByte();
            permission.Vault2        = (byte)packet.ReadByte();
            permission.Vault3        = (byte)packet.ReadByte();
            permission.Vault4        = (byte)packet.ReadByte();
            permission.CanChangeExternalAppearance = packet.ReadByte() != 0;
            permission.ChangeInterior      = (byte)packet.ReadByte();
            permission.ChangeGarden        = (byte)packet.ReadByte();
            permission.CanBanish           = packet.ReadByte() != 0;
            permission.CanUseMerchants     = packet.ReadByte() != 0;
            permission.CanUseTools         = packet.ReadByte() != 0;
            permission.CanBindInHouse      = packet.ReadByte() != 0;
            permission.ConsignmentMerchant = (byte)packet.ReadByte();
            permission.CanPayRent          = packet.ReadByte() != 0;
            packet.ReadByte(); // unk2

            // save the updated permission
            GameServer.Database.SaveObject(permission);
        }
コード例 #14
0
        /// <summary>
        /// List of items in the Consignment Merchants Inventory
        /// </summary>
        public virtual IList <InventoryItem> DBItems(GamePlayer player = null)
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

            if (house == null)
            {
                return(null);
            }

            return(MarketCache.Items.Where(item => item.OwnerID == house.OwnerID).ToList());
        }
コード例 #15
0
        /// <summary>
        /// What to do after an item is added.  For consignment merchants this is called after price is set
        /// </summary>
        /// <param name="player"></param>
        /// <param name="clientSlot"></param>
        /// <param name="price"></param>
        /// <returns></returns>
        public virtual bool SetSellPrice(GamePlayer player, ushort clientSlot, uint price)
        {
            GameConsignmentMerchant conMerchant = player.ActiveInventoryObject as GameConsignmentMerchant;

            if (conMerchant == null)
            {
                return(false);
            }
            House house = HouseMgr.GetHouse(conMerchant.HouseNumber);

            if (house == null)
            {
                return(false);
            }

            if (house.HasOwnerPermissions(player) == false)
            {
                return(false);
            }

            InventoryItem item = player.TempProperties.getProperty <InventoryItem>(GameInventoryObjectExtensions.ITEM_BEING_ADDED, null);

            if (item != null)
            {
                if (item.IsTradable)
                {
                    item.SellPrice = (int)price;
                }
                else
                {
                    // Unique DOL feature
                    item.SellPrice = 0;
                    player.Out.SendCustomDialog("This item is not tradable. You can store it here but cannot sell it.", null);
                }

                item.OwnerLot = conMerchant.HouseNumber;
                item.OwnerID  = conMerchant.GetOwner(player);
                GameServer.Database.SaveObject(item);
                ChatUtil.SendDebugMessage(player, item.Name + " SellPrice=" + price + ", OwnerLot=" + item.OwnerLot + ", OwnerID=" + item.OwnerID);
                player.Out.SendMessage("Price set!", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                if (ServerProperties.Properties.MARKET_ENABLE_LOG)
                {
                    log.DebugFormat("CM: {0}:{1} set sell price of '{2}' to {3} for consignment merchant on lot {4}.", player.Name, player.Client.Account.Name, item.Name, item.SellPrice, HouseNumber);
                }

                NotifyObservers(player, null);
            }


            return(true);
        }
コード例 #16
0
        /// <summary>
        /// Checks if the Player is allowed to move an Item
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public virtual bool HasPermissionToMove(GamePlayer player)
        {
            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

            if (house == null)
            {
                return(false);
            }

            if (house.HasOwnerPermissions(player))
            {
                return(true);
            }

            return(false);
        }
コード例 #17
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int pid         = packet.ReadShort();
            int housenumber = packet.ReadShort();
            int enter       = packet.ReadByte();

            // house is null, return
            House house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            new EnterLeaveHouseAction(client.Player, house, enter).Start(1);
        }
コード例 #18
0
        /// <summary>
        /// Player interacting with this Merchant.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public override bool Interact(GamePlayer player)
        {
            if (!base.Interact(player))
            {
                return(false);
            }

            CheckInventory();

            if (player.ActiveInventoryObject != null)
            {
                player.ActiveInventoryObject.RemoveObserver(player);
                player.ActiveInventoryObject = null;
            }

            player.ActiveInventoryObject = this;

            AddObserver(player);

            House house = HouseMgr.GetHouse(CurrentRegionID, HouseNumber);

            if (house == null)
            {
                return(false);
            }

            if (house.CanUseConsignmentMerchant(player, ConsignmentPermissions.Any))
            {
                player.Out.SendInventoryItemsUpdate(GetClientInventory(player), eInventoryWindowType.ConsignmentOwner);

                long amount = m_totalMoney;
                player.Out.SendConsignmentMerchantMoney(amount);

                if (ServerProperties.Properties.CONSIGNMENT_USE_BP)
                {
                    player.Out.SendMessage("Your merchant currently holds " + amount + " BountyPoints.", eChatType.CT_Important, eChatLoc.CL_ChatWindow);
                }
            }
            else
            {
                player.Out.SendInventoryItemsUpdate(GetClientInventory(player), eInventoryWindowType.ConsignmentViewer);
            }

            return(true);
        }
コード例 #19
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            ushort housenumber = packet.ReadShort();
            var    index       = (byte)packet.ReadByte();

            packet.ReadByte(); // unk1

            // house is null, return
            var house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // rotation only works for inside items
            if (!client.Player.InHouse)
            {
                return;
            }

            // no permission to change the interior, return
            if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
            {
                return;
            }

            var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HouseDecorationRotate));

            pak.WriteShort(housenumber);
            pak.WriteByte(index);
            pak.WriteByte(0x01);
            client.Out.SendTCP(pak);
        }
コード例 #20
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int    permissionSlot     = packet.ReadByte();
            int    newPermissionLevel = packet.ReadByte();
            ushort houseNumber        = packet.ReadShort();

            // house is null, return
            var house = HouseMgr.GetHouse(houseNumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // can't set permissions unless you're the owner.
            if (!house.HasOwnerPermissions(client.Player) && client.Account.PrivLevel <= 1)
            {
                return;
            }

            // check if we're setting or removing permissions
            if (newPermissionLevel == 100)
            {
                house.RemovePermission(permissionSlot);
            }
            else
            {
                house.AdjustPermissionSlot(permissionSlot, newPermissionLevel);
            }
        }
コード例 #21
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int housenumber = packet.ReadShort();
            int menuid      = packet.ReadByte();
            int flag        = packet.ReadByte();

            var house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber);

            if (house == null)
            {
                return;
            }

            if (client.Player == null)
            {
                return;
            }

            client.Player.CurrentHouse = house;

            var menu = _menu168;

            if (client.Version >= GameClient.eClientVersion.Version1127)
            {
                menu = _menu1127;
            }

            if (menu.TryGetValue(menuid, out var type))
            {
                OpenWindow(client, house, type);
            }
            else
            {
                client.Out.SendMessage("Invalid menu id " + menuid + " (hookpoint?).", eChatType.CT_System, eChatLoc.CL_SystemWindow);
            }
        }
コード例 #22
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            try
            {
                packet.ReadByte();                        // 1=Money 0=Item (?)
                int    slot        = packet.ReadByte();   // Item/money slot
                ushort housenumber = packet.ReadShort();  // N° of house
                packet.ReadByte();                        // unknown
                _position = (byte)packet.ReadByte();
                int method   = packet.ReadByte();         // 2=Wall 3=Floor
                int rotation = packet.ReadByte();         // garden items only
                var xpos     = (short)packet.ReadShort(); // x for inside objs
                var ypos     = (short)packet.ReadShort(); // y for inside objs.

                ChatUtil.SendDebugMessage(client, $"HousingPlaceItem: slot: {slot}, position: {_position}, method: {method}, xpos: {xpos}, ypos: {ypos}");

                if (client.Player == null)
                {
                    return;
                }

                // house must exist
                House house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber);
                if (house == null)
                {
                    client.Player.Out.SendInventorySlotsUpdate(null);
                    return;
                }

                if (slot >= 244 && slot <= 248) // money
                {
                    // check that player has permission to pay rent
                    if (!house.CanPayRent(client.Player))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    long moneyToAdd = _position;
                    switch (slot)
                    {
                    case 248:
                        moneyToAdd *= 1;
                        break;

                    case 247:
                        moneyToAdd *= 100;
                        break;

                    case 246:
                        moneyToAdd *= 10000;
                        break;

                    case 245:
                        moneyToAdd *= 10000000;
                        break;

                    case 244:
                        moneyToAdd *= 10000000000;
                        break;
                    }

                    client.Player.TempProperties.setProperty(HousingConstants.MoneyForHouseRent, moneyToAdd);
                    client.Player.TempProperties.setProperty(HousingConstants.HouseForHouseRent, house);
                    client.Player.Out.SendInventorySlotsUpdate(null);
                    client.Player.Out.SendHousePayRentDialog("Housing07");

                    return;
                }

                // make sure the item dropped still exists
                InventoryItem orgitem = client.Player.Inventory.GetItem((eInventorySlot)slot);
                if (orgitem == null)
                {
                    client.Player.Out.SendInventorySlotsUpdate(null);
                    return;
                }

                if (orgitem.Id_nb == "house_removal_deed")
                {
                    client.Out.SendInventorySlotsUpdate(null);

                    // make sure player has owner permissions
                    if (!house.HasOwnerPermissions(client.Player))
                    {
                        ChatUtil.SendSystemMessage(client.Player, "You don't own this house!");
                        return;
                    }

                    client.Player.TempProperties.setProperty(DeedWeak, new WeakRef(orgitem));
                    client.Player.TempProperties.setProperty(TargetHouse, house);
                    client.Player.Out.SendCustomDialog(LanguageMgr.GetTranslation(client.Account.Language, "WARNING: You are about to delete this house and all indoor and outdoor items attached to it!"), HouseRemovalDialog);

                    return;
                }

                if (orgitem.Id_nb.Contains("cottage_deed") || orgitem.Id_nb.Contains("house_deed") ||
                    orgitem.Id_nb.Contains("villa_deed") || orgitem.Id_nb.Contains("mansion_deed"))
                {
                    client.Out.SendInventorySlotsUpdate(null);

                    // make sure player has owner permissions
                    if (!house.HasOwnerPermissions(client.Player))
                    {
                        ChatUtil.SendSystemMessage(client, "You may not change other peoples houses");

                        return;
                    }

                    client.Player.TempProperties.setProperty(DeedWeak, new WeakRef(orgitem));
                    client.Player.TempProperties.setProperty(TargetHouse, house);
                    client.Player.Out.SendMessage("Warning:\n This will remove *all* items from your current house!", eChatType.CT_System, eChatLoc.CL_PopupWindow);
                    client.Player.Out.SendCustomDialog("Are you sure you want to upgrade your House?", HouseUpgradeDialog);

                    return;
                }

                if (orgitem.Name == "deed of guild transfer")
                {
                    // player needs to be in a guild to xfer a house to a guild
                    if (client.Player.Guild == null)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        ChatUtil.SendSystemMessage(client, "You must be a member of a guild to do that");
                        return;
                    }

                    // player needs to own the house to be able to xfer it
                    if (!house.HasOwnerPermissions(client.Player))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        ChatUtil.SendSystemMessage(client, "You do not own this house.");
                        return;
                    }

                    // guild can't already have a house
                    if (client.Player.Guild.GuildOwnsHouse)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        ChatUtil.SendSystemMessage(client, "Your Guild already owns a house.");
                        return;
                    }

                    // player needs to be a GM in the guild to xfer his personal house to the guild
                    if (!client.Player.Guild.HasRank(client.Player, Guild.eRank.Leader))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        ChatUtil.SendSystemMessage(client, "You are not the leader of a guild.");
                        return;
                    }

                    if (HouseMgr.HouseTransferToGuild(client.Player, house))
                    {
                        // This will still take the item even if player answers NO to confirmation.
                        // I'm fixing consignment, not housing, and frankly I'm sick of fixing stuff!  :)  - tolakram
                        client.Player.Inventory.RemoveItem(orgitem);
                        InventoryLogging.LogInventoryAction(client.Player, "(HOUSE;" + housenumber + ")", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                        client.Player.Guild.UpdateGuildWindow();
                    }

                    return;
                }

                if (house.CanChangeInterior(client.Player, DecorationPermissions.Remove))
                {
                    if (orgitem.Name == "interior banner removal")
                    {
                        house.IndoorGuildBanner = false;
                        ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.InteriorBannersRemoved", null);
                        return;
                    }

                    if (orgitem.Name == "interior shield removal")
                    {
                        house.IndoorGuildShield = false;
                        ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.InteriorShieldsRemoved", null);
                        return;
                    }

                    if (orgitem.Name == "carpet removal")
                    {
                        house.Rug1Color = 0;
                        house.Rug2Color = 0;
                        house.Rug3Color = 0;
                        house.Rug4Color = 0;
                        ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.CarpetsRemoved", null);
                        return;
                    }
                }

                if (house.CanChangeExternalAppearance(client.Player))
                {
                    if (orgitem.Name == "exterior banner removal")
                    {
                        house.OutdoorGuildBanner = false;
                        ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.OutdoorBannersRemoved", null);
                        return;
                    }

                    if (orgitem.Name == "exterior shield removal")
                    {
                        house.OutdoorGuildShield = false;
                        ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.OutdoorShieldsRemoved", null);
                        return;
                    }
                }

                int objType = orgitem.Object_Type;
                if (objType == 49) // Garden items
                {
                    method = 1;
                }
                else if (orgitem.Id_nb == "housing_porch_deed" || orgitem.Id_nb == "housing_porch_remove_deed" || orgitem.Id_nb == "housing_consignment_deed")
                {
                    method = 4;
                }
                else if (objType >= 59 && objType <= 64) // Outdoor Roof/Wall/Door/Porch/Wood/Shutter/awning Material item type
                {
                    ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.HouseUseMaterials", null);
                    return;
                }
                else if (objType == 56 || objType == 52 || (objType >= 69 && objType <= 71)) // Indoor carpets 1-4
                {
                    ChatUtil.SendSystemMessage(client.Player, "Scripts.Player.Housing.HouseUseCarpets", null);
                    return;
                }
                else if (objType == 57 || objType == 58 || // Exterior banner/shield
                         objType == 66 || objType == 67)    // Interior banner/shield
                {
                    method = 6;
                }
                else if (objType == 53 || objType == 55 || objType == 68)
                {
                    method = 5;
                }
                else if (objType == (int)eObjectType.HouseVault)
                {
                    method = 7;
                }

                ChatUtil.SendDebugMessage(client, $"Place Item: method: {method}");

                int pos;
                switch (method)
                {
                case 1:     // GARDEN OBJECT
                {
                    if (client.Player.InHouse)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // no permissions to add to the garden, return
                    if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // garden is already full, return
                    if (house.OutdoorItems.Count >= Properties.MAX_OUTDOOR_HOUSE_ITEMS)
                    {
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.GardenMaxObjects", null);
                        client.Out.SendInventorySlotsUpdate(new[] { slot });

                        return;
                    }

                    // create an outdoor item to represent the item being placed
                    var oitem = new OutdoorItem
                    {
                        BaseItem = GameServer.Database.FindObjectByKey <ItemTemplate>(orgitem.Id_nb),
                        Model    = orgitem.Model,
                        Position = (byte)_position,
                        Rotation = (byte)rotation
                    };

                    // add item in db
                    pos = GetFirstFreeSlot(house.OutdoorItems.Keys);
                    DBHouseOutdoorItem odbitem = oitem.CreateDBOutdoorItem(housenumber);
                    oitem.DatabaseItem = odbitem;

                    GameServer.Database.AddObject(odbitem);

                    // remove the item from the player's inventory
                    client.Player.Inventory.RemoveItem(orgitem);
                    InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);

                    // add item to outdooritems
                    house.OutdoorItems.Add(pos, oitem);

                    ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.GardenItemPlaced", Properties.MAX_OUTDOOR_HOUSE_ITEMS - house.OutdoorItems.Count);
                    ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.GardenItemPlacedName", orgitem.Name);

                    // update all nearby players
                    foreach (GamePlayer player in WorldMgr.GetPlayersCloseToSpot(house.RegionID, house, WorldMgr.OBJ_UPDATE_DISTANCE))
                    {
                        player.Out.SendGarden(house);
                    }

                    // save the house
                    house.SaveIntoDatabase();
                    break;
                }

                case 2:     // WALL OBJECT
                case 3:     // FLOOR OBJECT
                {
                    if (client.Player.InHouse == false)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // no permission to add to the interior, return
                    if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // not a wall object, return
                    if (!IsSuitableForWall(orgitem) && method == 2)
                    {
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.NotWallObject", null);
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // not a floor object, return
                    if (objType != 51 && method == 3)
                    {
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.NotFloorObject", null);
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // interior already has max items, return
                    if (house.IndoorItems.Count >= GetMaxIndoorItemsForHouse(house.Model))
                    {
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorMaxItems", GetMaxIndoorItemsForHouse(house.Model));
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // create an indoor item to represent the item being placed
                    var iitem = new IndoorItem
                    {
                        Model         = orgitem.Model,
                        Color         = orgitem.Color,
                        X             = xpos,
                        Y             = ypos,
                        Size          = orgitem.DPS_AF > 3 ? orgitem.DPS_AF : 100, // max size is 255
                        Position      = _position,
                        PlacementMode = method,
                        BaseItem      = null
                    };

                    // figure out proper rotation for item
                    int properRotation = client.Player.Heading / 10;
                    properRotation = properRotation.Clamp(0, 360);

                    if (method == 2 && IsSuitableForWall(orgitem))
                    {
                        properRotation = 360;
                        if (objType != 50)
                        {
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                        }
                    }

                    iitem.Rotation = properRotation;

                    pos = GetFirstFreeSlot(house.IndoorItems.Keys);
                    if (objType == 50 || objType == 51)
                    {
                        // its a housing item, so lets take it!
                        client.Player.Inventory.RemoveItem(orgitem);
                        InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);

                        // set right base item, so we can recreate it on take.
                        if (orgitem.Id_nb.Contains("GuildBanner"))
                        {
                            iitem.BaseItem = orgitem.Template;
                            iitem.Size     = 50;     // Banners have to be reduced in size
                        }
                        else
                        {
                            iitem.BaseItem = GameServer.Database.FindObjectByKey <ItemTemplate>(orgitem.Id_nb);
                        }
                    }

                    DBHouseIndoorItem idbitem = iitem.CreateDBIndoorItem(housenumber);
                    iitem.DatabaseItem = idbitem;
                    GameServer.Database.AddObject(idbitem);

                    house.IndoorItems.Add(pos, iitem);

                    // let player know the item has been placed
                    ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorItemPlaced", GetMaxIndoorItemsForHouse(house.Model) - house.IndoorItems.Count);

                    switch (method)
                    {
                    case 2:
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorWallPlaced", orgitem.Name);
                        break;

                    case 3:
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.IndoorFloorPlaced", orgitem.Name);
                        break;
                    }

                    // update furniture for all players in the house
                    foreach (GamePlayer plr in house.GetAllPlayersInHouse())
                    {
                        plr.Out.SendFurniture(house, pos);
                    }

                    break;
                }

                case 4:     // PORCH
                {
                    // no permission to add to the garden, return
                    if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    switch (orgitem.Id_nb)
                    {
                    case "housing_porch_deed":
                        // try and add the porch
                        if (house.AddPorch())
                        {
                            // remove the original item from the player's inventory
                            client.Player.Inventory.RemoveItem(orgitem);
                            InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                        }
                        else
                        {
                            ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.PorchAlready", null);
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                        }

                        return;

                    case "housing_porch_remove_deed":

                        var consignmentMerchant = house.ConsignmentMerchant;
                        if (consignmentMerchant != null && (consignmentMerchant.DBItems(client.Player).Count > 0 || consignmentMerchant.TotalMoney > 0))
                        {
                            ChatUtil.SendSystemMessage(client, "All items and money must be removed from your consigmment merchant in order to remove the porch!");
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                            return;
                        }

                        // try and remove the porch
                        if (house.RemovePorch())
                        {
                            // remove the original item from the player's inventory
                            client.Player.Inventory.RemoveItem(orgitem);
                            InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                        }
                        else
                        {
                            ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.PorchNone", null);
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                        }

                        return;

                    case "housing_consignment_deed":
                    {
                        // make sure there is a porch for this consignment merchant!
                        if (!house.Porch)
                        {
                            ChatUtil.SendSystemMessage(client, "Your House needs a Porch first.");
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                            return;
                        }

                        // try and add a new consignment merchant
                        if (house.AddConsignment(0))
                        {
                            // remove the original item from the player's inventory
                            client.Player.Inventory.RemoveItem(orgitem);
                            InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                        }
                        else
                        {
                            ChatUtil.SendSystemMessage(client, "You can not add a Consignment Merchant here.");
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                        }

                        return;
                    }

                    default:
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.PorchNotItem", null);
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }
                }

                case 5:     // HOOKPOINT
                {
                    if (client.Player.InHouse == false)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // no permission to add to the interior, return
                    if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // don't allow non-hookpoint items to be dropped on hookpoints
                    if (IsSuitableForHookpoint(orgitem) == false)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // if the hookpoint doesn't exist, prompt player to Log it in the database for us
                    if (house.GetHookpointLocation((uint)_position) == null)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });

                        if (client.Account.PrivLevel == (int)ePrivLevel.Admin)
                        {
                            if (client.Player.TempProperties.getProperty(HousingConstants.AllowAddHouseHookpoint, false))
                            {
                                ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointID", +_position);
                                ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointCloser", null);

                                client.Player.Out.SendCustomDialog(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Player.Housing.HookPointLogLoc"), LogLocation);
                            }
                            else
                            {
                                ChatUtil.SendDebugMessage(client, "use '/house addhookpoints' to allow addition of new housing hookpoints.");
                            }
                        }
                    }
                    else if (house.GetHookpointLocation((uint)_position) != null)
                    {
                        var point = new DBHouseHookpointItem
                        {
                            HouseNumber    = house.HouseNumber,
                            ItemTemplateID = orgitem.Id_nb,
                            HookpointID    = (uint)_position
                        };

                        // If we already have soemthing here, do not place more
                        foreach (var hpitem in GameServer.Database.SelectObjects <DBHouseHookpointItem>("`HouseNumber` = @HouseNumber", new QueryParameter("@HouseNumber", house.HouseNumber)))
                        {
                            if (hpitem.HookpointID == point.HookpointID)
                            {
                                ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointAlready", null);
                                client.Out.SendInventorySlotsUpdate(new[] { slot });
                                return;
                            }
                        }

                        if (house.HousepointItems.ContainsKey(point.HookpointID) == false)
                        {
                            house.HousepointItems.Add(point.HookpointID, point);
                            house.FillHookpoint((uint)_position, orgitem.Id_nb, client.Player.Heading, 0);
                        }
                        else
                        {
                            string error = $"Hookpoint already has item on attempt to attach {orgitem.Id_nb} to hookpoint {_position} for house {house.HouseNumber}!";
                            Log.ErrorFormat(error);
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                            throw new Exception(error);
                        }

                        // add the item to the database
                        GameServer.Database.AddObject(point);

                        // remove the original item from the player's inventory
                        client.Player.Inventory.RemoveItem(orgitem);
                        InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);

                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointAdded", null);

                        // save the house
                        house.SaveIntoDatabase();
                    }
                    else
                    {
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointNot", null);
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                    }

                    // broadcast updates
                    house.SendUpdate();
                    break;
                }

                case 6:
                {
                    // no permission to change external appearance, return
                    if (!house.CanChangeExternalAppearance(client.Player))
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    if (objType == 57)         // We have outdoor banner
                    {
                        house.OutdoorGuildBanner = true;
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.OutdoorBannersAdded", null);
                        client.Player.Inventory.RemoveItem(orgitem);
                        InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                    }
                    else if (objType == 58)         // We have outdoor shield
                    {
                        house.OutdoorGuildShield = true;
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.OutdoorShieldsAdded", null);
                        client.Player.Inventory.RemoveItem(orgitem);
                        InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                    }
                    else if (objType == 66)         // We have indoor banner
                    {
                        house.IndoorGuildBanner = true;
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.InteriorBannersAdded", null);
                        client.Player.Inventory.RemoveItem(orgitem);
                        InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                    }
                    else if (objType == 67)         // We have indoor shield
                    {
                        house.IndoorGuildShield = true;
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.InteriorShieldsAdded", null);
                        client.Player.Inventory.RemoveItem(orgitem);
                        InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);
                    }
                    else
                    {
                        ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.BadShieldBanner", null);
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                    }

                    // save the house and broadcast updates
                    house.SaveIntoDatabase();
                    house.SendUpdate();
                    break;
                }

                case 7:     // House vault.
                {
                    if (client.Player.InHouse == false)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // make sure the hookpoint position is valid
                    if (_position > HousingConstants.MaxHookpointLocations)
                    {
                        ChatUtil.SendSystemMessage(client, "This hookpoint position is unknown, error logged.");
                        Log.Error($"HOUSING: {client.Player.Name} working with invalid position {_position} in house {house.HouseNumber} model {house.Model}");

                        client.Out.SendInventorySlotsUpdate(new[] { slot });
                        return;
                    }

                    // if hookpoint doesn't exist, prompt player to Log it in the database for us
                    if (house.GetHookpointLocation((uint)_position) == null)
                    {
                        client.Out.SendInventorySlotsUpdate(new[] { slot });

                        if (client.Account.PrivLevel == (int)ePrivLevel.Admin)
                        {
                            if (client.Player.TempProperties.getProperty(HousingConstants.AllowAddHouseHookpoint, false))
                            {
                                ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointID", +_position);
                                ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointCloser", null);

                                client.Player.Out.SendCustomDialog(LanguageMgr.GetTranslation(client.Account.Language, "Scripts.Player.Housing.HookPointLogLoc"), LogLocation);
                            }
                            else
                            {
                                ChatUtil.SendDebugMessage(client, "use '/house addhookpoints' to allow addition of new housing hookpoints.");
                            }
                        }

                        return;
                    }

                    // make sure we have space to add another vult
                    int vaultIndex = house.GetFreeVaultNumber();
                    if (vaultIndex < 0)
                    {
                        client.Player.Out.SendMessage("You can't add any more vaults to this house!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        client.Out.SendInventorySlotsUpdate(new[] { slot });

                        return;
                    }

                    // If we already have soemthing here, do not place more
                    foreach (var hpitem in GameServer.Database.SelectObjects <DBHouseHookpointItem>("`HouseNumber` = @HouseNumber", new QueryParameter("@HouseNumber", house.HouseNumber)))
                    {
                        if (hpitem.HookpointID == _position)
                        {
                            ChatUtil.SendSystemMessage(client, "Scripts.Player.Housing.HookPointAlready", null);
                            client.Out.SendInventorySlotsUpdate(new[] { slot });
                            return;
                        }
                    }

                    // create the new vault and attach it to the house
                    var houseVault = new GameHouseVault(orgitem.Template, vaultIndex);
                    houseVault.Attach(house, (uint)_position, (ushort)((client.Player.Heading + 2048) % 4096));

                    // remove the original item from the player's inventory
                    client.Player.Inventory.RemoveItem(orgitem);
                    InventoryLogging.LogInventoryAction(client.Player, $"(HOUSE;{housenumber})", eInventoryActionType.Other, orgitem.Template, orgitem.Count);

                    // save the house and broadcast uodates
                    house.SaveIntoDatabase();
                    house.SendUpdate();
                    return;
                }

                default:
                {
                    ChatUtil.SendDebugMessage(client, "Place Item: Unknown method, do nothing.");
                    client.Out.SendInventorySlotsUpdate(null);
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Log.Error("HousingPlaceItemHandler", ex);
                client.Out.SendMessage("Error processing housing action; the error has been logged!", eChatType.CT_Staff, eChatLoc.CL_SystemWindow);
                client.Out.SendInventorySlotsUpdate(null);
            }
        }
コード例 #23
0
        /// <summary>
        /// Send Housing Items depending on last refresh.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="nowTicks"></param>
        public static void UpdatePlayerHousing(GamePlayer player, long nowTicks)
        {
            // If no house update needed exit.
            if (player.CurrentRegion == null || !player.CurrentRegion.HousingEnabled)
            {
                return;
            }

            // Get All House in Region
            IDictionary <int, House> housesDict = HouseMgr.GetHouses(player.CurrentRegionID);
            List <House>             houses     = new List <House>();

            // Build Vincinity List
            foreach (House h in housesDict.Values)
            {
                House house = h;

                if (house != null && player.IsWithinRadius(house, HousingConstants.HouseViewingDistance))
                {
                    houses.Add(house);
                }
            }

            try
            {
                // Clean Cache
                foreach (Tuple <ushort, ushort> houseKey in player.Client.HouseUpdateArray.Keys)
                {
                    House house = HouseMgr.GetHouse(houseKey.Item1, houseKey.Item2);

                    // We have a House in cache that is not in vincinity
                    if (!houses.Contains(house) && (nowTicks - player.Client.HouseUpdateArray[new Tuple <ushort, ushort>(house.RegionID, (ushort)house.HouseNumber)]) >= GetPlayerItemUpdateInterval())
                    {
                        long dummy;
                        player.Client.HouseUpdateArray.TryRemove(new Tuple <ushort, ushort>(house.RegionID, (ushort)house.HouseNumber), out dummy);
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("Error while Cleaning House cache for Player : {0}, Exception : {1}", player.Name, e);
                }
            }

            try
            {
                // Now Send remaining houses
                foreach (House lhouse in houses)
                {
                    House house = lhouse;

                    // Get last update time
                    long lastUpdate;
                    if (player.Client.HouseUpdateArray.TryGetValue(new Tuple <ushort, ushort>(house.RegionID, (ushort)house.HouseNumber), out lastUpdate))
                    {
                        // This House Needs Update
                        if ((nowTicks - lastUpdate) >= GetPlayerItemUpdateInterval())
                        {
                            player.Client.Out.SendHouse(house);
                            player.Client.Out.SendGarden(house);

                            if (house.IsOccupied)
                            {
                                player.Client.Out.SendHouseOccupied(house, true);
                            }
                        }
                    }
                    else
                    {
                        // Not in cache, House entering in range !
                        player.Client.Out.SendHouse(house);
                        player.Client.Out.SendGarden(house);

                        if (house.IsOccupied)
                        {
                            player.Client.Out.SendHouseOccupied(house, true);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("Error while updating Houses for Player : {0}, Exception : {1}", player.Name, e);
                }
            }
        }
コード例 #24
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            int housenumber = packet.ReadShort();
            int menuid      = packet.ReadByte();
            int flag        = packet.ReadByte();

            var house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber);

            if (house == null)
            {
                return;
            }

            if (client.Player == null)
            {
                return;
            }

            client.Player.CurrentHouse = house;

            switch (menuid)
            {
            case 0:                     // Exterior decoration (Garden)
            {
                if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingOutsideShop);
                break;
            }

            case 1:                     // Interior decoration
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingInsideShop);
                break;
            }

            case 2:                     // Exterior menu
            {
                if (!house.CanChangeGarden(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                client.Player.Out.SendMerchantWindow(HouseTemplateMgr.OutdoorMenuItems, eMerchantWindowType.HousingOutsideMenu);
                break;
            }

            case 3:                     // interior npc
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingNPCHookpoint);
                break;
            }

            case 4:                     // vault shop
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingVaultHookpoint);
                break;
            }

            case 5:                     // craft shop
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingCraftingHookpoint);
                break;
            }

            case 6:                     // bindstone shop
            {
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                HouseMgr.SendHousingMerchantWindow(client.Player, eMerchantWindowType.HousingBindstoneHookpoint);
                break;
            }

            case 7:
                house.SendHouseInfo(client.Player);
                break;

            case 8:                     // Interior menu (flag = 0x00 - roof, 0xFF - floor or wall)
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
                {
                    return;
                }

                client.Player.Out.SendMerchantWindow(HouseTemplateMgr.IndoorMenuItems, eMerchantWindowType.HousingInsideMenu);
                break;

            default:
                client.Out.SendMessage("Invalid menu id " + menuid + " (hookpoint?).", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                break;
            }
        }
コード例 #25
0
        /// <summary>
        /// Handle the packet
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        /// <returns></returns>
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            packet.ReadByte(); // unknown
            int position    = packet.ReadByte();
            int housenumber = packet.ReadShort();
            int method      = packet.ReadByte();

            House house = HouseMgr.GetHouse(client.Player.CurrentRegionID, housenumber);

            if (house == null)
            {
                return;
            }

            if (client.Player == null)
            {
                return;
            }

            // log.DebugFormat("House PickupItem - Method: {0}, Position: {0}", method, position);
            switch (method)
            {
            case 1:     // garden item
                // no permission to remove items from the garden, return
                if (!house.CanChangeGarden(client.Player, DecorationPermissions.Remove))
                {
                    return;
                }

                foreach (var entry in house.OutdoorItems)
                {
                    // continue if this is not the item in question
                    OutdoorItem oitem = entry.Value;
                    if (oitem.Position != position)
                    {
                        continue;
                    }

                    int i = entry.Key;
                    GameServer.Database.DeleteObject(oitem.DatabaseItem);     // delete the database instance

                    // return indoor item into inventory item, add to player inventory
                    var invitem = GameInventoryItem.Create(house.OutdoorItems[i].BaseItem);
                    if (client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, invitem))
                    {
                        InventoryLogging.LogInventoryAction($"(HOUSE;{house.HouseNumber})", client.Player, eInventoryActionType.Other, invitem.Template, invitem.Count);
                    }

                    house.OutdoorItems.Remove(i);

                    // update garden
                    client.Out.SendGarden(house);

                    ChatUtil.SendSystemMessage(client, "Garden object removed.");
                    ChatUtil.SendSystemMessage(client, $"You get {invitem.Name} and put it in your backpack.");
                    return;
                }

                // no object @ position
                ChatUtil.SendSystemMessage(client, $"There is no Garden Tile at slot {position}!");
                break;

            case 2:
            case 3:     // wall/floor mode
                // no permission to remove items from the interior, return
                if (!house.CanChangeInterior(client.Player, DecorationPermissions.Remove))
                {
                    return;
                }

                if (house.IndoorItems.ContainsKey(position) == false)
                {
                    return;
                }

                IndoorItem iitem = house.IndoorItems[position];
                if (iitem == null)
                {
                    client.Player.Out.SendMessage("error: id was null", eChatType.CT_Help, eChatLoc.CL_SystemWindow);
                    return;
                }

                if (iitem.BaseItem != null)
                {
                    var item = GameInventoryItem.Create(house.IndoorItems[position].BaseItem);
                    if (GetItemBack(item))
                    {
                        if (client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
                        {
                            string removalMsg = $"The {item.Name} is cleared from the {(method == 2 ? "wall surface" : "floor")}.";

                            ChatUtil.SendSystemMessage(client, removalMsg);
                            InventoryLogging.LogInventoryAction($"(HOUSE;{house.HouseNumber})", client.Player, eInventoryActionType.Other, item.Template, item.Count);
                        }
                        else
                        {
                            ChatUtil.SendSystemMessage(client, "You need place in your inventory !");
                            return;
                        }
                    }
                    else
                    {
                        ChatUtil.SendSystemMessage(client, $"The {item.Name} is cleared from the wall surface.");
                    }
                }
                else if (iitem.DatabaseItem.BaseItemID.Contains("GuildBanner"))
                {
                    var it = new ItemTemplate
                    {
                        Id_nb         = iitem.DatabaseItem.BaseItemID,
                        CanDropAsLoot = false,
                        IsDropable    = true,
                        IsPickable    = true,
                        IsTradable    = true,
                        Item_Type     = 41,
                        Level         = 1,
                        MaxCharges    = 1,
                        MaxCount      = 1,
                        Model         = iitem.DatabaseItem.Model,
                        Emblem        = iitem.DatabaseItem.Emblem,
                        Object_Type   = (int)eObjectType.HouseWallObject,
                        Realm         = 0,
                        Quality       = 100
                    };

                    string[] idnb = iitem.DatabaseItem.BaseItemID.Split('_');
                    it.Name = $"{idnb[1]}\'s Banner";

                    // TODO: Once again with guild banners, templates are memory only and will not load correctly once player logs out - tolakram
                    var inv = GameInventoryItem.Create(it);
                    if (client.Player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, inv))
                    {
                        string invMsg = $"The {inv.Name} is cleared from the {(method == 2 ? "wall surface" : "floor")}.";

                        ChatUtil.SendSystemMessage(client, invMsg);
                        InventoryLogging.LogInventoryAction($"(HOUSE;{house.HouseNumber})", client.Player, eInventoryActionType.Other, inv.Template, inv.Count);
                    }
                    else
                    {
                        ChatUtil.SendSystemMessage(client, "You need place in your inventory !");
                        return;
                    }
                }
                else if (method == 2)
                {
                    ChatUtil.SendSystemMessage(client, "The decoration item is cleared from the wall surface.");
                }
                else
                {
                    ChatUtil.SendSystemMessage(client, "The decoration item is cleared from the floor.");
                }

                GameServer.Database.DeleteObject(house.IndoorItems[position].DatabaseItem);
                house.IndoorItems.Remove(position);

                var pak = new GSTCPPacketOut(client.Out.GetPacketCode(eServerPackets.HousingItem));
                if (client.Version >= GameClient.eClientVersion.Version1125)
                {
                    pak.WriteShortLowEndian((ushort)housenumber);
                    pak.WriteByte(0x01);
                    pak.WriteByte(0x00);
                    pak.WriteByte((byte)position);
                    pak.Fill(0x00, 11);
                }
                else
                {
                    pak.WriteShort((ushort)housenumber);
                    pak.WriteByte(0x01);
                    pak.WriteByte(0x00);
                    pak.WriteByte((byte)position);
                    pak.WriteByte(0x00);
                }

                foreach (GamePlayer plr in house.GetAllPlayersInHouse())
                {
                    plr.Out.SendTCP(pak);
                }

                break;
            }
        }
コード例 #26
0
        public void HandlePacket(GameClient client, GSPacketIn packet)
        {
            packet.ReadByte(); // unk1
            int    position    = packet.ReadByte();
            ushort housenumber = packet.ReadShort();
            ushort angle       = packet.ReadShort();

            packet.ReadShort(); // unk2

            // rotation only works for inside items
            if (!client.Player.InHouse)
            {
                return;
            }

            // house is null, return
            var house = HouseMgr.GetHouse(housenumber);

            if (house == null)
            {
                return;
            }

            // player is null, return
            if (client.Player == null)
            {
                return;
            }

            // no permission to change the interior, return
            if (!house.CanChangeInterior(client.Player, DecorationPermissions.Add))
            {
                return;
            }

            if (house.IndoorItems.ContainsKey(position) == false)
            {
                return;
            }

            // grab the item in question
            IndoorItem iitem = house.IndoorItems[position];

            if (iitem == null)
            {
                client.Player.Out.SendMessage("error: id was null", eChatType.CT_Help, eChatLoc.CL_SystemWindow);
                return;
            } // should this ever happen?

            // adjust the item's roation
            int old = iitem.Rotation;

            iitem.Rotation = (iitem.Rotation + angle) % 360;

            if (iitem.Rotation < 0)
            {
                iitem.Rotation = 360 + iitem.Rotation;
            }

            iitem.DatabaseItem.Rotation = iitem.Rotation;

            // save item
            GameServer.Database.SaveObject(iitem.DatabaseItem);

            ChatUtil.SendSystemMessage(client, $"Interior decoration rotated from {old} degrees to {iitem.Rotation}");

            // update all players in the house.
            foreach (GamePlayer plr in house.GetAllPlayersInHouse())
            {
                plr.Client.Out.SendFurniture(house, position);
            }
        }
コード例 #27
0
        /// <summary>
        /// Is this a move request for a consigment merchant?
        /// </summary>
        /// <param name="playerInventory"></param>
        /// <param name="fromClientSlot"></param>
        /// <param name="toClientSlot"></param>
        /// <returns></returns>
        public virtual bool MoveItem(GamePlayer player, ushort fromClientSlot, ushort toClientSlot)
        {
            if (fromClientSlot == toClientSlot)
            {
                return(false);
            }

            House house = HouseMgr.GetHouse(HouseNumber);

            if (house == null)
            {
                return(false);
            }

            if (this.CanHandleRequest(player, fromClientSlot, toClientSlot) == false)
            {
                return(false);
            }

            // let's move it

            lock (m_vaultSync)
            {
                if (fromClientSlot == toClientSlot)
                {
                    NotifyObservers(player, null);
                }
                else if (fromClientSlot >= FirstClientSlot && fromClientSlot <= LastClientSlot)
                {
                    // Moving from the consignment merchant to ...

                    if (toClientSlot >= FirstClientSlot && toClientSlot <= LastClientSlot)
                    {
                        // ... consignment merchant
                        if (HasPermissionToMove(player))
                        {
                            NotifyObservers(player, this.MoveItemInsideObject(player, (eInventorySlot)fromClientSlot, (eInventorySlot)toClientSlot));
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        // ... player

                        InventoryItem toItem = player.Inventory.GetItem((eInventorySlot)toClientSlot);

                        if (toItem != null)
                        {
                            player.Client.Out.SendMessage("You can only move an item to an empty slot!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return(false);
                        }

                        if (HasPermissionToMove(player) == false)
                        {
                            // Move must be an attempt to buy
                            OnPlayerBuy(player, (eInventorySlot)fromClientSlot, (eInventorySlot)toClientSlot);
                        }
                        else if (player.TargetObject == this)
                        {
                            // Allow a move only if the player with permission is standing in front of the CM.
                            // This prevents moves if player has owner permission but is viewing from the Market Explorer
                            NotifyObservers(player, this.MoveItemFromObject(player, (eInventorySlot)fromClientSlot, (eInventorySlot)toClientSlot));
                        }
                        else
                        {
                            player.Client.Out.SendMessage("You can't buy items from yourself!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return(false);
                        }
                    }
                }
                else if (toClientSlot >= FirstClientSlot && toClientSlot <= LastClientSlot)
                {
                    // moving an item from the client to the consignment merchant
                    if (HasPermissionToMove(player))
                    {
                        InventoryItem toItem = player.Inventory.GetItem((eInventorySlot)toClientSlot);

                        if (toItem != null)
                        {
                            // in most clients this is actually handled ON the client, but just in case...
                            player.Client.Out.SendMessage("You can only move an item to an empty slot!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return(false);
                        }

                        NotifyObservers(player, this.MoveItemToObject(player, (eInventorySlot)fromClientSlot, (eInventorySlot)toClientSlot));
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #28
0
ファイル: jump.cs プロジェクト: towbes/DOLSharp
        public void OnCommand(GameClient client, string[] args)
        {
            try
            {
                #region Refresh
                if (args.Length == 2 && args[1].ToLower() == "refresh")
                {
                    client.Player.LeaveHouse();
                    client.Player.RefreshWorld();
                    return;
                }
                #endregion Refresh
                #region Jump to GT
                if (args.Length == 3 && args[1].ToLower() == "to" && args[2].ToLower() == "gt")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID, client.Player.GroundTarget.X, client.Player.GroundTarget.Y, client.Player.GroundTarget.Z, client.Player.Heading);
                    return;
                }
                #endregion Jump to GT
                #region Jump to house
                else if (args.Length >= 3 && args[1].ToLower() == "to" && (args[2].ToLower() == "house" || args[2].ToLower() == "myhouse"))
                {
                    House house = null;
                    if (args[2] == "myhouse")
                    {
                        house = HouseMgr.GetHouseByPlayer(client.Player);
                    }
                    else
                    {
                        house = HouseMgr.GetHouse(Convert.ToInt32(args[3]));
                    }
                    if (house != null)
                    {
                        client.Player.MoveTo(house.OutdoorJumpPoint);
                    }
                    else
                    {
                        client.Out.SendMessage("This house number is not owned by anyone!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                    return;
                }
                #endregion Jump to house
                #region Jump t region #
                if (args.Length == 4 && args[1] == "to" && args[2] == "region")
                {
                    client.Player.MoveTo(Convert.ToUInt16(args[3]), client.Player.X, client.Player.Y, client.Player.Z, client.Player.Heading);
                    return;
                }
                #endregion Jump t region #
                #region Jump to PlayerName or ClientID
                if (args.Length == 3 && args[1] == "to")
                {
                    GameClient clientc = null;
                    if (args[2].StartsWith("#"))
                    {
                        try
                        {
                            var sessionID = Convert.ToUInt32(args[2].Substring(1));
                            clientc = WorldMgr.GetClientFromID(sessionID);
                        }
                        catch
                        {
                        }
                    }
                    else
                    {
                        clientc = WorldMgr.GetClientByPlayerName(args[2], false, true);
                    }

                    if (clientc == null)
                    {
                        GameNPC[] npcs = WorldMgr.GetNPCsByName(args[2], eRealm.None);

                        if (npcs.Length > 0)
                        {
                            // for multiple npc's first try to jump to the npc in the players current region
                            GameNPC jumpTarget = npcs[0];

                            foreach (GameNPC npc in npcs)
                            {
                                if (npc.CurrentRegionID == client.Player.CurrentRegionID)
                                {
                                    jumpTarget = npc;
                                    break;
                                }
                            }

                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", npcs[0].CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            if (jumpTarget.InHouse && jumpTarget.CurrentHouse != null)
                            {
                                jumpTarget.CurrentHouse.Enter(client.Player);
                            }
                            else
                            {
                                client.Player.MoveTo(jumpTarget.CurrentRegionID, jumpTarget.X, jumpTarget.Y, jumpTarget.Z, jumpTarget.Heading);
                            }
                            return;
                        }

                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotBeFound", args[2]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    if (CheckExpansion(client, clientc, clientc.Player.CurrentRegionID))
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", clientc.Player.CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        if (clientc.Player.CurrentHouse != null && clientc.Player.InHouse)
                        {
                            clientc.Player.CurrentHouse.Enter(client.Player);
                        }
                        else
                        {
                            client.Player.MoveTo(clientc.Player.CurrentRegionID, clientc.Player.X, clientc.Player.Y, clientc.Player.Z, client.Player.Heading);
                        }
                        return;
                    }

                    client.Out.SendMessage("You don't have an expansion needed to jump to this location.", eChatType.CT_System, eChatLoc.CL_SystemWindow);

                    return;
                }
                #endregion Jump to PlayerName
                #region Jump to Name Realm
                else if (args.Length == 4 && args[1] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[2], false, true);
                    if (clientc == null)
                    {
                        int realm = 0;
                        int.TryParse(args[3], out realm);

                        GameNPC[] npcs = WorldMgr.GetNPCsByName(args[2], (eRealm)realm);

                        if (npcs.Length > 0)
                        {
                            // for multiple npc's first try to jump to the npc in the players current region
                            GameNPC jumpTarget = npcs[0];

                            foreach (GameNPC npc in npcs)
                            {
                                if (npc.CurrentRegionID == client.Player.CurrentRegionID)
                                {
                                    jumpTarget = npc;
                                    break;
                                }
                            }

                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", npcs[0].CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            client.Player.MoveTo(jumpTarget.CurrentRegionID, jumpTarget.X, jumpTarget.Y, jumpTarget.Z, jumpTarget.Heading);
                            return;
                        }

                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotBeFoundInRealm", args[2], realm), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (CheckExpansion(client, clientc, clientc.Player.CurrentRegionID))
                    {
                        if (clientc.Player.InHouse)
                        {
                            client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.CannotJumpToInsideHouse"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                            return;
                        }
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.JumpToX", clientc.Player.CurrentRegion.Description), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        if (clientc.Player.CurrentHouse != null && clientc.Player.InHouse)
                        {
                            clientc.Player.CurrentHouse.Enter(client.Player);
                        }
                        else
                        {
                            client.Player.MoveTo(clientc.Player.CurrentRegionID, clientc.Player.X, clientc.Player.Y, clientc.Player.Z, client.Player.Heading);
                        }
                        return;
                    }
                    return;
                }
                #endregion Jump to Name Realm
                #region Jump to X Y Z
                else if (args.Length == 5 && args[1] == "to")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID, Convert.ToInt32(args[2]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), client.Player.Heading);
                    return;
                }
                #endregion Jump to X Y Z
                #region Jump rel +/-X +/-Y +/-Z
                else if (args.Length == 5 && args[1] == "rel")
                {
                    client.Player.MoveTo(client.Player.CurrentRegionID,
                                         client.Player.X + Convert.ToInt32(args[2]),
                                         client.Player.Y + Convert.ToInt32(args[3]),
                                         client.Player.Z + Convert.ToInt32(args[4]),
                                         client.Player.Heading);
                    return;
                }
                #endregion Jump rel +/-X +/-Y +/-Z
                #region Jump to X Y Z RegionID
                else if (args.Length == 6 && args[1] == "to")
                {
                    if (CheckExpansion(client, client, (ushort)Convert.ToUInt16(args[5])))
                    {
                        client.Player.MoveTo(Convert.ToUInt16(args[5]), Convert.ToInt32(args[2]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), client.Player.Heading);
                        return;
                    }
                    return;
                }
                #endregion Jump to X Y Z RegionID
                #region Jump PlayerName to X Y Z
                else if (args.Length == 6 && args[2] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    clientc.Player.MoveTo(clientc.Player.CurrentRegionID, Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), Convert.ToInt32(args[5]), clientc.Player.Heading);
                    return;
                }
                #endregion Jump PlayerName to X Y Z
                #region Jump PlayerName to X Y Z RegionID
                else if (args.Length == 7 && args[2] == "to")
                {
                    GameClient clientc;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (CheckExpansion(clientc, clientc, (ushort)Convert.ToUInt16(args[6])))
                    {
                        clientc.Player.MoveTo(Convert.ToUInt16(args[6]), Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), Convert.ToInt32(args[5]), clientc.Player.Heading);
                        return;
                    }
                    return;
                }
                #endregion Jump PlayerName to X Y Z RegionID
                #region Jump PlayerName to PlayerCible
                else if (args.Length == 4 && args[2] == "to")
                {
                    GameClient clientc;
                    GameClient clientto;
                    clientc = WorldMgr.GetClientByPlayerName(args[1], false, true);
                    if (clientc == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[1]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    if (args[3] == "me")
                    {
                        clientto = client;
                    }
                    else
                    {
                        clientto = WorldMgr.GetClientByPlayerName(args[3], false, false);
                    }

                    if (clientto == null)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PlayerIsNotInGame", args[3]), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }
                    else
                    {
                        if (CheckExpansion(clientto, clientc, clientto.Player.CurrentRegionID))
                        {
                            if (clientto.Player.CurrentHouse != null && clientto.Player.InHouse)
                            {
                                clientto.Player.CurrentHouse.Enter(clientc.Player);
                            }
                            else
                            {
                                clientc.Player.MoveTo(clientto.Player.CurrentRegionID, clientto.Player.X, clientto.Player.Y, clientto.Player.Z, client.Player.Heading);
                            }
                            return;
                        }
                        return;
                    }
                }
                #endregion Jump PlayerName to PlayerCible
                #region push/pop
                else if (args.Length > 1 && args[1] == "push")
                {
                    Stack <GameLocation> locations;

                    locations = client.Player.TempProperties.getProperty <object>(TEMP_KEY_JUMP, null) as Stack <GameLocation>;

                    if (locations == null)
                    {
                        locations = new Stack <GameLocation>(3);
                        client.Player.TempProperties.setProperty(TEMP_KEY_JUMP, locations);
                    }

                    locations.Push(new GameLocation("temploc", client.Player.CurrentRegionID, client.Player.X, client.Player.Y, client.Player.Z, client.Player.Heading));

                    string message = LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.Pushed");

                    if (locations.Count > 1)
                    {
                        message += " " + LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PushedTotal", locations.Count);
                    }

                    message += " - " + LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.PopInstructions");

                    client.Out.SendMessage(message, eChatType.CT_System, eChatLoc.CL_SystemWindow);
                }
                else if (args.Length > 1 && args[1] == "pop")
                {
                    Stack <GameLocation> locations;

                    locations = client.Player.TempProperties.getProperty <object>(TEMP_KEY_JUMP, null) as Stack <GameLocation>;

                    if (locations == null || locations.Count < 1)
                    {
                        client.Out.SendMessage(LanguageMgr.GetTranslation(client.Account.Language, "GMCommands.Jump.NothingPushed"), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        return;
                    }

                    GameLocation jumploc = locations.Pop();

                    // slight abuse of the stack principle, but convenient to always have your last popped loc jumpable
                    if (locations.Count < 1)
                    {
                        locations.Push(jumploc);
                    }

                    client.Player.MoveTo(jumploc.RegionID, jumploc.X, jumploc.Y, jumploc.Z, jumploc.Heading);
                }
                #endregion push/pop
                #region DisplaySyntax
                else
                {
                    DisplaySyntax(client);
                    return;
                }
                #endregion DisplaySyntax
            }

            catch (Exception ex)
            {
                DisplayMessage(client, ex.Message);
            }
        }
コード例 #29
0
ファイル: house.cs プロジェクト: JVirant/DOLSharp
        public void OnCommand(GameClient client, string[] args)
        {
            try
            {
                if (client.Account.PrivLevel > (int)ePrivLevel.Player)
                {
                    if (args.Length > 1)
                    {
                        HouseAdmin(client.Player, args);
                        return;
                    }

                    if (client.Account.PrivLevel >= (int)ePrivLevel.GM)
                    {
                        DisplayMessage(client, "GM: info - Display house info for a nearby house");
                    }

                    if (client.Account.PrivLevel == (int)ePrivLevel.Admin)
                    {
                        DisplayMessage(client, "Admin: model <1 - 12> - change house model");
                        DisplayMessage(client, "Admin: restart - restart the housing manager");
                        DisplayMessage(client, "Admin: addhookpoints - allow adding of missing hookpoints");
                        DisplayMessage(client, "Admin: remove <YES> - remove this house!");
                    }
                }

                House house = HouseMgr.GetHouseByPlayer(client.Player);

                if (house != null)
                {
                    if (client.Player.Guild != null)
                    {
                        // check to see if guild emblem is current
                        if (house.Emblem != client.Player.Guild.Emblem)
                        {
                            house.Emblem = client.Player.Guild.Emblem;
                            house.SaveIntoDatabase();
                        }
                    }

                    if (house.RegionID == client.Player.CurrentRegionID && client.Player.InHouse == false)
                    {
                        // let's force update their house to make sure they can see it

                        client.Out.SendHouse(house);
                        client.Out.SendGarden(house);

                        if (house.IsOccupied)
                        {
                            client.Out.SendHouseOccupied(house, true);
                        }
                    }

                    // Send the house info dialog
                    house.SendHouseInfo(client.Player);
                }
                else
                {
                    DisplayMessage(client, "You do not own a house.");
                }

                // now check for a guild house and update emblem if needed, then force update

                if (client.Player.Guild != null && client.Player.Guild.GuildOwnsHouse && client.Player.Guild.GuildHouseNumber > 0)
                {
                    House guildHouse = HouseMgr.GetHouse(client.Player.Guild.GuildHouseNumber);

                    if (guildHouse != null)
                    {
                        if (guildHouse.Emblem != client.Player.Guild.Emblem)
                        {
                            guildHouse.Emblem = client.Player.Guild.Emblem;
                            guildHouse.SaveIntoDatabase();
                            guildHouse.SendUpdate();                             // forces refresh
                        }
                        else if (guildHouse.RegionID == client.Player.CurrentRegionID)
                        {
                            guildHouse.SendUpdate();                             // forces refresh
                        }
                    }
                }
            }
            catch
            {
                DisplaySyntax(client);
            }
        }