It seems that
[lua]
local SOUND = Sound("path/to/sound.mp3")
local SOUND_2 = CreateSound(self.Entity, SOUND)
SOUND_2:Play()
[/lua]
Doesn't loop my sound.
Any help
[QUOTE=Ronon Dex;16945070]It seems that
[lua]
local SOUND = Sound("path/to/sound.mp3")
LOCAL SOUND_2 = CreateSound(self.Entity, SOUND)
SOUND_2:Play()
[/lua]
Doesn't loop my sound.
Any help[/QUOTE]
Why did you capitilise 'Local'?
You do know that lua is case sensitive?
Yeah sorry, i know, thats not the code im using. i quickly typed that up
[editline]07:29PM[/editline]
Fixed it now by doing
[lua]
local SOUND=Sound("path/to/sound.mp3")
if(!self.Sound) then
self.Sound=CreateSound(self.Entity, SOUND)
end
self.Sound:Play()
[/lua]
mp3's do not loop, only the correctly cued wav files do.
To do something like that try this:
[lua]
function ENT.ConstantLoopingSound()
local snd_path = Sound( "path/to/sound.mp3" )
local snd_duration = SoundDuration( snd_path )
if self.Sound then
self.Sound:Stop()
self.Sound = nil
end
self.Sound = CreateSound( self, snd_path )
self.Sound:Play()
timer.Simple( snd_duration, self.ConstantLoopingSound )
end
[/lua]
self == self.Entity in SENT's now, no need for self.Entity
Sorry mp3 was only for example im using wav's in SENT and thanks for the self = self.Entity heads up
No problem, for wav's its the same principle. If it doesn't loop, use that.
[QUOTE=TehBigA;16946325]mp3's do not loop, only the correctly cued wav files do.
To do something like that try this:
[lua]
function ENT.ConstantLoopingSound()
local snd_path = Sound( "path/to/sound.mp3" )
local snd_duration = SoundDuration( snd_path )
if self.Sound then
self.Sound:Stop()
self.Sound = nil
end
self.Sound = CreateSound( self, snd_path )
self.Sound:Play()
timer.Simple( snd_duration, self.ConstantLoopingSound )
end
[/lua]
self == self.Entity in SENT's now, no need for self.Entity[/QUOTE]
You might want to change ENT. to ENT:
Yea sorry, do what kevkev said lol
[QUOTE=Ronon Dex;16946394]Sorry mp3 was only for example im using wav's in SENT and thanks for the self = self.Entity heads up[/QUOTE]
To loop a wav-file you should use cue points.
If you don't know how to add those to a wav-file, read [URL=http://developer.valvesoftware.com/wiki/Looping_A_Sound]this[/URL].
[QUOTE=Silverlan;16956490]To loop a wav-file you should use cue points.
If you don't know how to add those to a wav-file, read [URL=http://developer.valvesoftware.com/wiki/Looping_A_Sound]this[/URL].[/QUOTE]
Not if he is trying to use a sound from HL2
Sorry, you need to Log In to post a reply to this thread.