I am trying to do something like that. Is that possible?Code:void OnEntityBuilt(Planner plan, GameObject go) { if (go.name.Contains("something")) { go.Destroy(); } }
Solved Destroying entity on OnEntityBuilt
Discussion in 'Rust Development' started by Reynostrum, Jul 9, 2016.
-
This should work.Code:
private void OnEntityBuilt(Planner plan, GameObject objectBlock) { var block = objectBlock?.ToBaseEntity()?.GetComponent<BuildingBlock>() ?? null; if (block == null) return; block.Kill(BaseNetworkable.DestroyMode.None); } -
Thank you. It works.
But if I want to destroy a stash, for example? -
I don't think deployables, or items like stashes/furnaces are called through OnEntityBuilt, since OnEntityBuilt specifies a building plan. (Planner)
You could use on OnEntitySpawned, but if you don't want to destroy entities that are be loaded from the save in server startup, you'd do something like this:
So it will only get called after the server is fully started.Code:bool init = false; void OnServerInitialized() => init = true; void OnEntitySpawned(BaseNetworkable entity) { if (!init) return; } -
Thank you!
