Guest User

Untitled

a guest
Sep 5th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. using Facepunch;
  2. using Rust;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. namespace Oxide.Plugins
  7. {
  8.     [Info("CombatLog Bug", "miRror", "1.0.0")]
  9.    
  10.     public class CombatLogBug : RustPlugin
  11.     {
  12.         Dictionary<int, int> kit = new Dictionary<int, int>()
  13.         {
  14.             { 1545779598, 1 }, // AK-47
  15.             { -1211166256, 500 }, // 556 ammo
  16.         };
  17.  
  18.         object CanBeWounded(BasePlayer victim, HitInfo info)
  19.         {
  20.             return false;
  21.         }
  22.  
  23.         object OnPlayerDeath(BasePlayer victim, HitInfo info)
  24.         {
  25.             victim.Teleport(victim.transform.position);
  26.             StripInventory(victim);
  27.  
  28.             victim.StopWounded();
  29.             victim.health = 100f;
  30.  
  31.             foreach(var kv in kit)
  32.             {
  33.                 GiveItem(victim, kv.Key, kv.Value);
  34.             }
  35.  
  36.             return false;
  37.         }
  38.  
  39.         [ChatCommand("tp")]
  40.         void cmdChatTP(BasePlayer player, string command, string[] args)
  41.         {
  42.             player.Teleport(new Vector3(-1030f, 10f, -1548f));
  43.         }
  44.  
  45.         void GiveItem(BasePlayer player, int itemid, int amount)
  46.         {
  47.             Item item = ItemManager.CreateByItemID(itemid, amount);
  48.            
  49.             if(item == null)           
  50.                 return;
  51.    
  52.             BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile;
  53.            
  54.             if(weapon != null)
  55.             {
  56.                 weapon.primaryMagazine.contents = weapon.primaryMagazine.capacity;
  57.                 weapon.SendNetworkUpdateImmediate();
  58.             }
  59.            
  60.             if(!item.MoveToContainer(player.inventory.containerBelt, -1, false))
  61.                 item.Remove(0f);   
  62.         }
  63.  
  64.         void StripInventory(BasePlayer player)
  65.         {          
  66.             List<Item> itemList = Pool.GetList<Item>();
  67.  
  68.             itemList.AddRange(player.inventory.containerMain.itemList);
  69.             itemList.AddRange(player.inventory.containerBelt.itemList);
  70.             itemList.AddRange(player.inventory.containerWear.itemList);
  71.            
  72.             for(int i = 0; i < itemList.Count; i++)
  73.             {
  74.                 itemList[i].RemoveFromContainer();
  75.                 itemList[i].Remove();
  76.             }
  77.  
  78.             Pool.FreeList(ref itemList);
  79.         }
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment