1. serezhadelaet

    serezhadelaet Shack Builder Plugin Developer

    ResourceDispenser =>
    Code (Text):
    public void AssignFinishBonus(global::BasePlayer player, float fraction)
        {
            base.SendMessage("FinishBonusAssigned", SendMessageOptions.DontRequireReceiver);
            if (fraction <= 0f)
            {
                return;
            }
            Interface.CallHook("OnAssignFinishBonus", new object[]
            {
                this,
                player,
                fraction
            });
            foreach (global::ItemAmount current in this.finishBonus)
            {
                global::Item item = global::ItemManager.Create(current.itemDef, Mathf.CeilToInt((float)((int)current.amount) * Mathf.Clamp01(fraction)), 0uL);
                if (item != null)
                {
                    player.GiveItem(item, global::BaseEntity.GiveItemReason.ResourceHarvested);
                }
            }
        }
    Will be very usefull for modify bonus (for example players want usuall gather rates HQM or individual rates with permissions)
     
    Vlad-00003, Shady757 and Ryan like this.
  2. Ryan

    Ryan Master Researcher Plugin Developer

    @Mughisi Said he plans to add something like that when he's feeling better, he's currently ill though unfortunately.
     
  3. I AM SUPA MIDA

    I AM SUPA MIDA Naked Wanderer

    pls add hook OnDispenserFinishBonus(ResourceDispenser dispenser, BasePlayer player, Item item) { }
    in ResourceDispenser.Initialize();
     
  4. Fujikura

    Fujikura Grenade Master Plugin Developer

    Nonsense...
     
  5. I AM SUPA MIDA

    I AM SUPA MIDA Naked Wanderer

    Delirium in what? Then you need to add the OnDispenserFinishBonus hook to the ResourceDispenser.Initialize ();
     
  6. wzp

    wzp Wood Hoarder Plugin Developer

    yep, it would be better with this hook return handling to control bonus

    ADD: but i think better do it in DoGather(), like OnDispenserGather hook, we will have ResourceDispenser object and gather tool:

    Interface.CallHook("OnAssignFinishBonus", (object) this, (object) info.Initiator);

    Ok, OnDispenserGather can fit my needs
     
    Last edited by a moderator: Aug 17, 2017
  7. Vlad-00003

    Vlad-00003 Master Researcher Plugin Developer

    Tumbs up for this!
    Also - made this hook on myself, so, @Mughisi, can you add my hook to the main oxide build?
    Hook file: [JSON] FinishBonus hook - Pastebin.com
    Also - for some reason after patching my servers version downgrades... o_O
    Can any one explain my why?
     
  8. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Sounds like you have an old Assembly-CSharp_Original.dll
     
  9. Vlad-00003

    Vlad-00003 Master Researcher Plugin Developer

    Possible. So what about adding this hook to the game? It's being a mounth since original request.
    Yep. That was the reson. Thanks!

    @Wulf, Can't you add it on your own?
     
  10. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Yes, we just haven't added it yet. :p
     
  11. Vlad-00003

    Vlad-00003 Master Researcher Plugin Developer

    So, can I ask you a favour? Since I've made this hook already - can you implement it as I made it?
    I mean with the same name and with the same arguments order. Thanks =3
     
  12. wzp

    wzp Wood Hoarder Plugin Developer

    if u want to manipulate bonus resources, it can be easily done in OnEntitySpawned
    if for some smelted purposes - OnDispenserGather and monitoring eg. fractionRemaining
     
    Last edited: Aug 13, 2017
  13. Vlad-00003

    Vlad-00003 Master Researcher Plugin Developer

    Ok, simple example - Enchanted Tools - how they suppose to work? They should replace item on getting it, before the item assigned to the player.
    Yeah - sure - you can check the player inventory... but how we suppose to know the amount? Loop thro dispenser finish bonus every hit? Nonsense.
    This hook is very simple, and I've already made it. The only thing that's left to do - add it to the main oxide release.
    @Mughisi, can you do it? As I said above - this is the hook: [JSON] FinishBonus hook - Pastebin.com
     
  14. wzp

    wzp Wood Hoarder Plugin Developer

    in OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
    Code (Text):
                    if ((double) dispenser.fractionRemaining <= 0.2)
                    {
                               .....
                    }
     
  15. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Were you wanting the hook to trigger for every item given? It'd probably be better to have the hook above the loop and have the finishBonus as the arg.
     
    Last edited: Aug 17, 2017
  16. Vlad-00003

    Vlad-00003 Master Researcher Plugin Developer

    I'm pretty sure that this wuold be better for the hook to be called exacly in the loop. Did you even watch what I've made?
    Why so - simple. The hook would be called with exact item before it would be given.
     
  17. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Yes, I looked at your hook, but the index has changed and what you provided was no longer valid, which is why I asked. No need to be snarky.
     
  18. Vlad-00003

    Vlad-00003 Master Researcher Plugin Developer

    oops, my bad. here it is -
     
  19. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    An index of 35 would be what you'd need for today's update. Are you wanting to be able to modify the Item via a return or anything?
     
  20. Vlad-00003

    Vlad-00003 Master Researcher Plugin Developer

    Yep. I wanna modify the item itself. Amount and the ItemDefenition =)
    1.png