Raised This Month: $51 Target: $400
 12% 

[CS:GO] Countdown Timers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-22-2015 , 03:45   [CS:GO] Countdown Timers
Reply With Quote #1

The hint text shows, but the sounds aren't
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <emitsoundany>

new Handle:Countdown INVALID_HANDLE;
new 
Second;

public 
Plugin:myinfo 
{
    
name "Privat",
    
author "Mado",
    
description "none",
    
version "X",
    
url "."
};

public 
OnPluginStart()
{
    
HookEvent("round_start"OnRoundStart);
    
AddFileToDownloadsTable("sound/furienmdx/countdown/1.mp3");
    
AddFileToDownloadsTable("sound/furienmdx/countdown/2.mp3");
    
AddFileToDownloadsTable("sound/furienmdx/countdown/3.mp3");
    
AddFileToDownloadsTable("sound/furienmdx/countdown/4.mp3");
    
AddFileToDownloadsTable("sound/furienmdx/countdown/5.mp3");
    
PrecacheSoundAny("furienmdx/countdown/1.mp3");
    
PrecacheSoundAny("furienmdx/countdown/2.mp3");
    
PrecacheSoundAny("furienmdx/countdown/3.mp3");
    
PrecacheSoundAny("furienmdx/countdown/4.mp3");
    
PrecacheSoundAny("furienmdx/countdown/5.mp3");
}

public 
OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
Second 5;
    
EmitSoundToAllAny("furienmdx/countdown/5.mp3");
    
Countdown CreateTimer(1.0Timer_4_TIMER_DATA_HNDL_CLOSE ); 
    
Countdown CreateTimer(2.0Timer_3_TIMER_DATA_HNDL_CLOSE );
    
Countdown CreateTimer(3.0Timer_2_TIMER_DATA_HNDL_CLOSE ); 
    
Countdown CreateTimer(4.0Timer_1_TIMER_DATA_HNDL_CLOSE );
    
Countdown CreateTimer(5.0Timer_0_TIMER_DATA_HNDL_CLOSE);
    
PrintHintTextToAll("<font color='#ff0000'><b>5 Second(s) remaning</b></font>");
}

public 
Action:Timer_4(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/4.mp3");
    
PrintHintTextToAll("<font color='#00ffde'><b>4 Second(s) remaning</b></font>");
}  

public 
Action:Timer_3(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/3.mp3");    
    
PrintHintTextToAll("<font color='#00ff00'><b>3 Second(s) remaning</b></font>");
}  

public 
Action:Timer_2(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/2.mp3");    
    
PrintHintTextToAll("<font color='#fffc00'><b>2 Second(s) remaning</b></font>");
}  

