Auto authoring a placed cupboard?
Discussion in 'Rust Development' started by Makuko, Nov 1, 2016.
-
Hook OnEntitySpawn -> Check if is an Cupboard -> Check if is your (ownerid) -> Than add you userid in the cupboard
-
Ah.. Looks like someone had the pleasure to see one of my custom plugins in action
-
You Share it?
-
Probably wouldn't even need to check if it's your id, Just add the ownerid to the cupboard.
Probably a couple of lines plugin tbh -
I so far have some code to call entity and to ensure it is a cupboard along with who placed it. But can someone help me with adding them to that cupboard?
-
Ez Pz, enjoy

Code:using System.Reflection; using UnityEngine;namespace Oxide.Plugins { [Info("AutoCupboard", "DefaultPlayer", "1.0")] public class AutoCupboard : RustPlugin { private static readonly MethodInfo AuthMethod = typeof (BuildingPrivlidge).GetMethod("AddSelfAuthorize", BindingFlags.Instance | BindingFlags.NonPublic); private void OnEntityBuilt(Planner plan, GameObject entity) { var cupboard = entity.GetComponent<BuildingPrivlidge>(); if (cupboard) AuthMethod.Invoke(cupboard, new object[]{new BaseEntity.RPCMessage {player = plan.GetOwnerPlayer()}}); } } } -
If you really wanted to you could get that users friends list and also add their ID's.
Also could do the same with Auto Turrent -
Here is a variant with Friends API support for anyone curious.
AutoCupboard.cs ยท GitHub -
Not the best implementation...and the add friends function makes the whole thing before worthless...
-
It does not pretends to be the best one, just a sample.
Yeah, probably there an some overhead on invoking UpdateAllPlayers/Update, but it works.
You may advise the better way of doing this, at your wish.
Edit:
Updated gistLast edited by a moderator: Nov 20, 2016
