Need Help, trying to make SWEP not take fall damage when equipped. (TTT)

Hello! So, this new weapon I’m trying to get is a Spider-man Gun to work the way I want it to. But it won’t. I’m trying to get it so when it’s equipped, it negates fall damage. I’m also new to coding. Please help if you can.



SWEP.Author			= "-----------"

SWEP.Contact		= "-------------"

SWEP.Purpose		= "Allows you to swing all over the place like!"

SWEP.Instructions	= "Left click to shot web"



SWEP.Spawnable			= true

SWEP.AdminSpawnable		= true



SWEP.PrintName			= "Spiderman's Gun"			

SWEP.Slot				= 6

SWEP.SlotPos			= 0

SWEP.DrawAmmo			= false

SWEP.DrawCrosshair		= false

SWEP.ViewModel			= "models/weapons/v_pistol.mdl"

SWEP.WorldModel			= "models/weapons/w_pistol.mdl"



SWEP.Base = "weapon_tttbase"

SWEP.Kind = WEAPON_EQUIP1

SWEP.AmmoEnt = "item_ammo_pistol_ttt"

SWEP.CanBuy = { ROLE_DETECTIVE }

SWEP.EquipMenuData = {

	type = "Weapon",

	desc = "Spider Gun"

};

SWEP.InLoadoutFor = nil

SWEP.AutoSpawnable = false

SWEP.AllowDrop = true

SWEP.IsSilent = false

SWEP.NoSights = false

SWEP.Icon = "vgui/ttt/icon_spider"

if SERVER then

	resource.AddFile("materials/vgui/ttt/icon_spider.vmt")

end



function SWEP:Initialize()



	nextshottime = CurTime()

	self:SetWeaponHoldType( "pistol" )

	

end



function SWEP:Think()



	if (!self.Owner || self.Owner == NULL) then return end

	

	if ( self.Owner:KeyPressed( IN_ATTACK ) ) then

	

		self:StartAttack()

		

	elseif ( self.Owner:KeyDown( IN_ATTACK ) && inRange ) then

	

		self:UpdateAttack()

		

	elseif ( self.Owner:KeyReleased( IN_ATTACK ) && inRange ) then

	

		self:EndAttack( true )

	

	end

	

	if ( self.Owner:KeyPressed( IN_ATTACK2 ) ) then

	

		self:Attack2()

		

	end



end



function SWEP:DoTrace( endpos )

	local trace = {}

		trace.start = self.Owner:GetShootPos()

		trace.endpos = trace.start + (self.Owner:GetAimVector() * 14096)

		if(endpos) then trace.endpos = (endpos - self.Tr.HitNormal * 7) end

		trace.filter = { self.Owner, self.Weapon }

		

	self.Tr = nil

	self.Tr = util.TraceLine( trace )

end



function SWEP:StartAttack()

	local gunPos = self.Owner:GetShootPos()

	local disTrace = self.Owner:GetEyeTrace()

	local hitPos = disTrace.HitPos

	

	local x = (gunPos.x - hitPos.x)^2;

	local y = (gunPos.y - hitPos.y)^2;

	local z = (gunPos.z - hitPos.z)^2;

	local distance = math.sqrt(x + y + z);

	

	local distanceCvar = GetConVarNumber("rope_distance")

	inRange = false

	if distance <= distanceCvar then

		inRange = true

	end

	

	if inRange then

		if (SERVER) then

			

			if (!self.Beam) then

				self.Beam = ents.Create( "rope" )

					self.Beam:SetPos( self.Owner:GetShootPos() )

				self.Beam:Spawn()

			end

			

			self.Beam:SetParent( self.Owner )

			self.Beam:SetOwner( self.Owner )

		

		end

		

		self:DoTrace()

		self.speed = 10000

		self.startTime = CurTime()

		self.endTime = CurTime() + self.speed

		self._dt = -1

		

		if (SERVER && self.Beam) then

			self.Beam:GetTable():SetEndPos( self.Tr.HitPos )

		end

		

		self:UpdateAttack()

		

	else

	end

end



function SWEP:UpdateAttack()



	self.Owner:LagCompensation( true )

	

	if (!endpos) then endpos = self.Tr.HitPos end

	

	if (SERVER && self.Beam) then

		self.Beam:GetTable():SetEndPos( endpos )

	end



	lastpos = endpos

	

	

			if ( self.Tr.Entity:IsValid() ) then

			

					endpos = self.Tr.Entity:GetPos()

					if ( SERVER ) then

					self.Beam:GetTable():SetEndPos( endpos )

					end

			

			end

			

			local vVel = (endpos - self.Owner:GetPos())

			local Distance = endpos:Distance(self.Owner:GetPos())

			

			local et = (self.startTime + (Distance/self.speed))

			if(self._dt != 0) then

				self._dt = (et - CurTime()) / (et - self.startTime)

			end

			if(self._dt < 0) then

				self._dt = 0

			end

			

			if(self._dt == 0) then

			zVel = self.Owner:GetVelocity().z

			vVel = vVel:GetNormalized()*(math.Clamp(Distance,0,7))

				if( SERVER ) then

				local gravity = GetConVarNumber("sv_Gravity")

				vVel:Add(Vector(0,0,(gravity/100)*1.5))

				if(zVel < 0) then

					vVel:Sub(Vector(0,0,zVel/100))

				end

				self.Owner:SetVelocity(vVel)

				end

			end

	

	endpos = nil

	

	self.Owner:LagCompensation( false )

	

end



function SWEP:EndAttack( shutdownsound )

	

	if ( CLIENT ) then return end

	if ( !self.Beam ) then return end

	

	self.Beam:Remove()

	self.Beam = nil

	

end


function SWEP:Attack2()

			



	if (CLIENT) then return end

		local CF = self.Owner:GetFOV()

		if CF == 90 then

			self.Owner:SetFOV(30,.3)

		elseif CF == 30 then

			self.Owner:SetFOV(90,.3)

	end

end



function SWEP:Holster()

	self:EndAttack( false )

	return true

end



function SWEP:OnRemove()

	self:EndAttack( false )

	return true

end





function SWEP:PrimaryAttack()

end



function SWEP:SecondaryAttack()

end


It has a couple problems. 1, it’s a leftie based weapon. So it’s in the wrong hand. And 2, when equipped and you fall, you still take damage.

I looked at this thread http://forum.facepunch.com/showthread.php?t=1421372 but, I still had trouble. I tried inserting this


hook.Add( "GetFallDamage", "SwepRemovesFallDamage", function( _p, _fallspeed )
	if ( !IsValid( _p ) ) then return; end

	// Make sure the weapon is valid, and that it is a swep
	local _w = _p:GetActiveWeapon( );
	if ( !IsValid( _w ) || !_w.Clip1 ) then return; end

	// Make sure the swep table exists..
	local _tab = _w:GetTable( );
	if ( !istable( _tab ) ) then return; end

	// Now, if SWEP.KillFallDamagePERK = true; then we have 0 fall damage.
	if ( _tab.KillFallDamagePERK ) then
		return 0;
	end
end );

into it at the bottom or somewhere in the middle but the swep didn’t even show in the detective menu when I put that in. Is there anyone who can help?

Welp, still no help received…

Try changing WEAPON_EQUIP1 to WEAPON_EQUIP, add


SWEP.KillFallDamagePERK = true

and add


SWEP.ViewModelFlip		= true

https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index5fc8.html Taking a look at this might help you.