1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Custom Clothes Base

Discussion in 'Development' started by 8bitMafia, Jul 14, 2018.

  1. I posted about this a long time ago and I don't think its even possible at this point but I'm trying to make a suits base and if i copy the entire clothes base and make an item for it changing the name of the file and the clothes base item breaks everything, anyone know why? The item exists but the inventory model is an error and it has no options.

    Code:
    local Clockwork = Clockwork;
    
    local ITEM = Clockwork.item:New(nil, true);
    
    ITEM.name = "Suits Base";
    ITEM.model = "models/props_c17/suitcase_passenger_physics.mdl";
    ITEM.weight = 2;
    ITEM.useText = "Wear";
    ITEM.category = "Clothing";
    ITEM.description = "A suitcase full of clothes.";
    
    -- A function to get the model name.
    function ITEM:GetModelName(player, group)
        local modelName = nil;
        local modelDefault = Clockwork.player:GetDefaultModel(player);
    
        for i = 1, 9 do
            if ( string.find(string.lower(modelDefault), "male_0"..i ) ) then
                local modelName = "male_0"..i;
    
                break
            elseif ( string.find(string.lower(modelDefault), "female_0"..i ) ) then
                local modelName = "female_0"..i;
    
                break
            end;
        end;
    
        if (self("group") == "shirt") then
            return modelName.."_shirt.mdl";
        end;
    end;
    
    -- Called when the item's client side model is needed.
    function ITEM:GetClientSideModel()
        local replacement = nil;
       
        if (self.GetReplacement) then
            replacement = self:GetReplacement(Clockwork.Client);
        end;
       
        if (type(replacement) == "string") then
            return replacement;
        elseif (self("replacement")) then
            return self("replacement");
        elseif (self("group")) then
            return "models/humans/"..self("group").."/"..self:GetModelName();
        end;
    end;
    
    -- Called when a player changes clothes.
    function ITEM:OnChangeClothes(player, isWearing)
        if (isWearing) then
            local replacement = nil;
           
            if (self.GetReplacement) then
                replacement = self:GetReplacement(player);
            end;
           
            if (type(replacement) == "string") then
                player:SetModel(replacement);
            elseif (self("replacement")) then
                player:SetModel(self("replacement"));
            elseif (self("group")) then
                player:SetModel("models/humans/"..self("group").."/"..self:GetModelName(player));
            end;
        else
            Clockwork.player:SetDefaultModel(player);
            Clockwork.player:SetDefaultSkin(player);
        end;
       
        if (self.OnChangedClothes) then
            self:OnChangedClothes(player, isWearing);
        end;
    end;
    
    -- Called to get whether a player has the item equipped.
    function ITEM:HasPlayerEquipped(player, bIsValidWeapon)
        if (CLIENT) then
            return Clockwork.player:IsWearingItem(self);
        else
            return player:IsWearingItem(self);
        end;
    end;
    
    -- Called when a player has unequipped the item.
    function ITEM:OnPlayerUnequipped(player, extraData)
        player:RemoveClothes();
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position)
        if (player:IsWearingItem(self)) then
            Clockwork.player:Notify(player, {"CannotDropWhileWearing"});
            return false;
        end;
    end;
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
        if (self("whitelist") and !table.HasValue(self("whitelist"), player:GetFaction())) then
            Clockwork.player:Notify(player, {"FactionCannotWearThis"});
            return false;
        end;
       
        if (player:Alive() and !player:IsRagdolled()) then
            if (!self.CanPlayerWear or self:CanPlayerWear(player, itemEntity) != false) then
                player:SetClothesData(self);
                return true;
            end;
        else
            Clockwork.player:Notify(player, {"CannotActionRightNow"});
        end;
       
        return false;
    end;
    
    if (CLIENT) then
        function ITEM:GetClientSideInfo()
            if (!self:IsInstance()) then return; end;
           
            if (Clockwork.player:IsWearingAccessory(self)) then
                return L("ItemInfoIsWearingYes");
            else
                return L("ItemInfoIsWearingNo");
            end;
        end;
    end;
    
    Clockwork.item:Register(ITEM);
    
    -------
    SHIRT ITEM:
    local ITEM = Clockwork.item:New("suits_base");
    ITEM.name = "White Shirt";
    ITEM.group = "shirt";
    ITEM.weight = 3;
    ITEM.access = "m";
    ITEM.business = true;
    ITEM.protection = 0.1;
    ITEM.description = "A white shirt, paired with black pants, and black shoes.";
    --[[
    -- Called when a replacement is needed for a player.
    function ITEM:GetReplacement(player)
        if (string.lower( player:GetModel() ) == "models/humans/group01/jasona.mdl") then
            return "models/humans/group03/male_02.mdl";
        end;
    end;
    ]]
    ITEM:Register();
    
    
    
     
  2. Aspect

    Aspect =) Legend Clockwork Customer

    Er, what are you trying to do?

    -----Edit------
    I mean what do you want a clothes base for? Adding stuff like uniforms?
     
  3. Suits, but I haven't really changed anything yet since its been broken. I'm just adding different skins to different shirts and when they put on a suit jacket it just changes the model and keeps the skin. Simple stuff, but its broken for some reason.
     
  4. Aspect

    Aspect =) Legend Clockwork Customer

    Oh, idk. Probs has something to do with the clothes base.
     
  5. Viz

    Viz Legend Clockwork Customer

    Not too sure, but it may be to do with this?
    Code:
    -- A function to get the model name.
    function ITEM:GetModelName(player, group)
        local modelName = nil;
        local modelDefault = Clockwork.player:GetDefaultModel(player);
    
        for i = 1, 9 do
            if ( string.find(string.lower(modelDefault), "male_0"..i ) ) then
                local modelName = "male_0"..i;
    
                break
            elseif ( string.find(string.lower(modelDefault), "female_0"..i ) ) then
                local modelName = "female_0"..i;
    
                break
            end;
        end;
    
        if (self("group") == "shirt") then
            return modelName.."_shirt.mdl";
        end;
    end;
    
    You declare 'local modelName = nil', and then use a loop to determine what model that should be, but you redefine modelName as a new local variable within that loop, so the original modelName isn't being set, and is therefore always set to nil.
     
  6. So i have fixed about two errors so far in my search for the issue but if it were working correctly im pretty sure I would've gotten an error so far, so im not sure.

    Update:
    Code:
    local Clockwork = Clockwork;
    
    local ITEM = Clockwork.item:New(nil, true);
    
    ITEM.name = "Suits Base";
    ITEM.model = "models/props_c17/suitcase_passenger_physics.mdl";
    ITEM.weight = 2;
    ITEM.useText = "Wear";
    ITEM.category = "Clothing";
    ITEM.description = "A suitcase full of clothes.";
    
    -- A function to get the model name.
    function ITEM:GetModelName(player, group)
        local modelName = nil;
        local modelDefault = Clockwork.player:GetDefaultModel(player);
    
        if (!player) then
            player = Clockwork.Client;
        end;
    
        for i = 1, 9 do
            if ( string.find( string.lower(modelDefault), "male_0"..i ) ) then
                modelName = "male_0"..i;
    
                break
            elseif ( string.find( string.lower(modelDefault), "female_0"..i ) ) then
                modelName = "female_0"..i;
    
                break
            end;
        end;
    
        if (self("group") == "shirt") then
            return modelName.."_shirt.mdl";
        end;
    end;
    
    -- Called when the item's client side model is needed.
    function ITEM:GetClientSideModel()
        local replacement = nil;
       
        if (self.GetReplacement) then
            replacement = self:GetReplacement(Clockwork.Client);
        end;
       
        if (type(replacement) == "string") then
            return replacement;
        elseif (self("replacement")) then
            return self("replacement");
        elseif (self("group")) then
            return "models/humans/"..self("group").."/"..self:GetModelName();
        end;
    end;
    
    -- Called when a player changes clothes.
    function ITEM:OnChangeClothes(player, isWearing)
        if (isWearing) then
            local replacement = nil;
           
            if (self.GetReplacement) then
                replacement = self:GetReplacement(player);
            end;
           
            if (type(replacement) == "string") then
                player:SetModel(replacement);
            elseif (self("replacement")) then
                player:SetModel(self("replacement"));
            elseif (self("group")) then
                player:SetModel("models/humans/"..self("group").."/"..self:GetModelName(player));
            end;
        else
            Clockwork.player:SetDefaultModel(player);
            Clockwork.player:SetDefaultSkin(player);
        end;
       
        if (self.OnChangedClothes) then
            self:OnChangedClothes(player, isWearing);
        end;
    end;
    
    -- Called to get whether a player has the item equipped.
    function ITEM:HasPlayerEquipped(player, bIsValidWeapon)
        if (CLIENT) then
            return Clockwork.player:IsWearingItem(self);
        else
            return player:IsWearingItem(self);
        end;
    end;
    
    -- Called when a player has unequipped the item.
    function ITEM:OnPlayerUnequipped(player, extraData)
        player:RemoveClothes();
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position)
        if (player:IsWearingItem(self)) then
            Clockwork.player:Notify(player, {"CannotDropWhileWearing"});
            return false;
        end;
    end;
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
        if (self("whitelist") and !table.HasValue(self("whitelist"), player:GetFaction())) then
            Clockwork.player:Notify(player, {"FactionCannotWearThis"});
            return false;
        end;
       
        if (player:Alive() and !player:IsRagdolled()) then
            if (!self.CanPlayerWear or self:CanPlayerWear(player, itemEntity) != false) then
                player:SetClothesData(self);
                return true;
            end;
        else
            Clockwork.player:Notify(player, {"CannotActionRightNow"});
        end;
       
        return false;
    end;
    
    if (CLIENT) then
        function ITEM:GetClientSideInfo()
            --if (!self:IsInstance()) then return; end;
           
            if (Clockwork.player:IsWearingAccessory(self)) then
                return L("ItemInfoIsWearingYes");
            else
                return L("ItemInfoIsWearingNo");
            end;
        end;
    end;
    
    Clockwork.item:Register(ITEM);
     
  7. duck

    duck Phant0m Legend

    What do the model paths look like.
     

Previous Readers (Total: 0)