1. Not even sure if this is possible... But I am working on my quests plugin... And I am trying to handle gathering items for a quest.

    So I can use the "OnGather" but the problem is... When I get to the point of removing the gathered item after the quest has been finished, I come into the complication of it not actually getting the item since the server hasn't actually given the item to the player until after "OnGather" has finished.

    So basically I would require "OnGather" hook and "OnFinishedGather" hook... That way I can get real item amount instead of a non updated amount.

    Unless you have a better way of going about this...
    Code:
            public static int hasPlayerFinishedQuest_Gather(BasePlayer player, BaseEntity entity, Item item)
            {
                Notification(player, "Updated Amount: " + (player.inventory.GetAmount(item.info.itemid) + item.amount));
                AmountGathered += item.amount;
                Quest myQuest = GetActiveQuest(player);
                if (myQuest != null)
                {
                    if (myQuest.qObjective != item.info.shortname) return 0;
                    var cP = (double)AmountGathered / myQuest.qAmount;
                    if (LastPercentChange == 0.00)
                        LastPercentChange = cP;
                    var lP = LastPercentChange;
                    var rPC = 0.25;
                    double pC = (double)cP - lP;
                    //player.ChatMessage(String.Format("Amount Gathered: {0} | PercentGathered: {1} | lastPercent: {2} | percentChange: {3}", AmountGathered, cP, lP, pC));
                    if (pC >= rPC)
                    {
                        Notification(player, String.Format("Amount Gathered: <color=aqua>{0} / {1}</color>", AmountGathered, myQuest.qAmount));
                        LastPercentChange = cP;
                    }
                    return hasCompletedQuest(player, item, myQuest);
                }
                else
                {
                    return 0;
                }
            }        public static int hasCompletedQuest(BasePlayer player, Item item, Quest myQuest)
            {
                string FullItemName = String.Empty;
                if (AmountGathered >= myQuest.qAmount && player.inventory.GetAmount(item.info.itemid) + item.amount >= myQuest.qAmount)
                {
                    if (player.inventory.GetAmount(item.info.itemid) + item.amount < myQuest.qAmount)
                    {
                        switch (myQuest.qObjective)
                        {
                            case "wood": FullItemName = "Wood"; break;
                            case "stones": FullItemName = "Stones"; break;
                            case "metal_ore": FullItemName = "Metal Ore"; break;
                            case "sulfur_ore": FullItemName = "Sulfur Ore"; break;
                            case "fat_animal": FullItemName = "Animal Fat"; break;
                            case "cloth": FullItemName = "Cloth"; break;
                            case "bones": FullItemName = "Bones"; break;
                            case "wolfmeat_raw": FullItemName = "Raw Wolf Meat"; break;
                            case "bone_fragments": FullItemName = "Bone Fragments"; break;
                        }                    if (player.inventory.GetAmount(item.info.itemid) + item.amount < myQuest.qAmount)
                        {
                            Notification(player, String.Format("Insufficent amount of <color=aqua>{0}</color> to finish quest. Fixing...", FullItemName));
                            return 0;
                        }
                    }
                    RemoveItems(player.inventory, item, item.info.itemid, myQuest.qAmount);
                    Notification(player, String.Format("Amount Gathered: <color=aqua>{0}</color>", myQuest.qAmount));
                    CompletedQuest(myQuest.qName, player);
                    return Convert.ToInt32(myQuest.qReward);
                }
                return 0;
            }        // skillKey = char.ToUpper(skillKey[0]) + skillKey.Substring(1);
            public static int hasPlayerFinishedQuest_KillAnimal(BasePlayer player, string entityName)
            {
                Quest myQuest = GetActiveQuest(player);
                if (myQuest == null) return 0;
                if(entityName != myQuest.qObjective) return 0;
                AmountKilled++;
                Notification(player, String.Format("You have killed {0}/{1} <color=aqua>{2}</color>", AmountKilled, myQuest.qAmount, char.ToUpper(myQuest.qObjective[0]) + myQuest.qObjective.Substring(1)));
                if(AmountKilled >= myQuest.qAmount)
                {
                    CompletedQuest(myQuest.qName, player);
                    return Convert.ToInt32(myQuest.qReward);
                }
                return 0;
            }        public static void RemoveItems(PlayerInventory inventory, Item item, int itemId, int amount)
            {
                List<Item> i = new List<Item>();
                i.Add(item);
                int GiveBack = Convert.ToInt32(inventory.GetAmount(itemId) + item.amount - amount);
                int num = 0;
                num = num + inventory.containerMain.Take(i, itemId, amount);
                if (amount == num)
                {
                    return;
                }
                num = num + inventory.containerBelt.Take(i, itemId, amount);
                if (amount == num)
                {
                    return;
                }
                num = num + inventory.containerWear.Take(i, itemId, amount);
                if (amount == num)
                {
                    return;
                }
            }
     
  2. How about instead of removing the items gathered, to just not give them and only credit them towards the quest progress
    Code:
    OnGather:
      Quest active for this resource?
      No:
        Resume normal behavior
      Yes:
        Required amount > gathered amount?
        Yes:
          Update quest progress, don't give any items (set amount to 0)
        No:
          Update quest progress, give the remaining items gathered past the objective (set amount to x)
     
  3. Well the quest is to gather 10,000 wood for the server or whatever... since you are gathering wood for someone else, makes sense not to keep the wood no? :|
    [DOUBLEPOST=1432920112][/DOUBLEPOST]Or do you mean don't give them the item at all?
     
  4. Exactly, when you are on the quest, the items gathered aren't given to the user but are instead counted towards the quest objective.
     
  5. So... If the person abandons the quest give them the items? Sounds decent... Good idea! Thanks! <3