Ejemplo n.º 1
0
        private static void HandleBuyPlot(GameSession session, PacketReader packet)
        {
            int groupId         = packet.ReadInt();
            int housingTemplate = packet.ReadInt();

            //TODO: If player already owns a plot, reject

            UGCMapGroup land = UGCMapMetadataStorage.GetMetadata(session.Player.MapId, (byte)groupId);

            if (!HandlePlotPayment(session, land.PriceItemCode, land.Price))
            {
                return;
            }

            session.Player.PlotMapId      = session.Player.MapId;
            session.Player.HomePlotNumber = land.Id;
            session.Player.HomeExpiration = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount + (land.ContractDate * (24 * 60 * 60));
            session.Player.HomeName       = session.Player.Name;

            session.FieldManager.BroadcastPacket(ResponseCubePacket.PurchasePlot(session.Player));
            session.FieldManager.BroadcastPacket(ResponseCubePacket.EnablePlotFurnishing(session.Player));
            session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer));
            session.FieldManager.BroadcastPacket(ResponseCubePacket.NameHome(session.Player), session);
            session.Send(ResponseCubePacket.CompletePurchase());
        }
Ejemplo n.º 2
0
        private static void HandleNameHome(GameSession session, PacketReader packet)
        {
            string name = packet.ReadUnicodeString();

            session.Player.HomeName = name;
            session.FieldManager.BroadcastPacket(ResponseCubePacket.NameHome(session.Player));
            session.FieldManager.BroadcastPacket(ResponseCubePacket.LoadHome(session.FieldPlayer));
        }
Ejemplo n.º 3
0
        private static void HandleBuyPlot(GameSession session, PacketReader packet)
        {
            int groupId         = packet.ReadInt();
            int housingTemplate = packet.ReadInt();

            //TODO: If player already owns a plot, reject

            UGCMapGroup land = UGCMapMetadataStorage.GetMetadata(session.Player.MapId, (byte)groupId);

            if (land == null)
            {
                return;
            }

            //Check if sale event is active
            int       price     = land.Price;
            GameEvent gameEvent = DatabaseManager.GetSingleGameEvent(GameEventType.UGCMapContractSale);

            if (gameEvent != null)
            {
                int markdown = land.Price * ((gameEvent.UGCMapContractSale.DiscountAmount / 100) / 100);
                price = land.Price - markdown;
            }

            if (!HandlePlotPayment(session, land.PriceItemCode, price))
            {
                return;
            }

            session.Player.PlotMapId      = session.Player.MapId;
            session.Player.HomePlotNumber = land.Id;
            session.Player.HomeExpiration = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount + (land.ContractDate * (24 * 60 * 60));
            session.Player.HomeName       = session.Player.Name;

            session.FieldManager.BroadcastPacket(ResponseCubePacket.PurchasePlot(session.Player));
            session.FieldManager.BroadcastPacket(ResponseCubePacket.EnablePlotFurnishing(session.Player));
            session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer));
            session.FieldManager.BroadcastPacket(ResponseCubePacket.NameHome(session.Player), session);
            session.Send(ResponseCubePacket.CompletePurchase());
        }