• How to change melee weapon damage
    3 replies, posted
Recently, I added the melee sweps adodn to my server. https://steamcommunity.com/sharedfiles/filedetails/?id=369150821&searchtext=Melee+weapon+pack So, I am running a murder server. As you know, the knife you spawn with as the murderer is an instant kill. I've managed to figure out how to swap out the default knife with a custom knife from pointshop 2, however, I still haven't been able to find out how to change the weapon's damage. So, I extracted the addon and added all the folders to my server, and deleted the addon off my collection. The weapons still appear in-game fully modeled, so I know it worked. I tried changing the base damage in the shared.lua file of the "Meat Cleaver" weapon. if (SERVER) then AddCSLuaFile( "shared.lua" ) SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false local ActIndex = {} ActIndex[ "knife" ] = ACT_HL2MP_IDLE_KNIFE function SWEP:SetWeaponHoldType( t ) local index = ActIndex[ t ] if (index == nil) then return end self.ActivityTranslate = {} self.ActivityTranslate [ ACT_HL2MP_IDLE ] = index self.ActivityTranslate [ ACT_HL2MP_WALK ] = index + 1 self.ActivityTranslate [ ACT_HL2MP_RUN ] = index + 2 self.ActivityTranslate [ ACT_HL2MP_IDLE_CROUCH ] = index + 3 self.ActivityTranslate [ ACT_HL2MP_WALK_CROUCH ] = index + 4 self.ActivityTranslate [ ACT_HL2MP_GESTURE_RANGE_ATTACK ] = index + 5 self.ActivityTranslate [ ACT_HL2MP_GESTURE_RELOAD ] = index + 6 self.ActivityTranslate [ ACT_HL2MP_JUMP ] = index + 7 self.ActivityTranslate [ ACT_RANGE_ATTACK1 ] = index + 8 self:SetupWeaponHoldTypeForAI( t ) end end if ( CLIENT ) then SWEP.PrintName = "Meat Cleaver" SWEP.DrawAmmo = false SWEP.DrawCrosshair = false SWEP.ViewModelFOV = 60 SWEP.ViewModelFlip = false SWEP.CSMuzzleFlashes = false SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.IconLetter = "j" killicon.AddFont("ptp_cs_knife", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 )) surface.CreateFont("CSKillIcons", {font = "csd", size = ScreenScale(30), weight = 500, antialias = true, additive = true}) surface.CreateFont("CSSelectIcons", {font = "csd", size = ScreenScale(60), weight = 500, antialias = true, additive = true}) end SWEP.Category = "Melee Pack" SWEP.HoldType = "knife" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.ViewModel = "models/weapons/v_cleaver_t.mdl" SWEP.WorldModel = "models/weapons/w_cleaver_t.mdl"  SWEP.UseHands = true SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.Primary.ClipSize = -1 SWEP.Primary.Damage = 500 SWEP.Primary.DefaultClip = -1 SWEP.Primary.Automatic = true SWEP.Primary.Ammo ="none" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Damage = 500 SWEP.Secondary.Automatic = false SWEP.MissSound = Sound("weapons/knife/knife_slash1.wav") SWEP.WallSound = Sound("weapons/knife/knife_hitwall1.wav") SWEP.DeploySound = Sound("weapons/knife/knife_deploy1.wav") /*--------------------------------------------------------- Think ---------------------------------------------------------*/ function SWEP:Think() end /*--------------------------------------------------------- Initialize ---------------------------------------------------------*/ function SWEP:Initialize()  self:SetWeaponHoldType( self.HoldType )  util.PrecacheSound("weapons/iceaxe/iceaxe_swing1.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")    end  /*--------------------------------------------------------- Deploy ---------------------------------------------------------*/ function SWEP:Deploy() self.Weapon:SendWeaponAnim( ACT_VM_DRAW ) self.Weapon:SetNextPrimaryFire(CurTime() + 1) self.Weapon:EmitSound( self.DeploySound, 50, 100 ) return true end /*--------------------------------------------------------- PrimaryAttack ---------------------------------------------------------*/ function SWEP:PrimaryAttack() local tr = {} tr.start = self.Owner:GetShootPos() tr.endpos = self.Owner:GetShootPos() + ( self.Owner:GetAimVector() * 50 ) tr.filter = self.Owner tr.mask = MASK_SHOT local trace = util.TraceLine( tr ) self.Weapon:SetNextPrimaryFire(CurTime() + 0.5) self.Owner:SetAnimation( PLAYER_ATTACK1 ) if ( trace.Hit ) then if trace.Entity:IsPlayer() or string.find(trace.Entity:GetClass(),"npc") or string.find(trace.Entity:GetClass(),"prop_ragdoll") then self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER) 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 = 500 self.Owner:FireBullets(bullet)  self.Weapon:EmitSound( "weapons/knife/knife_hit" .. math.random(1, 4) .. ".wav" ) else self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER) 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 = 500 self.Owner:FireBullets(bullet)  self.Weapon:EmitSound( self.WallSound ) util.Decal("ManhackCut", trace.HitPos + trace.HitNormal, trace.HitPos - trace.HitNormal) end else self.Weapon:EmitSound(self.MissSound,100,math.random(90,120)) self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER) end end /*--------------------------------------------------------- Reload ---------------------------------------------------------*/ function SWEP:SecondaryAttack() end /*--------------------------------------------------------- Reload ---------------------------------------------------------*/ function SWEP:Reload() return false end /*--------------------------------------------------------- OnRemove ---------------------------------------------------------*/ function SWEP:OnRemove() return true end /*--------------------------------------------------------- Holster ---------------------------------------------------------*/ function SWEP:Holster() return true end /*--------------------------------------------------------- ShootEffects ---------------------------------------------------------*/ function SWEP:ShootEffects() end local IRONSIGHT_TIME = 0.15 /*--------------------------------------------------------- DrawWeaponSelection ---------------------------------------------------------*/ function SWEP:DrawWeaponSelection(x, y, wide, tall, alpha) draw.SimpleText(self.IconLetter, "CSSelectIcons", x + wide / 2, y + tall * 0.2, Color(255, 210, 0, 255), TEXT_ALIGN_CENTER) -- Draw a CS:S select icon end /*--------------------------------------------------------- DrawHUD Just a rough mock up showing how to draw your own crosshair. ---------------------------------------------------------*/ function SWEP:DrawHUD() local x, y // If we're drawing the local player, draw the crosshair where they're aiming, // instead of in the center of the screen. if ( self.Owner == LocalPlayer() && self.Owner:ShouldDrawLocalPlayer() ) then local tr = util.GetPlayerTrace( self.Owner ) tr.mask = bit.bor( CONTENTS_SOLID,CONTENTS_MOVEABLE,CONTENTS_MONSTER,CONTENTS_WINDOW,CONTENTS_DEBRIS,CONTENTS_GRATE,CONTENTS_AUX ) local trace = util.TraceLine( tr ) local coords = trace.HitPos:ToScreen() x, y = coords.x, coords.y else x, y = ScrW() / 2.0, ScrH() / 2.0 end local scale = 1  // Scale the size of the crosshair according to how long ago we fired our weapon local LastShootTime = self.Weapon:GetNetworkedFloat( "LastShootTime", 0 ) scale = scale * (2 - math.Clamp( (CurTime() - LastShootTime) * 5, 0.0, 1.0 )) surface.SetDrawColor( 0, 255, 0, 255 ) // Draw an awesome crosshair local gap = scale local length = gap + 6 * scale surface.DrawLine( x - length, y, x - gap, y ) surface.DrawLine( x + length, y, x + gap, y ) surface.DrawLine( x, y - length, x, y - gap ) surface.DrawLine( x, y + length, x, y + gap ) end As you can see, under damage the value is changed to 500. But, this did not do anything! The cleaver still takes 3 hits to kill. Did I change the wrong value? Or am I trying to change the value in the wrong place? Please let me know. If you were wondering, here are the paths for the basic files: https://i.gyazo.com/3fbbc5b6dcd7c4a63074057b8b94b264.png https://i.gyazo.com/ad9da74abe03a5c97fc60b4e7a53ccac.png https://i.gyazo.com/bd865715a4f61a5e0ad0d0c7b2778532.png
It all seems fine to me but someone else may be able to find something. If you haven't already, do a map change or just restart your server.
Thank you, I already tried restarting the server, but I never thought that changing the map would make it work! Thanks!
No worries buddy. Map changes usually initialize a lua refresh, which... Is pretty self explanatory. Glad I could help <3
Sorry, you need to Log In to post a reply to this thread.