Advertisement
Guest User

Nutscript

a guest
Feb 28th, 2017
450
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.50 KB | None | 0 0
  1. ITEM.name = "PAC Outfit"
  2. ITEM.desc = "A PAC Outfit Base."
  3. ITEM.category = "Outfit"
  4. ITEM.model = "models/Gibs/HGIBS.mdl"
  5. ITEM.width = 1
  6. ITEM.height = 1
  7. ITEM.outfitCategory = "hat"
  8. ITEM.pacData = {}
  9.  
  10. --[[
  11. ITEM.pacData = {
  12. [1] = {
  13. ["children"] = {
  14. [1] = {
  15. ["children"] = {
  16. },
  17. ["self"] = {
  18. ["Angles"] = Angle(12.919322967529, 6.5696062847564e-006, -1.0949343050015e-005),
  19. ["Position"] = Vector(-2.099609375, 0.019973754882813, 1.0180969238281),
  20. ["UniqueID"] = "4249811628",
  21. ["Size"] = 1.25,
  22. ["Bone"] = "eyes",
  23. ["Model"] = "models/Gibs/HGIBS.mdl",
  24. ["ClassName"] = "model",
  25. },
  26. },
  27. },
  28. ["self"] = {
  29. ["ClassName"] = "group",
  30. ["UniqueID"] = "907159817",
  31. ["EditorExpand"] = true,
  32. },
  33. },
  34. }
  35. -- This will change a player's skin after changing the model. Keep in mind it starts at 0.
  36. ITEM.newSkin = 1
  37. -- This will change a certain part of the model.
  38. ITEM.replacements = {"group01", "group02"}
  39. -- This will change the player's model completely.
  40. ITEM.replacements = "models/manhack.mdl"
  41. -- This will have multiple replacements.
  42. ITEM.replacements = {
  43. {"male", "female"},
  44. {"group01", "group02"}
  45. }
  46. -- This will apply body groups.
  47. ITEM.bodyGroups = {
  48. ["blade"] = 1,
  49. ["bladeblur"] = 1
  50. }
  51. --]]
  52.  
  53. -- Inventory drawing
  54. if (CLIENT) then
  55. -- Draw camo if it is available.
  56. function ITEM:paintOver(item, w, h)
  57. if (item:getData("equip")) then
  58. surface.SetDrawColor(110, 255, 110, 100)
  59. surface.DrawRect(w - 14, h - 14, 8, 8)
  60. end
  61. end
  62. end
  63.  
  64. function ITEM:removeParts(client)
  65. local character = client:getChar()
  66.  
  67. self:setData("equip", false)
  68. character:removePart(self.uniqueID)
  69.  
  70. if (character:getData("oldMdl")) then
  71. character:setModel(character:getData("oldMdl"))
  72. character:setData("oldMdl", nil)
  73. end
  74.  
  75. if (self.newSkin) then
  76. if (character:getData("oldSkin")) then
  77. client:SetSkin(character:getData("oldSkin"))
  78. character:setData("oldSkin", nil)
  79. else
  80. client:SetSkin(0)
  81. end
  82. end
  83.  
  84. for k, v in pairs(self.bodyGroups or {}) do
  85. local index = client:FindBodygroupByName(k)
  86.  
  87. if (index > -1) then
  88. client:SetBodygroup(index, 0)
  89.  
  90. local groups = character:getData("groups", {})
  91.  
  92. if (groups[index]) then
  93. groups[index] = nil
  94. character:setData("groups", groups)
  95. end
  96. end
  97. end
  98.  
  99. if (self.attribBoosts) then
  100. for k, _ in pairs(self.attribBoosts) do
  101. character:removeBoost(self.uniqueID, k)
  102. end
  103. end
  104. end
  105.  
  106. -- On item is dropped, Remove a weapon from the player and keep the ammo in the item.
  107. ITEM:hook("drop", function(item)
  108. if (item:getData("equip")) then
  109. item:removeParts(item.player)
  110. end
  111. end)
  112.  
  113. -- On player uneqipped the item, Removes a weapon from the player and keep the ammo in the item.
  114. ITEM.functions.EquipUn = { -- sorry, for name order.
  115. name = "Unequip",
  116. tip = "equipTip",
  117. icon = "icon16/cross.png",
  118. onRun = function(item)
  119. item:removeParts(item.player)
  120.  
  121. return false
  122. end,
  123. onCanRun = function(item)
  124. return (!IsValid(item.entity) and item:getData("equip") == true)
  125. end
  126. }
  127.  
  128. -- On player eqipped the item, Gives a weapon to player and load the ammo data from the item.
  129. ITEM.functions.Equip = {
  130. name = "Equip",
  131. tip = "equipTip",
  132. icon = "icon16/tick.png",
  133. onRun = function(item)
  134. local char = item.player:getChar()
  135. local items = char:getInv():getItems()
  136.  
  137. for k, v in pairs(items) do
  138. if (v.id != item.id) then
  139. local itemTable = nut.item.instances[v.id]
  140.  
  141. if (itemTable.pacData and v.outfitCategory == item.outfitCategory and itemTable:getData("equip")) then
  142. item.player:notify("You're already equipping this kind of outfit")
  143.  
  144. return false
  145. end
  146. end
  147. end
  148.  
  149. item:setData("equip", true)
  150. char:addPart(item.uniqueID)
  151.  
  152. if (type(item.onGetReplacement) == "function") then
  153. char:setData("oldMdl", char:getData("oldMdl", item.player:GetModel()))
  154. char:setModel(item:onGetReplacement())
  155. elseif (item.replacement or item.replacements) then
  156. char:setData("oldMdl", char:getData("oldMdl", item.player:GetModel()))
  157.  
  158. if (type(item.replacements) == "table") then
  159. if (#item.replacements == 2 and type(item.replacements[1]) == "string") then
  160. char:setModel(item.player:GetModel():gsub(item.replacements[1], item.replacements[2]))
  161. else
  162. for k, v in ipairs(item.replacements) do
  163. char:setModel(item.player:GetModel():gsub(v[1], v[2]))
  164. end
  165. end
  166. else
  167. char:setModel(item.replacement or item.replacements)
  168. end
  169. end
  170.  
  171. if (item.newSkin) then
  172. char:setData("oldSkin", item.player:GetSkin())
  173. item.player:SetSkin(item.newSkin)
  174. end
  175.  
  176. if (item.bodyGroups) then
  177. local groups = {}
  178.  
  179. for k, value in pairs(item.bodyGroups) do
  180. local index = item.player:FindBodygroupByName(k)
  181.  
  182. if (index > -1) then
  183. groups[index] = value
  184. end
  185. end
  186.  
  187. local newGroups = char:getData("groups", {})
  188.  
  189. for index, value in pairs(groups) do
  190. newGroups[index] = value
  191. item.player:SetBodygroup(index, value)
  192. end
  193.  
  194. if (table.Count(newGroups) > 0) then
  195. char:setData("groups", newGroups)
  196. end
  197. end
  198.  
  199. if (item.attribBoosts) then
  200. for k, v in pairs(item.attribBoosts) do
  201. char:addBoost(item.uniqueID, k, v)
  202. end
  203. end
  204.  
  205. return false
  206. end,
  207. onCanRun = function(item)
  208. return (!IsValid(item.entity) and item:getData("equip") != true)
  209. end
  210. }
  211.  
  212. function ITEM:onCanBeTransfered(oldInventory, newInventory)
  213. if (newInventory and self:getData("equip")) then
  214. return newInventory:getID() == 0
  215. end
  216.  
  217. return true
  218. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement