With the changes made to the OnPlayerLoot(...) hooks it doesn't seem possible to get the looting player anymore. Might I be missing something?
Solved Get looting BasePlayer with OnLoot hooks?
Discussion in 'Rust Development' started by Tuntenfisch, Jan 7, 2016.
-
Wulf Community Admin
OnLootPlayer(BaseEntity source, BasePlayer target)
You'd need to cast target as BasePlayer for that hook, but you could try with BasePlayer for the target/victim as that may work directly. We may handle this in a future update automatically. For the others, you wouldn't need the cast. -
Code:public void StartLootingEntity(BaseEntity targetEntity, bool doPositionChecks = true) { this.Clear(); if (!targetEntity) { return; } if (!targetEntity.OnStartBeingLooted(base.baseEntity)) { return; } Assert.Test(targetEntity.isServer, "Assure is server", null); this.PositionChecks = doPositionChecks; this.entitySource = targetEntity; this.itemSource = null; this.MarkDirty(); object[] objArray = new object[] { this.entitySource, targetEntity }; Interface.CallHook("OnLootEntity", objArray); }
Besides that, isn't the target you are referencing and the targetEntity in the object array the entity that is being looted, not the entity (player) that is looting?
I had no luck casting the entitySource provided by the OnLootEntity hook, either. -
Wulf Community Admin
OnLootEntity(BaseEntity source, BaseEntity target) is what you'd want I believe, those are the correct arguments.
-
-
Wulf Community Admin