BananasTheKing

TheSpireRoleplay Clothes Base

Aug 27th, 2019
930
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. --[[
  2. © 2015 CloudSixteen.com do not share, re-distribute or modify
  3. without permission of its author ([email protected]).
  4.  
  5. Clockwork was created by Conna Wiles (also known as kurozael.)
  6. http://cloudsixteen.com/license/clockwork.html
  7. --]]
  8.  
  9. local Clockwork = Clockwork;
  10.  
  11. local ITEM = Clockwork.item:New(nil, true);
  12. ITEM.name = "TSR Clothes Base";
  13. ITEM.model = "models/props_c17/suitcase_passenger_physics.mdl";
  14. ITEM.weight = 2;
  15. ITEM.useText = "Wear";
  16. ITEM.category = "Clothing";
  17. ITEM.description = "A suitcase full of clothes.";
  18.  
  19. -- A function to get the model name.
  20. function ITEM:GetModelName(player, group)
  21. local modelName = nil;
  22.  
  23. if (!player) then
  24. player = Clockwork.Client;
  25. end;
  26.  
  27. if (group) then
  28. modelName = string.gsub(string.lower(Clockwork.player:GetDefaultModel(player)), "^.-/.-/", "");
  29. else
  30. modelName = string.gsub(string.lower(Clockwork.player:GetDefaultModel(player)), "^.-/.-/.-/.-/", "");
  31. end;
  32.  
  33. if (!string.find(modelName, "male") and !string.find(modelName, "female")) then
  34. if (group) then
  35. group = "group05/";
  36. else
  37. group = "";
  38. end;
  39.  
  40. if (SERVER) then
  41. if (player:GetGender() == GENDER_FEMALE) then
  42. return group.."female_04.mdl";
  43. else
  44. return group.."male_05.mdl";
  45. end;
  46. elseif (player:GetGender() == GENDER_FEMALE) then
  47. return group.."female_04.mdl";
  48. else
  49. return group.."male_05.mdl";
  50. end;
  51. else
  52. return modelName;
  53. end;
  54. end;
  55.  
  56. -- Called when the item's client side model is needed.
  57. function ITEM:GetClientSideModel()
  58. local replacement = nil;
  59.  
  60. if (self.GetReplacement) then
  61. replacement = self:GetReplacement(Clockwork.Client);
  62. end;
  63.  
  64. if (type(replacement) == "string") then
  65. return replacement;
  66. elseif (self("replacement")) then
  67. return self("replacement");
  68. elseif (self("group")) then
  69. return "models/thespireroleplay/humans/"..self("group").."/"..self:GetModelName();
  70. end;
  71. end;
  72.  
  73. -- Called when a player changes clothes.
  74. function ITEM:OnChangeClothes(player, bIsWearing)
  75. if (bIsWearing) then
  76. local replacement = nil;
  77.  
  78. if (self.GetReplacement) then
  79. replacement = self:GetReplacement(player);
  80. end;
  81.  
  82. if (type(replacement) == "string") then
  83. player:SetModel(replacement);
  84. elseif (self("replacement")) then
  85. player:SetModel(self("replacement"));
  86. elseif (self("group")) then
  87. player:SetModel("models/thespireroleplay/humans/"..self("group").."/"..self:GetModelName(player));
  88. end;
  89. else
  90. Clockwork.player:SetDefaultModel(player);
  91. Clockwork.player:SetDefaultSkin(player);
  92. end;
  93.  
  94. if (self.OnChangedClothes) then
  95. self:OnChangedClothes(player, bIsWearing);
  96. end;
  97. end;
  98.  
  99. -- Called to get whether a player has the item equipped.
  100. function ITEM:HasPlayerEquipped(player, bIsValidWeapon)
  101. if (CLIENT) then
  102. return Clockwork.player:IsWearingItem(self);
  103. else
  104. return player:IsWearingItem(self);
  105. end;
  106. end;
  107.  
  108. -- Called when a player has unequipped the item.
  109. function ITEM:OnPlayerUnequipped(player, extraData)
  110. player:RemoveClothes();
  111. end;
  112.  
  113. -- Called when a player drops the item.
  114. function ITEM:OnDrop(player, position)
  115. if (player:IsWearingItem(self)) then
  116. Clockwork.player:Notify(player, "You cannot drop this while you are wearing it!");
  117. return false;
  118. end;
  119. end;
  120.  
  121. -- Called when a player uses the item.
  122. function ITEM:OnUse(player, itemEntity)
  123. if (self("whitelist") and !table.HasValue(self("whitelist"), player:GetFaction())) then
  124. Clockwork.player:Notify(player, "Your faction cannot wear this clothing!");
  125. return false;
  126. end;
  127.  
  128. if (player:Alive() and !player:IsRagdolled()) then
  129. if (!self.CanPlayerWear or self:CanPlayerWear(player, itemEntity) != false) then
  130. player:SetClothesData(self);
  131. return true;
  132. end;
  133. else
  134. Clockwork.player:Notify(player, "You cannot do this action at the moment!");
  135. end;
  136.  
  137. return false;
  138. end;
  139.  
  140. if (CLIENT) then
  141. function ITEM:GetClientSideInfo()
  142. if (!self:IsInstance()) then return; end;
  143.  
  144. if (Clockwork.player:IsWearingItem(self)) then
  145. return "Is Wearing: Yes";
  146. else
  147. return "Is Wearing: No";
  148. end;
  149. end;
  150. end;
  151.  
  152. Clockwork.item:Register(ITEM);
Advertisement
Add Comment
Please, Sign In to add comment