Code:
#include <amxmodx>
#include <amxmisc>
#define task_id 1445
new g_iCounter
new g_HudSyncObj
new p_delay
public plugin_init()
{
register_plugin( "respawn", "1.0", "matsi")
register_clcmd( "say /respawn", "cmd_respawn" )
p_delay = register_cvar( "amx_respawn_delay", "3" )
}
public plugin_cfg()
{
g_HudSyncObj = CreateHudSyncObj()
}
public cmd_respawn( id )
{
if( task_exists( task_id ) )
remove_task( task_id )
g_iCounter = get_pcvar_num( p_delay )
set_task( 1.0, "start_countdown", task_id, _, _, "b" )
return PLUGIN_HANDLED
}
public start_countdown( id )
{
if( !g_iCounter ) //time is up
{
remove_task( task_id )
set_hudmessage( 255, 255, 255, -1.0, 0.79, 0, 6.0, 1.0, 0.1, 0.2, -1 )
ShowSyncHudMsg( 0, g_HudSyncObj, "You have been respawned" )
//set player to respawn here
return
}
set_hudmessage( 255, 255, 255, -1.0, 0.79, 0, 6.0, 1.0, 0.1, 0.2, -1 )
ShowSyncHudMsg( 0, g_HudSyncObj, "You will respawn in %i second%s", g_iCounter, g_iCounter < 2 ? "" : "s" )
g_iCounter--
}
I didn't really understand what you were doing but this is what i came up with.