splewis/csgo-practice-mode

sm_practicemode_autostart 1 triggers on round start (not just map start)

Lidbetter opened this issue · 2 comments

Expected behavior

When using sm_practicemode_autostart 1 I expect:

  • practice mode to be on after changing level (which it is)
  • disable practice mode (sm_exitpractice) then mp_restartgame 1 / get5 scrim, practice mode remains disabled

Actual behavior

When using sm_practicemode_autostart 1 I experience:

  • (after exiting prac mode) every time a new round starts practice mode is re-enabled

Steps to reproduce

  • Plugin version: 1.3.4
  • Sourcemod version: 1.10.0.6524
  • Steps to reproduce (please be specific):
    • in csgo/cfg/practicemode.cfg have sm_practicemode_autostart 1
    • disable practice mode via menu or sm_exitpractice
    • mp_restartgame 1

Practice mode is also re-enabled on round restart even if sm_practicemode_can_be_started 0

For now I have worked around this issue (because it is nice to have the server start in prac mode) by adding the following lines to the cfg files which get5 executes when starting a scrim

sm_practicemode_autostart 0
sm_exitpractice

So looks like this is intentional:

public void CheckAutoStart() {
// Autostart practicemode if enabled.
if (g_AutostartCvar.IntValue != 0 && !g_InPracticeMode) {
bool pugsetup_live = g_PugsetupLoaded && PugSetup_GetGameState() != GameState_None;
if (!pugsetup_live) {
LaunchPracticeMode();
}
}
}

public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
CheckAutoStart();
if (!g_InPracticeMode) {
return Plugin_Continue;
}
int client = GetClientOfUserId(event.GetInt("userid"));
if (IsPlayer(client) && g_SavedRespawnActive[client]) {
TeleportEntity(client, g_SavedRespawnOrigin[client], g_SavedRespawnAngles[client], NULL_VECTOR);
}
if (IsPMBot(client)) {
GiveBotParams(client);
}
// TODO: move this elsewhere and save it properly.
if (g_InBotReplayMode && g_BotMimicLoaded && IsReplayBot(client)) {
Client_SetArmor(client, 100);
SetEntData(client, FindSendPropInfo("CCSPlayer", "m_bHasHelmet"), true);
}
return Plugin_Continue;
}

Without introducing anymore state, perhaps one way we could address this is to set g_AutostartCvar.IntValue 0 when disabling prac mode (and re-reading from cfg file when (re)enabled (via ingame menu or command))

I would agree the current behavior is a little strange in the way you describe. IMO, once practicemode is turned off by players on a server, it shouldn't be restarted without a map change.

I think I would prefer doing that without actually having to modify the g_AutostartCvar value.