Raised This Month: $ Target: $400
 0% 

Why is this getting called multiple times?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 12-13-2011 , 16:31   Why is this getting called multiple times?
Reply With Quote #1

Ok, I would like to hook, when T's and CT's win. Doing it right now like that:

PHP Code:
public plugin_init()
{
    
register_event("SendAudio""t_win""a""2&%!MRAD_terwin")
    
register_event("SendAudio""ct_win""a""2&%!MRAD_ctwin")
}

public 
t_win()
{
    
client_print(0print_chat"[Team] T's win!")
}

public 
ct_win()
{
    
client_print(0print_chat"[Team] CT's win!")

This works perfectly, and both get called once when their team wins. However, when I add some more stuff, it does give the winner team another +1 round as win, and all players die when there was a bomb explosion, all players were outside of the range for sure. And also, it calls sometimes both events multiple times. Could anyone help me with that? There are no other 3rd party plugins installed.

PHP Code:
public plugin_init()
{
    
register_event("SendAudio""t_win""a""2&%!MRAD_terwin")
    
register_event("SendAudio""ct_win""a""2&%!MRAD_ctwin")
}

public 
t_win()
{
    
client_print(0print_chat"[Team] All CTs should die now!")
    
    
cvar get_pcvar_num(amx_sl_silentkill)
    
    new 
iPlayers[32], iNumid 
    get_players
(iPlayersiNum
    for(new 
ii<iNumi++) 
    {
        
id iPlayers[i]
        
        if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT)
        {
            if(
cvar)
            {
                
user_silentkill(id)
            }
            else
            {
                
user_kill(id1)
            }
        }
    }
}

public 
ct_win()
{
    
client_print(0print_chat"[Team] All T's should die now!")
    
    
cvar get_pcvar_num(amx_sl_silentkill)
    
    new 
iPlayers[32], iNumid 
    get_players
(iPlayersiNum
    for(new 
ii<iNumi++) 
    {
        
id iPlayers[i]
        
        if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
        {
            if(
cvar)
            {
                
user_silentkill(id)
            }
            else
            {
                
user_kill(id1)
            }
        }
    }

__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
Wildo
New Member
Join Date: Nov 2011
Old 12-17-2011 , 17:25   Re: Why is this getting called multiple times?
Reply With Quote #2

Im interested in this too, since i just like bibu can't get it to work prober. :/ Anyone ?
Wildo is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-17-2011 , 17:36   Re: Why is this getting called multiple times?
Reply With Quote #3

Debug it and log what is happening.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 12-17-2011 , 17:44   Re: Why is this getting called multiple times?
Reply With Quote #4

Did some prints as you can see. There is nothing in the logs.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 12-18-2011 , 07:00   Re: Why is this getting called multiple times?
Reply With Quote #5

See here, I tested it alone when I was Terrorist, twice. It worked fine. After adding a bot in the CT team, it even forced T's to die.

Quote:
Scoring will not start until both teams have players
[Slay Loser Team] All CTs should die now!
Scoring will not start until both teams have players
[Slay Loser Team] All CTs should die now!
nub connected
nub is joining the Counter-Terrorist force
nub died
[Slay Loser Team] All CTs should die now!
[Slay Loser Team] All CTs should die now!
[Slay Loser Team] All T's should die now!
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-18-2011 , 07:10   Re: Why is this getting called multiple times?
Reply With Quote #6

Show the whole plugin code.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-18-2011 at 07:47.
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 12-18-2011 , 07:21   Re: Why is this getting called multiple times?
Reply With Quote #7

See the second method, just remove the cvar part and see if it happens for you. I tried it on a local server and on a public one. Happend on both.
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-18-2011 , 07:45   Re: Why is this getting called multiple times?
Reply With Quote #8

I get this log file :
Code:
L 12/18/2011 - 13:42:08 - 20.087203: Round Start
L 12/18/2011 - 13:42:45 - 56.659656: TERRORISTs WIN slay CTs <%!MRAD_terwin>
L 12/18/2011 - 13:42:45 - 56.659656: TERRORISTs WIN slay CTs <%!MRAD_terwin>
L 12/18/2011 - 13:42:45 - 56.659656: TERRORISTs WIN slay CTs <%!MRAD_terwin>
L 12/18/2011 - 13:42:45 - 56.659656: Round End
L 12/18/2011 - 13:42:45 - 56.659656: CTs WIN slay TERRORISTs <#Target_Bombed>
L 12/18/2011 - 13:42:45 - 56.659656: Round End
L 12/18/2011 - 13:42:50 - 61.662677: New Round
With plugin :

PHP Code:
#include <amxmodx>

#define VERSION "0.0.1"
#define PLUGIN "Slay Loosers Debug"

new bool:g_bRestarting

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
    
register_logevent("LogEvent_Round_Start"2"1=Round_Start")
    
register_logevent("Logevent_Round_End"2"1=Round_End")
    
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w")
    
register_event("SendAudio""Event_SendAudio_terwin""a""2=%!MRAD_terwin")
    
register_event("SendAudio""Event_SendAudio_ctwin""a""2=%!MRAD_ctwin")
    
LogToFile("NEW MAP")
}

public 
Event_SendAudio_terwin()
{
    new 
szAudioString[32]
    
read_data(2szAudioStringcharsmax(szAudioString))
    
LogToFile("TERRORISTs WIN slay CTs <%s>"szAudioString)
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum"ae""CT")
    for(--
iNumiNum>=0iNum--)
    {
        
user_kill(iPlayers[iNum], 1)
    }
}

public 
Event_SendAudio_ctwin()
{
    new 
szAudioString[32]
    
read_data(2szAudioStringcharsmax(szAudioString))
    
LogToFile("CTs WIN slay TERRORISTs <%s>"szAudioString)
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum"ae""TERRORIST")
    for(--
iNumiNum>=0iNum--)
    {
        
user_kill(iPlayers[iNum], 1)
    }
}

