Skip to content

Commit

Permalink
Silence by default, use USP sound for silence & move fully to !stopsound
Browse files Browse the repository at this point in the history
  • Loading branch information
Vauff authored and xen-000 committed Oct 20, 2023
1 parent 2bdb7a4 commit 29a699a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
29 changes: 6 additions & 23 deletions src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/cs2fixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/playermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 29a699a

Please sign in to comment.