Exemplo n.º 1
0
        public void SetupAPWeapon()
        {
            var shopItem = GameDatabase.Instance.GetShopItem(Category, SubCategory, ItemID, ProductID);

            if (shopItem == null)
            {
                return;
            }
            if (shopItem.Type <= 0)
            {
                return;
            }
            DateTime tmpExpire;

            switch (shopItem.Type)
            {
            case 1:     // 1 day
                tmpExpire  = HelperUtils.UnixToDateTime(PurchaseTime).AddDays(1);
                ExpireTime = HelperUtils.GetUnixTimestamp(tmpExpire);
                break;

            case 2:     // 7 days
                tmpExpire  = HelperUtils.UnixToDateTime(PurchaseTime).AddDays(7);
                ExpireTime = HelperUtils.GetUnixTimestamp(tmpExpire);
                break;

            case 3:     // 30 days
                tmpExpire  = HelperUtils.UnixToDateTime(PurchaseTime).AddDays(30);
                ExpireTime = HelperUtils.GetUnixTimestamp(tmpExpire);
                break;
            }

            Type = shopItem.Type;
        }
Exemplo n.º 2
0
        public bool IsAccountBanned(string name)
        {
            using (var con = GetConnection())
            {
                using (var cmd = BuildQuery(con, "SELECT Banned FROM accounts WHERE Username=@Username", "@Username", name))
                {
                    using (var r = cmd.ExecuteReader())
                    {
                        if (!r.Read())
                        {
                            return(false);
                        }

                        var banned = r.GetUInt64("Banned");
                        if (banned == 0)
                        {
                            return(false);
                        }

                        var timestamp = (ulong)HelperUtils.GetUnixTimestamp();
                        if (banned >= timestamp)
                        {
                            return(true);
                        }
                        UpdateBannedStatus(name, 0);
                        return(false);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private string AddItem(string[] args, Player sender)
        {
            if (sender.GMLevel < 2)
            {
                return(HelperUtils.GetS4Color(255, 0, 0) + "Nope.");
            }

            byte   category;
            byte   subCategory;
            ushort itemID;
            byte   productID;
            ulong  accountID;
            var    nickname = "";

            if (args.Length < 6)
            {
                return(_commandDescriptions["additem"]);
            }

            if (!byte.TryParse(args[1], out category))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!byte.TryParse(args[2], out subCategory))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!ushort.TryParse(args[3], out itemID))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!byte.TryParse(args[4], out productID))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!ulong.TryParse(args[5], out accountID))
            {
                nickname = args[5];
            }

            var time = DateTime.Now;
            var item = new Item
            {
                Category     = category,
                SubCategory  = subCategory,
                ItemID       = itemID,
                ProductID    = productID,
                PurchaseTime = HelperUtils.GetUnixTimestamp(time)
            };

            var shopItem = GameDatabase.Instance.GetShopItem(item.Category, item.SubCategory, item.ItemID, item.ProductID);

            if (shopItem == null)
            {
                item.ProductID  = 1;
                item.Energy     = 2400;
                item.ExpireTime = -1;
                //return HelperUtils.GetS4Color(255, 0, 0) + "ShopItem not found.";
            }
            else
            {
                item.Energy     = shopItem.Energy;
                item.ExpireTime = (shopItem.Time == -1) ? -1 : HelperUtils.GetUnixTimestamp(time.AddSeconds(shopItem.Time));
            }

            var targetPlr = accountID > 0 ? GameServer.Instance.Players.GetPlayerByID(accountID) : GameServer.Instance.Players.GetPlayerByNickname(nickname);

            if (targetPlr == null)
            {
                return(HelperUtils.GetS4Color(255, 0, 0) + "Player not found.");
            }

            var id = GameDatabase.Instance.CreateItem(item, targetPlr.AccountID);

            if (id == 0)
            {
                return(HelperUtils.GetS4Color(255, 0, 0) + "Failed to create item.");
            }
            item.ID = id;
            item.SetupAPWeapon();
            targetPlr.AddItem(item);

            return(HelperUtils.GetS4Color(0, 255, 0) + "Done.");
        }