Finding out who consume item
Discussion in 'Rust Development' started by w4ssup, Feb 21, 2016.
-
Hi
I haven't tested this but it should point you in the right direction:
You can retrieve the owner of the consumable via item.GetOwnerPlayer. After that you should be able to change things like health. I suppose you could even add conditions for the type of consumable allowing you to override the effects of various consumed items.Code:void OnConsumableUse(Item item) { BasePlayer ownerPlayer = item.GetOwnerPlayer(); float newHealth = 100f; ownerPlayer.ChangeHealth(newHealth); } -
it works like a charm! How did you you find out about GetOwnerPlayer()?
-
Glad it works
I looked at the disassembled method list for the BasePlayer class -
I attach the it as reference, but I don't know how to read it, but Idk what yo search up for tutorials on
