I'm trying to get either the player or location details when someone loots a pumpjack or quarry. Is this possible, I'd have thought it'd be pretty easy. But so far I've drawn a blank.
Thanks in advance,
T.
Getting player from OnItemAddedToContainer?
Discussion in 'Rust Development' started by Rebajas, May 3, 2017.
-
Code:
void OnLootEntity(BasePlayer player, BaseEntity entity) { if (entity.parentEntity.Get(true)?.GetComponent<MiningQuarry>() != null) Puts($"{player.displayName} looting {entity.parentEntity.Get(true).ShortPrefabName}"); }
upd: Bad idea. Wait, I'll try something better
upd: Never mind, use this
upd: Okay, next example will be faster, but requied some list of shortNames from needed entities
Code:List<string> neededShortNames = new List<string> { "fuelstorage", "hopperoutput" }; void OnLootEntity(BasePlayer player, BaseEntity entity) { var st = entity.GetComponent<StorageContainer>(); if (neededShortNames.Contains(st?.inventory.entityOwner.ShortPrefabName)) { Puts($"{player.displayName} looting {st.inventory.entityOwner.ShortPrefabName} at {entity.transform.position}"); } }
Last edited by a moderator: May 3, 2017 -
Thanks, will this only trigger when an item is actually removed/added - or is this triggered upon viewing the LootContainer?
T. -