示例#1
0
        private static bool HandleExchangeRedemption(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event)
            {
                case ItemEventType.Interact:

                    int ItemValue = 0;
                    int.TryParse(Item.Flags, out ItemValue);

                    using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                    {
                        if (ItemValue != 0)
                        {
                            Session.CharacterInfo.UpdateCreditsBalance(MySqlClient, ItemValue);
                            Session.SendData(CreditsBalanceComposer.Compose(Session.CharacterInfo.CreditsBalance));
                        }

                        Item.RemovePermanently(MySqlClient);
                    }

                    Instance.TakeItem(Item.Id);
                    Instance.RegenerateRelativeHeightmap();
                    break;
            }

            return true;
        }
示例#2
0
        private static bool HandleRental(Session Session, Item Item, RoomInstance Instance, ItemEventType Event, int RequestData, uint Opcode)
        {
            switch (Event)
            {
                case ItemEventType.Placed:
                case ItemEventType.InstanceLoaded:

                    if (Item.PendingExpiration)
                    {
                        int DesiredTicks = (int)((double)(Math.Ceiling(Item.ExpireTimeLeft * 2)));

                        if (DesiredTicks <= 0)
                        {
                            goto case ItemEventType.UpdateTick;
                        }

                        Item.RequestUpdate(DesiredTicks);
                        return true;
                    }

                    break;

                case ItemEventType.UpdateTick:

                    if (Item.PendingExpiration)
                    {
                        using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                        {
                            Item.RemovePermanently(MySqlClient);
                            Instance.TakeItem(Item.Id);
                            Instance.RegenerateRelativeHeightmap();
                        }

                        return true;
                    }

                    break;
            }

            return HandleGenericSwitch(Session, Item, Instance, Event, RequestData, 0);
        }