1. Is there a method that can send the Player object and CodeLock object to Oxide plugin when the player sets his password on the combination lock?
     
  2. i don't think its possible as the code is saved on a private string, and every hook i make then use CodeLock i cant seem to call code from it so it seems like its a no can do
     
  3. There are no hooks for codelocks unfortunately but there is for opening doors. You could in theory hook that and call a UI to ask for a password and allow the possibility to set one if there isn't one (and object is owned by user or has cupboard access for instance). The UI stuff is still very rough around the edges though, good luck with that.
     
  4. edit oops i thought this was the thread about brute forcing locks but that must be the reason why this guy posted this due to the issue i have patched code lock brute forcing

    i did it already a requested them to add the hooks ill release the plugin once its done, i had some fun with oxide patcher and submitted the hooks to their git currently i have a perfectly good working anti code brute force on my server, i did release they scrip but they denied it due to me supplying dlls with the 2 hooks so im waiting on oxide to push my hooks into the live version i created 2 hooks,

    just save this as anyname.obj and load it in oxide patcher
    Code:
    {
      "Name": "Untitled Oxide Project",
      "TargetDirectory": "C:\\Users\\Steven\\Desktop\\RustServer\\Rust\\RustDedicated_Data\\Managed",
      "Manifests": [
        {
          "AssemblyName": "Assembly-CSharp",
          "Hooks": [
            {
              "Type": "Simple",
              "Hook": {
                "InjectionIndex": 13,
                "ReturnBehavior": 0,
                "ArgumentBehavior": 3,
                "ArgumentString": "",
                "HookTypeName": "Simple",
                "Name": "OnUnlockWithCodeFailed",
                "HookName": "OnUnlockWithCodeFailed",
                "AssemblyName": "Assembly-CSharp.dll",
                "TypeName": "CodeLock",
                "Flagged": false,
                "Signature": {
                  "Exposure": 0,
                  "Name": "UnlockWithCode",
                  "ReturnType": "System.Void",
                  "Parameters": [
                    "BaseEntity/RPCMessage"
                  ]
                },
                "MSILHash": "E7MT7zTBPPuYX3wRZW25abJqFdhxhQlftsUF6aDPc7Y=",
                "BaseHookName": null
              }
            },
            {
              "Type": "Simple",
              "Hook": {
                "InjectionIndex": 0,
                "ReturnBehavior": 1,
                "ArgumentBehavior": 3,
                "ArgumentString": "!=flase",
                "HookTypeName": "Simple",
                "Name": "OnUnlockWithCode",
                "HookName": "OnUnlockWithCode",
                "AssemblyName": "Assembly-CSharp.dll",
                "TypeName": "CodeLock",
                "Flagged": false,
                "Signature": {
                  "Exposure": 0,
                  "Name": "UnlockWithCode",
                  "ReturnType": "System.Void",
                  "Parameters": [
                    "BaseEntity/RPCMessage"
                  ]
                },
                "MSILHash": "E7MT7zTBPPuYX3wRZW25abJqFdhxhQlftsUF6aDPc7Y=",
                "BaseHookName": "OnUnlockWithCodeFailed"
              }
            }
          ]
        }
      ]
    }
    
    and heres the plugin:
    Code:
    using UnityEngine;
    using Rust;
    using Oxide.Core.Plugins;namespace Oxide.Plugins
    {
        [Info("AntiLockPick", "Steven", "1.0.0", ResourceId = 8915)]
        class AntiLockPick : RustPlugin
        {
            static System.DateTime epoch = new System.DateTime(2015, 1, 1, 0, 0, 0);
            System.Collections.Generic.Dictionary<ulong, System.Collections.Generic.Dictionary<CodeLock, CodeAttempts>> LockHistory = new System.Collections.Generic.Dictionary<ulong, System.Collections.Generic.Dictionary<CodeLock, CodeAttempts>>();
               
            static double GetTimestamp()
            {
                return System.DateTime.UtcNow.Subtract(epoch).TotalMilliseconds;
            }
       
            class CodeAttempts
            {
                public double LastTime, CreationTime;
                public int FailedAttempts;
                public bool Blocked;
                public CodeAttempts()
                {
                    Blocked = false;
                    FailedAttempts = 0;
                    LastTime = GetTimestamp() + 1500;
                    CreationTime = GetTimestamp();
                }
            }
       
            [HookMethod("OnUnlockWithCode")]
            object OnUnlockWithCode(CodeLock c, BaseEntity.RPCMessage b)
            {
                if(LockHistory.ContainsKey(b.player.userID) && LockHistory[b.player.userID].ContainsKey(c) && LockHistory[b.player.userID][c].Blocked) return 1;
                return null;
            }
       
            [HookMethod("OnUnlockWithCodeFailed")]
            void OnUnlockWithCodeFailed(CodeLock c, BaseEntity.RPCMessage b)
            {
                if(LockHistory.ContainsKey(b.player.userID))
                {
                    if(LockHistory[b.player.userID].ContainsKey(c))
                    {
                        double Time = GetTimestamp();
                        if(LockHistory[b.player.userID][c].LastTime > Time && LockHistory[b.player.userID][c].FailedAttempts++ >= 4) LockHistory[b.player.userID][c].Blocked = true;
                        LockHistory[b.player.userID][c].LastTime = Time + 1500;
                    }
                    else LockHistory[b.player.userID].Add(c, new CodeAttempts());
                }
                else
                {
                    System.Collections.Generic.Dictionary<CodeLock, CodeAttempts> newcode = new System.Collections.Generic.Dictionary<CodeLock, CodeAttempts>();
                    newcode.Add(c, new CodeAttempts());
                    LockHistory.Add(b.player.userID, newcode);
                }
            }
       
            [HookMethod("OnPlayerDisconnected")]
            void OnPlayerDisconnected(BasePlayer player)
            {
                if(LockHistory.ContainsKey(player.userID))
                {
                    LockHistory[player.userID].Clear();
                    LockHistory.Remove(player.userID);           
                }
            }
        }
    }
     
    Last edited by a moderator: Jul 15, 2015
  5. do you want to get the current door code or set a new one?

    and is the brute force stuff still needed? thought the damage on failed unlock is enough?
    Code:
    private void UnlockWithCode(BaseEntity.RPCMessage rpc)
    {
        string str = rpc.read.String();
        if (!base.IsLocked())
        {
            return;
        }
        if (str != this.code)
        {
            this.DoEffect(this.effectDenied);
            rpc.player.Hurt(1f, DamageType.ElectricShock, this, true);
            return;
        }
        this.DoEffect(this.effectUnlocked);
        base.SetFlag(BaseEntity.Flags.Locked, false);
        base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
        if (!this.whitelistPlayers.Contains(rpc.player.userID))
        {
            this.whitelistPlayers.Add(rpc.player.userID);
        }
    }
     
  6. big thx
     
  7. no problem mate

    godmode ?