AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
|
09-25-2020
, 17:45
Re: help register_event
|
#23
|
Quote:
Originally Posted by Supremache
I made this plugin yesterday, for coutdown timer, follow steps and you will know how to do that !!
P.s: Use "show_hudmessage" not "SyncObj hud"
|
There are a few issues in your code
Spoiler
PHP Code:
#include <amxmodx>
#define PLUGIN "Countdown"
#define VERSION "1.0"
#define AUTHOR "Supremache"
const TaskStartCountdown = 34234243;
const TaskCountdown = 34234244;
new const PrecacheSoundList[ 11 ][] =
{
"",
"fvox/one.wav",
"fvox/two.wav",
"fvox/three.wav",
"fvox/four.wav",
"fvox/five.wav",
"fvox/six.wav",
"fvox/seven.wav",
"fvox/eight.wav",
"fvox/nine.wav",
"fvox/ten.wav"
};
new g_iCountdown
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
//This is new round,. not round start
//register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0")
//This is round start
register_logevent( "EventRoundStart" , 2 , "1=Round_Start" )
}
public plugin_precache()
{
//This should be < not <=
//You need to use sizeof() not charsmax() when working with arrays. Charsmax is only used
//when working with a string. This here is an array of strings, so you should treat it as an
//array in this context.
for ( new i = 0 ; i < sizeof( PrecacheSoundList ); i++ )
{
if ( PrecacheSoundList[ i ][ 0 ] != EOS )
precache_sound( PrecacheSoundList[ i ] )
}
}
public EventRoundStart()
{
//It's not ideal to repeatedly call set_task(), so you should call it once with flag a and set the
//repeat parameter to the appropriate number of times.
if ( !task_exists( TaskStartCountdown ) && !task_exists( TaskCountdown ) )
set_task( 4.0 , "StartCountdown" , TaskStartCountdown );
}
public StartCountdown()
{
set_task( 1.0 , "ZombieCountdown" , TaskCountdown , .flags="a" , .repeat= ( g_iCountdown = 10 ) )
}
public ZombieCountdown()
{
emit_sound( 0 , CHAN_VOICE , PrecacheSoundList[ g_iCountdown ] , 1.0 , ATTN_NORM , 0 , PITCH_NORM )
set_hudmessage(179, 0, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10);
show_hudmessage(0, "Infection in %i", g_iCountdown-- );
//It's not ideal to call set_task(), so you should call it once with flag a and set the
//repeat parameter to the appropriate number of times.
//if(iTime >= 1)
//{
// set_task(1.0, "ZombieCountdown")
//}
}
__________________
|
|