• Swep not firing silenced anims
    3 replies, posted
Ok, I'm trying to make this swep permanently silenced, and its made some progress, but the deploy animations are bugged and the firing animations arent running at all. Here's my code, what do I have to do to run the animation correctly ? Please help me lol. [lua] if ( SERVER ) then AddCSLuaFile( "shared.lua" ) SWEP.HoldType = "pistol" end if ( CLIENT ) then SWEP.PrintName = "USP" SWEP.Author = "Stretch" SWEP.Slot = 1 SWEP.SlotPos = 1 SWEP.IconLetter = "a" killicon.AddFont( "garrysfield_usp", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) ) end SWEP.Base = "garrysfield_base" SWEP.Category = "GarrysField 2" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false SWEP.ViewModel = "models/weapons/v_pist_usp.mdl" SWEP.WorldModel = "models/weapons/w_pist_usp.mdl" SWEP.Primary.Sound = Sound("Weapon_USP.SilencedShot") SWEP.Primary.Damage = 20 SWEP.Primary.Recoil = 1 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.0155 SWEP.Primary.ClipSize = 12 SWEP.Primary.Delay = 0.16 SWEP.Primary.DefaultClip = 12 SWEP.Primary.Automatic = false SWEP.Primary.Ammo = "pistol" SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.IronSightsPos = Vector( 5.15, -2, 2.6 ) function SWEP:Think() self.Weapon:SendWeaponAnim(ACT_VM_IDLE_SILENCED) self:IronSight() end function SWEP:Deploy() self.Weapon:SendWeaponAnim(ACT_VM_DRAW_SILENCED) self.Reloadaftershoot = CurTime() + 1 self:SetIronsights(false) self.Weapon:SetNextPrimaryFire(CurTime() + 1) return true end function SWEP:Reload() if ( self.Reloadaftershoot > CurTime() ) then return end self.Weapon:DefaultReload(ACT_VM_RELOAD_SILENCED) if ( self.Weapon:Clip1() < self.Primary.ClipSize ) and self.Owner:GetAmmoCount(self.Primary.Ammo) > 0 then self.Owner:SetFOV( 0, 0.15 ) self:SetIronsights(false) end end function SWEP:PrimaryAttack() if not self:CanPrimaryAttack() or self.Owner:WaterLevel() > 2 then return end self.Reloadaftershoot = CurTime() + self.Primary.Delay self.Weapon:SetNextSecondaryFire(CurTime() + self.Primary.Delay) self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) self.Weapon:EmitSound(self.Primary.Sound) self:RecoilPower() self:TakePrimaryAmmo(1) if ((SinglePlayer() and SERVER) or CLIENT) then self.Weapon:SetNetworkedFloat("LastShootTime", CurTime()) end end function SWEP:CSShootBullet(dmg, recoil, numbul, cone) numbul = numbul or 1 cone = cone or 0.01 local bullet = {} bullet.Num = numbul bullet.Src = self.Owner:GetShootPos() -- Source bullet.Dir = self.Owner:GetAimVector() -- Dir of bullet bullet.Spread = Vector(cone, cone, 0) -- Aim Cone bullet.Tracer = 1 -- Show a tracer on every x bullets bullet.Force = 0.5 * dmg -- Amount of force to give to phys objects bullet.Damage = dmg -- Amount of damage to give to the bullets self.Owner:FireBullets(bullet) -- Fire the bullets self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK_SILENCED) -- View model animation self.Owner:MuzzleFlash() -- Crappy muzzle light self.Owner:SetAnimation(PLAYER_ATTACK1) -- 3rd Person Animation if ((SinglePlayer() and SERVER) or (not SinglePlayer() and CLIENT)) then local eyeang = self.Owner:EyeAngles() eyeang.pitch = eyeang.pitch - recoil self.Owner:SetEyeAngles(eyeang) end end [/lua]
anyone? have any ideas?
The problem is because of your code in SWEP:Think(). It's resetting the weapon's animation dozens of times per second. That's not how you want to make it use the silenced idle animation - it should do that automatically if you make it deploy, fire, or reload silenced. Also, it's probably a bad idea to make it run IronSight() on itself that many times. Just remove SWEP:Think() or comment it out with a multi-line comment (--[[ commented code ]] ) and the animations should work perfectly.
Hi, I am Andres Kramack from [url]http://www.cathybarryadultstore.com/[/url]. It's a 'pleasure' serving the public if you know what I mean and this message is Here at Cathy Barry Adult Store, we offer a wide variety of dildos that come in all sizes from goblin-sized dicks to black-man draconic dicks. I know at Facepunch everyone loves good old dicks which is why [B]I[/B] personally offer anyone with an association with Facepunch Forums a 50% discount code "DIL4FACEPUNCH". Don't forget, this offer lasts until the next Garry's Mod update which we so much love. Here are pictures of our products just for you! [IMG]http://pic.esmatube.com/imgs/a/g/t/x/x/giant_dildo_in_my_ass_part_ii-3_tmb.jpg[/IMG] [IMG]http://pic.esmatube.com/imgs/a/d/d/h/r/bbw_giant_dildo_squat_25cm_round-3_tmb.jpg[/IMG] [IMG]http://xxxdessert.com/tube/contents/videos_screenshots/15000/15261/preview.mp4.jpg[/IMG] [IMG]http://g04.a.alicdn.com/kf/HTB1JlHlIpXXXXaJXVXXq6xXFXXXo/Silicone-Huge-Dildos-Vibrator-for-woman-shake-Horse-Dildos-penis-swith-sucker-african-Dong-dildos.jpg[/IMG] Sponsored Images: [IMG]http://45.media.tumblr.com/f81f8d61fa253dc804edb423c8ab149f/tumblr_mfbk96QAug1rvbfkuo1_500.gif[/IMG] [IMG]http://49.media.tumblr.com/9110819111aa37acf4cd1c9d5341dd97/tumblr_nc4hqkdESo1skwv6ko1_500.gif[/IMG] [IMG]http://1.bp.blogspot.com/-gueWbSnnsIc/UUtenyLS0oI/AAAAAAAANF4/L4aZnTrMaqs/s1600/dermatologists-hate-her.jpg[/IMG] [IMG]http://static.fjcdn.com/pictures/Gym+leaders+hate+him_ab471d_5017861.jpg[/IMG] [IMG]https://static.fjcdn.com/comments/That+one+with+the+lamp+got+me+_e68beb19422eea14289caa5f4d6dffb7.jpg[/IMG] Got any questions? Visit my Steam Profile! [url]http://steamcommunity.com/id/Robotboy655[/url]
Sorry, you need to Log In to post a reply to this thread.