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!

Other Custom Clothes Base

Discussion in 'Development' started by 8bitMafia, Mar 29, 2018.

  1. I have a multitude of suits with many bodygroups that I want to integrate into Clockwork. So basically I'm going to make separate items as follows: a shirt, jacket, and tie. Each will have to have their bodygroups match for them to pair together on the models. The player will have to wear the shirt first, then choose either the tie or the jacket, or both to have different combinations of clothing with the same items. However, when I duplicate the clothes base, change the file name, then change the item.name, create a clothing item with the suit_base filename in the Clockwork.item:New the item exists. Essentially I can /chargiveitem myself a shirt, however it doesn't actually show up in my inventory. No errors in the client or server, any ideas?
    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;

    if (!player) then
    player = Clockwork.Client;
    end;

    if (group) then
    modelName = string.gsub(string.lower(Clockwork.player:GetDefaultModel(player)), "^.-/.-/", "");
    else
    modelName = string.gsub(string.lower(Clockwork.player:GetDefaultModel(player)), "^.-/.-/.-/", "");
    end;

    if (!string.find(modelName, "male") and !string.find(modelName, "female")) then
    if (group) then
    group = "group05/";
    else
    group = "";
    end;

    if (SERVER) then
    if (player:GetGender() == GENDER_FEMALE) then
    return group.."female_04.mdl";
    else
    return group.."male_05.mdl";
    end;
    elseif (player:GetGender() == GENDER_FEMALE) then
    return group.."female_04.mdl";
    else
    return group.."male_05.mdl";
    end;
    else
    return modelName;
    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, bIsWearing)
    if (bIsWearing) 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, bIsWearing);
    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, "You cannot drop this while you are wearing it!");
    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, "Your faction cannot wear this clothing!");
    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, "You cannot do this action at the moment!");
    end;

    return false;
    end;

    if (CLIENT) then
    function ITEM:GetClientSideInfo()
    if (!self:IsInstance()) then return; end;

    if (Clockwork.player:IsWearingItem(self)) then
    return "Is Wearing: Yes";
    else
    return "Is Wearing: No";
    end;
    end;
    end;

    Clockwork.item:Register(ITEM);
    ----------
    local ITEM = Clockwork.item:New("suits_base");
    ITEM.name = "Shirt";
    ITEM.group = "shirt";
    ITEM.weight = 3;
    ITEM.business = true;
    ITEM.protection = 0.1;
    ITEM.description = "A resistance uniform with a yellow symbol on the sleeve.";

    ITEM:Register();
     
  2. duck

    duck Phant0m Legend

    Wait, there's supposed to be a different result depending on which order they equip the items? That just sounds like a bad idea.
     
  3. No, not the order necessarily. It's required you have a shirt on for you to add a tie or jacket, however that's it. Eg. You have a shirt equipped you can have a shirt and tie, a shirt and jacket, or a shirt; jacket; and tie.

    I just want to make the clothes interchangable because the prices for suits are going to be steep.

    @duck
     
  4. Bump/Update

    I've concluded that I have at least 1 brain cell and found out it wasn't showing up because the file name was "sh_closed_tie.lua" while the ITEM.name was "Jacket". Now the file name is "sh_suit_jacket.lua" and the ITEM.name is "Suit Jacket". However the item still isn't showing up in the business menu and when I give myself the item it is in the Other category and doesn't have any options.
    [​IMG]
    When I switch Clockwork.item:New("suits_base"); to Clockwork.item:New("clothing_base"); it works, vice versa it doesn't.
     

Previous Readers (Total: 0)