Barrel Points Not Working With Auto Pickup Barrel

Whenever I am in the auto-pickup range barrel points do not give points for destroying the barrel when I am outside the range of auto pickup it works.

autopickup kills the barrel not the player so nothing triggers i reported it to dev of  one of the plugins doing this method

I got it to work with Auto Pick up Barrel. Open the Auto Pickup Barrel plugin in the plugins folder and replace the code with

using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Rust;
using UnityEngine;
using Oxide.Core;

namespace Oxide.Plugins
{
    [Info("Auto Pickup Barrel", "l3rady", "1.3")]
    [Description("Allows players to pick up dropped loot from barrels and road signs on destroy automatically.")]
    public class AutoPickupBarrel : RustPlugin
    {
        private readonly string[] BarrelContainerShortPrefabNames = { "loot_barrel_1", "loot_barrel_2", "loot-barrel-1", "loot-barrel-2", "oil_barrel" };
        private readonly string[] RoadSignContainerShortPrefabNames = { "roadsign1", "roadsign2", "roadsign3", "roadsign4", "roadsign5", "roadsign6", "roadsign7", "roadsign8", "roadsign9" };

        #region Configuration

        private Configuration Settings;

        public class Configuration
        {
            [JsonProperty("Auto pickup distance")]
            public float AutoPickupDistance = 3f;

            public string ToJson() => JsonConvert.SerializeObject(this);

            public Dictionary<string, object> ToDictionary() => JsonConvert.DeserializeObject<Dictionary<string, object>>(ToJson());
        }

        protected override void LoadDefaultConfig() => Settings = new Configuration();

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                Settings = Config.ReadObject<Configuration>();
                if (Settings == null)
                {
                    throw new JsonException();
                }

                if (!Settings.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys))
                {
                    PrintWarning("Configuration appears to be outdated; updating and saving");
                    SaveConfig();
                }
            }
            catch
            {
                PrintWarning($"Configuration file {Name}.json is invalid; using defaults");
                LoadDefaultConfig();
            }
        }

        protected override void SaveConfig()
        {
            PrintWarning($"Configuration changes saved to {Name}.json");
            Config.WriteObject(Settings, true);
        }

        #endregion Configuration

        private void Init()
        {
            permission.RegisterPermission("AutoPickupBarrel.Barrel.On", this);
            permission.RegisterPermission("AutoPickupBarrel.Barrel.NoGibs", this);
            permission.RegisterPermission("AutoPickupBarrel.Barrel.InstaKill", this);
            permission.RegisterPermission("AutoPickupBarrel.RoadSign.On", this);
            permission.RegisterPermission("AutoPickupBarrel.RoadSign.NoGibs", this);
            permission.RegisterPermission("AutoPickupBarrel.RoadSign.InstaKill", this);
        }

        // Hook to OnEntityDeath to handle loot pickup after death
        private void OnEntityDeath(BaseEntity entity, HitInfo hitInfo)
        {
            if (entity is LootContainer lootContainer)
            {
                var lootContainerName = lootContainer.ShortPrefabName;
                Puts($"OnEntityDeath triggered for {lootContainerName}");

                // Check if the entity is a barrel or a road sign
                if (IsBarrel(lootContainerName) || IsRoadSign(lootContainerName))
                {
                    AutoPickup(lootContainer, hitInfo);
                }
            }
        }

        private bool IsBarrel(string lootContainerName)
        {
            return BarrelContainerShortPrefabNames.Contains(lootContainerName);
        }

        private bool IsRoadSign(string lootContainerName)
        {
            return RoadSignContainerShortPrefabNames.Contains(lootContainerName);
        }

        private void AutoPickup(LootContainer lootContainer, HitInfo hitInfo)
        {
            var player = lootContainer.lastAttacker as BasePlayer ?? hitInfo.InitiatorPlayer;
            if (player == null)
            {
                Puts("No player found. Skipping loot pickup.");
                return;
            }

            // Debugging: Log player information
            Puts($"Player {player.displayName} is attempting to pick up loot from {lootContainer.ShortPrefabName}");

            // Temporarily bypass permissions and distance checks for debugging
            // Check if loot container has inventory
            var lootContainerInventory = lootContainer?.inventory;
            if (lootContainerInventory == null || lootContainerInventory.itemList.Count == 0)
            {
                Puts("Loot container is empty. No items to pick up.");
                return;
            }

            // Debugging: Log distance between player and loot container
            var lootContainerDistance = Vector2.Distance(player.transform.position, lootContainer.transform.position);
            Puts($"Distance to loot container: {lootContainerDistance}");

            // Bypass distance check for debugging
            if (lootContainerDistance > Settings.AutoPickupDistance)
            {
                Puts("Player is out of range, skipping loot pickup.");
                return;
            }

            // Give loot to player
            foreach (var item in lootContainerInventory.itemList.ToArray())
            {
                if (item != null)
                {
                    Puts($"Giving item {item.info.displayName.english} to player.");
                    player.GiveItem(item, BaseEntity.GiveItemReason.PickedUp);
                }
            }

            // After loot is given, destroy the container (with or without gibs)
            if (lootContainerInventory.itemList.Count == 0)
            {
                Puts("Loot container is now empty, destroying.");
                NextTick(() =>
                {
                    Interface.CallHook("OnEntityDeath", lootContainer, hitInfo);

                    if (permission.UserHasPermission(player.UserIDString, $"AutoPickupBarrel.{lootContainer.ShortPrefabName}.NoGibs"))
                    {
                        lootContainer.Kill();
                    }
                    else
                    {
                        lootContainer.Kill(BaseNetworkable.DestroyMode.Gib);
                    }
                });
            }
        }
    }
}