Raised This Month: $ Target: $400
 0% 

loop emit_sound optimize


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
adbajota
New Member
Join Date: Jun 2012
Old 06-29-2012 , 00:39   loop emit_sound optimize
Reply With Quote #1

Hello Am.

I was looking for a repeat of the same sound a number of times (5 seconds):

PHP Code:
emit_sound(0CHAN_VOICE"player/heartbeat1.wav"0.2ATTN_NORM0PITCH_NORM)
emit_sound(0CHAN_VOICE"player/heartbeat1.wav"0.2ATTN_NORM0PITCH_NORM)
emit_sound(0CHAN_VOICE"player/heartbeat1.wav"0.2ATTN_NORM0PITCH_NORM)
emit_sound(0CHAN_VOICE"player/heartbeat1.wav"0.2ATTN_NORM0PITCH_NORM)
emit_sound(0CHAN_VOICE"player/heartbeat1.wav"0.2ATTN_NORM0PITCH_NORM
I made the following code to optimize:

PHP Code:
remove_task(9393939932);
        
timer 5
        
set_task
(1.0"countdown"9393939932);
// [...]

public countdown()
{
    if (
timer >= 0)
    { 
        
emit_sound(0CHAN_VOICE"player/heartbeat1.wav"0.2ATTN_NORM0PITCH_NORM)
    }
    
    --
timer;

    if (
timer 0)
    {
        
set_task(1.0"countdown"9393939932);
    }
    else
    {
        
remove_task(9393939932);
    }

what I want to know is whether it can improve the code otherwise

Thanks in advance
adbajota is offline
 



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 15:21.


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