AddCSLuaFile("hands.lua") SWEP.ViewModel = ""--"models/error.mdl" SWEP.WorldModel = ""--"models/error.mdl" SWEP.HoldType = "normal" SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "none" SWEP.Secondary.Clipsize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.DrawAmmo = false SWEP.DrawCrosshair = false function SWEP:Initialize() self:SetWeaponHoldType(self.HoldType) self:DrawShadow(false) self:SetNoDraw(true) --[[ if (CLIENT) then self.MOB = ClientsideModel("error.mdl") self.MOB:SetNoDraw(true) self.MOB:DrawShadow(false) end ]] end SWEP.Pickup = nil SWEP.PickupAngles = Angle(0,0,0) SWEP.PickupOffset = 100 local buildzones = { ["artery_shipyard"] = true, } function SWEP:DefaultPickup() print("Default pickup fired, self.pickup is", self.Pickup) local zc = self.Owner:GetCurrentZone() local building = zc != nil and buildzones[zc] != nil if self.Pickup == nil then local tr = self.Owner:GetEyeTrace() local dist = self.Owner:GetPos():Distance(tr.HitPos) local mass = -1 pcall(function() mass = tr.Entity:GetPhysicsObject():GetMass() end,function() print("Failed to get mass") end) if building or (dist < 100 and mass != -1 and mass < 400) then self.OldMass = mass self.Pickup = tr.Entity self.PickupAngles = tr.Entity:GetAngles() - self.Owner:EyeAngles() self.PickupOffset = dist tr.Entity:GetPhysicsObject():SetMass(3) tr.Entity:GetPhysicsObject():EnableCollisions(false) else print("dist is:" ,dist) if tr.Entity.GetMass then print("Mass is", tr.Entity:GetMass()) else print("Ent does not have mass!", mass) end print("Could not pick that up") end else if IsValid(self.Pickup) and zc != nil and buildzones[zc.class] then --self.Pickup:GetPhysicsObject():EnableMotion(false) end self.Pickup:GetPhysicsObject():SetMass(self.OldMass) self.Pickup:GetPhysicsObject():EnableCollisions(true) self.Pickup = nil end end function SWEP:Tick() if self.Pickup ~= nil and IsValid(self.Pickup) then local crouchadd if self.Owner:Crouching() then crouchadd = Vector(0,0,32) else crouchadd = Vector(0,0,64) end local targetpos = (self.Owner:EyeAngles():Forward() * self.PickupOffset * 2) + self.Owner:GetPos() + crouchadd local targetang = self.Owner:EyeAngles() + self.PickupAngles --Check if we're inside a build zone local zc = self.Owner:GetCurrentZone() if zc != nil and zc.class == "artery_shipyard" then self.Pickup:SetPos(targetpos) self.Pickup:SetAngles(targetang) else --Set position local pow = 100 local deltavel = targetpos - (self.Pickup:GetPos() + (self.Pickup:GetVelocity() / pow)) local vlim = 100000 local clampvel = Vector(math.Clamp(deltavel.x,-vlim,vlim),math.Clamp(deltavel.y,-vlim,vlim),math.Clamp(deltavel.z,-vlim,vlim)) local speed = 20 self.Pickup:GetPhysicsObject():SetVelocity(clampvel * speed) --Set angles local angvel = self.Pickup:GetAngles() - targetang local deltaang = self.Pickup:GetPhysicsObject():GetAngleVelocity() - angvel:Forward() self.Pickup:SetAngles(targetang) --self.Pickup:GetPhysicsObject():AddAngleVelocity(angvel:Forward()) end end end function SWEP:ShouldDropOnDie() return false end function SWEP:PrimaryAttack() if CLIENT then return end --Make sure we have an equipment inventory if not self.Owner then return end if not self.Owner.data then return end if not self.Owner.data.inventories then return end if not self.Owner.data.inventories[1] then return end local eqpd = self.Owner.data.inventories[1] --Get the weapon we want to fire, and fire it! local weapon = eqpd:Get({"Left Hand"}) or eqpd:Get({"Dual"}) if not weapon then self:DefaultPickup() elseif weapon.onClick ~= nil then weapon:onClick(self.Owner) end --Make sure we have a weapon end function SWEP:SecondaryAttack() if CLIENT then return end --Make sure we have an equipment inventory if not self.Owner then return end if not self.Owner.data then return end if not self.Owner.data.inventories then return end if not self.Owner.data.inventories[1] then return end local eqpd = self.Owner.data.inventories[1] --Get the weapon we want to fire, and fire it! local weapon = eqpd:Get({"Right Hand"}) or eqpd:Get({"Dual"}) if not weapon then self:DefaultPickup() elseif weapon.onClick ~= nil then weapon:onClick(self.Owner) end --Make sure we have a weapon end hook.Add("PlayerSpawn","give_hands",function(ply) ply:Give("hands") end)