1. Just a bit of butchered code from the cupboard radius if anyone wants to test it out and post suggestions if it is broken, I am currently away on holidays and unable to test.

    Essentially the only function this plugin should do is ignore cupboard influence.
    Code:
    using Oxide.Core;
    using Oxide.Core.Plugins;
    using System.Linq;
    using UnityEngine;namespace Oxide.Plugins
    {
        [Info("CupboardOverlap", "Virobeast", "1.0.0", ResourceId = 2131)]
        public class CupboardOverlap : RustPlugin
        {
            // Do not edit this file anymore: There is a config file now.        protected override void LoadDefaultConfig() {
                Config["ignoreInfluenceRestriction"] = false;
            }        private int Overlap;
            private bool ignoreInfluence;
            private CupboardOverlapPersistence pst = null;
            private bool initialized = false;        [HookMethod("OnServerInitialized")]
            private void onServerInitialized() {
                if (initialized)
                    return;
                LoadConfig();
                ignoreInfluence = Config.Get<bool>("ignoreInfluenceRestriction");            Puts("Using a Overlap of {0}, {1} influence restrictions", Overlap, ignoreInfluence ? "ignoring" : "not ignoring");            bool reloaded = false;
                foreach (var prevPst in ServerMgr.Instance.gameObject.GetComponents<MonoBehaviour>()) {
                    if (prevPst.GetType().Name == "CupboardOverlapPersistence") {
                        reloaded = true;
                        pst.influenceIgnored = (bool)prevPst.GetType().GetField("influenceIgnored").GetValue(prevPst);
                        pst.influenceBackup = (SocketMod[])prevPst.GetType().GetField("influenceBackup").GetValue(prevPst);
                        UnityEngine.Object.Destroy(prevPst);
                        break;
                    }
                }            var bpts = UnityEngine.Object.FindObjectsOfType<BuildPrivilegeTrigger>();
                var updated = 0;
                foreach (var bpt in bpts)
                    if (updateTrigger(bpt))
                        ++updated;            Puts("Updated Influence", updated, bpts.Length);            if (bpts.Length > 0)
                    updateInfluence(bpts[0].privlidgeEntity.prefabID);            initialized = true;
            }        [HookMethod("OnEntitySpawned")]
            private void onEntitySpawned(BaseNetworkable ent) {
                if (!initialized || !(ent is BuildingPrivlidge))
                    return;            updateInfluence(ent.prefabID);            var trig = ent.GetComponentInChildren<BuildPrivilegeTrigger>();
                if (trig == null)
                    Interface.Oxide.NextTick(() => {
                        trig = ent.GetComponentInChildren<BuildPrivilegeTrigger>();
                        if (trig == null) {
                            PrintWarning("Failed to update BuildingPrivlige: Missing BuildPrivilegeTrigger");
                            return;
                        }
                        updateTrigger(trig);
                    });
                else
                    updateTrigger(trig);
            }        private void updateInfluence(uint privlidgePrefabID) {
                if (ignoreInfluence == pst.influenceIgnored)
                    return;
                var attr = PrefabAttribute.server.Find(privlidgePrefabID);
                var socketBases = attr.Find<Socket_Base>();
                if (socketBases.Length < 1) {
                    PrintWarning("Failed to update cupboard influence: Missing Socket_Base attribute");
                    return;
                }
                var socketBase = socketBases[0];
                if (ignoreInfluence) {
                    if (pst.influenceBackup == null)
                        pst.influenceBackup = socketBase.socketMods;
                    socketBase.socketMods = socketBase.socketMods.Where(mod => mod.FailedPhrase.english != "You're trying to place too close to another cupboard").ToArray();
                    pst.influenceIgnored = true;
                    Puts("Cupboard influence restrictions are now ignored");
                } else {
                    socketBase.socketMods = pst.influenceBackup;
                    pst.influenceIgnored = false;
                    Puts("Cupboard influence restrictions are no longer ignored");
                }
            }        private class CupboardOverlapPersistence : MonoBehaviour
            {
                public bool influenceIgnored = false;
                public SocketMod[] influenceBackup = null;
            }
        }
    }
    
     
  2. You have calls to a method updateTrigger but the method doesn't exist
     
  3. You could have just asked him to implement a config entry to disable all features except the overlapping ;) You pretty much just copied it and removed methods, which will basically not work.

    Missing/Removed method:
    Code:
    private bool updateTrigger(BuildPrivilegeTrigger bpt) {
                var col = bpt.GetComponent<UnityEngine.Collider>();
                var wasTrigger = true;
                if (col != null) { // should always be the case
                    if (col is SphereCollider && Mathf.Approximately((col as SphereCollider).radius, radius))
                        return false; // Already a sphere with that radius
                    wasTrigger = col.isTrigger;
                    UnityEngine.Object.Destroy(col);
                }
                col = bpt.gameObject.AddComponent<SphereCollider>();
                col.transform.localPosition = Vector3.zero;
                col.transform.localScale = Vector3.one;
                (col as SphereCollider).radius = radius;
                col.isTrigger = wasTrigger;
                return true;
            }
    This is the part which changes the shape to a sphere. Instead of removing that,
    dcode could just add a bool somewhere which allows us to disable it via config.
    No need to create a separate plugin for that.

    The bool has to be added where I marked it in the following method:
    Code:
    [HookMethod("OnEntitySpawned")]
            private void onEntitySpawned(BaseNetworkable ent) {
                if (!initialized || !(ent is BuildingPrivlidge))
                    return;            updateInfluence(ent.prefabID);// Check if shape changing is enabled in config
    // {
                var trig = ent.GetComponentInChildren<BuildPrivilegeTrigger>();
                if (trig == null)
                    Interface.Oxide.NextTick(() => {
                        trig = ent.GetComponentInChildren<BuildPrivilegeTrigger>();
                        if (trig == null) {
                            PrintWarning("Failed to update BuildingPrivlige: Missing BuildPrivilegeTrigger");
                            return;
                        }
                        updateTrigger(trig);
                    });
                else
                    updateTrigger(trig);
    // }
            }
    Also in onServerInitialized():
    Code:
     var bpts = UnityEngine.Object.FindObjectsOfType<BuildPrivilegeTrigger>();
    // Check if shape changing is enabled in config
    // {
                var updated = 0;
                foreach (var bpt in bpts)
                    if (updateTrigger(bpt))
                        ++updated;            Puts("Updated {0} of {1} cupboards to use a sphere trigger", updated, bpts.Length);
    // }
    
     
    Last edited by a moderator: Jan 10, 2016
  4. We'll to contribute with this topic, at my server I had to remove the plugin since it started to give allowed build or build block to random players on entire map. Suddenly appear someone with enable build everywhere. Or blocked everywhere. It happens until he dies, one time dead it backs to normal.