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!

Can someone help me fix a plugin?

Discussion in 'Discussion' started by Iridium616, Jul 14, 2013.

  1. Code:
    local ITEM = Clockwork.item:New("clothes_base");
    ITEM.name = "Gasmask";
    ITEM.replacement = "models/citizen_17.mdl";
    ITEM.model = "models/citizen_17.mdl";
    ITEM.weight = 3;
    ITEM.access = "V";
    ITEM.business = true;
    ITEM.protection = 0.1;
    ITEM.description = "A suit. Perfect for toxins";
    
    --[[
    --Called when a player uses the item.
    function ITEM:OnEquip(player)
    	print("THIS SHIT IS BEING CALLED IT'S BEING CALLED YES IT IS BEING CALLED.");
    	print( player:SteamID() );
    	--player:EmitSound("xhosters/a_breath.mp3", 500, 200)
    	player:SetSharedVar("wearingRespirator", true);
    end;
    --]]
    
    -- Called when the attachment offset info should be adjusted.
    function ITEM:AdjustAttachmentOffsetInfo(player, entity, info)
    	if ( string.find(player:GetModel(), "female") ) then
    		info.offsetVector = Vector(0, 0, 0);
    	end;
    end;
    
    -- A function to get whether the attachment is visible.
    function ITEM:GetAttachmentVisible(player, entity)
    	if ( player:GetSharedVar("gasmask1") ) then
    		return true;
    	end;
    end;
    
    -- Called when the item's local amount is needed.
    function ITEM:GetLocalAmount(amount)
    	if ( Clockwork.Client:GetSharedVar("gasmask1") ) then
    		return amount - 1;
    	else
    		return amount;
    	end;
    end;
    
    -- Called to get whether a player has the item equipped.
    function ITEM:HasPlayerEquipped(player, arguments)
    	return player:GetSharedVar("gasmask1");
    end;
    
    -- Called when a player has unequipped the item.
    function ITEM:OnPlayerUnequipped(player, arguments)
    	local skullMaskGear = Clockwork.player:GetGear(player, "gasmask1");
    	
    	if ( player:GetSharedVar("gasmask1") and IsValid(skullMaskGear) ) then
    		player:SetCharacterData("gasmask1", nil);
    		player:SetSharedVar("gasmask1", false);
    		player:SetSharedVar("wearingRespirator", false);
    		
    		if ( IsValid(gasmask1Gear) ) then
    			gasmask1Gear:Remove();
    		end;
    	end;
    	player:RebuildInventory();
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position)
    	if (player:GetSharedVar("gasmask1") and player:HasItem(self.uniqueID) == 1) 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 ( player:Alive() and !player:IsRagdolled() ) then
    		Clockwork.player:CreateGear(player, "gasmask1", self);
    		
    		player:SetCharacterData("gasmask1", true);
    		player:SetSharedVar("gasmask1", true);
    		player:SetSharedVar("wearingRespirator", true);
    		player:RebuildInventory();
    		
    		itemEntity:Remove();
    		
    		if (itemEntity) then
    			return true;
    		end;
    	else
    		Clockwork.player:Notify(player, "You don't have permission to do this right now!");
    	end;
    	
    	return false;
    end;
    
    ITEM:Register();
    As you can see, It was made as an attachment, and I want it to be a playermodel.
     
  2. Use this format.

    Code:
    local ITEM = Clockwork.item:New("clothes_base");
     
     
    -- ONLY EDIT THE STARS.
     
    -- Name for the Uniform
    ITEM.name = "***";
    -- Weight for the Uniform
    ITEM.weight = ***;
    -- Can it be bought from the business menu?
    ITEM.business = ***;
    -- How much does it protect you?
    -- 1 = 100%
    -- 0.1 = 10%
    ITEM.protection = ***;
    -- What model does it switch to?
    ITEM.replacement = "***";
    -- A description for your Uniform.
    ITEM.description = "***";
     
    ITEM:Register();
     
  3. from where did you got that file?
     
  4. Made it myself.
     
  5. If you could give more examples of that, like when making a SWEP, it could help me a lot with CW lua.
     
  6. Sweps are a bit more complicated, but I'll see about it soon.
     
  7. New code:

    Code:
     --[[
                ? 2012 CloudSixteen.com do not share, re-distribute or modify
                without permission of its author ([email protected]).
        --]]
         
        local ITEM = Clockwork.item:New("clothes_base");
         
         
        -- ONLY EDIT THE STARS.
         
        -- Name for the Uniform
        ITEM.name = "AirEx Sewer Mantenience Gasmask";
        -- Weight for the Uniform
        ITEM.weight = 1;
        -- Can it be bought from the business menu?
        ITEM.business = false;
        -- How much does it protect you?
        -- 1 = 100%
        -- 0.1 = 10%
        ITEM.protection = 0.05;
        -- What model does it switch to?
        ITEM.replacement = "models/humans/airex/airex_male.mdl";
        -- A description for your Uniform.
        ITEM.description = "A Sewer Mantenience Suit. Protects you from Hazards.";
    
    --[[
    --Called when a player uses the item.
    function ITEM:OnEquip(player)
    	print("THIS SHIT IS BEING CALLED IT'S BEING CALLED YES IT IS BEING CALLED.");
    	print( player:SteamID() );
    	--player:EmitSound("xhosters/a_breath.mp3", 500, 200)
    	player:SetSharedVar("wearingRespirator", true);
    end;
    --]]
    
    -- Called when the attachment offset info should be adjusted.
    function ITEM:AdjustAttachmentOffsetInfo(player, entity, info)
    	if ( string.find(player:GetModel(), "female") ) then
    		info.offsetVector = Vector(0, 0, 0);
    	end;
    end;
    
    -- A function to get whether the attachment is visible.
    function ITEM:GetAttachmentVisible(player, entity)
    	if ( player:GetSharedVar("gasmask1") ) then
    		return true;
    	end;
    end;
    
    -- Called when the item's local amount is needed.
    function ITEM:GetLocalAmount(amount)
    	if ( Clockwork.Client:GetSharedVar("gasmask1") ) then
    		return amount - 1;
    	else
    		return amount;
    	end;
    end;
    
    -- Called to get whether a player has the item equipped.
    function ITEM:HasPlayerEquipped(player, arguments)
    	return player:GetSharedVar("gasmask1");
    end;
    
    -- Called when a player has unequipped the item.
    function ITEM:OnPlayerUnequipped(player, arguments)
    	local skullMaskGear = Clockwork.player:GetGear(player, "gasmask1");
    	
    	if ( player:GetSharedVar("gasmask1") and IsValid(skullMaskGear) ) then
    		player:SetCharacterData("gasmask1", nil);
    		player:SetSharedVar("gasmask1", false);
    		player:SetSharedVar("wearingRespirator", false);
    		
    		if ( IsValid(gasmask1Gear) ) then
    			gasmask1Gear:Remove();
    		end;
    	end;
    	player:RebuildInventory();
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position)
    	if (player:GetSharedVar("gasmask1") and player:HasItem(self.uniqueID) == 1) 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 ( player:Alive() and !player:IsRagdolled() ) then
    		Clockwork.player:CreateGear(player, "gasmask1", self);
    		
    		player:SetCharacterData("gasmask1", true);
    		player:SetSharedVar("gasmask1", true);
    		player:SetSharedVar("wearingRespirator", true);
    		player:RebuildInventory();
    		
    		itemEntity:Remove();
    		
    		if (itemEntity) then
    			return true;
    		end;
    	else
    		Clockwork.player:Notify(player, "You don't have permission to do this right now!");
    	end;
    	
    	return false;
    end;
    
    ITEM:Register();
    Pretty much same. Freezes my game when wearing it, and trows this error: [Clockwork] The 'InvAction' command has failed to run. gamemodes/cwhl2rp/plugins/gasmasks/plugin/item/sh_gasmask01.lua:99: attempt to index local 'itemEntity' (a nil value)

    PD: I'm using the code modified, not just how you gave me it, becouse I want to use it with the toxins plugin.

    EDIT: I think it doesen't freezes my game, but the uniform doesen't show up on thirdperson (like i'm not wearing it) and I can't unequip it.
     
  8. Try this.

    Code:
    --[[
                ? 2012 CloudSixteen.com do not share, re-distribute or modify
                without permission of its author ([email protected]).
        --]]
         
        local ITEM = Clockwork.item:New("clothes_base");
         
         
        -- ONLY EDIT THE STARS.
         
        -- Name for the Uniform
        ITEM.name = "AirEx Sewer Mantenience Gasmask";
        -- Weight for the Uniform
        ITEM.weight = 1;
        -- Can it be bought from the business menu?
        ITEM.business = false;
        -- How much does it protect you?
        -- 1 = 100%
        -- 0.1 = 10%
        ITEM.protection = 0.05;
        -- What model does it switch to?
        ITEM.replacement = "models/humans/airex/airex_male.mdl";
        -- A description for your Uniform.
        ITEM.description = "A Sewer Mantenience Suit. Protects you from Hazards.";
    
    --[[
    --Called when a player uses the item.
    function ITEM:OnEquip(player)
     print("THIS SHIT IS BEING CALLED IT'S BEING CALLED YES IT IS BEING CALLED.");
     print( player:SteamID() );
     --player:EmitSound("xhosters/a_breath.mp3", 500, 200)
     player:SetSharedVar("wearingRespirator", true);
    end;
    --]]
    
    -- Called when the attachment offset info should be adjusted.
    function ITEM:AdjustAttachmentOffsetInfo(player, entity, info)
     if ( string.find(player:GetModel(), "female") ) then
      info.offsetVector = Vector(0, 0, 0);
     end;
    end;
    
    -- A function to get whether the attachment is visible.
    function ITEM:GetAttachmentVisible(player, entity)
     if ( player:GetSharedVar("gasmask1") ) then
      return true;
     end;
    end;
    
    -- Called when the item's local amount is needed.
    function ITEM:GetLocalAmount(amount)
     if ( Clockwork.Client:GetSharedVar("gasmask1") ) then
      return amount - 1;
     else
      return amount;
     end;
    end;
    
    -- Called to get whether a player has the item equipped.
    function ITEM:HasPlayerEquipped(player, arguments)
     return player:GetSharedVar("gasmask1");
    end;
    
    -- Called when a player has unequipped the item.
    function ITEM:OnPlayerUnequipped(player, arguments)
     local skullMaskGear = Clockwork.player:GetGear(player, "gasmask1");
     
     if ( player:GetSharedVar("gasmask1") and IsValid(skullMaskGear) ) then
      player:SetCharacterData("gasmask1", nil);
      player:SetSharedVar("gasmask1", false);
      player:SetSharedVar("wearingRespirator", false);
      
      if ( IsValid(gasmask1Gear) ) then
       gasmask1Gear:Remove();
      end;
     end;
     player:RebuildInventory();
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position)
     if (player:GetSharedVar("gasmask1") and player:HasItem(self.uniqueID) == 1) 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 ( player:Alive() and !player:IsRagdolled() ) then
      Clockwork.player:CreateGear(player, "gasmask1", self);
      
      player:SetCharacterData("gasmask1", true);
      player:SetSharedVar("gasmask1", true);
      player:SetSharedVar("wearingRespirator", true);
      player:RebuildInventory();
      
      
      if (itemEntity) then
       return true;
      end;
     else
      Clockwork.player:Notify(player, "You don't have permission to do this right now!");
     end;
     
     return false;
    end;
    
    ITEM:Register();
     
  9. Still not working, no errors this time. Just I can't take it off and It doesent actually changes the playermodel.
     
  10. What error are you getting now?
     
  11. no errors this time
     
  12. Well, it is trowing Couldn't include file 'sh_coms.lua' (File not found) (@gamemodes/clockwork/framework/sh_kernel.lua (line 3570)) on my client but I don't think it's anything important as it happened always and never conflicted with any plugin.
     
  13. Try ITEM.model instead of ITEM.Replacement
     
  14. it's not working. the only difference is that when I drop the item, it looks like a T-shape version of the ragdoll. Still bugged
     
  15. Alright, keep the ITEM.Replacement in that case.

    I'm really thinking this has to do with the toxins.
     
  16. The problem is the toxins plugin. Needs fixing. Any ways to fix so far?
     

Previous Readers (Total: 0)