Raised This Month: $ Target: $400
 0% 

hooking restart


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 05-09-2011 , 10:53   hooking restart
Reply With Quote #1

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.
reinert is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-09-2011 , 11:09   Re: hooking restart
Reply With Quote #2

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

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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:26.


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