C#:
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("FAutoKit", "fufeldev", "1.0.0")]
public class FAutoKit : RustPlugin
{
private readonly HashSet<string> _wear = new HashSet<string> { "hoodie", "pants" };
private readonly HashSet<string> _remove = new HashSet<string> { "hoodie", "pants", "rock", "torch" };
private void OnPlayerRespawned(BasePlayer player)
{
if (player == null || !player.userID.IsSteamId() || player.IsNpc) return;
timer.Once(0.2f, () =>
{
if (player == null || !player.IsConnected || player.IsDead()) return;
var wear = player.inventory.containerWear;
foreach (var name in _wear)
{
if (Has(wear, name)) continue;
var item = ItemManager.CreateByName(name, 1);
if (item != null && !item.MoveToContainer(wear)) item.Remove();
}
});
}
private void OnPlayerCorpseSpawned(BasePlayer player, PlayerCorpse corpse)
{
if (corpse?.containers == null) return;
var removed = false;
foreach (var container in corpse.containers)
{
var list = container?.itemList;
if (list == null) continue;
for (var i = list.Count - 1; i >= 0; i--)
{
var item = list[i];
if (item?.info == null || !_remove.Contains(item.info.shortname)) continue;
item.Remove();
removed = true;
}
}
if (removed) ItemManager.DoRemoves();
}
private static bool Has(ItemContainer container, string shortName)
{
var list = container.itemList;
for (var i = 0; i < list.Count; i++)
{
var item = list[i];
if (item?.info != null && item.info.shortname == shortName) return true;
}
return false;
}
}
}