1. Hey, I'm currently trying to upgrade all my blocks to armored if you upgrade them for testing purpose.
    Code:
    function PLUGIN:OnStructureUpgrade(block, player, grade)
        return global.BuildingGrade.Enum.TopTier;
    end
    But the above code is just ignoring everything and upgrade is not working anymore. It will stay as a twig tier.

    Or am I doing something wrong?
     
  2. Pretty sure you can't use return in that hook and you just have to set whatever grade you want in the block... by doing nothing you overrode the function to do nothing.
     
  3. [​IMG]

    Code:
            private BuildingGrade.Enum OnStructureUpgrade(BuildingBlock block, BasePlayer player, BuildingGrade.Enum grade)
            {
                return BuildingGrade.Enum.TopTier;
            }
    
    Doesn't work aswell.
     
  4. Always check the Oxide documentation for proper function signatures. You can't just convert a function that returns VOID to a function that returns a building grade, you have to work with what's given to you.

    I'm at work and can't test this, but this should work or at least has a much better chance of doing so if the doc is still up to date on that hook:
    Code:
    void OnStructureUpgrade(BuildingBlock block, BasePlayer player, BuildingGrade.Enum grade)
    {
        block.grade = BuildingGrade.Enum.TopTier;
    }
     
  5. Wulf

    Wulf Community Admin

    The docs have been updated. :)
     
  6. Thanks for your help but this code isn't working. It keeps upgrading the block to the seleceted grade ingame so I think it's a oxide bug.

    Edit: Thanks Wolf !
    [DOUBLEPOST=1442508683][/DOUBLEPOST]Sorry for bumping again, but returning true or false doens't make any difference, both gets blocked.
     
  7. Might have to do a network update on the block for it to take effect......
    [DOUBLEPOST=1442509445][/DOUBLEPOST]Nevermind!
     
    Last edited by a moderator: Sep 17, 2015
  8. Didn't try it but returning null works fine with C# if you#re using a object function. This problem is fixed.
     
  9. Post the code please?
     
  10. Wulf

    Wulf Community Admin

    You don't need to return anything if you aren't wanting to cancel it. Anything other than null cancels it.
     
  11. The c# example in the doc is still listing this as a void return type :)
     
  12. Code:
    object OnStructureUpgrade(BuildingBlock block, BasePlayer player, BuildingGrade.Enum grade)
    {
        if (player.displayName == "Mughisi")
        {
            block.grade = BuildingGrade.Enum.TopTier;
            return null;
        }
        PrintToChat(player, "You can't upgrade");
        return false;
    }
    The example in the docs doesn't matter that much, you can still use it as a void, just if you want to cancel it you have to use a different return type. But the examples need some updates which I hope to get to at some point.