• Help with Muzzle Flashes
    1 replies, posted
So uh, I'm working on a Silenced SMG that I made using the SWEP Construction Kit. The problem is the muzzle flash appears inside the model for the silencer. Is there a way to be able to move where the muzzle flash appears when shooting? If not, is there at least a way to disable/remove the muzzle flash for the swep? Here's the code I'm using btw: [code] SWEP.PrintName = "SMG" SWEP.Author = "FS_Aaronautics" SWEP.Contact = "" SWEP.Purpose = "" SWEP.Instructions = "" SWEP.Category = "My ARs, SMGs and More!" SWEP.Spawnable= true SWEP.AdminSpawnable= true SWEP.AdminOnly = false SWEP.ViewModelFOV = 50 SWEP.ViewModel = "models/weapons/c_smg1.mdl" SWEP.WorldModel = "models/weapons/w_smg1.mdl" SWEP.ViewModelFlip = false SWEP.AutoSwitchTo = true SWEP.AutoSwitchFrom = true SWEP.Slot = 3 SWEP.SlotPos = 1 SWEP.UseHands = true SWEP.HoldType = "smg" SWEP.FiresUnderwater = true SWEP.DrawCrosshair = false SWEP.DrawAmmo = true SWEP.ReloadSound = "Weapon_SMG1.Reload" SWEP.Base = "weapon_base" SWEP.Primary.Sound = Sound("Weapon_SuppressedSMG1.Single") SWEP.Primary.Damage = 12 SWEP.Primary.TakeAmmo = 1 SWEP.Primary.ClipSize = 45 SWEP.Primary.Ammo = "SMG1" SWEP.Primary.DefaultClip = 45 SWEP.Primary.Spread = 0.1 SWEP.Primary.NumberofShots = 1 SWEP.Primary.Automatic = true SWEP.Primary.Recoil = 0.20 SWEP.Primary.Delay = 0.07 SWEP.Primary.Force = 4 SWEP.Secondary.ClipSize = 0 SWEP.Secondary.DefaultClip = 0 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none" SWEP.WElements = {Hid WElements for personal reasons} SWEP.VElements = {Hid VElements for personal reasons} function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end local bullet = {} bullet.Num = self.Primary.NumberofShots bullet.Src = self.Owner:GetShootPos() bullet.Dir = self.Owner:GetAimVector() bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0) bullet.Tracer = 1 bullet.Force = self.Primary.Force bullet.Damage = self.Primary.Damage bullet.AmmoType = self.Primary.Ammo local rnda = self.Primary.Recoil * -1 local rndb = self.Primary.Recoil * math.random(-1, 1) self:ShootEffects() self.Owner:FireBullets( bullet ) self:EmitSound(Sound(self.Primary.Sound)) self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self:TakePrimaryAmmo(self.Primary.TakeAmmo) self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end function SWEP:SecondaryAttack() end function SWEP:Reload() self:SetIronsights(false) if self.ReloadingTime and CurTime() <= self.ReloadingTime then return end if ( self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then self:DefaultReload( ACT_VM_RELOAD ) local AnimationTime = self.Owner:GetViewModel():SequenceDuration() self.ReloadingTime = CurTime() + AnimationTime self:SetNextPrimaryFire(CurTime() + AnimationTime) self:SetNextSecondaryFire(CurTime() + AnimationTime) self.Weapon:EmitSound("Weapon_SMG1.Reload") end end local IRONSIGHT_TIME = 0.25 function SWEP:GetViewModelPosition( pos, ang ) if ( !self.IronSightsPos ) then return pos, ang end local bIron = self.Weapon:GetNetworkedBool( "Ironsights" ) if ( bIron != self.bLastIron ) then self.bLastIron = bIron self.fIronTime = CurTime() if ( bIron ) then self.SwayScale = 0.3 self.BobScale = 0.1 else self.SwayScale = 1.0 self.BobScale = 1.0 end end local fIronTime = self.fIronTime or 0 if ( !bIron && fIronTime < CurTime() - IRONSIGHT_TIME ) then return pos, ang end local Mul = 1.0 if ( fIronTime > CurTime() - IRONSIGHT_TIME ) then Mul = math.Clamp( (CurTime() - fIronTime) / IRONSIGHT_TIME, 0, 1 ) if (!bIron) then Mul = 1 - Mul end end local Offset = self.IronSightsPos if ( self.IronSightsAng ) then ang = ang * 1 ang:RotateAroundAxis( ang:Right(), self.IronSightsAng.x * Mul ) ang:RotateAroundAxis( ang:Up(), self.IronSightsAng.y * Mul ) ang:RotateAroundAxis( ang:Forward(), self.IronSightsAng.z * Mul ) end local Right = ang:Right() local Up = ang:Up() local Forward = ang:Forward() pos = pos + Offset.x * Right * Mul pos = pos + Offset.y * Forward * Mul pos = pos + Offset.z * Up * Mul return pos, ang end /*--------------------------------------------------------- SetIronsights ---------------------------------------------------------*/ function SWEP:SetIronsights( b ) self.Weapon:SetNetworkedBool( "Ironsights", b ) end SWEP.NextSecondaryAttack = 0 /*--------------------------------------------------------- SecondaryAttack ---------------------------------------------------------*/ function SWEP:SecondaryAttack() if ( !self.IronSightsPos ) then return end if ( self.NextSecondaryAttack > CurTime() ) then return end bIronsights = !self.Weapon:GetNetworkedBool( "Ironsights", false ) self:SetIronsights( bIronsights ) self.NextSecondaryAttack = CurTime() + 0.3 end /*--------------------------------------------------------- onRestore Loaded a saved game (or changelevel) ---------------------------------------------------------*/ function SWEP:OnRestore() self.NextSecondaryAttack = 0 self:SetIronsights( false ) end SWEP.Primary.Cone = 0.02 SWEP.IronSightsPos = Vector(-6.441, -5.428, 1) SWEP.IronSightsAng = Vector(0, 0, 0) /******************************************************** SWEP Construction Kit base code Created by Clavus Available for public use, thread at: facepunch.com/threads/1032378 DESCRIPTION: This script is meant for experienced scripters that KNOW WHAT THEY ARE DOING. Don't come to me with basic Lua questions. Just copy into your SWEP or SWEP base of choice and merge with your own code. The SWEP.VElements, SWEP.WElements and SWEP.ViewModelBoneMods tables are all optional and only have to be visible to the client. ********************************************************/ function SWEP:Initialize() // other initialize code goes here util.PrecacheSound(self.Primary.Sound) util.PrecacheSound(self.ReloadSound) self:SetWeaponHoldType( self.HoldType ) if CLIENT then // Create a new table for every weapon instance self.VElements = table.FullCopy( self.VElements ) self.WElements = table.FullCopy( self.WElements ) self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods ) self:CreateModels(self.VElements) // create viewmodels self:CreateModels(self.WElements) // create worldmodels // init view model bone build function if IsValid(self.Owner) then local vm = self.Owner:GetViewModel() if IsValid(vm) then self:ResetBonePositions(vm) // Init viewmodel visibility if (self.ShowViewModel == nil or self.ShowViewModel) then vm:SetColor(Color(255,255,255,255)) else // we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called vm:SetColor(Color(255,255,255,1)) // ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in // however for some reason the view model resets to render mode 0 every frame so we just apply a debug material to prevent it from drawing vm:SetMaterial("Debug/hsv") end end end end end function SWEP:Holster() if CLIENT and IsValid(self.Owner) then local vm = self.Owner:GetViewModel() if IsValid(vm) then self:ResetBonePositions(vm) end end return true end function SWEP:OnRemove() self:Holster() end if CLIENT then SWEP.vRenderOrder = nil function SWEP:ViewModelDrawn() local vm = self.Owner:GetViewModel() if !IsValid(vm) then return end if (!self.VElements) then return end self:UpdateBonePositions(vm) if (!self.vRenderOrder) then // we build a render order bec
*bump*
Sorry, you need to Log In to post a reply to this thread.