So right. I have the code below and preferably I need to refund it. So say he places a furnace down(now I wont know for a fact he will place a furnace, might even be a lantern). But, how would I get the item id/name to refund the object at hand. Thanks
Code:List<string> Placeables = new List<string>(){ "furnace", "box", "sleeping", "camp", "light", "lantern", "repair", "cupboard", "bed", "research", }; void OnEntitySpawned(BaseNetworkable entity){ var ent = entity as BaseEntity; var player = BasePlayer.FindByID(ent.OwnerID); List<BaseEntity> blocks = new List<BaseEntity>(); Vis.Entities(ent.transform.position, 3f, blocks); foreach(var entry in blocks){ if(entry.ToString().Contains("foundation")){ if(entry.transform.position.y > ent.transform.position.y){ if(ent is BuildingBlock){ break; } foreach(var basic in Placeables){ if(ent.ToString().Contains(basic)){ SendReply(player, lang.GetMessage("Bad Boy", this, player.UserIDString)); if(ent != null) ent.Kill(); break; } } } } }
Getting itemname from entity?
Discussion in 'Rust Development' started by DylanSMR, Jan 16, 2017.