Implemented OnPlayerViolation hook (Rust)

Discussion in 'Feature Suggestions' started by wzp, Apr 17, 2017.

  1. wzp

    wzp Wood Hoarder Plugin Developer

    Please add something like this to Antihack
    Code (Text):
      public static void AddViolation(BasePlayer ply, object sender, float amount)
      {
        if (!ConVar.AntiHack.enabled)
          return;

      Interface.CallHook("OnAddViolation", (object) ply, (object) sender, (object) amount);

        ply.lastViolationTime = UnityEngine.Time.realtimeSinceStartup;
        ply.violationLevel += amount;
        if (ConVar.AntiHack.debuglevel >= 2 && (double) amount > 0.0 || ConVar.AntiHack.debuglevel >= 3)
          AntiHack.Log(ply, sender, (object) ("Added violation of " + (object) amount + " in frame " + (object) UnityEngine.Time.frameCount + " (now has " + (object) ply.violationLevel + ")"));
        AntiHack.EnforceViolations(ply);
      }
     
     
    miRror likes this.
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    I'm not seeing some of those things int he original hook such as the if check at the top, was that added by you?

    I did add object OnPlayerViolation(BasePlayer player, AntiHackType type, float amount) locally.
     
  3. wzp

    wzp Wood Hoarder Plugin Developer

    "if check" was in source that time, but it's excluded for now, yes
     
  4. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Okay, I made it an object hook so that you can cancel it still.