i have found a post that says how to fix this but ive tried it but it dident work here is the thred
[url]http://www.facepunch.com/threads/792189-SWEP-s-Shooting-Sound-Wont-Work?highlight=swep+effects[/url]
code [lua]-- Swep Creator - Bullets N Explosions
// Made By BummieHead
-- Have Fun !
-- Ver 1.0.0
//General Settings \\
SWEP.AdminSpawnable = true // Is the swep spawnable for admin
SWEP.ViewModelFOV = 64 // How much of the weapon do u see ?
SWEP.ViewModel = "models/weapons/v_dc-15.mdl" // The viewModel, the model you se when you are holding it-.-
SWEP.WorldModel = "models/weapons/w_dc-15.mdl" // The worlmodel, The model yu when it's down on the ground
SWEP.AutoSwitchTo = false // when someone walks over the swep, chould i automatectly change to your swep ?
SWEP.Slot = 3 // Deside wich slot you want your swep do be in 1 2 3 4 5 6
SWEP.HoldType = "ar2" // How the swep is hold Pistol smg greanade melee
SWEP.PrintName = "DC-15A" // your sweps name
SWEP.Author = "Jangofett890" // Your name
SWEP.Spawnable = true // Can everybody spawn this swep ? - If you want only admin keep this false and adminsapwnable true.
SWEP.AutoSwitchFrom = false // Does the weapon get changed by other sweps if you pick them up ?
SWEP.FiresUnderwater = false // Does your swep fire under water ?
SWEP.Weight = 5 // Chose the weight of the Swep
SWEP.DrawCrosshair = true // Do you want it to have a crosshair ?
SWEP.Category = "Star Wars" // Make your own catogory for the swep
SWEP.SlotPos = 0 // Deside wich slot you want your swep do be in 1 2 3 4 5 6
SWEP.DrawAmmo = true // Does the ammo show up when you are using it ? True / False
SWEP.ReloadSound = "Weapon_smg.Reload" // Reload sound, you can use the default ones, or you can use your one; Example; "sound/myswepreload.waw"
SWEP.Instructions = "left click shoot right nothing" // How do pepole use your swep ?
SWEP.Contact = "....." // How Pepole chould contact you if they find bugs, errors, etc
SWEP.Purpose = "Just have fun" // What is the purpose with this swep ?
SWEP.base = "weapon_base"
//General settings\\
//PrimaryFire Settings\\
SWEP.Primary.Sound = "DC-15A/fire_DC_15.wav" // The sound that plays when you shoot :]
SWEP.Primary.Damage = 15 // How much damage the swep is doing
SWEP.Primary.TakeAmmo = 1 // How much ammo does it take for each shot ?
SWEP.Primary.ClipSize = 50 // The clipsize
SWEP.Primary.Ammo = "ar2" // ammmo type pistol/ smg1
SWEP.Primary.DefaultClip = 300 // How much ammo does the swep come with `?
SWEP.Primary.Spread = 0.1 // Does the bullets spread all over, if you want it fire exactly where you are aiming leave it o.1
SWEP.Primary.NumberofShots = 1 // How many bullets you are firing each shot.
SWEP.Primary.Automatic = true // Is the swep automatic ?
SWEP.Primary.Recoil = 1 // How much we should punch the view
SWEP.Primary.Delay = 0.2 // How long time before you can fire again
SWEP.Primary.Force = 60 // The force of the shot
//PrimaryFire settings\\
//Secondary Fire Variables\\
SWEP.Secondary.NumberofShots = 0 // How many explosions for each shot
SWEP.Secondary.Force = 0 // Explosions Force
SWEP.Secondary.Spread = 0.1 // How much the explosion does spread
SWEP.Secondary.Sound = "Weapon_RPG.Single" // Fire sound
SWEP.Secondary.DefaultClip = 0 // How much ammo the secoindary swep comes with
SWEP.Secondary.Automatic = false // Is it automactic ?
SWEP.Secondary.Ammo = "Pistol" // Leave as Pistol !
SWEP.Secondary.Recoil = 0 // How uch we should punch the view
SWEP.Secondary.Delay = 0.2 // How long you have to wait before fire a new shot
SWEP.Secondary.TakeAmmo = 100 // How much ammo Does it take ?
SWEP.Secondary.ClipSize = 0 // ClipSize
SWEP.Secondary.Damage = 0 -- The damage the explosion does.
SWEP.Secondary.Magnitude = "0" -- How big its the explosion ?
//Secondary Fire Variables\\
//SWEP:Initialize()\\
function SWEP:Initialize()
util.PrecacheSound(self.Primary.Sound)
util.PrecacheSound(self.Secondary.Sound)
if ( SERVER ) then
self:SetWeaponHoldType( self.HoldType )
end
end
//SWEP:Initialize()\\
//SWEP:PrimaryFire()\\
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
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.Weapon:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )
self:TakePrimaryAmmo(self.Primary.TakeAmmo)
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
end
//SWEP:PrimaryFire()\\ [/lua]
uhhh can anyone help me with this its getting verry frustrating.
[editline]21st May 2011[/editline]
help???
Sure this shouldn't be
[lua]
SWEP.Primary.Sound = Sound( "weapons/DC-15A/fire_DC_15.wav" );
-- play
self.Weapon:EmitSound(self.Primary.Sound);
[/lua]
EmitSound takes a string path as an argument, not a Sound object.
[lua]
SWEP.Primary.Sound = "your/path/here.wav"
self.Weapon:EmitSound(self.Primary.Sound)[/lua]
i got it to work thanks alot i had to add resource.AddFile( "sound/weapons/fire_DC_15.wav" )
admin please lock this thred :)
[QUOTE=Feihc;29981599]EmitSound takes a string path as an argument, not a Sound object.
[lua]
SWEP.Primary.Sound = "your/path/here.wav"
self.Weapon:EmitSound(self.Primary.Sound)[/lua][/QUOTE]
Sound returns the path to the file (Sound also caches it, as mentioned below)
[lua]
SWEP.Primary.Sound =
{
Sound( "weapons/pistol_beretta92fs/m9_fire1.wav" ),
Sound( "weapons/pistol_beretta92fs/m9_fire2.wav" ),
Sound( "weapons/pistol_beretta92fs/m9_fire3.wav" ),
Sound( "weapons/pistol_beretta92fs/m9_fire4.wav" ),
Sound( "weapons/pistol_beretta92fs/m9_fire5.wav" )
};
-- MEANWHILE
function SWEP:EmitRandomFireSound()
if( type( self.Primary.Sound ) == "table" ) then
self.Weapon:EmitSound( table.Random( self.Primary.Sound ) )
else
self.Weapon:EmitSound( self.Primary.Sound );
end
end
[/lua]
[QUOTE=Feihc;29981599]EmitSound takes a string path as an argument, not a Sound object.
[lua]
SWEP.Primary.Sound = "your/path/here.wav"
self.Weapon:EmitSound(self.Primary.Sound)[/lua][/QUOTE]
Sound object?
Wrong.
You are not toying with Sound objects,you are just using sound strings.
Sound(String sound) just precaches the sound and returns the input string.
Calling Sound(String sound) in there is correct,as it precaches the sound when the swep is getting registered in Lua.
[b][url=http://wiki.garrysmod.com/?title=G.Sound]G.Sound [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
Sorry, you need to Log In to post a reply to this thread.