public 
Event_TextMsg_Restart()
{
    
g_bRestarting true
    LogToFile
("Restart has been triggered")
}

public 
Event_HLTV_New_Round()
{
    if( 
g_bRestarting )
    {
        
LogToFile("New Round (RESTARTED)")
        
g_bRestarting false
    
}
    else
    {
        
LogToFile("New Round")
    }
}

public 
LogEvent_Round_Start()
{
    
LogToFile("Round Start")
}

public 
Logevent_Round_End()
{
    
LogToFile("Round End")
}

LogToFile(const fmt[], any:...)
{
    static 
szLogFile[64]
    static 
date[64]
    if( !
szLogFile[0] )
    {
        
get_localinfo("amxx_logs"szLogFilecharsmax(szLogFile))
        
format(szLogFilecharsmax(szLogFile), "%s/slay_loosers_%s.log"szLogFiledate)
    }

    new 
szLog[256]
    
vformat(szLogcharsmax(szLog), fmt2)

    
get_time("%m/%d/%Y - %H:%M:%S"datecharsmax(date))

    new 
fp fopen(szLogFile"at")
    
fprintf(fp"L %s - %f: %s^n"dateget_gametime(), szLog)
    
fclose(fp)


So, yes, i guess there is a problem with amxx.

Have you tried with last official amxx release ?


EDIT :

I've fixed with rechecking in callback.
I still log Round_End 2 times...

PHP Code:
#include <amxmodx>

#define VERSION "0.0.2"
#define PLUGIN "Slay Loosers Debug"

new bool:g_bRestarting

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_event("HLTV""Event_HLTV_New_Round""a""1=0""2=0")
    
register_logevent("LogEvent_Round_Start"2"1=Round_Start")
    
register_logevent("Logevent_Round_End"2"1=Round_End")
    
register_event("TextMsg""Event_TextMsg_Restart""a""2&#Game_C""2&#Game_w")
    
register_event("SendAudio""Event_SendAudio""a")
    
LogToFile("NEW MAP")
}

public 
Event_SendAudio()
{
    new 
szAudioString[32], Float:flGameTime get_gametime()
    
read_data(2szAudioStringcharsmax(szAudioString))
    if( 
equal(szAudioString"%!MRAD_terwin") )
    {
        static 
Float:flOldTerGameTime
        
if( flGameTime flOldTerGameTime )
        {
            
flOldTerGameTime flGameTime
            LogToFile
("TERRORISTs WIN slay CTs <%s>"szAudioString)
            new 
iPlayers[32], iNum
            get_players
(iPlayersiNum"ae""CT")
            for(--
iNumiNum>=0iNum--)
            {
                
user_kill(iPlayers[iNum], 1)
            }
        }
    }
    else if( 
equal(szAudioString"%!MRAD_ctwin" ) )
    {
        static 
Float:flOldCtGameTime
        
if( flGameTime flOldCtGameTime )
        {
            
flOldCtGameTime flGameTime
            LogToFile
("CTs WIN slay TERRORISTs <%s>"szAudioString)
            new 
iPlayers[32], iNum
            get_players
(iPlayersiNum"ae""TERRORIST")
            for(--
iNumiNum>=0iNum--)
            {
                
user_kill(iPlayers[iNum], 1)
            }
        }
    }
}

