Raised This Month: $ Target: $400
 0% 

[L4D2] Map Change on empty server bugging out


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dustinandband
Senior Member
Join Date: May 2015
Old 09-28-2018 , 18:55   [L4D2] Map Change on empty server bugging out
Reply With Quote #1

I've spent the better part of the day writing debug logs for a plugin which I eventually plan to add functionality to. But for now, it simply grabs whatever the map, game mode, and server slots are set to when the server first starts up - and when all players disconnect it changes those settings back.

So, to test this manually, all you have to do is connect and disconnect from the server, and it'll write a log file to "logs/RestoreOnEmptyDebug.log".

I have my server startup script set to c1m4_atrium, and the game mode I switch between survival and coop. When it starts on survival, this plugin works fine and resets the map + game mode correctly - but when the game mode is set to coop, after everyone disconnects it sets the map to the first chapter (c1m1_hotel) instead of the 4th (c1m4_atrium).

I was trying to further debug the issue - but it appears the server actually thinks that the map is set correctly, though the server browser clearly says it's on "c1m1_hotel" after I disconnect.
PHP Code:
public void OnMapStart()
{
    if (
g_bEnforceCorrectMap// debug tool to try and manually call another map change if it gets set on the wrong map during the first map change..
    
{
        
#if DEBUG
        
LogToFile(sDebugLog"........................");
        
LogToFile(sDebugLog"OnMapStart - 'g_bEnforceCorrectMap' executed.");
        
#endif
        
        
char sCurrentMap[64];
        
GetCurrentMap(sCurrentMapsizeof(sCurrentMap));
        
        if (
StrEqual(sCurrentMapg_sMap))
        {
            
#if DEBUG
            
LogToFile(sDebugLog"........................");
            
LogToFile(sDebugLog"Current Map [%s] Matches the map originally stored on bootup [%s]. PASS"sCurrentMapg_sMap);
            
#endif
            
            
g_bEnforceCorrectMap false;
        } 
        else 
        {
            
#if DEBUG
            
LogToFile(sDebugLog"........................");
            
LogToFile(sDebugLog"Current Map [%s] doesn't match map originally stored on bootup [%s]. Forcing level change.."sCurrentMapg_sMap);
            
#endif
            
            
ServerCommand("changelevel %s"g_sMap);
            
//ForceChangeLevel(g_sMap, "Resetting map..");
        
}
        
    }
    
    
    
// ... some other code
    
    
    
if (g_bGrabGameSettings// Store map, gamemode, sv_maxslots settings. Only done once during lifetime of plugin.
    
{
        
g_bGrabGameSettings false;
        
        
GetCurrentMap(g_sMapsizeof(g_sMap));
        
GetConVarString(g_hGameModeg_sGameModesizeof(g_sGameMode));
        
g_iSlots GetConVarInt(g_hMaxSlots);
        if (
g_iSlots == -1// sv_maxplayers not set in server.cfg
        
{
            
g_iSlots 4;
        }
        
        
#if DEBUG
        
LogToFile(sDebugLog"........................");
        
LogToFile(sDebugLog"OnMapStart - storing map, gamemode, and slots on first bootup.");
        
LogToFile(sDebugLog"Map detected: %s"g_sMap);
        
LogToFile(sDebugLog"Game Mode detected: %s"g_sGameMode);
        
LogToFile(sDebugLog"Slots detected: %i"g_iSlots);
        
#endif
    
}

Debug log:
Code:
L 09/28/2018 - 17:14:25: [plugin.smx] ........................
L 09/28/2018 - 17:14:25: [plugin.smx] Current Map [c1m4_atrium] Matches the map originally stored on bootup [c1m4_atrium]. PASS
L 09/28/2018 - 17:14:25: [plugin.smx] ........................

The code's a mess right now because I've been heavily focused on debugging everything to see where the problem lies. So far all the other debug logs have passed correctly except this one.
Attached Files
File Type: sp Get Plugin or Get Source (resetonempty.sp - 281 views - 8.0 KB)

Last edited by dustinandband; 09-28-2018 at 18:56.
dustinandband is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 09-28-2018 , 21:55   Re: [L4D2] Map Change on empty server bugging out
Reply With Quote #2

I think "sv_hibernate_when_empty" command is the culprit here. Is it set to "1"?

Cause from what I've noticed, when the server enters hibernation, it reverts back to the first map.

Last edited by cravenge; 09-28-2018 at 21:57.
cravenge 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 19:48.


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