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 Equipable Item on Spawn

Discussion in 'Development' started by Milk 2, May 30, 2019.

  1. Hi, referring to http://forums.cloudsixteen.com/thre...groups-on-my-clothing-item.37894/#post-281836;

    Code:
    local ITEM = Clockwork.item:New("equipable_item_base");
    ITEM.name = "Metrocop Vest";
    ITEM.uniqueID = "metrocop_vest";
    ITEM.model = "models/tnb/items/shirt_metrocop.mdl";
    ITEM.cost = 10;
    ITEM.weight = 2;
    ITEM.business = true;
    ITEM.category = "Clothing";
    ITEM.access = "z";
    ITEM.description = "A Metrocop vest with light armor.";
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
        findTorso = player:FindBodygroupByName("Torso");
        player:SetBodygroup(findTorso, 6);
    
        if (player:Alive() and !player:IsRagdolled()) then
            if (self:GetData("equipped") != true) then
                if (self:CanPlayerWear(player, itemEntity) != false) then
                    self:SetData("equipped", true);
                    self:OnWearItem(player, true);
                    player:RebuildInventory();
                    return true;
                end;
            else
                Clockwork.player:Notify(player, "You are already wearing this item!");
            end;
        else
            Clockwork.player:Notify(player, "You cannot do this action at the moment!");
        end;
       
        return false;
    end;
    
    function ITEM:OnPlayerUnequipped(player, extraData)
        findTorso = player:FindBodygroupByName("Torso");
        player:SetBodygroup(findTorso, 0);
    
        self:OnWearItem(player, false);
        player:RebuildInventory();
    end;
    
    function ITEM:OnStorageGive(player, storageTable)
        if (self:GetData("equipped") == true) then
            self:OnWearItem(player, false);
        end;
    end;
    
    function ITEM:OnDrop(player, position)
        findTorso = player:FindBodygroupByName("Torso");
        player:SetBodygroup(findTorso, 0);
    
        if (self:GetData("equipped") == true) then
            self:OnWearItem(player, false);
        end;
    end;
    
    -- Called when a player's character has loaded.
    function Clockwork:PlayerCharacterLoaded(player)
            findTorso = player:FindBodygroupByName("Torso");
            player:SetBodygroup(findTorso, 0);
    end;
    
    ITEM:Register();
    
    How do you ensure equipped items are shown when a character loads in? As it is, this code does not show equipped items on spawn. And once equipped, the next character I load in has their bodygroups manipulated as well, depsite not having this item equipped.

    Thank you!
     
  2. Oliver

    Oliver Some kinda has-been Legend Clockwork Customer

    1. You can't afaik.
    2. That issue has been around for years. No fix.
     
    • Disagree Disagree x 1
  3. Why does clothing base have these capabilities, but it is impossible to make it work w/ bodygroups? I'm confused.
     
    • Agree Agree x 1

Previous Readers (Total: 0)