AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get round and change cvar (https://forums.alliedmods.net/showthread.php?t=114006)

asd13 01-01-2010 08:13

get round and change cvar
 
Could anyone do a code what changes cvar on round 2 after sv_restartround 1 is trigered :)

xPaw 01-01-2010 08:39

Re: get round and change cvar
 
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( ); }

asd13 01-01-2010 09:24

Re: get round and change cvar
 
actualy i had in mind that
round is restarted
1 round played and if comes second round server executes like my_cvar "1"

kielor 01-01-2010 09:49

Re: get round and change cvar
 
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( );



asd13 01-02-2010 04:40

Re: get round and change cvar
 
This not it :(
I had in mind if sv_restartround is executed you can play 2 rounds then server executes the command :)

RadiaX^ 01-02-2010 06:52

Re: get round and change cvar
 
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.


All times are GMT -4. The time now is 04:11.

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