AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   hooking restart (https://forums.alliedmods.net/showthread.php?t=156605)

reinert 05-09-2011 10:53

hooking restart
 
Hey, why the hell my array doesn't set to 0 when someone joins a game and the game is starting.

here is my code:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Plugin name"
#define VERSION "1.0"
#define AUTHOR "ADDiNOL"

new iRound 0;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSION"ADDiNOL")

    
register_logevent("Event_HLTV_Round_End"2"1=Round_End")
    
register_event("TextMsg""eRestart""a""2&#Game_C""2&#Game_W");
    
register_event("TextMsg""eRestart""a""2=#Game_will_restart_in")
    
register_clcmd("say /round""CmdRound")
}

public 
eRestart()
{
    
iRound 0;
}

public 
Event_HLTV_Round_End()
{
    
iRound+=1;
}

public 
CmdRound()
{
    
client_print(0print_chat"round: %d"iRound)


But if I use sv_restart 1 or sv_restartround 1, it works, and iRound is set to 0.

ConnorMcLeod 05-09-2011 11:09

Re: hooking restart
 
First, note that "2&#Game_W" is wrong, it's "2&#Game_w"
2nd, "2&#Game_w" covers "2=#Game_will_restart_in", so you don't have to register it.
End, the game reset stuff at new round when there is a restart, so i would rather wait new round, and also increment round count at this time.

PHP Code:

#include <amxmodx>

#define VERSION "0.0.1"
#define PLUGIN ""

new g_iRoundCount 1
new bool:g_bRestarting

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w")
    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
}

public 
Event_TextMsg_Restart()
{
    
g_bRestarting true
}

public 
Event_HLTV_New_Round()
{
    if( 
g_bRestarting )
    {
        
g_bRestarting false
        g_iRoundCount 
0
    
}
    ++
g_iRoundCount




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

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