Raised This Month: $ Target: $400
 0% 

Optimize my code and a countdown bug.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 10-14-2011 , 12:30   Optimize my code and a countdown bug.
Reply With Quote #1

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

Last edited by GarbageBox; 10-14-2011 at 12:32.
GarbageBox is offline
 



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 20:29.


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