Hey, so recently I have installed a T weapon that cloaks a player when in their hands. The addon can be found here:
[URL="https://steamcommunity.com/sharedfiles/filedetails/?id=278890424"]https://steamcommunity.com/sharedfiles/filedetails/?id=278890424[/URL]
At this stage, the T weapon can cloak playermodels. But it can't cloak hats or the jump pack, I know the addon page says that it can't cloak Pointshop items,
however I was hoping that someone on here has a fix.
[CODE]if SERVER then
AddCSLuaFile( "shared.lua" )
resource.AddFile("materials/VGUI/ttt/lykrast/icon_cloak.vmt")
resource.AddFile("materials/VGUI/ttt/lykrast/icon_cloak.vtf")
end
if( CLIENT ) then
SWEP.PrintName = "Cloaking Device";
SWEP.Slot = 7;
SWEP.DrawAmmo = false;
SWEP.DrawCrosshair = false;
SWEP.Icon = "VGUI/ttt/lykrast/icon_cloak";
SWEP.EquipMenuData = {
type = "item_weapon",
desc = "Hold it to become nearly invisible.\n\nDoesn't hide your name, pointshop items, shadow or\nbloodstains on your body."
};
end
SWEP.Author= "Lykrast"
SWEP.Base = "weapon_tttbase"
SWEP.Spawnable= false
SWEP.AdminSpawnable= true
SWEP.HoldType = "slam"
SWEP.Kind = WEAPON_EQUIP2
SWEP.CanBuy = {ROLE_TRAITOR}
SWEP.ViewModelFOV= 60
SWEP.ViewModelFlip= false
SWEP.ViewModel = "models/weapons/c_slam.mdl"
SWEP.WorldModel = "models/weapons/w_slam.mdl"
SWEP.UseHands = true
--- PRIMARY FIRE ---
SWEP.Primary.Delay= 0.5
SWEP.Primary.Recoil= 0
SWEP.Primary.Damage= 0
SWEP.Primary.NumShots= 1
SWEP.Primary.Cone= 0
SWEP.Primary.ClipSize= -1
SWEP.Primary.DefaultClip= -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.NoSights = true
SWEP.AllowDrop = false
function SWEP:PrimaryAttack()
return false
end
function SWEP:DrawWorldModel() -- Thanks v_hana :)
-- if not IsValid(self.Owner) then -- Well let's test this way then
-- self:DrawWorldModel()
-- end
end
function SWEP:DrawWorldModelTranslucent()
end
function SWEP:Cloak()
self.Owner:SetColor( Color(255, 255, 255, 3) )
self.Owner:SetMaterial( "sprites/heatwave" )
-- self.Weapon:SetMaterial("sprites/heatwave")
self:EmitSound( "AlyxEMP.Charge" )
-- self.Owner:DrawWorldModel( false ) -- Thanks v_hana :)
self.conceal = true
end
function SWEP:UnCloak()
self.Owner:SetMaterial("models/glass")
-- self.Weapon:SetMaterial("models/glass")
self:EmitSound( "AlyxEMP.Discharge" )
-- self.Owner:DrawWorldModel( true ) -- Thanks v_hana :)
self.conceal = false
end
function SWEP:Deploy()
self:Cloak()
end
function SWEP:Holster()
if ( self.conceal ) then
self:UnCloak()
end
return true
end
function SWEP:PreDrop()
if ( self.conceal ) then
self:UnCloak()
end
end
function SWEP:OnDrop() --Hopefully this'll work
self:Remove()
end
hook.Add("TTTPrepareRound", "UnCloakAll",function()
for k, v in pairs(player.GetAll()) do
v:SetMaterial("models/glass")
end
end
)[/CODE]
*The following is for users that don't have time to extract the addon
EDIT: I added 'Doesn't hide your name, pointshop items, shadow or\nbloodstains on your body' for now so my players don't get confused
In the function SWEP:Cloak() put this
[CODE]
for item_id, item in pairs(self.Owner.PS_Items) do
if item.Equipped then
self.Owner:PS_HolsterItem(item_id)
end
end
[/CODE]
That should holster all the items for you when the player cloaks themselves, I used something like this in a updated disguiser addon when I borrowed/stole the Idea from a coderhire addon.
This code is
[QUOTE=keensta;51874518]In the function SWEP:Cloak() put this
[CODE]
for item_id, item in pairs(self.Owner.PS_Items) do
if item.Equipped then
self.Owner:PS_HolsterItem(item_id)
end
end
[/CODE]
That should holster all the items for you when the player cloaks themselves, I used something like this in a updated disguiser addon when I borrowed/stole the Idea from a coderhire addon.
This code is[/QUOTE]
I noticed that the cloak doesn't re-equip the PS items after turning it off.
would I have to add something along the line of this to function SWEP:UnCloak():
[CODE]
for item_id, item in pairs(self.Owner.PS_Items) do
if item.Holstered then
self.Owner:PS_EquipItem(item_id)
end
end
[/CODE]
[QUOTE=DeadPixelz01;51874644]I noticed that the cloak doesn't re-equip the PS items after turning it off.
would I have to add something along the line of this to function SWEP:UnCloak():
[CODE]
for item_id, item in pairs(self.Owner.PS_Items) do
if item.Holstered then
self.Owner:PS_EquipItem(item_id)
end
end
[/CODE][/QUOTE]
change the top code in Cloak to this
[CODE]
self.Owner.cloakedItems = {}
num = 1
for item_id, item in pairs(self.Owner.PS_Items) do
if item.Equipped then
self.Owner:PS_HolsterItem(item_id)
self.Owner.cloakedItems[num] = item_id
num = num + 1
end
end
[/CODE]
then in uncloak do
[CODE]
for _, item_id in pairs(self.Owner.cloakedItems) do
self.Owner:PS_EquipItem(item_id)
end
[/CODE]
[QUOTE=keensta;51874743]change the top code in Cloak to this
[CODE]
self.Owner.cloakedItems = {}
num = 1
for item_id, item in pairs(self.Owner.PS_Items) do
if item.Equipped then
self.Owner:PS_HolsterItem(item_id)
self.Owner.cloakedItems[num] = item_id
num = num + 1
end
end
[/CODE]
then in uncloak do
[CODE]
for _, item_id in pairs(self.Owner.cloakedItems) do
self.Owner:PS_EquipItem(item_id)
end
[/CODE][/QUOTE]
Omg, thanks! You're a legend mate! :)
Sorry, you need to Log In to post a reply to this thread.