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.