Raised This Month: $ Target: $400
 0% 

Please add a countdown for this restart map code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GarbageBox
Senior Member
Join Date: Feb 2010
Old 01-07-2011 , 12:48   Please add a countdown for this restart map code
Reply With Quote #1

I have try to study the countdown from other people code, but I find that it's not easy...So, I decided to post this code out.
I want a client_print version countdown...
Please help.
Thank
Code:
#include <amxmodx>

public plugin_init()
{	
	register_plugin("Auto-Restart", "1.0", "ToT | V!PER")
	register_event("TextMsg", "restart_time", "a", "2&#Game_C")
	register_cvar("amx_autorestart", "15.0")
	return PLUGIN_CONTINUE
}

public restart_time()	
	set_task (get_cvar_float("amx_autorestart"),"restart_map",0)	

public restart_map()
{	 
	set_hudmessage(0, 100, 200, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, 2)	  
	show_hudmessage(0, "Restart Now!")	 
	set_cvar_float("sv_restart",1.0)	
	return PLUGIN_HANDLED
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-07-2011 , 13:57   Re: Please add a countdown for this restart map code
Reply With Quote #2

change this:
PHP Code:
set_hudmessage(01002000.050.6520.026.00.010.12)      
show_hudmessage(0"Restart Now!"
to
PHP Code:
client_print(0print_chat"Restart Now"); 
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
GarbageBox
Senior Member
Join Date: Feb 2010
Old 01-08-2011 , 12:16   Re: Please add a countdown for this restart map code
Reply With Quote #3

I mean a text countdown
10, 9 , 8 etc
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-08-2011 , 12:20   Re: Please add a countdown for this restart map code
Reply With Quote #4

set_task(1.0, "countdown", _, _, "b")

make an array like counttime, and use counttime--; on countdown :S
reinert is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 01-09-2011 , 01:28   Re: Please add a countdown for this restart map code
Reply With Quote #5

This is what I edit.
But this code won't stop countdown after restart once.
What's wrong?
Code:
#include <amxmodx>

new countdown
new g_SayText
new roundstart

public plugin_init()
{	
	register_plugin("Auto-Restart", "1.0", "ToT | V!PER")
	register_event("TextMsg", "restart_countdown", "a", "2&#Game_C")
 	register_cvar("amx_autorestart", "10.0")
	g_SayText = get_user_msgid("SayText")
}

public restart_countdown()
{
	set_task(1.0, "start_countdown", _, _, _, "b")
	set_task(get_cvar_float("amx_autorestart"), "restart_round", _)
}

public start_countdown()
{
	countdown++
	new sec = 11 - countdown
	client_printc(0, "\y[AMXX] After %i sec will restart once", sec)
	
	if(countdown == get_cvar_float("amx_autorestart"))
	{
		countdown = 0
		client_printc(0, "\y[AMXX] Game Start")
	}

	return PLUGIN_HANDLED
}

public restart_round()
{	 
	server_cmd("sv_restartround 1")	
	return PLUGIN_HANDLED
}	

stock client_printc(const id, const string[], {Float, Sql, Resul,_}:...) {
	
	new msg[191], players[32], count = 1;
	vformat(msg, sizeof msg - 1, string, 3);
	
	replace_all(msg,190,"\g","^4");
	replace_all(msg,190,"\y","^1");
	replace_all(msg,190,"\t","^3");
	
	if(id)
		players[0] = id;
	else
		get_players(players,count,"ch");
	
	new index;
	for (new i = 0 ; i < count ; i++)
	{
		index = players[i];
		message_begin(MSG_ONE_UNRELIABLE, g_SayText,_, index);
		write_byte(index);
		write_string(msg);
		message_end();  
	}  
}
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 01-09-2011 , 01:57   Re: Please add a countdown for this restart map code
Reply With Quote #6

PHP Code:
#define TASKID 452

public restart_countdown()
{
    
set_task(1.0"start_countdown"TASKID);
}

public 
restart_round()
{
    
server_cmd("sv_restartround 1");
    
remove_task(TASKID);

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
GarbageBox
Senior Member
Join Date: Feb 2010
Old 01-09-2011 , 02:54   Re: Please add a countdown for this restart map code
Reply With Quote #7

Quote:
Originally Posted by drekes View Post
PHP Code:
#define TASKID 452

public restart_countdown()
{
    
set_task(1.0"start_countdown"TASKID);
}

public 
restart_round()
{
    
server_cmd("sv_restartround 1");
    
remove_task(TASKID);

What does TASKID 452 mean?

I edited the code, but the countdown will only show After 10 sec will restart once.
The countdown text doest show 9, 8, 7...
But after 10 second it still will restart
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others

Last edited by GarbageBox; 01-09-2011 at 03:04.
GarbageBox is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-09-2011 , 03:18   Re: Please add a countdown for this restart map code
Reply With Quote #8

you define the task, the number means nothing it can be various ...

Just it needs to match the number on set_task and remove_task to remove the correct one...
reinert is offline
GarbageBox
Senior Member
Join Date: Feb 2010
Old 01-09-2011 , 03:27   Re: Please add a countdown for this restart map code
Reply With Quote #9

But I when I change
Code:
"set_task(1.0, "start_countdown", _, _, _, "b")"
to
Code:
"set_task(1.0, "start_countdown", TASKID)"
, the countdown doest not show with 9, 8, 7 etc.
__________________
You can be a SUPER coder but you Haven't to say such as "stupid, etc." words to the others
GarbageBox is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-09-2011 , 03:30   Re: Please add a countdown for this restart map code
Reply With Quote #10

set_task(1.0, "start_countdown", TASKID, _, _, "b")
reinert 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 02:08.


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