Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. local ITEM = Clockwork.item:New();
  2. ITEM.name = "Tattered Gloves";
  3. ITEM.model = "models/tnb/items/gloves.mdl";
  4. ITEM.weight = 0.5;
  5. ITEM.useText = "Wear Gloves";
  6. ITEM.category = "Clothing";
  7. ITEM.description = "A pair of grey mittens, the fingers have been removed.";
  8. ITEM.customFunctions = {"Remove"};
  9. ITEM.access = "1";
  10. ITEM.business = false;
  11.  
  12. local bodyGroup = 3;
  13.  
  14.  
  15. -- Called when a player drops the item.
  16. function ITEM:OnDrop(player, position)
  17.  
  18.  
  19. local target = player
  20. local targetBodyGroups = target:GetCharacterData("BodyGroups") or {};
  21. local bodyGroupState = 0;
  22. local model = target:GetModel();
  23.  
  24. if( bodyGroup < target:GetNumBodyGroups() )then
  25. targetBodyGroups[model] = targetBodyGroups[model] or {};
  26.  
  27. if( bodyGroupState == 0 )then
  28. targetBodyGroups[model][tostring(bodyGroup)] = nil;
  29. else
  30. targetBodyGroups[model][tostring(bodyGroup)] = bodyGroupState;
  31. end;
  32.  
  33. target:SetBodygroup(bodyGroup, bodyGroupState);
  34.  
  35. target:SetCharacterData("BodyGroups", targetBodyGroups);
  36.  
  37. end;
  38. return true
  39.  
  40. end;
  41.  
  42. if (CLIENT) then
  43. function ITEM:GetClientSideInfo()
  44. if (!self:IsInstance()) then return; end;
  45.  
  46. if (Clockwork.player:IsWearingItem(self)) then
  47. return "Is Wearing: Yes";
  48. else
  49. return "Is Wearing: No";
  50. end;
  51. end;
  52. end;
  53.  
  54. -- Called when a player uses the item.
  55. function ITEM:OnUse(player, itemEntity)
  56. if (player:Alive() and !player:IsRagdolled()) then
  57. if (!self.CanPlayerWear or self:CanPlayerWear(player, itemEntity) != false) then
  58.  
  59. local target = player
  60. local targetBodyGroups = target:GetCharacterData("BodyGroups") or {};
  61. local bodyGroupState = 1;
  62.  
  63. local model = target:GetModel();
  64.  
  65. if( bodyGroup < target:GetNumBodyGroups() )then
  66. targetBodyGroups[model] = targetBodyGroups[model] or {};
  67.  
  68. if( bodyGroupState == 0 )then
  69. targetBodyGroups[model][tostring(bodyGroup)] = nil;
  70. else
  71. targetBodyGroups[model][tostring(bodyGroup)] = bodyGroupState;
  72. end;
  73.  
  74. target:SetBodygroup(bodyGroup, bodyGroupState);
  75.  
  76. target:SetCharacterData("BodyGroups", targetBodyGroups);
  77.  
  78. return true;
  79.  
  80. end;
  81. end;
  82. end;
  83. end;
  84.  
  85. if (SERVER) then
  86. function ITEM:OnCustomFunction(player, name)
  87. if (name == "Remove") then
  88.  
  89. local target = player
  90. local targetBodyGroups = target:GetCharacterData("BodyGroups") or {};
  91. local bodyGroupState = 0;
  92. local model = target:GetModel();
  93.  
  94. if( bodyGroup < target:GetNumBodyGroups() )then
  95. targetBodyGroups[model] = targetBodyGroups[model] or {};
  96.  
  97. if( bodyGroupState == 0 )then
  98. targetBodyGroups[model][tostring(bodyGroup)] = nil;
  99. else
  100. targetBodyGroups[model][tostring(bodyGroup)] = bodyGroupState;
  101. end;
  102.  
  103. target:SetBodygroup(bodyGroup, bodyGroupState);
  104.  
  105. target:SetCharacterData("BodyGroups", targetBodyGroups);
  106.  
  107. end;
  108.  
  109. end;
  110. end;
  111. end;
  112.  
  113. ITEM:Register();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement