1. I'm trying to call the BuildingBlock.UpgradeToGrade function with C#, but this method is private.

    Private Methods & Fields | Oxide
    I found this but it doesn't really help me. I have never working with these kind of things.

    Is it even possible?

    - Ino
     
  2. UpgradeToGrade? this doesn't exist.
    you have DoUpgradeToGrade(RPCMessage msg)
    but you can't use this
    if you want to set a grade just use:
    BuildingBlock.SetGrade( BuildingGrade.Enum iGradeID )
     
  3. My bad, had client assembly csharp opened.

    But still how's it possible to call a privat method?

    EDIT: I'm looking for a function to upgrade the wall and take the items away from the player without using the hammer.
     
  4. Code:
    [MaxDistance(4f), RPC_Server]
    private void DoUpgradeToGrade(BaseEntity.RPCMessage msg)
    {
        BuildingGrade.Enum iGrade = (BuildingGrade.Enum) msg.read.Int32();
        ConstructionGrade g = this.GetGrade(iGrade);
        object[] args = new object[] { this, msg, iGrade };
        if (((((Interface.CallHook("IOnStructureUpgrade", args) == null) && (g != null)) && this.CanChangeToGrade(iGrade, msg.player)) && this.CanAffordUpgrade(iGrade, msg.player)) && (base.TimeSinceAttacked() >= 8f))
        {
            this.PayForUpgrade(g, msg.player);
            this.SetGrade(iGrade);
            this.SetHealthToMax();
            this.StartBeingRotatable();
            base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            Effect.server.Run("assets/bundled/prefabs/fx/build/promote_" + iGrade.ToString().ToLower() + ".prefab", this, 0, Vector3.zero, Vector3.zero, null, false);
        }
    }
    that's the original function. You can use most of the code.
    As for using private methods.
    read this plugin: Oxide2Plugins/Build.cs at master · strykes/Oxide2Plugins · GitHub
    private MethodInfo CreateEntity;
    private MethodInfo FindPrefab;
     
  5. Thanks!
     
  6. ok wrong example, forgot that i don't use t in this plugin
    private MethodInfo inventoryClear = typeof(ItemContainer).GetMethod("Clear", BindingFlags.NonPublic | BindingFlags.Instance);
    inventoryClear.Invoke(box.inventory, null);

    so try something like
    Code:
    MethodInfo DoUpgradeToGrade = typeof(BasePlayer).GetMethod("CanChangeToGrade", BindingFlags.NonPublic | BindingFlags.Instance);
    DoUpgradeToGrade.Invoke(Block, new object[] { BuildingGrade.Enum.TopTier, Player} );
    [DOUBLEPOST=1442531725][/DOUBLEPOST]Block, Player musnt be null ofc
    [DOUBLEPOST=1442531795][/DOUBLEPOST]if you want a return just add var thereturn = DoUpgradeToGrade.Invoke(Block, new object[] { BuildingGrade.Enum.TopTier, Player} );
     
  7. typeof(BasePlayer) was my mistake, didn't see i have defined BasePlayer right there, it needed to be BuildingBlock.

    My question is solved, ty.
     
  8. lol sorry foro that ^^