Guest User

Untitled

a guest
Sep 8th, 2020
2,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.02 KB | None | 0 0
  1. -- YOU DON'T NEED TO TOUCH THIS IF YOU DON'T KNOW WHAT IT IS
  2. RARITY_COMMON = 1
  3. RARITY_UNCOMMON = 2
  4. RARITY_RARE = 3
  5. RARITY_EPIC = 4
  6. RARITY_LEGENDARY = 5
  7.  
  8. XeninInventory.Config = XeninInventory.Config or {}
  9. function XeninInventory.Config:AddRarity(entClass, rarity)
  10.   self.Rarities[entClass] = rarity
  11. end
  12. XeninInventory.Config.Items = XeninInventory.Config.Items or {}
  13. XeninInventory.Config.Rarities = {}
  14. -- TOUCH BELOW HERE
  15.  
  16. -- Should you be able to use ALT + *key* to pick up items?
  17. XeninInventory.Config.PickUpWithALT = true
  18.  
  19. -- What key should the modifier key be? (default: KEY_LALT)
  20. -- https://wiki.facepunch.com/gmod/Enums/KEY
  21. XeninInventory.Config.ModifierKey = KEY_LALT
  22. -- How should it be displayed?
  23. XeninInventory.Config.ModifierKeyStr = "ALT"
  24.  
  25. -- What key should be used in combination with alt?
  26. -- https://wiki.facepunch.com/gmod/Enums/KEY
  27. XeninInventory.Config.AltKey = KEY_E
  28. -- Type the letter that ^ actually is.
  29. XeninInventory.Config.AltKeyStr = "E"
  30.  
  31. -- When using weapons from inventory, should it spawn with no ammo?
  32. -- Inventory automatically saves ammo from weapons that are holstered.
  33. XeninInventory.Config.GiveAmmoClip = false
  34.  
  35. -- What key should you open the inventory menu with?
  36. -- https://wiki.facepunch.com/gmod/Enums/KEY
  37. -- If you want to disable this, set it to false instead of a key!
  38. XeninInventory.Config.InventoryKey = KEY_I
  39.  
  40. -- Should users spawn with an inventory weapon allowing them to pick up items with the weapon?
  41. XeninInventory.Config.SpawnWithInventorySWEP = true
  42.  
  43. -- What color should the standard chat messages prefix have?
  44. XeninInventory.Config.PrefixCol = Color(46, 204, 113)
  45. -- What should the prefix say?
  46. XeninInventory.Config.PrefixText = "[INVENTORY]"
  47.  
  48. -- What language?
  49. -- By default this only supports English, but you can add your own language
  50. XeninInventory.Config.Language = "English"
  51.  
  52. -- The NPC's model?
  53. XeninInventory.Config.NPCModel = "models/humans/group02/female_01.mdl"
  54. -- The outline color of the NPC's overhead HUD.
  55. XeninInventory.Config.NPCColor = Color(201, 176, 15)
  56. -- The text on the NPC's overhead HUD
  57. XeninInventory.Config.NPCText = "Bank"
  58. -- The icon for the NPC's overhead HUD
  59. XeninInventory.Config.NPCIcon = Material("xenin/inventory/icon.png", "smooth")
  60.  
  61. XeninInventory.Config.EasySkinsEnabled = true
  62.  
  63. -- How many items should there be in a row in the bank?
  64. XeninInventory.Config.BankItemsPerRow = 6
  65. -- Slots for the bank.
  66. -- Free is for everyone that isn't in the paid list.
  67. -- The paid list works by doing ["rank"] = amount_of_slots
  68. XeninInventory.Config.BankSlots = {
  69.   Free = 16,
  70.   Paid = {
  71.     ["admin"] = 30,
  72.     ["superadmin"] = 45
  73.   }
  74. }
  75.  
  76. -- Same as above but for the inventory itself, not the bank
  77. XeninInventory.Config.ItemsPerRow = 8
  78. -- Same as above but for the inventory itself, not the bank
  79. XeninInventory.Config.Slots = {
  80.   Free = 24,
  81.   Paid = {
  82.     ["admin"] = 30,
  83.     ["superadmin"] = 36
  84.   }
  85. }
  86.  
  87. XeninInventory.Config.Admins = {
  88.   ["superadmin"] = true
  89. }
  90.  
  91. -- The categories are defined here
  92. -- [number] is the number the category will be known as.
  93. -- name is obviously the name.
  94. -- color represents the color used to visualise the category
  95. -- maxStack is how many items can max be stacked if it's that category
  96. -- amountBackgroundColor is an optional thing! Use this for colors where seeing the default amount text background color might be hard.
  97. XeninInventory.Config.Categories = {
  98.   [1] = { name = "Common", color = Color(125, 125, 125), maxStack = 50 }, -- grey
  99.   [2] = { name = "Uncommon", color = Color(46, 204, 113), maxStack = 30 }, -- green
  100.   [3] = { name = "Rare", color = Color(41, 128, 185), maxStack = 20 }, -- blue
  101.   [4] = { name = "Epic", color = Color(142, 68, 173), maxStack = 10 }, -- purple
  102.   [5] = { name = "Legendary", color = Color(251, 197, 49), maxStack = 5, amountBackgroundColor = Color(0, 0, 0, 225) }, -- orange
  103. }
  104.  
  105. -- Should users be able to sort by rarity quality?
  106. XeninInventory.Config.EnableRaritySorting = true
  107.  
  108. -- **WARNING**
  109. -- This is a whitelist for entities that should be allowed to pick up that DOES NOT have a template in configuration/items/
  110. -- I can not be 100% certain that the entity will save and behave exactly as it should but it will try to find all the data it needs to save!
  111. -- Please use this for generic things only, such as some weed seeds or something, not DarkRP money printers!!
  112. -- If an item doesn't work you should either get your developer to make a template in configuration/items/ folder or create a support ticket!
  113. -- Also please be aware that the way it saves data is inefficient the first time it saves that kind of entity after a restart.
  114. --
  115. -- The syntax is simple, just do ["ent_class_name"] = true,
  116. -- Example:
  117. -- ["bank_npc"] = true,
  118. XeninInventory.Config.WhitelistEntities = {
  119.   --["bank_npc"] = true,
  120. }
  121.  
  122. -- BLacklist, works same as whitelist configuration wise.
  123. XeninInventory.Config.Blacklist = {
  124.   --["fas2_ak47"] = true,
  125. }
  126.  
  127. -- Should peoples inventories be cleared on leaving the server?
  128. XeninInventory.Config.WipeInventoryOnDisconnect = false
  129.  
  130. -- A few theme options
  131. -- Slot background
  132. XeninInventory.Config.SlotColor = XeninUI.Theme.Navbar
  133. -- The name bar background
  134. XeninInventory.Config.SlotNameColor = XeninUI.Theme.Primary
  135. -- The name bar's text
  136. XeninInventory.Config.SlotNameTextColor = Color(225, 225, 225)
  137.  
  138.  
  139. -- Input in pixels. They will automatically fit on any resolution, even if the resolution are lower than these numbers
  140. XeninInventory.Config.ContextMenuSize = {
  141.   Width = 1000,
  142.   Height = 534
  143. }
  144.  
  145. -- Should some weapons take longer to holster?
  146. -- In seconds. If not specified here it will take a second to holster
  147. XeninInventory.Config.HolsterTime = {
  148.   ["weapon_ak472"] = 3,
  149.   ["weapon_mp52"] = 2,
  150.   ["fas2_ak74"] = 4
  151. }
  152.  
  153. -- Should C menu be be disabled?
  154. XeninInventory.Config.ContextMenuDisabled = false
  155.  
  156. -- How many items on each row in the C menu?
  157. XeninInventory.Config.ContextMenuColumns = 6
  158.  
  159. -- If you want a specific entity class to be a rarity.
  160. -- Thanks to Rexxor for the default config
  161. XeninInventory.Config:AddRarity("weapon_ak472", RARITY_LEGENDARY)
  162. XeninInventory.Config:AddRarity("weapon_m42", RARITY_UNCOMMON)
  163. XeninInventory.Config:AddRarity("weapon_mp52", RARITY_EPIC)
  164. XeninInventory.Config:AddRarity("m9k_spas12", RARITY_LEGENDARY)
  165. XeninInventory.Config:AddRarity("m9k_dbarrel", RARITY_LEGENDARY)
  166. XeninInventory.Config:AddRarity("m9k_usas", RARITY_EPIC)
  167. XeninInventory.Config:AddRarity("m9k_mossberg590", RARITY_UNCOMMON)
  168. XeninInventory.Config:AddRarity("m9k_jackhammer", RARITY_RARE)
  169. XeninInventory.Config:AddRarity("m9k_barret_m82", RARITY_LEGENDARY)
  170. XeninInventory.Config:AddRarity("m9k_m24", RARITY_EPIC)
  171. XeninInventory.Config:AddRarity("m9k_svu", RARITY_EPIC)
  172. XeninInventory.Config:AddRarity("m9k_dragunov", RARITY_LEGENDARY)
  173. XeninInventory.Config:AddRarity("m9k_remington7615p", RARITY_RARE)
  174. XeninInventory.Config:AddRarity("m9k_aw50", RARITY_LEGENDARY)
  175. XeninInventory.Config:AddRarity("m9k_sl8", RARITY_RARE)
  176. XeninInventory.Config:AddRarity("m9k_intervention", RARITY_EPIC)
  177. XeninInventory.Config:AddRarity("m9k_contender", RARITY_RARE)
  178. XeninInventory.Config:AddRarity("m9k_psg1", RARITY_RARE)
  179. XeninInventory.Config:AddRarity("m9k_ragingbull", RARITY_RARE)
  180. XeninInventory.Config:AddRarity("m9k_deagle", RARITY_RARE)
  181. XeninInventory.Config:AddRarity("m9k_ragingbull", RARITY_RARE)
  182. XeninInventory.Config:AddRarity("m9k_usp", RARITY_RARE)
  183. XeninInventory.Config:AddRarity("m9k_ares_shrike", RARITY_LEGENDARY)
  184. XeninInventory.Config:AddRarity("m9k_fg42", RARITY_LEGENDARY)
  185. XeninInventory.Config:AddRarity("m9k_m1918bar", RARITY_LEGENDARY)
  186. XeninInventory.Config:AddRarity("m9k_m249lmg", RARITY_LEGENDARY)
  187. XeninInventory.Config:AddRarity("m9k_m60", RARITY_LEGENDARY)
  188. XeninInventory.Config:AddRarity("m9k_winchester73", RARITY_UNCOMMON)
  189. XeninInventory.Config:AddRarity("m9k_amd65", RARITY_RARE)
  190. XeninInventory.Config:AddRarity("m9k_m416", RARITY_EPIC)
  191. XeninInventory.Config:AddRarity("m9k_m14sp", RARITY_UNCOMMON)
  192. XeninInventory.Config:AddRarity("m9k_vikhr", RARITY_UNCOMMON)
  193. XeninInventory.Config:AddRarity("m9k_g36", RARITY_UNCOMMON)
  194. XeninInventory.Config:AddRarity("m9k_l85", RARITY_EPIC)
  195. XeninInventory.Config:AddRarity("m9k_val", RARITY_LEGENDARY)
  196. XeninInventory.Config:AddRarity("m9k_m60", RARITY_RARE)
  197. XeninInventory.Config:AddRarity("m9k_tar21", RARITY_UNCOMMON)
  198. XeninInventory.Config:AddRarity("m9k_f2000", RARITY_UNCOMMON)
  199. XeninInventory.Config:AddRarity("m9k_m4a1", RARITY_UNCOMMON)
  200. XeninInventory.Config:AddRarity("m9k_machete", RARITY_EPIC)
  201. XeninInventory.Config:AddRarity("m9k_harpoon", RARITY_RARE)
  202. XeninInventory.Config:AddRarity("m9k_damascus", RARITY_LEGENDARY)
  203. XeninInventory.Config:AddRarity("m9k_m61_frag", RARITY_LEGENDARY)
  204. XeninInventory.Config:AddRarity("m9k_honeybadger", RARITY_UNCOMMON)
  205. XeninInventory.Config:AddRarity("m9k_mp7", RARITY_UNCOMMON)
  206. XeninInventory.Config:AddRarity("m9k_bizonp19", RARITY_UNCOMMON)
  207. XeninInventory.Config:AddRarity("m9k_mp5sd", RARITY_RARE)
  208. XeninInventory.Config:AddRarity("m9k_mp40", RARITY_EPIC)
  209. XeninInventory.Config:AddRarity("m9k_thompson", RARITY_LEGENDARY)
  210. XeninInventory.Config:AddRarity("m9k_kac_pdw", RARITY_RARE)
  211. XeninInventory.Config:AddRarity("m9k_tec9", RARITY_RARE)
  212. XeninInventory.Config:AddRarity("m9k_usc", RARITY_UNCOMMON)
  213.  
  214. -- Chat commands
  215. -- Code to holster weapons
  216. local funcHolster = function(ply)
  217.   if (!IsValid(ply)) then return end
  218.   if (!ply:IsPlayer()) then return end
  219.   if (!ply:Alive()) then return end
  220.   if (!XeninInventory:CanUseInventory(ply)) then
  221.     return ply:XeninInventory():Message(XeninInventory:GetPhrase("ChatCommand.AccessRestricted"))
  222.   end
  223.   local activeWep = ply:GetActiveWeapon()
  224.   if (!IsValid(activeWep)) then return end
  225.   local inv = ply:XeninInventory()
  226.   local amt = table.Count(inv:GetInventory())
  227.   local slots = inv:GetSlots()
  228.   if (amt >= slots) then
  229.     return XeninUI:Notify(ply, XeninInventory:GetPhrase("ChatCommand.Holster.Unable"), 1, 4, XeninUI.Theme.Red)
  230.   end
  231.   if (activeWep.ignoreInv) then return end
  232.   if (XeninInventory.Config.Blacklist[activeWep:GetClass()]) then
  233.     return XeninUI:Notify(ply, XeninInventory:GetPhrase("ChatCommand.Blacklisted"), 1, 4, XeninUI.Theme.Red)
  234.   end
  235.  
  236.   ply:dropDRPWeapon(activeWep, function(wep)
  237.     ply:XeninInventory():Pickup(wep)
  238.   end, true)
  239. end
  240.  
  241. local openMenu = function(ply)
  242.   ply:ConCommand("inventory")
  243. end
  244. local openAdmin = function(ply)
  245.   ply:ConCommand("inventory_admin")
  246. end
  247.  
  248. XeninInventory.Config.ChatCommands = {
  249.   ["/holster"] = funcHolster,
  250.   ["/holsterwep"] = funcHolster,
  251.   ["/gunholster"] = funcHolster,
  252.   ["/invholster"] = funcHolster,
  253.   ["/drop"] = function(ply)
  254.     if (!IsValid(ply)) then return end
  255.     if (!ply:IsPlayer()) then return end
  256.     if (!ply:Alive()) then return end
  257.     local activeWep = ply:GetActiveWeapon()
  258.     if (!IsValid(activeWep)) then return end
  259.    
  260.     ply:dropDRPWeapon(activeWep)
  261.   end,
  262.   ["/inventory"] = openMenu,
  263.   ["!inventory"] = openMenu,
  264.   ["/inv"] = openMenu,
  265.   ["!inv"] = openMenu,
  266.   ["/invadmin"] = openAdmin,
  267.   ["!invadmin"] = openAdmin,
  268.   ["/inventoryadmin"] = openAdmin,
  269.   ["!inventoryadmin"] = openAdmin
  270. }
Add Comment
Please, Sign In to add comment