1. hello, i have some question. at first can i change / add variables into Oxide hooks as example this.

    original:
    Code:
    void OnCrateHack(HackableLockedCrate crate)
    {
        Puts("OnCrateHack works!");
    }
    
    add player:
    Code:
    void OnCrateHack(HackableLockedCrate crate, BasePlayer player)
    {
        Puts("OnCrateHack works!");
    }
    
    so next one i want tracking player who is start hack the CodeLockedCrate
    as example:

    Code:
    void OnCrateHack(HackableLockedCrate crate, BasePlayer player)
    {
        Puts(player.displayName + "start hacking!");
    }
    
    but this one dont work, so my question can somebody show me a example how it would work, or give me the right direction how i add player variable into a hook where no player is as function.
    i am very new to this and i am learning. thx.
     
  2. The "variables being added into the hook" (arguments into the method) cannot be changed by you. They get changed by Oxide.

    In this example, it looks like you cannot get the player who is starting to hack the crate.

    Sometimes the arguments contain objects that you can get the player from. But you cannot here unfortunately.
     
  3. > can somebody show me a example how it would work, or give me the right direction how i add player variable into a hook where no player is as function.

    I will explain.
    You have hook
    Code:
    void OnCrateHack(HackableLockedCrate crate)
    {
        Puts("OnCrateHack works!");
    }
    
    You have arg "HackableLockedCrate crate". You cant add/remove args (because hook will not be triggered)
    BUT

    You can get vars (like position, player who started from "crate". How? Let me show you.
    Code:
    void OnCrateHack(HackableLockedCrate crate)
                {
                    crate.transform.position // position
                    crate.hackSeconds // seconds since hack
                }
    
    etc, etc. Everyrhing you want - you get get from "HackableLockedCrate" class.
    upload_2018-8-8_11-28-37.png
    ===========================================================================

    You cant get player from "HackableLockedCrate", because there are no way where its storing
    Code:
      [BaseEntity.RPC_Server]
      [BaseEntity.RPC_Server.IsVisible(3f)]
      public void RPC_Hack(BaseEntity.RPCMessage msg)
      {
        if (this.IsBeingHacked() || Interface.CallHook("CanHackCrate", (object) msg.player, (object) this) != null)
          return;
        this.StartHacking();
      }  public void StartHacking()
      {
        Interface.CallHook("OnCrateHack", (object) this);
        this.SetFlag(BaseEntity.Flags.Reserved1, true, false);
        // ISSUE: method pointer
        this.InvokeRepeating(new Action((object) this, __methodptr(HackProgress)), 1f, 1f);
        this.ClientRPC<int, int>((Network.Connection) null, "UpdateHackProgress", 0, (int) HackableLockedCrate.requiredHackSeconds);
        this.RefreshDecay();
      }
    
    You can try it with "Vis.Entities"(examples in Nteleportation) or "CanHackCrate" hook
     
  4. oh wow, thx to all i didnt see this hook

    Code:
    object CanHackCrate(BasePlayer player, HackableLockedCrate crate)
    {
        Puts("CanHackCrate works!");
        return null;
    }
    
    this was i search for :)