I'm trying to spawn some wood (into a players invetory, or just around him so he can pick it up) but the problem is the prefab for resource/wood/wood.item doesnt work...
Couldn't find prefab [path]Code:string name = "assets/prefabs/resource/wood/wood.prefab"; BaseEntity entity = GameManager.server.CreateEntity(name, pos); entity.Spawn(true);
[DOUBLEPOST=1457831309][/DOUBLEPOST]Ok, just another issue of mine: How do i remove an entity ? like a tree or an item on the ground.. ?
[DOUBLEPOST=1457833250][/DOUBLEPOST]Figured out how to remove an entity: BaseEntity.Kill(); heh, quite simple
But still need the first question solved![]()
Spawning wood for a player?
Discussion in 'Rust Development' started by Asbest, Mar 13, 2016.
-
To put items in a players inventory you must first create the item
To spawn piles of wood on the floor you must specify the correct prefab name, I am pretty sure the one you have listed is the item, not the entity itself? For this example I will just spawn it on the player positionCode:void GiveItem(BasePlayer player, string shortname, int amount) { var definition = ItemManager.FindItemDefinition(shortname); //Find the item using its shortname if (definition != null) { Item item = ItemManager.CreateByItemID(definition.itemid, amount); // Create the item if (item != null) player.inventory.GiveItem(item); // Place it in the players inventory } }
Code:void SpawnWood(BasePlayer player) { string name = "assets/bundled/prefabs/autospawn/collectable/stone/wood.prefab"; BaseEntity entity = GameManager.server.CreateEntity(name, player.transform.position); entity.Spawn(true); } -
I will look into it later today, thank you very much k1lly0u
-
Use rustadmin it lets you give any item to the player right into their inventory
