• Sounds being overlayed
    5 replies, posted
im trying to make a flamethrower swep for teh lols, and im having a problem with the Sounds. the swep works perfectly fine with the sounds and such... but the sounds dont STOP this code is SUPPOSED to stop the sound either when reloading, or when you release the fire or secondary fire. but its not doing anything! therefore overlaying the sound over and over! function SWEP:Reload() self.Weapon:DefaultReload( ACT_VM_RELOAD ) self:StopSounds() end function SWEP:Think() if self.Owner:KeyReleased(IN_ATTACK) or self.Owner:KeyRelease(IN_ATTACK2) then self:StopSounds() end end Why exactly isnt the self:StopSounds() working?? did garry change this too?
Use this instead. Much more useful since you can change the pitch/ volume of without making a new sound. i see its a swep so.. put this in the SWEP:Initialize() [CODE]self.<<Some unique name>> = CreateSound(self, Sound("<<Your sound>>"))[/CODE]It just creates a sound it doesnt play it. To play and stop it use this [CODE]self.<<A unique name you've given earlier>>:Stop() self.<<A unique name you've given earlier>>:Play()[/CODE]Also.. for some reason sometimes in order for it to play correctly you have to stop the sound before playing.. so when ever you want to play it use [CODE]self.<<A unique name you've given earlier>>:Stop() self.<<A unique name you've given earlier>>:Play()[/CODE]For more info like changing pitch/sound search the wiki.
im not exactly trying to change pitch or sound, i simply want the sound to stop playing when you release the PRimary or secondary attack as well as the reload
[QUOTE=Kruel Kramer;23622843]im not exactly trying to change pitch or sound, i simply want the sound to stop playing when you release the PRimary or secondary attack as well as the reload[/QUOTE]Didint i just tell you how?.. -.-
To tell the truth that line of code confuses me. function SWEP:Initialize() self:SetWeaponHoldType( self.HoldType ) util.PrecacheModel("models/player/charple01.mdl") end Can you try and plug it in for me? Have the unique name be anything you want.
[QUOTE=Kruel Kramer;23623989]To tell the truth that line of code confuses me. function SWEP:Initialize() self:SetWeaponHoldType( self.HoldType ) util.PrecacheModel("models/player/charple01.mdl") end Can you try and plug it in for me? Have the unique name be anything you want.[/QUOTE] Its not really rocket science.. But i see this is your first/second swep? So here's how the initialize function should be judging by the code you given:[LUA]function SWEP:Initialize() self:SetWeaponHoldType(self.HoldType) --yes the name can be anything you want.. i suggest rs_<<weapons name>>. Like if your sweps name is ar5 self.rs_ar5 = CreateSound(self, Sound("<<The Reload Sound you want>>")) util.PrecacheModel("models/player/charple01.mdl") end[/LUA]When ever you want to play the sound just put in [CODE]self.rs_ar5:Stop() self.rs_ar5:Play()[/CODE]And when you want to stop ( i suggest you also paste this into SWEP:Holster()) [CODE]self.rs_ar5:Stop()[/CODE]
Sorry, you need to Log In to post a reply to this thread.