Raised This Month: $32 Target: $400
 8% 

Problem with CountDown


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jaxoR
Member
Join Date: Dec 2014
Location: Argentina
Old 04-13-2016 , 19:33   Problem with CountDown
Reply With Quote #1

Hi, I can't make a countdown for CS:GO. I have the sounds, precache and the download table, but I can't listen the sounds.

What is wrong?

PHP Code:
#include <emitsoundany>

int soundscount 9

char sCountdownSoundsAnnouncer[][] = 

    
"hns/one.mp3"
    
"hns/two.mp3"
    
"hns/three.mp3"
    
"hns/four.mp3"
    
"hns/five.mp3"
    
"hns/six.mp3"
    
"hns/seven.mp3"
    
"hns/eight.mp3"
    
"hns/nine.mp3"
    
"hns/ten.mp3"
}; 

public 
OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStart);
}

public 
OnMapStart() 
{
    for(new 
010i++)
    { 
        
AddFileToDownloadsTable(sCountdownSoundsAnnouncer[i]);
        
PrecacheSoundAny(sCountdownSoundsAnnouncer[i]);
    } 
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
CreateTimer(1.0Timer_Countdown);
    
EmitSoundToAllAny(sCountdownSoundsAnnouncer[soundscount]);
    
}

public 
Action Timer_Countdown(Handle hTimer)

     
    if(
soundscount > -1)
    { 
        
soundscount--; 
         
        
CreateTimer(1.0Timer_Countdown); 
         
        
EmitSoundToAllAny(sCountdownSoundsAnnouncer[soundscount]); 
     
    }
    
    return 
Plugin_Stop


Thanks!
jaxoR is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-13-2016 , 19:46   Re: Problem with CountDown
Reply With Quote #2

Any errors in your client console?
__________________
Neuro Toxin is offline
jaxoR
Member
Join Date: Dec 2014
Location: Argentina
Old 04-13-2016 , 19:56   Re: Problem with CountDown
Reply With Quote #3

Quote:
Originally Posted by Neuro Toxin View Post
Any errors in your client console?
L 04/13/2016 - 18:51:47: [SM] Plugin encountered error 15: Array index is out of bounds
L 04/13/2016 - 18:51:47: [SM] Displaying call stack trace for plugin "Count.smx":
L 04/13/2016 - 18:51:47: [SM] [0] Line 207, H:\SourceMod\Count.sp::Timer_Countdown()
jaxoR is offline
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 04-13-2016 , 21:11   Re: Problem with CountDown
Reply With Quote #4

AddFileToDownloadsTable("sound/hns/one.mp3");
lingzhidiyu is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 04-13-2016 , 22:34   Re: Problem with CountDown
Reply With Quote #5

You should decrease the soundscount after you emit it. You are checking if it's greater than -1 to play it but when it's 0, you set it to -1, hence the array bounds error.

One more thing though, you can use CreateTimer() only once by adding TIMER_REPEAT flag to the one in Event_RoundStart(), and then returning Plugin_Continue, when you want it to count another second, or Plugin_Stop, when you want to stop it.

Last edited by Phil25; 04-13-2016 at 22:34.
Phil25 is offline
jaxoR
Member
Join Date: Dec 2014
Location: Argentina
Old 04-14-2016 , 00:45   Re: Problem with CountDown
Reply With Quote #6

Quote:
Originally Posted by lingzhidiyu View Post
AddFileToDownloadsTable("sound/hns/one.mp3");
Quote:
Originally Posted by Phil25 View Post
You should decrease the soundscount after you emit it. You are checking if it's greater than -1 to play it but when it's 0, you set it to -1, hence the array bounds error.

One more thing though, you can use CreateTimer() only once by adding TIMER_REPEAT flag to the one in Event_RoundStart(), and then returning Plugin_Continue, when you want it to count another second, or Plugin_Stop, when you want to stop it.
Thank you both guys, now works
jaxoR 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 23:49.


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