コード例 #1
0
 public static bool transferFP(ulong userID, string factiontag, int amount)
 {
     if (amount < 0)
     {
         ChatUtil.SendPrivateChat(userID, "Please enter a positive value");
         return(false);
     }
     if (Faction.getFactionIDfromTag(factiontag) != 0)
     {
         if (FactionPoints.RemoveFP((ulong)Faction.getFactionID(userID), amount) == true)
         {
             FactionPoints.AddFP(Faction.getFactionIDfromTag(factiontag), amount);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         ChatUtil.SendPrivateChat(userID, "Factionx tag does not exist");
         return(false);
     }
 }
コード例 #2
0
        public static bool buyItem(string itemname, long buyamount, ulong userID)
        {
            ShopItems = getshoppinglist(ShopItems);
            DynShopPrices.DynPrices(ShopItems, Faction.getFactionID(userID));
            //ChatUtil.SendPrivateChat(userID, "Buying Item.");
            long   amount           = -1;
            string itemnamelowerend = itemname.ToLower().Substring(1);
            string itemnamecapital  = itemname.ToUpper().Substring(0, 1);

            itemname = itemnamecapital + itemnamelowerend;
            if (buyamount < 0)
            {
                ChatUtil.SendPrivateChat(userID, "Please enter a positive value.");
                return(false);
            }
            foreach (ShopItem item in ShopItems)
            {
                if (item.ItemName == itemname)
                {
                    amount = item.ItemPrice * buyamount;
                }
            }
            if (amount == -1)
            {
                ChatUtil.SendPrivateChat(userID, "Item does not exist.");
                return(false);
            }
            long facID     = Faction.getFactionID(userID);
            int  intAmount = Convert.ToInt32(amount);

            if (ChatUtil.CheckPlayerIsInWorld(userID))
            {
                if (!FactionPoints.RemoveFP(Convert.ToUInt64(facID), intAmount))
                {
                    ChatUtil.SendPrivateChat(userID, "You do not have sufficient points to complete your purchase.");
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            Boolean component = false;

            switch (itemname)
            {
            case ("UpgradedConstruction"):
            case ("AdvancedConstruction"):
            case ("QuantumConstruction"):
            {
                component = true;
                break;
            }

            default:
                break;
            }

            if (component)
            {
                ChatUtil.AddComp(userID, itemname, Convert.ToInt32(buyamount));
                return(true);
            }
            else
            {
                ChatUtil.AddIngot(userID, itemname, Convert.ToInt32(buyamount));
                return(true);
            }
        }