• Weapon viewmodel animation
    6 replies, posted
I have a melee SWEP using the crowbar model, and I want it to swing when the user attacks. The world model swings fine, but the first person viewmodel doesn't budge. This is the code I use for both: [lua]self.Owner:SetAnimation( PLAYER_ATTACK1 ) self.Weapon:SendWeaponAnim( ACT_VM_SWINGMISS )[/lua]
Is line 2 on the client?
Yes
2nd line should be in shared.lua.
It was, but it was after a check to make sure it was the server that was executing it. This is the primary attack function now: [lua]function SWEP:PrimaryAttack() if CurTime() > self.NextHit then self.Weapon:EmitSound( "Weapon_Crowbar.Single" ) self.Owner:SetAnimation( PLAYER_ATTACK1 ) self.Weapon:SendWeaponAnim( ACT_VM_SWINGMISS ) if !SERVER then return end local trace = self.Owner:GetEyeTrace(); if trace.HitPos:Distance( self.Owner:GetShootPos() ) <= 48 then if string.sub( trace.Entity:GetClass(), 1, 4 ) == "krp_" then local cash = ply_getVal( self.Owner, 2 ) - 50 if trace.Entity:GetEntHealth() != 0 and trace.Entity:GetEntHealth() != trace.Entity:GetEntMaxHealth() and cash >= 0 then self.Owner:EmitSound( "ItemBattery.Touch" ); trace.Entity:SetEntHealth( trace.Entity:GetEntHealth() + 20 ) ply_setVal( self.Owner, 2, cash ) elseif cash < 0 then self.Owner:PrintMessage( HUD_PRINTTALK, "Not enough money!" ) end end end self.NextHit = CurTime() + .75 end end[/lua]
I still have this problem.
I've seen custom melee sweps use the crowbar or stunstick, so this must be possible.
Sorry, you need to Log In to post a reply to this thread.