public 
Action:Timer_1(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/1.mp3");
    
PrintHintTextToAll("<font color='#ff9500'><b>1 Second(s) remaning</b></font>");

 
public 
Action:Timer_0(Handle:Timer)
{
    
PrintHintTextToAll("<font color='#ff0000'><b>ATTACK!!!</b></font>")
    if (
Second == 0)
        
KillTimer(Countdown);

I get those things...

PHP Code:
SV_StartSound: *furienmdx/countdown/4.mp3 not precached (0)
12/22/2015 10:40:40: [SMPlugin "countdown.smx" encountered error 23Native detected error
12
/22/2015 10:40:40: [SMInvalid data handle 0 (error 4passed during timer end with TIMER_DATA_HNDL_CLOSE
12
/22/2015 10:40:40: [SMUnable to call function "Timer_4" due to above error(s).
SV_StartSound: *furienmdx/countdown/3.mp3 not precached (0)
12/22/2015 10:40:41: [SMPlugin "countdown.smx" encountered error 23Native detected error
12
/22/2015 10:40:41: [SMInvalid data handle 0 (error 4passed during timer end with TIMER_DATA_HNDL_CLOSE
12
/22/2015 10:40:41: [SMUnable to call function "Timer_3" due to above error(s).
SV_StartSound: *furienmdx/countdown/2.mp3 not precached (0)
12/22/2015 10:40:42: [SMPlugin "countdown.smx" encountered error 23Native detected error
12
/22/2015 10:40:42: [SMInvalid data handle 0 (error 4passed during timer end with TIMER_DATA_HNDL_CLOSE
12
/22/2015 10:40:42: [SMUnable to call function "Timer_2" due to above error(s).
SV_StartSound: *furienmdx/countdown/1.mp3 not precached (0)
12/22/2015 10:40:43: [SMPlugin "countdown.smx" encountered error 23Native detected error
12
/22/2015 10:40:43: [SMInvalid data handle 0 (error 4passed during timer end with TIMER_DATA_HNDL_CLOSE
12
/22/2015 10:40:43: [SMUnable to call function "Timer_1" due to above error(s).
12/22/2015 10:40:44World triggered "Round_Start"
12/22/2015 10:40:44: [SMPlugin "countdown.smx" encountered error 23Native detected error
12
/22/2015 10:40:44: [SMInvalid data handle 0 (error 4passed during timer end with TIMER_DATA_HNDL_CLOSE 
I also tried with TIMER_REPEAT instead of TIMER_DATA_HNDL_CLOSE and it makes it an infinite countdown that gets faster every round and never stops. It's like 543214231231231234123434... .
And KillTimer doesn't work when I use TIMER_REPEAT... I also tried with return Plugin_Stop;

Don't tell me that sounds aren't precached, it works with TIMER_REPEAT, but the countdown doesn't stop at 0.
__________________
valio_skull is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-22-2015 , 04:11   Re: [CS:GO] Countdown Timers
Reply With Quote #2

first where are you subtracting Second and i don't think you need to do
Countdown = and , _, TIMER_DATA_HNDL_CLOSE );

since
Quote:
Timer Death
All timers are guaranteed to die either by:


CloseHandle() being called (or on plugin unload);
KillTimer() being called;
Plugin_Stop being returned from a repeatable timer;
TriggerTimer() being called on a one-time timer;
Execution of a one-time timer finishes.
from Wiki https://wiki.alliedmods.net/Timers_(...g)#Timer_Death
__________________

Last edited by 8guawong; 12-22-2015 at 04:13.
8guawong is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-22-2015 , 04:17   Re: [CS:GO] Countdown Timers
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
first where are you subtracting Second and i don't think you need to do
Countdown = and , _, TIMER_DATA_HNDL_CLOSE );
I did use Countdown = for KillTimer(countdown)
But that works better, thanks:
PHP Code:
public OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
EmitSoundToAllAny("furienmdx/countdown/5.mp3");
    
CreateTimer(1.0Timer_4); 
    
CreateTimer(2.0Timer_3);
    
CreateTimer(3.0Timer_2); 
    
CreateTimer(4.0Timer_1);
    
CreateTimer(5.0Timer_0);
    
PrintHintTextToAll("<font color='#ff0000'><b>5 Second(s) remaning</b></font>");
}

public 
Action:Timer_4(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/4.mp3");
    
PrintHintTextToAll("<font color='#00ffde'><b>4 Second(s) remaning</b></font>");
}  

public 
Action:Timer_3(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/3.mp3");    
    
PrintHintTextToAll("<font color='#00ff00'><b>3 Second(s) remaning</b></font>");
}  

public 
Action:Timer_2(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/2.mp3");    
    
PrintHintTextToAll("<font color='#fffc00'><b>2 Second(s) remaning</b></font>");
}  

public 
Action:Timer_1(Handle:Timer)
{
    
EmitSoundToAllAny("furienmdx/countdown/1.mp3");
    
PrintHintTextToAll("<font color='#ff9500'><b>1 Second(s) remaning</b></font>");

 
public 
Action:Timer_0(Handle:Timer)
{
    
PrintHintTextToAll("<font color='#ff0000'><b>ATTACK!!!</b></font>")

__________________

Last edited by valio_skull; 12-22-2015 at 04:17.
valio_skull is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-22-2015 , 04:33   Re: [CS:GO] Countdown Timers
Reply With Quote #4

fml, it works just one map and then it doesn't
PHP Code:
SV_StartSound: *furienmdx/countdown/3.mp3 not precached (0)
SV_StartSound: *furienmdx/countdown/3.mp3 not precached (0)
SV_StartSound: *furienmdx/countdown/3.mp3 not precached (0)
SV_StartSound: *furienmdx/countdown/2.mp3 not precached (0)
SV_StartSound: *furienmdx/countdown/2.mp3 not precached (0
__________________
valio_skull is offline
Core.tCM
Junior Member
Join Date: Oct 2015
Old 12-22-2015 , 05:08   Re: [CS:GO] Countdown Timers
Reply With Quote #5

Quote:
Originally Posted by valio_skull View Post

public OnPluginStart()
{
HookEvent("round_start", OnRoundStart);
AddFileToDownloadsTable("sound/furienmdx/countdown/1.mp3");
AddFileToDownloadsTable("sound/furienmdx/countdown/2.mp3");
AddFileToDownloadsTable("sound/furienmdx/countdown/3.mp3");
AddFileToDownloadsTable("sound/furienmdx/countdown/4.mp3");
AddFileToDownloadsTable("sound/furienmdx/countdown/5.mp3");
PrecacheSoundAny("furienmdx/countdown/1.mp3");
PrecacheSoundAny("furienmdx/countdown/2.mp3");
PrecacheSoundAny("furienmdx/countdown/3.mp3");
PrecacheSoundAny("furienmdx/countdown/4.mp3");
PrecacheSoundAny("furienmdx/countdown/5.mp3");
}

Don't tell me that sounds aren't precached, it works with TIMER_REPEAT, but the countdown doesn't stop at 0.
Um, they are, but only once since you do that on Plugin_start, which only happens once. So this will only work on the first map. Remove this and use what I wrote below.

Code:
public OnMapStart()
{
    AddFileToDownloadsTable("sound/furienmdx/countdown/1.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/2.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/3.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/4.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/5.mp3");
    PrecacheSoundAny("furienmdx/countdown/1.mp3");
    PrecacheSoundAny("furienmdx/countdown/2.mp3");
    PrecacheSoundAny("furienmdx/countdown/3.mp3");
    PrecacheSoundAny("furienmdx/countdown/4.mp3");
    PrecacheSoundAny("furienmdx/countdown/5.mp3");
}

This should work.
__________________
I popped it!
Core.tCM is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-22-2015 , 05:13   Re: [CS:GO] Countdown Timers
Reply With Quote #6

Quote:
Originally Posted by Core.tCM View Post
Um, they are, but only once since you do that on Plugin_start, which only happens once. So this will only work on the first map. Remove this and use what I wrote below.

Code:
public OnMapStart()
{
    AddFileToDownloadsTable("sound/furienmdx/countdown/1.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/2.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/3.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/4.mp3");
    AddFileToDownloadsTable("sound/furienmdx/countdown/5.mp3");
    PrecacheSoundAny("furienmdx/countdown/1.mp3");
    PrecacheSoundAny("furienmdx/countdown/2.mp3");
    PrecacheSoundAny("furienmdx/countdown/3.mp3");
    PrecacheSoundAny("furienmdx/countdown/4.mp3");
    PrecacheSoundAny("furienmdx/countdown/5.mp3");
}

This should work.
damn ninjaed
was going to say precache on mapstart
__________________
8guawong is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-22-2015 , 08:09   Re: [CS:GO] Countdown Timers
Reply With Quote #7

Quote:
Originally Posted by 8guawong View Post
damn ninjaed
was going to say precache on mapstart
Damn, I'm so stupid, I thought the plugin starts every map, I'm so ******* stupid
Thanks xD
__________________
valio_skull 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 17:37.


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