1. Hi, I'm starting to get a headache on trying to rewrite this plugin to detect multiple cupboards in a sphere within range of initial cupboard. Any smart people out there to help me solve this? ^^
     
  2. Code:
    private void OnEntityBuilt(Planner plan, GameObject ent)
    {
        var cupboard = ent.GetComponent<BuildingPrivlidge>();
        if (cupboard)
        {
            var hits = Physics.OverlapSphere(cupboard.transform.position, 35);
            foreach (var ents in hits)
            {
                BuildingPrivlidge privs = ents.GetComponentInParent<BuildingPrivlidge>();
            }
        }
    }
    
    This should do what you are looking if i am right 35 is the default radius but not completely sure
     
  3. This is a definitely a push in a right direction, thank you so much ! And I found a method "PreventBuilding (UnityEngine.BoxCollider)" . Could this be implemented and how to use it ? if max ents in hits is like >5 ? And would this actually work ? Thanks again.
    [DOUBLEPOST=1488934852][/DOUBLEPOST]Also this code triggers even if cupboards are outside the set collision radius, tested with a TC 100m away, with radius set to 15.
     
  4. Alright, on closer inspection it would seem that the collider reacts to all of the surrounding objects <----X_X----< I am completely braindead at this point xD
     
  5. Ok, in the end I had to resort to something retarded as this, but now it now detects only the tcs in set radius. In the end this basically works with minimal knowledge of C#, pretty much a copy-paste case. Credits to Fujikura for "DoRemove" and sami37 for providing me an absolutely amazing template to work with ;)

    Code:
            static void DoRemove(BaseEntity Entity, bool gibs = true)
            {
                if (Entity != null)
                {
                    Interface.Oxide.CallHook("OnRemovedEntity", Entity);
                    if (!Entity.IsDestroyed)
                        Entity.Kill(gibs ? BaseNetworkable.DestroyMode.Gib : BaseNetworkable.DestroyMode.None);
                }
            }
          
            private void OnEntityBuilt(Planner plan, GameObject ent)
            {
                bool allowbuild = true;
                var cupboard = ent.GetComponent<BuildingPrivlidge>();
                if (cupboard)
                {
                    var hits = Physics.OverlapSphere(cupboard.transform.position, radius);
                    int i = 0;
                    foreach (var ents in hits)
                    {
                      
                        var privs = ents.GetComponentInParent<BuildingPrivlidge>();
                        if (ents.ToString() == "assets/prefabs/deployable/tool cupboard/cupboard.tool.deployed.prefab (UnityEngine.BoxCollider)")
                        {
                         i++;
                         PrintWarning("Number of TC in range : " + i  +"");
                        }
                      
                        if (i >= 6)
                        {
                            PrintWarning("Max cupboards reached, destroying");
                            allowbuild = false;
                            DoRemove(cupboard, removeGibsAdmin);
                            break;
                        }
                    }
                                
                }
            }
    
     
    Last edited by a moderator: Mar 8, 2017
  6. how can i set this so you can only place 1 tc every 3 or 4 foundations apart
     
  7. Under your oxide folder, go to config folder, edit the CupboardRadius.json file to say:
    "ignoreInfluenceRestriction": true
     
  8. i can still place 4 tc in 1 foundation
     
  9. I misunderstood, set the cupboard radius to 3 or 2 under the same file, and ignore to false.

    {
    "cupboardRadius": 3,
    "ignoreInfluenceRestriction": false
    }

    You'll find a happy medium, if you play w/ that radius number.
     
  10. i tryed this but if i place 2 tcs down and i auth on them both i can then place more down next to them on the same foundation so i could have 10 in a line i want to only let it place 1 down in the radius of the tc and anymore that get placed in the same radius of the first 2 to be destoyed when placing
     
  11. I'm out of ideas ^^
     
  12. Use my script above...
    var hits = Physics.OverlapSphere(cupboard.transform.position, radius); . Change "radius" to distance you want.
    And the last thing this script is missing is to send network update of an object state.
     
  13. something is broke, can no longer place cupboards near each other anymore since updates. anyone have a fix?
     
  14. Wulf

    Wulf Community Admin

    This isn't maintained by the original author, but you could try MultiCupboard for Rust | Oxide.
     
  15. well unless you are willing to take a crack at fixing it i will look into that one you mentioned.
     
  16. Wulf

    Wulf Community Admin

    I'm not the author of this plugin and not really familiar with it, but it's on the list of ones to fix.
     
  17. yeah i think it broke right after this patch
     
  18. Here to confirm it!
    Code:
    "ignoreInfluenceRestriction": true
    is not working anymore
    [DOUBLEPOST=1494684267][/DOUBLEPOST]MultiCupboard | Oxide also isn't working.

    But he said he is on it
     
  19. @Wulf Do you know something about SocketMods/SocketBase?

    As far as I understand this plugin updates the BuildPrivilegeTrigger to a sphere in the updateTriggerMethod and sets a specific radius to it. This changes the area for the building privilege.

    Then it tries to change where you can build a cupboard:
    It changes the SocketMods of the "cupboard.tool.deployed.prefab" and removes a specific mod which outpts the phrase "You're trying to place too close to another cupboard". So as far as I understood it just removes a placing rule but somehow this behaviour has changed. I just tried to remove all rules but it's still getting ignored.
     
    Last edited by a moderator: May 13, 2017
  20. Wulf

    Wulf Community Admin

    I don't, I haven't really done much with any cupboard stuff or building.