public 
Event_TextMsg_Restart()
{
    
g_bRestarting true
    LogToFile
("Restart has been triggered")
}

public 
Event_HLTV_New_Round()
{
    if( 
g_bRestarting )
    {
        
LogToFile("New Round (RESTARTED)")
        
g_bRestarting false
    
}
    else
    {
        
LogToFile("New Round")
    }
}

public 
LogEvent_Round_Start()
{
    
LogToFile("Round Start")
}

public 
Logevent_Round_End()
{
    
LogToFile("Round End")
}

LogToFile(const fmt[], any:...)
{
    static 
szLogFile[64]
    static 
date[64]
    if( !
szLogFile[0] )
    {
        
get_localinfo("amxx_logs"szLogFilecharsmax(szLogFile))
        
format(szLogFilecharsmax(szLogFile), "%s/slay_loosers_%s.log"szLogFiledate)
    }

    new 
szLog[256]
    
vformat(szLogcharsmax(szLog), fmt2)

    
get_time("%m/%d/%Y - %H:%M:%S"datecharsmax(date))

    new 
fp fopen(szLogFile"at")
    
fprintf(fp"L %s - %f: %s^n"dateget_gametime(), szLog)
    
fclose(fp)

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-18-2011 at 08:01.
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 12-18-2011 , 08:04   Re: Why is this getting called multiple times?
Reply With Quote #9

Wow, this is really weird. I wonder why this was never found out before

I tried it now with 1.8.2, and it is the same. A little odd is, that I was using this way in several mods to reverse the players to change the teams. But what would I need todo now? File a bug? Or would you look in it abit more?
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-18-2011 , 08:12   Re: Why is this getting called multiple times?
Reply With Quote #10

Tried with amx1.8.1 and have same results.

Code:
L 12/18/2011 - 14:08:44 - 1.000000: NEW MAP
L 12/18/2011 - 14:08:53 - 9.003758: Round Start
L 12/18/2011 - 14:09:08 - 24.115863: Restart has been triggered
L 12/18/2011 - 14:09:08 - 24.115863: Restart has been triggered
L 12/18/2011 - 14:09:09 - 25.117305: New Round (RESTARTED)
L 12/18/2011 - 14:09:10 - 26.117609: Round Start
L 12/18/2011 - 14:09:45 - 61.448158: TERRORISTs WIN slay CTs <%!MRAD_terwin>
L 12/18/2011 - 14:09:45 - 61.448158: Round End
L 12/18/2011 - 14:09:50 - 66.451591: New Round
L 12/18/2011 - 14:09:51 - 67.452041: Round Start
L 12/18/2011 - 14:09:52 - 68.142684: Restart has been triggered
L 12/18/2011 - 14:09:52 - 68.142684: Round End
L 12/18/2011 - 14:09:55 - 71.144470: New Round (RESTARTED)
L 12/18/2011 - 14:09:56 - 72.145050: Round Start
L 12/18/2011 - 14:10:43 - 119.130653: TERRORISTs WIN slay CTs <%!MRAD_terwin>
L 12/18/2011 - 14:10:43 - 119.130653: TERRORISTs WIN slay CTs <%!MRAD_terwin>
L 12/18/2011 - 14:10:43 - 119.130653: TERRORISTs WIN slay CTs <%!MRAD_terwin>
L 12/18/2011 - 14:10:43 - 119.130653: Round End
L 12/18/2011 - 14:10:43 - 119.130653: CTs WIN slay TERRORISTs <#Target_Bombed>
L 12/18/2011 - 14:10:43 - 119.130653: Round End
L 12/18/2011 - 14:10:48 - 124.134735: New Round
L 12/18/2011 - 14:10:49 - 125.137092: Round Start
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 12-18-2011 at 08:14.
ConnorMcLeod 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 11:55.


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