Hi Guys,
I'm trying to make my own small plugin for Rust which will add the stash box to MiniCopter allowing to transport some stuff. I was able to create the box and attach it to the copter but after opening it, the stash object vanishes and is no more accesible. What is that I'm missing here?
Here is some code I came up with:
private void AddBox(BasePlayer player, Vector3 location, Quaternion rotation)
{
var pos = new Vector3(location.x, location.y + 1f, location.z -1f);
var rot = new Quaternion(rotation.x, rotation.y, rotation.z, rotation.w);
string weaponToolboxPerf = "assets/prefabs/deployable/small stash/small_stash_deployed.prefab";
weaponToolbox = GameManager.server.CreateEntity(weaponToolboxPerf, pos, rot, true);
weaponToolbox.enableSaving = true;
weaponToolbox.OwnerID = player.OwnerID;
weaponToolbox.Spawn();
weaponToolbox.transform.SetParent(activeCopter.transform, true);
var weaponToolboxContainer = weaponToolbox.GetComponent<StorageContainer>();
weaponToolboxContainer.transform.SetParent(activeCopter.transform, true);
weaponToolboxContainer.inventory.capacity = 2;
weaponToolboxContainer.isLootable = true;
}