I setup a way to get random coordinates around the map and even in test situations where I have a fixed vector position whenever i try to spawn a radtown loot prefab it is invisible or just instant kills itself i think..
BaseEntity entity = SpawnBoxEntity("assets/bundled/prefabs/radtown/dmloot/dm tier3 lootbox.prefab", (Vector3)lootSpawnPoints[string.Format("{0}", i)], 0.0f);
If i spawn a storage container such as a wood box or a large wood box it works fine.
[DOUBLEPOST=1487643598][/DOUBLEPOST]for example
this code wont work nothing appears.Code:[ChatCommand("boxhere")] private void cmdBoxHere(BasePlayer player, string command, string[] args) { var box = GameManager.server.CreateEntity("assets/bundled/prefabs/radtown/crate_normal.prefab", player.transform.position, new Quaternion(), true); box.Spawn(); }
Spawning radtown loot boxes in random areas?
Discussion in 'Rust Development' started by ThunderZ, Feb 21, 2017.
-
Seems to work fine for me. Copied that exact code and ran it on my local server.
Screenshot - What was your exact problem? Just that the entity did not spawn?
[DOUBLEPOST=1487648103][/DOUBLEPOST]Also, if you want to get the inventory to add items or clear it:
Code:[ChatCommand("boxhere")] private void cmdBoxHere(BasePlayer player, string command, string[] args) { var box = GameManager.server.CreateEntity("assets/bundled/prefabs/radtown/crate_normal.prefab", player.transform.position, new Quaternion(), true); //Create box box.Spawn(); //Spawn box StorageContainer container = box.GetComponent<StorageContainer>(); //Get container of inventory ItemContainer inven = container.inventory; //Get inventory of container if(container == null) return; //Check if container is null if(inven == null) return; //Check if inventory is null inven.itemList.Clear(); //Clear inventory //Cont //Inven //List //Clear }
-