diff --git a/gamemode/core/util/cl_draw.lua b/gamemode/core/util/cl_draw.lua index 3966751d..d587c2a6 100644 --- a/gamemode/core/util/cl_draw.lua +++ b/gamemode/core/util/cl_draw.lua @@ -26,7 +26,7 @@ function nut.util.wrapText(text, width, font) local maxW = 0 if (w <= width) then - return {(text:gsub("%s", " "))}, w + return {text:gsub("%s", " ")}, w end for i = 1, #exploded do diff --git a/gamemode/items/base/sh_outfit.lua b/gamemode/items/base/sh_outfit.lua index eb91b0af..e99f30ee 100644 --- a/gamemode/items/base/sh_outfit.lua +++ b/gamemode/items/base/sh_outfit.lua @@ -60,11 +60,13 @@ function ITEM:removeOutfit(client) client:SetSkin(character:getData("oldSkin", character:getData("skin", 0))) character:setData("oldSkin", nil) - for k, v in pairs(self.bodyGroups or {}) do + + local oldGroups = character:getData("oldGroups", {}) + for k in pairs(self.bodyGroups or {}) do local index = client:FindBodygroupByName(k) if (index > -1) then - client:SetBodygroup(index, 0) + client:SetBodygroup(index, oldGroups[index] or 0) local groups = character:getData("groups", {}) @@ -74,6 +76,7 @@ function ITEM:removeOutfit(client) end end end + character:setData("oldGroups", nil) end -- Then, remove PAC parts from this outfit. @@ -134,7 +137,7 @@ ITEM.functions.Equip = { local char = item.player:getChar() local items = char:getInv():getItems() - for id, other in pairs(items) do + for _, other in pairs(items) do if ( item ~= other and item.outfitCategory == other.outfitCategory and @@ -167,7 +170,7 @@ ITEM.functions.Equip = { ):lower() char:setModel(newModel) else - for k, v in ipairs(item.replacements) do + for _, v in ipairs(item.replacements) do char:setModel(item.player:GetModel():gsub(v[1], v[2])) end end @@ -185,18 +188,21 @@ ITEM.functions.Equip = { -- Then set appropriate body groups for the model. if (istable(item.bodyGroups)) then + local oldGroups = {} local groups = {} for k, value in pairs(item.bodyGroups) do local index = item.player:FindBodygroupByName(k) if (index > -1) then + oldGroups[index] = item.player:GetBodygroup(index) groups[index] = value end end - local newGroups = char:getData("groups", {}) + char:setData("oldGroups", oldGroups) + local newGroups = char:getData("groups", {}) for index, value in pairs(groups) do newGroups[index] = value item.player:SetBodygroup(index, value) @@ -239,11 +245,9 @@ function ITEM:onLoadout() end function ITEM:onRemoved() - local inv = nut.item.inventories[self.invID] - if (IsValid(receiver) and receiver:IsPlayer()) then - if (self:getData("equip")) then - self:removeOutfit(receiver) - end + --local inv = nut.item.inventories[self.invID] + if (IsValid(receiver) and receiver:IsPlayer()) and (self:getData("equip")) then + self:removeOutfit(receiver) end end