Raised This Month: $ Target: $400
 0% 

Need help looping sounds!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-15-2007 , 04:09   Need help looping sounds!
Reply With Quote #1

I have a set_task that is called every 0.01 seconds.

I want to loop a 1 second long sound inside of this set_task.

How would I do this?
__________________
Bad_Bud is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 01-15-2007 , 04:12   Re: Need help looping sounds!
Reply With Quote #2

You can't, you will have to make a function,
don't know if this is good for you, but it should work.

Code:
new soundloop[33] public plugin_init() {  register_plugin("somesoundplugin","1.0a", "Some strange guy") } public somefunction(id){  soundloop[id] = 1  sound(id)  set_task(1.0,resetloop,id) } public sound(id){ if (soundloop[id] != 1)  return PLUGIN_HANDLED emit_sound(id,CHAN_VOICE,"misc/mysound.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) sound(id) } public resetloop(id){  soundloop[id] = 0 } public plugin_precache() {      precache_sound("misc/mysound.wav")      return PLUGIN_CONTINUE }
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.

Last edited by dutchmeat; 01-15-2007 at 04:20.
dutchmeat is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-15-2007 , 04:39   Re: Need help looping sounds!
Reply With Quote #3

I'm actually kind of wondering why this method won't work:

PHP Code:
new Float:SoundTimer[33]
 
set_task(0.01,"My_0.01_settask",0,"",0,"b")
 
public 
client_putinserver(id)
   
SoundTimer[id]=halflife_time()
 
public 
My_0.01_settask(id)
{
if(
SoundTimer[id]-halflife_time()>1.0)
   {
    
emit_sound(id,CHAN_ITEM,"mysoundloop.wav",1.0,ATTN_NORM,0,PITCH_NORM)
    
SoundTimer[id]=halflife_time()
   }

I could possibly try to mimic having it timed, since theoretically it should go through this task 10 times each sound play, so I could just keep track of it that way, but I'm not sure if that's where the problem is or not.
__________________

Last edited by Bad_Bud; 01-15-2007 at 15:26.
Bad_Bud is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 01-15-2007 , 04:43   Re: Need help looping sounds!
Reply With Quote #4

well first of all, you don't execute 'My_0.01_settask', but the problem is that that function isn't really looped, or executed every frame.
So this check:
if(SoundTimer[id]-halflife_time()>1.0)
is only called one time.
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-15-2007 , 05:05   Re: Need help looping sounds!
Reply With Quote #5

I was implying that I had a settask looping it. I'll fix that.
__________________
Bad_Bud is offline
dutchmeat
Senior Member
Join Date: Sep 2006
Old 01-15-2007 , 05:55   Re: Need help looping sounds!
Reply With Quote #6

you should also put 'public' infront of 'My_0.01_settask(id)'
__________________
before you criticize someone, you should walk a mile in their shoes. that way, when you criticize them, you're a mile away and you have their shoes.
dutchmeat is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-15-2007 , 15:25   Re: Need help looping sounds!
Reply With Quote #7

...piddly stuff aside, how can I make this work in theory.
__________________
Bad_Bud is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-15-2007 , 16:16   Re: Need help looping sounds!
Reply With Quote #8

SoundTimer[id]-halflife_time() will be a negative value. You want to do this the other way around.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-15-2007 , 22:35   Re: Need help looping sounds!
Reply With Quote #9

AH! *gives you 18 flies*
__________________
Bad_Bud is offline
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-15-2007 , 22:46   Re: Need help looping sounds!
Reply With Quote #10

Hmm, well it works great, but I have another question. Is there a way to play only part of a sound? Once you tap your jetpack key once, you're committed to playing the whole one second sound loop, and it's kind of awkward.
__________________
Bad_Bud is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode