TOOL.Category = "Construction" TOOL.Name = "#Invisible" TOOL.Command = nil TOOL.ConfigName = "" TOOL.ClientConVar["key"] = "0" if (CLIENT) then language.Add("Tool_Invisible_name", "Invisible props") language.Add("Tool_Invisible_desc", "Make stuff invisible") language.Add("Tool_Invisible_0", "Click a prop, then press the assigned button to toggle invisibility." ) end function TOOL:LeftClick(trace) if trace.Entity && trace.Entity:IsPlayer() then return false end if ( SERVER && !util.IsValidPhysicsObject( trace.Entity, trace.PhysicsBone ) ) then return false end if (CLIENT) then return true end for _,ent in pairs(duplicator.GetEnts(trace.Entity)) do ent:SetNetworkedBool("iv01",false) numpad.OnUp(self:GetOwner(), self:GetClientNumber("key"), "Invisible_toggle", ent) end return true end local function ivzent(entity) if entity:GetNetworkedBool("iv01")==true then entity:Fire("addoutput","rendermode 2",0) entity:Fire("addoutput","renderamt 0",0) entity:GetPhysicsObject():Wake() end end local function revis(entity) entity:Fire("addoutput","renderamt 255",0) entity:GetPhysicsObject():Wake() end function TOOL.Reveal(entity,att,inf,dmg) if entity:GetNetworkedBool("iv01")==true then entity:Fire("addoutput","renderfx 16",0) entity:Fire("addoutput","renderfx 6",4) timer.Simple(4,ivzent,entity) local ed = EffectData() ed:SetEntity(entity) util.Effect( "go_invisible", ed ) entity:GetPhysicsObject():Wake() end end if (SERVER) then hook.Add("EntityTakeDamage", "WhatAGiveAway", TOOL.Reveal) end function TOOL.ToggleShiznit(ply,entity,key) if not entity:IsValid() then return end if entity:GetNetworkedBool("iv01")==true then entity:DrawShadow(true) entity:Fire("addoutput","renderfx 7",0) entity:Fire("addoutput","renderfx 0",5) timer.Simple(5,revis,entity) entity:SetNetworkedBool("iv01",false) entity:GetPhysicsObject():Wake() else entity:Fire("addoutput","renderamt 255",0) local ed = EffectData() ed:SetEntity(entity) util.Effect( "go_invisible", ed ) entity:DrawShadow(false) entity:Fire("addoutput","renderfx 6",0) timer.Simple(6,ivzent,entity) entity:SetNetworkedBool("iv01",true) entity:GetPhysicsObject():Wake() end end if (SERVER) then numpad.Register("Invisible_toggle",TOOL.ToggleShiznit) end function TOOL.BuildCPanel(CPanel) CPanel:AddControl("Numpad", {Label = "Toggle:", ButtonSize = "22", Command = "Invisible_key"}) end