using System; using System.Collections.Generic; using Oxide.Core; using Oxide.Core.Plugins; using UnityEngine; namespace Oxide.Plugins { [Info("SupplyLock", "Ghosty", "1.0.4")] [Description("Locks Supplydrops to a player or team.")] public class SupplyLock : RustPlugin { Queue> supplySignals = new Queue>(); Dictionary supplyOwners = new Dictionary(); private void Init() { Puts("SupplyLock has been loaded!"); } void OnExplosiveThrown(BasePlayer player, BaseEntity entity, ThrownWeapon item) { if (entity is SupplySignal) { if (entity.net == null || entity.net.ID == null || player == null) { return; } supplySignals.Enqueue(Tuple.Create(player.userID.Get(), entity.transform.position, DateTime.Now)); } } void OnEntitySpawned(BaseNetworkable entity) { if (entity is SupplyDrop drop) { drop.MakeLootable(); //Im doing this as a fix for cargo, Yes i know its bad but i ran out of ideas.. string dropIdStr = drop.net.ID.ToString(); if (supplySignals.Count > 0) { var signal = supplySignals.Dequeue(); supplyOwners[dropIdStr] = signal.Item1; } } } object CanLootEntity(BasePlayer player, StorageContainer container) { if (container is SupplyDrop drop) { string dropID = drop.net.ID.ToString(); if (supplyOwners.TryGetValue(dropID, out ulong ownerID)) { if (ownerID == player.userID) { return null; } RelationshipManager.PlayerTeam team = RelationshipManager.ServerInstance.FindPlayersTeam(ownerID); if (team != null && team.members.Contains(player.userID)) { return null; } player.ChatMessage("SupplyLock\nThis supply drop is locked!\nYou must be in a team with this player to loot the drop."); return false; // forgot to add a return here, whoops. } } return null; } } }