diff --git a/src/commands.cpp b/src/commands.cpp index be5e20d1..176ffc79 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -187,36 +187,19 @@ void ClientPrint(CBasePlayerController *player, int hud_dest, const char *msg, . addresses::ClientPrint(player, hud_dest, buf, nullptr, nullptr, nullptr, nullptr); } -CON_COMMAND_CHAT(stopsound, "stop weapon sounds") +CON_COMMAND_CHAT(stopsound, "toggle weapon sounds") { if (!player) return; int iPlayer = player->GetPlayerSlot(); - bool bSet = !g_playerManager->IsPlayerUsingStopSound(iPlayer); + bool bStopSet = g_playerManager->IsPlayerUsingStopSound(iPlayer); + bool bSilencedSet = g_playerManager->IsPlayerUsingSilenceSound(iPlayer); - g_playerManager->SetPlayerStopSound(iPlayer, bSet); + g_playerManager->SetPlayerStopSound(iPlayer, bSilencedSet); + g_playerManager->SetPlayerSilenceSound(iPlayer, !bSilencedSet && !bStopSet); - if (bSet) - g_playerManager->SetPlayerSilenceSound(iPlayer, false); - - ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have %s weapon effects.", bSet ? "disabled" : "enabled"); -} - -CON_COMMAND_CHAT(silencesound, "silence weapon sounds") -{ - if (!player) - return; - - int iPlayer = player->GetPlayerSlot(); - bool bSet = !g_playerManager->IsPlayerUsingSilenceSound(iPlayer); - - g_playerManager->SetPlayerSilenceSound(iPlayer, bSet); - - if (bSet) - g_playerManager->SetPlayerStopSound(iPlayer, false); - - ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have %s weapon sounds.", bSet ? "silenced" : "unsilenced"); + ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have %s weapon sounds.", bSilencedSet ? "disabled" : !bSilencedSet && !bStopSet ? "silenced" : "enabled"); } CON_COMMAND_CHAT(toggledecals, "toggle world decals, if you're into having 10 fps in ZE") diff --git a/src/cs2fixes.cpp b/src/cs2fixes.cpp index d4a7359f..7b5c8f10 100644 --- a/src/cs2fixes.cpp +++ b/src/cs2fixes.cpp @@ -322,7 +322,7 @@ void CS2Fixes::Hook_PostEvent(CSplitScreenSlot nSlot, bool bLocalOnly, int nClie // original weapon_id will override new settings if not removed msg->set_weapon_id(0); msg->set_sound_type(10); - msg->set_item_def_index(60); // weapon_m4a1_silencer + msg->set_item_def_index(61); // weapon_usp_silencer uint64 clientMask = *(uint64 *)clients & g_playerManager->GetSilenceSoundMask(); diff --git a/src/playermanager.cpp b/src/playermanager.cpp index 49dd2302..50ba547f 100644 --- a/src/playermanager.cpp +++ b/src/playermanager.cpp @@ -335,6 +335,6 @@ void CPlayerManager::SetPlayerStopDecals(int slot, bool set) void CPlayerManager::ResetPlayerFlags(int slot) { SetPlayerStopSound(slot, false); - SetPlayerSilenceSound(slot, false); + SetPlayerSilenceSound(slot, true); SetPlayerStopDecals(slot, true); } diff --git a/src/playermanager.h b/src/playermanager.h index afe8b3d3..7d1c2d9a 100644 --- a/src/playermanager.h +++ b/src/playermanager.h @@ -103,7 +103,7 @@ class CPlayerManager V_memset(m_vecPlayers, 0, sizeof(m_vecPlayers)); V_memset(m_UserIdLookup, -1, sizeof(m_UserIdLookup)); m_nUsingStopSound = 0; - m_nUsingSilenceSound = 0; + m_nUsingSilenceSound = -1; // On by default m_nUsingStopDecals = -1; // On by default }