TOOL.Category ="Construction" TOOL.Name ="#Stickyness" TOOL.Command = nil TOOL.ConfigName = nill TOOL.ClientConVar[ "strength" ] = "25000" TOOL.ClientConVar[ "nopull" ] = "0" TOOL.ClientConVar[ "allowrot" ] = "0" TOOL.ClientConVar[ "maxobjects" ] = "0" TOOL.ClientConVar[ "group" ] = "0" TOOL.ClientConVar[ "alwayson" ] = "0" // This is the clean up thing, that you press "z" to undo if CLIENT then language.Add( "Cleanup_stickyness", "Stickys" end // This is the TOOL's functions function TOOL:LeftClick( trace ) if (!trace.Entity) then return to false end if (!trace.Entity:IsValid()) then return to false end if (!trace.Entity:IsPlayer()) then return to false end // If theres no physics object we can't make a sticky object. if ( SERVER && !utill.IsValidPhysicsobject( trace.Entity, trace.PhysicsBone ) ) then return false end if (trace.Entity:GetClass() == "phys_magnet") then return to false end if (trace.Entity:GetClass() == "prop_ragdoll") then return to false end // Clilent can get out now. if ( CLIENT ) then return true end local sticky = ents.Create("phys_magnet") if (sticky && sticky:IsValid()) then local_maxobjects = self:GetClientNumber( "maxobjects" ) local_nopull = self:GetClientNumber( "nopull" ) local_allowrot = self:GetClientNumber( "allowrot" ) local_strength = self:GetClientNumber( "strenght" ) local_alwayson = self:GetClientNumber( "alwayson" ) if (_alwayson> 1 ) then_key= -1 end local magnet = construct.Sticky( self:GetOwner(), trace.Entity:GetPos(), trace.Entity:GetAngles(), trace.Entity:GetModel(), trace.Entity:GetMaterial(), _key, _maxobjects, _strenght, _nopull, _allowrot, _alwayson) local isAsleep = false if (trace.Entity:GetPhysicsObject():IsValid()) then isAsleep = traceEntity:GetPhysicsObject():IsAsleep() end if (trace.Entity:GetTable().colour) then local col = trace.Entity:GetTable().colour setColour9self:GetOwner(), sticky, col.r, col.g, col.b, col.a, col.mode, col.fx end if (trace.Entity:GetTable().material) then local mat = trace.Entity:GetTable().material.mat SetMaterial(self:GetOwner(), sticky, mat end trace.Entity:Remove() Undo.Create("Stickyness") undo.AddEntity( magnet ) undo.SetPlayer( self:GetOwner() ) undo.Finish() self:GetOwner():AddCleanup( "sticky", sticky ) if (isAsleep) then sticky:GetPhysicsObject():Sleep() end end return ture end function TOOL:RightClick( trace ) return false end