Drop backpack only on predefined types of deathSolved

I would like to ask you, if you can find a way, how to prevent players to use backpack as a teleport with loot. On server we have enabled backpacks.keepondeath, but if player commit suicide, they will by teleported home, with loot. I imagine it that way: make it configurable, if keep on death  enabled, be able to set dropOnSuicide. 

And define type of suicide, for example klilled by own c4, grenade and so on..

Thank you very much for your consideration 😃 W

 

The way you can get maximum flexibility would be to disable backpacks dropping on death (config option "Drop on Death (true/false)": false) and write a simple add-on plugin that hooks player death and tells the Backpacks plugin when to drop a player's backpack. Here is a simple example (save as DropBackpacksOnSuicide.cs).

using Oxide.Core.Plugins;
using Rust;

namespace Oxide.Plugins
{
    [Info("Drop Backpacks On Suicide", "Nobody", "1.0.0")]
    [Description("Drops Backpacks when players commit suicide.")]
    internal class DropBackpacksOnSuicide : CovalencePlugin
    {
        [PluginReference]
        private Plugin Backpacks;

        private void OnEntityDeath(BasePlayer player, HitInfo info)
        {
            if (info.damageTypes.Has(DamageType.Suicide))
                Backpacks.Call("API_DropBackpack", player);
        }
    }
}

 

Wau! That was quick, and it works! Thank you very much 😃 

Locked automatically