My countdown doesn't work, can anyone look why, also help me to optimize the code.
Red line is when I compile it, it show me tag mismatch and I don't notice any problems.
Code:
#include < amxmodx >
#include < cstrike >
#include < fun >
#include < hamsandwich >
#define PLUGIN "M4 Training"
#define VERSION "1.0"
#define AUTHOR "WS.Chu:)"
#define TASKID 1357
new g_Countdown, g_HudSync;
new players[ 32 ], num;
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR );
RegisterHam( Ham_Killed, "player", "Player_Killed" );
register_cvar( "amx_respawndelay", "3.0" ); // Delay before respawning
g_HudSync = CreateHudSyncObj();
}
public Player_Killed(id)
{
set_task( 1.0, "countdown", TASKID, _, _, "b" )
}
public countdown()
{
get_players( players, num, "h" );
for( new i = 0; i < num; i++ )
{
if( is_user_connected( players[ i ] ) )
{
if( cs_get_user_team( players[ i ] ) != CS_TEAM_SPECTATOR )
{
set_task( get_cvar_float( "amx_respawndelay" ), "respawn_player", TASKID, _, _, "b" );
}
}
g_Countdown++;
new fsec = ( get_cvar_float( "amx_respawndelay" ) + 1.0 ) - g_Countdown
set_hudmessage( 85, 85, 85, 0.05, 0.50, 0, 1.0, 1.0, 1.0, 1.0, -1 );
ShowSyncHudMsg( players[ i ], g_HudSync, "You will respawn after %.1f sec!", fsec );
}
if( g_Countdown == get_cvar_float( "amx_respawndelay" ) )
{
g_Countdown = 0;
remove_task( TASKID );
}
return PLUGIN_CONTINUE;
}
public respawn_player()
{
get_players( players, num, "h" );
for( new i = 0; i < num; i++ )
{
/*if( is_user_alive( players[ i ] ) )
{
}
else */
if( !is_user_alive( players[ i ] ) )
{
ExecuteHamB( Ham_CS_RoundRespawn, players[ i ] );
give_item( players[ i ], "weapon_m4a1" );
give_item( players[ i ], "ammo_556nato" );
give_item( players[ i ], "ammo_556nato" );
give_item( players[ i ], "ammo_556nato" );
give_item( players[ i ], "ammo_556nato" );
}
remove_task( TASKID );
}
return PLUGIN_CONTINUE;
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others