Is there any way from blocking item drop on death? I'd like to avoid using ZoneManager for my Gun Game plugin. We already have corpses.
Blocking dropped items?
Discussion in 'Rust Development' started by Kappasaurus, Dec 25, 2016.
-
By using GetHeldEntity()
-
Oxide has a hook for OnPlayerDie so you can manually handle the death. Here is an example of how I do it.
Code:private object OnPlayerDie(BasePlayer player, HitInfo info) { if ((bool)player.GetType().GetMethod("WoundInsteadOfDying", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(player, new object[] { info }) || player.IsDead()) return true; Interface.CallHook("OnEntityDeath", player, info); if (ConVar.Global.developer > 1) Debug.Log("[Combat]".PadRight(10) + player.gameObject.name + " died"); player.health = 0.0f; player.lifestate = BaseCombatEntity.LifeState.Dead; using (TimeWarning.New("OnKilled", 0.1f)) player.OnKilled(info); return true; }
In BasePlayer.cs
Code:public override void Die(HitInfo info = null) { using (TimeWarning.New("Player.Die", 0.1f)) { if (this.IsDead()) return; if (Interface.CallHook("OnPlayerDie", (object) this, (object) info) != null) return; if ((UnityEngine.Object) this.belt != (UnityEngine.Object) null) this.belt.DropActive(new UnityEngine.Vector3(UnityEngine.Random.Range(-2f, 2f), 0.2f, UnityEngine.Random.Range(-2f, 2f)).normalized * 3f); if (this.WoundInsteadOfDying(info)) return; base.Die(info); } }
Code:private bool WoundInsteadOfDying(HitInfo info) { if (this.IsWounded() || !this.EligibleForWounding(info)) return false; this.lastWoundedTime = UnityEngine.Time.realtimeSinceStartup; this.health = (float) UnityEngine.Random.Range(2, 6); this.metabolism.bleeding.value = 0.0f; this.StartWounded(); return true; }
Code:public virtual void Die(HitInfo info = null) { if (this.IsDead()) return; Interface.CallHook("OnEntityDeath", (object) this, (object) info); if (ConVar.Global.developer > 1) Debug.Log((object) ("[Combat]".PadRight(10) + this.gameObject.name + " died")); this.health = 0.0f; this.lifestate = BaseCombatEntity.LifeState.Dead; using (TimeWarning.New("OnKilled", 0.1f)) this.OnKilled(info); }