From 217456cbb6535d6dbe065afb075b44362fdf5076 Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Sat, 2 Feb 2019 18:12:35 +0100 Subject: [PATCH] Added setting to disable spree sounds (entirely, or for others) --- config/wolfadmin.toml | 1 + luascripts/wolfadmin/game/sprees.lua | 19 +++++++++++++++---- luascripts/wolfadmin/util/settings.lua | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/config/wolfadmin.toml b/config/wolfadmin.toml index b5bf60e..cf52af7 100644 --- a/config/wolfadmin.toml +++ b/config/wolfadmin.toml @@ -62,4 +62,5 @@ bots = 1 [sprees] file = "sprees.toml" messages = 7 +sounds = 3 records = 1 diff --git a/luascripts/wolfadmin/game/sprees.lua b/luascripts/wolfadmin/game/sprees.lua index edcbe1e..a85b530 100644 --- a/luascripts/wolfadmin/game/sprees.lua +++ b/luascripts/wolfadmin/game/sprees.lua @@ -36,6 +36,9 @@ sprees.RECORD_DEATH = 1 sprees.RECORD_REVIVE = 2 sprees.RECORD_NUM = 3 +sprees.SOUND_PLAY_SELF = 0 +sprees.SOUND_PLAY_PUBLIC = 1 + sprees.RECORD_KILL_NAME = "kill" sprees.RECORD_DEATH_NAME = "death" sprees.RECORD_REVIVE_NAME = "revive" @@ -257,8 +260,12 @@ function sprees.onPlayerSpree(clientId, type, sourceId) currentSpree, spreeNames[type]) - if spreeMessage["sound"] and spreeMessage["sound"] ~= "" then - et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound \"sound/spree/"..spreeMessage["sound"].."\";") + if settings.get("g_spreeSounds") > 0 and spreeMessage["sound"] and spreeMessage["sound"] ~= "" then + if bits.hasbit(settings.get("g_spreeSounds"), sprees.SOUND_PLAY_PUBLIC) then + et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound \"sound/spree/"..spreeMessage["sound"].."\";") + else + et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..clientId.." \"sound/spree/"..spreeMessage["sound"].."\";") + end end et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \""..msg.."\";") @@ -270,8 +277,12 @@ function sprees.onPlayerSpree(clientId, type, sourceId) currentSpree, spreeNames[type]) - if maxSpreeMessage["sound"] and maxSpreeMessage["sound"] ~= "" then - et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound \"sound/spree/"..maxSpreeMessage["sound"].."\";") + if settings.get("g_spreeSounds") > 0 and maxSpreeMessage["sound"] and maxSpreeMessage["sound"] ~= "" then + if bits.hasbit(settings.get("g_spreeSounds"), sprees.SOUND_PLAY_PUBLIC) then + et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound \"sound/spree/"..maxSpreeMessage["sound"].."\";") + else + et.trap_SendConsoleCommand(et.EXEC_APPEND, "playsound "..clientId.." \"sound/spree/"..maxSpreeMessage["sound"].."\";") + end end et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \""..msg.."\";") diff --git a/luascripts/wolfadmin/util/settings.lua b/luascripts/wolfadmin/util/settings.lua index 3d30c51..a2b64f8 100644 --- a/luascripts/wolfadmin/util/settings.lua +++ b/luascripts/wolfadmin/util/settings.lua @@ -28,6 +28,7 @@ local data = { ["g_fileSprees"] = "sprees.toml", ["g_playerHistory"] = 1, ["g_spreeMessages"] = 7, + ["g_spreeSounds"] = 3, ["g_spreeRecords"] = 1, ["g_botRecords"] = 1, ["g_announceRevives"] = 1, @@ -111,6 +112,7 @@ local cfgStructure = { ["sprees"] = { ["file"] = "g_fileSprees", ["messages"] = "g_spreeMessages", + ["sounds"] = "g_spreeSounds", ["records"] = "g_spreeRecords" } }