Raised This Month: $ Target: $400
 0% 

get round and change cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asd13
Member
Join Date: Apr 2009
Old 01-01-2010 , 08:13   get round and change cvar
Reply With Quote #1

Could anyone do a code what changes cvar on round 2 after sv_restartround 1 is trigered
asd13 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-01-2010 , 08:39   Re: get round and change cvar
Reply With Quote #2

Next time post in requests section.

Code:
#include < amxmodx > public plugin_init( ) {     register_plugin( "Execute Cfg After Restart", "1.0", "xPaw" );         register_event( "TextMsg", "EventRoundRestart", "a", "2=#Game_will_restart_in" ); } public EventRoundRestart( ) {     server_cmd( "exec yourconfig.cfg" );     server_exec( ); }
__________________
xPaw is offline
asd13
Member
Join Date: Apr 2009
Old 01-01-2010 , 09:24   Re: get round and change cvar
Reply With Quote #3

actualy i had in mind that
round is restarted
1 round played and if comes second round server executes like my_cvar "1"
asd13 is offline
kielor
Senior Member
Join Date: Jan 2009
Location: Russia, Novosibirsk
Old 01-01-2010 , 09:49   Re: get round and change cvar
Reply With Quote #4

PHP Code:
#include < amxmodx >

public plugin_init( ) {
         
register_plugin"Execute Cfg After Restart or Round Start""1.0""xPaw" );
    
         
register_event"TextMsg""EventRoundRestart""a""2=#Game_will_restart_in" );
         
register_event"HLTV""EventRoundRestart""a""1=0""2=0" );
}

public 
EventRoundRestart( ) {
         
server_cmd"exec yourconfig.cfg" );
         
server_exec( );

__________________
try using +karma if i helped you...
kielor is offline
Send a message via ICQ to kielor Send a message via Skype™ to kielor
asd13
Member
Join Date: Apr 2009
Old 01-02-2010 , 04:40   Re: get round and change cvar
Reply With Quote #5

This not it
I had in mind if sv_restartround is executed you can play 2 rounds then server executes the command
asd13 is offline
RadiaX^
Junior Member
Join Date: May 2005
Old 01-02-2010 , 06:52   Re: get round and change cvar
Reply With Quote #6

Code:
// amx_autorestart 1/0, Enables and disables the function
// amx_autorestartrounds 1-10, Sets the amount of restarts before loading config

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define RESROUNDS 2 //Default restarts before executing config

new g_restarted,g_dorestart,cvar_dorestart,cvar_dorestartrounds

public plugin_init( )
{
    register_plugin( "Execute Cfg After Restart", "1.0", "xPaw" );
    cvar_dorestart = register_cvar("amx_autorestart", "0")
    cvar_dorestartrounds = register_cvar("amx_autorestartrounds", "2")
    register_event( "TextMsg", "EventRoundRestart", "a", "2=#Game_will_restart_in" );
}
public EventRoundRestart( )
{
	g_dorestart = get_pcvar_num(cvar_dorestart)
	g_restarted = get_pcvar_num(cvar_dorestartrounds)
	if(g_dorestart > 0)
	{
		if(g_restarted == 0)
		{
			server_cmd( "exec yourconfig.cfg" );
			client_print(0,print_chat,"Autorestarting.")
			set_cvar_num("amx_autorestart", 0)
			set_cvar_num("amx_autorestartrounds", RESROUNDS)
		}
		else
		{
			g_restarted--
			set_cvar_num("amx_autorestartrounds", g_restarted)
			client_print(0,print_chat,"%d restarts to autorestart.",g_restarted)
		}
	}
}
This will not load the config 2 rounds after sv_restartround, but it will load it after 2 restarts.

If you still want it to do it after 2 played rounds, just change
EventRoundRestart into the New-round event trigger and hook the clients sv_restartround and link it to the currently named "EventRoundRestart" function.
This is just briefly made to give you an idea about how to do it yourself. Hope it works.
RadiaX^ is offline
Reply


Thread Tools
Display Modes

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 04:11.


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