Raised This Month: $32 Target: $400
 8% 

Solved [ISSUE] Round End in Loop (AMXX) / Server Crash (ReGame)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-22-2017 , 08:51   [ISSUE] Round End in Loop (AMXX) / Server Crash (ReGame)
Reply With Quote #1

So i created a plugin that whenever the server restarts ( sv_restart ) to kill all the players alive
But it happened that i noticed that sometimes things are getting a little crazy

If the server restart happens during the round end event, it has some crazy outcomes

On stock HLDS/GameDLL running AMXX 1.8.3 ( probably happens and on 1.8.2 )
- The server gets stuck in a round ending loop

On ReHLDS/ReGame running AMXX 1.8.3 ( probably happens and on 1.8.2 )
- Both the client and the server are crashing


Now i'm no genius, but in the first case, the round end should not be called again, if it is already ended.. and in the second case i have no idea..

Steps to reproduce
Code:
Version 1
Join the game
set mp_roundtime to 1
set mp_freezetime to 0
set sv_restart to 1
Now you will either get stuck in a round end loop / in case of ReHLDS + ReGame it will either loop or crash

Version 2
set mp_roundtime to 1 ( from .cfg file )
set mp_freezetime to 0 ( from .cfg file )
Join the game
Wait for the round to end
Now both the client and the server shall crash
Now you will get stuck in a round end loop, in case of ReHLDS +ReGame it will crash
Builds Used
Code:
REHLDS : 1291
REGAME : 5.3.0.270 dev
AMXMODX : 5144 dev
OS: Windows 10 & Linux
Test Code
PHP Code:

public plugin_init()
{
    
register_plugin("Plugin Test""1.0""Depresie")

    
register_logevent("logevent_round_end"2"1=Round_End")
    
register_message(get_user_msgid("TextMsg"), "hook_message_text")

}

public 
logevent_round_end()
{
    
server_cmd("sv_restart 1")
}

public 
hook_message_text(iMessageiDestiPlayer)
{
    new 
szMessage[32]
    
get_msg_arg_string(2szMessagecharsmax(szMessage))

    
// Handle Server Restart
    
if(equal(szMessage"#Game_will_restart_in"))
    {
        
kill_alive_players()
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}


public 
kill_alive_players()
{
    
client_print(0print_chat"called")

    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum"ch")

    for(new 
0iNumi++)
    {
        new 
iPlayer iPlayers[i]
        if(
is_user_alive(iPlayer))
        {
            
user_silentkill(iPlayer)
        }

    }

__________________

Last edited by Depresie; 11-22-2017 at 12:18.
Depresie is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-22-2017 , 11:35   Re: [ISSUE] Round End in Loop (AMXX) / Server Crash (ReGame)
Reply With Quote #2

Use register_event("TextMsg", "Function", "a", "2=#Game_will_restart_in") instead of register_message. When you try to kill the player, game is executing code from PlayerKilled and DeathNotice, which in turn are sending messages. But when you hook a message with register_message, it is not sent already, so most likely game tries to send another message while the previous one is not finished yet.
__________________

Last edited by HamletEagle; 11-22-2017 at 11:35.
HamletEagle is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-22-2017 , 12:08   Re: [ISSUE] Round End in Loop (AMXX) / Server Crash (ReGame)
Reply With Quote #3

Yep, works correctly now, it is like you said, it seems like sending messages in a get_user_msgid hook is not a thing to do, thanks Hamlet
__________________
Depresie 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 02:46.


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