• No fall damage + Damage to self weapon
    1 replies, posted
I found a sword and I want it editted to that the user doesnt take any fall damage, and gets inflicted 1hp per second. Can somebody please help me? [code]if( SERVER ) then AddCSLuaFile( "shared.lua" ); end if( CLIENT ) then SWEP.PrintName = "Flashstep"; SWEP.Slot = 7 SWEP.SlotPos = 8 SWEP.DrawAmmo = false; SWEP.DrawCrosshair = false; end SWEP.Author = "Captain Pip" SWEP.Instructions = "Primary=stab Secondary=firestrike" SWEP.Contact = "www.randomroleplay.com" SWEP.Purpose = "" SWEP.ViewModelFOV = 62 SWEP.ViewModelFlip = false SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.AllowDelete = false -- never removed for weapon reduction SWEP.AllowDrop = false SWEP.NextStrike = 0; SWEP.Base = "weapon_tttbase" SWEP.ViewModel = "models/weapons/v_fagot_t.mdl" SWEP.WorldModel = "models/weapons/w_fagot_t.mdl" -------------Primary Fire Attributes---------------------------------------- SWEP.Primary.Delay = 2 --In seconds SWEP.Primary.Recoil = 0 --Gun Kick SWEP.Primary.Damage = 60 --Damage per Bullet SWEP.Primary.NumShots = 1 --Number of shots per one fire SWEP.Primary.Cone = 0 --Bullet Spread SWEP.Primary.ClipSize = -1 --Use "-1 if there are no clips" SWEP.Primary.DefaultClip = -1 --Number of shots in next clip SWEP.Primary.Automatic = true --Pistol fire (false) or SMG fire (true) SWEP.Primary.Ammo = "none" --Ammo Type -------------Secondary Fire Attributes------------------------------------- SWEP.Secondary.Delay = 2 SWEP.Secondary.Recoil = 0 SWEP.Secondary.Damage = 0 SWEP.Secondary.NumShots = 1 SWEP.Secondary.Cone = 0 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" util.PrecacheSound("weapons/knife/knife_deploy1.wav") util.PrecacheSound("weapons/knife/knife_hitwall1.wav") util.PrecacheSound("weapons/knife/knife_hit1.wav") util.PrecacheSound("weapons/knife/knife_hit2.wav") util.PrecacheSound("weapons/knife/knife_hit3.wav") util.PrecacheSound("weapons/knife/knife_hit4.wav") util.PrecacheSound("weapons/iceaxe/iceaxe_swing1.wav") function SWEP:Think() -- Called every frame if ( !self.Owner:KeyDown( IN_JUMP ) ) then return end local trace = {} local vStart = self.Owner:GetPos() trace.start = vStart trace.endpos = vStart - Vector(0,0,20) trace.filter = self.Owner local tr1 = util.TraceLine( trace ) if(!tr1.Hit) then return end if SERVER then self.Owner:SetVelocity( self.Owner:GetAimVector() * 500 ) end end function SWEP:Initialize() if( SERVER ) then self:SetWeaponHoldType( "melee" ); end self.Hit = { Sound( "weapons/knife/knife_hitwall1.wav" )}; self.FleshHit = { Sound( "weapons/knife/knife_hit1.wav" ), Sound( "weapons/knife/knife_hit2.wav" ), Sound( "weapons/knife/knife_hit3.wav" ), Sound( "weapons/knife/knife_hit4.wav" ) }; end function SWEP:Deploy() self.Owner.ShouldReduceFallDamage = true return true end function SWEP:Precache() end function SWEP:Deploy() self.Owner:EmitSound( "weapons/knife/knife_deploy1.wav" ); return true; end function SWEP:PrimaryAttack() if( CurTime() < self.NextStrike ) then return; end self.NextStrike = ( CurTime() + .5 ); local trace = self.Owner:GetEyeTrace(); if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then if( trace.Entity:IsPlayer() or trace.Entity:IsNPC() or trace.Entity:GetClass()=="prop_ragdoll" ) then self.Owner:EmitSound( self.FleshHit[math.random(1,#self.FleshHit)] ); else self.Owner:EmitSound( self.Hit[math.random(1,#self.Hit)] ); end self.Owner:SetAnimation( PLAYER_ATTACK1 ); self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER ); bullet = {} bullet.Num = 1 bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector(0, 0, 0) bullet.Tracer = 0 bullet.Force = 1 bullet.Damage = 25 self.Owner:FireBullets(bullet) else self.Owner:SetAnimation( PLAYER_ATTACK1 ); self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER ); self.Weapon:EmitSound("weapons/iceaxe/iceaxe_swing1.wav") end end function SWEP:SecondaryAttack() local trace = self.Owner:GetEyeTrace() trace.endpos = self.Owner:GetPos() + (self.Owner:GetAimVector() * dist) if trace.HitNonWorld then util.BlastDamage(self.Owner, self.Owner, trace.HitPos, 1, 25) end self.Owner:SetPos(trace.endpos + Vector(0,0,150)) self.Weapon:EmitSound("weapons/airboat/airboat_gun_energy1.wav") self.Weapon:SetNextSecondaryFire(CurTime() + 2) self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER ) end[/code]
In the SWEP:Deploy() function you should start a timer for every second and remove one health every time it runs. You should also look into EntityTakeDamage and if the players' active weapon is this sword the set the damage to 0.
Sorry, you need to Log In to post a reply to this thread.