• TTT - Stalker Knife - Lua Help -
    4 replies, posted
Making a knife that cloaks / gives speed to the player when they equip it, or have it out. Issue - It only does 50 damage, and it will deal 50 damage, but no more then 50 to a player, so it doesn't kill them. - It also swings fast, even though the delay is 1.1. I took the code from the TTT knife, edited and it just wouldn't give the weapon to you. I changed it to the crowbar and just renamed the model to knife, but it didn't do damage. Replaced primary fire of crowbar with primary fire of knife, and it works, swings super fast but doesn't kill. What's wrong? [CODE]if SERVER then AddCSLuaFile( "shared.lua" ) end SWEP.HoldType = "knife" if CLIENT then SWEP.PrintName = "Stalker Knife" SWEP.Slot = 6 SWEP.ViewModelFlip = false SWEP.EquipMenuData = { type = "item_weapon", desc = "A knife that cloaks you and makes you run faster" }; SWEP.Icon = "VGUI/ttt/icon_knife" end SWEP.Base = "weapon_tttbase" SWEP.ViewModel = "models/weapons/v_knife_t.mdl" SWEP.WorldModel = "models/weapons/w_knife_t.mdl" SWEP.DrawCrosshair = false SWEP.Primary.Damage = 50 SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = true SWEP.Primary.Delay = 1.1 SWEP.Primary.Ammo = "none" SWEP.Kind = WEAPON_EQUIP SWEP.CanBuy = {ROLE_TRAITOR} -- only traitors can buy SWEP.LimitedStock = true -- only buyable once SWEP.WeaponID = AMMO_STALKER SWEP.IsSilent = true SWEP.DeploySpeed = 2 SWEP.Kind = WEAPON_EQUIP SWEP.NoSights = true SWEP.AutoSpawnable = false SWEP.AllowDelete = false -- never removed for weapon reduction SWEP.AllowDrop = false function SWEP:PrimaryAttack() self.Owner:LagCompensation(true) local spos = self.Owner:GetShootPos() local sdest = spos + (self.Owner:GetAimVector() * 70) local kmins = Vector(1,1,1) * -10 local kmaxs = Vector(1,1,1) * 10 local tr = util.TraceHull({start=spos, endpos=sdest, filter=self.Owner, mask=MASK_SHOT_HULL, mins=kmins, maxs=kmaxs}) -- Hull might hit environment stuff that line does not hit if not IsValid(tr.Entity) then tr = util.TraceLine({start=spos, endpos=sdest, filter=self.Owner, mask=MASK_SHOT_HULL}) end local hitEnt = tr.Entity -- effects if IsValid(hitEnt) then self.Weapon:SendWeaponAnim( ACT_VM_HITCENTER ) local edata = EffectData() edata:SetStart(spos) edata:SetOrigin(tr.HitPos) edata:SetNormal(tr.Normal) edata:SetEntity(hitEnt) if hitEnt:IsPlayer() or hitEnt:GetClass() == "prop_ragdoll" then util.Effect("BloodImpact", edata) end else self.Weapon:SendWeaponAnim( ACT_VM_MISSCENTER ) end if SERVER then self.Owner:SetAnimation( PLAYER_ATTACK1 ) end if SERVER and tr.Hit and tr.HitNonWorld and IsValid(hitEnt) then if hitEnt:IsPlayer() then -- knife damage is never karma'd, so don't need to take that into -- account we do want to avoid rounding error strangeness caused by -- other damage scaling, causing a death when we don't expect one, so -- when the target's health is close to kill-point we just kill if hitEnt:Health() < (self.Primary.Damage + 10) then self:StabKill(tr, spos, sdest) else local dmg = DamageInfo() dmg:SetDamage(self.Primary.Damage) dmg:SetAttacker(self.Owner) dmg:SetInflictor(self.Weapon or self) dmg:SetDamageForce(self.Owner:GetAimVector() * 5) dmg:SetDamagePosition(self.Owner:GetPos()) dmg:SetDamageType(DMG_SLASH) hitEnt:DispatchTraceAttack(dmg, spos + (self.Owner:GetAimVector() * 3), sdest) end end end self.Owner:LagCompensation(false) end function SWEP:Equip() self.SetWalkSpeed(1500) self.SetRunSpeed(1500) end[/CODE]
If you're copying directly from the TTT knife you need to change these values to make it one hit. [B]entities/weapons/weapon_ttt_knife/shared.lua:[/B] [lua] SWEP.Primary.Damage = 999 [/lua] [B]entities/entities/ttt_knife_proj/shared.lua:[/B] [lua] ENT.Damage = 999 [/lua]
I don't want it to one hit. It can damage a player to 50 hp, but it doesn't damage them any lower, like their HP is stuck at 50 and it won't do any more damage.
[QUOTE=Fscreams;40933155]I don't want it to one hit. It can damage a player to 50 hp, but it doesn't damage them any lower, like their HP is stuck at 50 and it won't do any more damage.[/QUOTE] What you posted doesn't even look like the full knife weapon file anyway.
It isn't. I cut out the throwing part.
Sorry, you need to Log In to post a reply to this thread.