tinnitus chooser
This commit is contained in:
parent
e38052e10e
commit
f95f6bac74
5
tinnitus_chooser/addon.json
Normal file
5
tinnitus_chooser/addon.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"title" : "Tinnitus Chooser",
|
||||
"type" : "effects",
|
||||
"tags" : [ "fun", "realism" ]
|
||||
}
|
27
tinnitus_chooser/lua/autorun/client/cl_tinnitus_chooser.lua
Normal file
27
tinnitus_chooser/lua/autorun/client/cl_tinnitus_chooser.lua
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
function tinnitus_panel(CPanel)
|
||||
CPanel:AddControl("Header", {Description = "Don't like the server's tinnitus setting? Enable the override and choose what you want here."})
|
||||
|
||||
CPanel:AddControl("Checkbox", {Label = "Enable client-side override", Command = "cl_tinnitus_override", min = 0, max = 1, Type = "int"})
|
||||
|
||||
local combobox = vgui.Create("DComboBox", CPanel)
|
||||
combobox.OnSelect = function(self, index, value)
|
||||
RunConsoleCommand("cl_tinnitus", self:GetOptionData(index))
|
||||
end
|
||||
combobox:Dock(TOP)
|
||||
combobox:DockMargin(10, 10, 10, 10)
|
||||
combobox:SetValue("Select a setting")
|
||||
combobox:AddChoice("0 - Disabled", 0)
|
||||
combobox:AddChoice("1 - Enabled - HL2 Default", 1)
|
||||
combobox:AddChoice("2 - Enabled - Workshop Overhaul", 2)
|
||||
combobox:AddChoice("3 - Enabled - Custom", 3)
|
||||
|
||||
CPanel:AddControl("Textbox", {Label = "Custom sound file", Command = "cl_tinnitus_custom"})
|
||||
CPanel:AddControl("Label", {Text = "(There is a 31 character limit for client-side custom sound file)"})
|
||||
|
||||
CPanel:AddControl("Checkbox", {Label = "Enable DSP on custom sound file", Command = "cl_tinnitus_custom_dsp", min = 0, max = 1, Type = "int"})
|
||||
end
|
||||
|
||||
hook.Add("PopulateToolMenu", "edshot_custom_tinnitus_panel", function()
|
||||
spawnmenu.AddToolMenuOption("Options", "Tinnitus", "edshot_custom_tinnitus_panel", "Settings", "", "", tinnitus_panel)
|
||||
end)
|
63
tinnitus_chooser/lua/autorun/server/sv_tinnitus_chooser.lua
Normal file
63
tinnitus_chooser/lua/autorun/server/sv_tinnitus_chooser.lua
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
resource.AddWorkshop("3191391926")
|
||||
|
||||
local MAX_SFX = 3
|
||||
|
||||
CreateConVar("cl_tinnitus", 1, {FCVAR_ARCHIVE, FCVAR_USERINFO}, "Tinnitus setting", 0, MAX_SFX)
|
||||
CreateConVar("cl_tinnitus_override", 0, {FCVAR_ARCHIVE, FCVAR_USERINFO}, "Override server-side tinnitus setting", 0, 1)
|
||||
CreateConVar("cl_tinnitus_custom", "", {FCVAR_ARCHIVE, FCVAR_USERINFO}, "Custom tinnitus sound file (31 character limit)")
|
||||
CreateConVar("cl_tinnitus_custom_dsp", 0, {FCVAR_ARCHIVE, FCVAR_USERINFO}, "Enable or disable DSP on custom sound file", 0, 1)
|
||||
|
||||
local svtype = CreateConVar("sv_tinnitus", 1, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Tinnitus setting", 0, MAX_SFX)
|
||||
local svcustom = CreateConVar("sv_tinnitus_custom", "", {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Custom tinnitus sound file")
|
||||
local svcustomdsp = CreateConVar("sv_tinnitus_custom_dsp", 0, {FCVAR_ARCHIVE, FCVAR_REPLICATED}, "Enable or disable DSP on custom sound file", 0, 1)
|
||||
|
||||
hook.Add("OnDamagedByExplosion", "edshot_custom_tinnitus", function(ply, dmginfo)
|
||||
if IsValid(ply) and ply:IsPlayer() then
|
||||
local client_override = ply:GetInfoNum("cl_tinnitus_override", 0)
|
||||
local type = 0
|
||||
|
||||
if (client_override == 1) then
|
||||
type = ply:GetInfoNum("cl_tinnitus", 0)
|
||||
else
|
||||
type = svtype:GetInt()
|
||||
end
|
||||
|
||||
if (type == 0) then
|
||||
return true
|
||||
elseif (type == 1) then
|
||||
-- do nothing
|
||||
elseif (type == 2) then
|
||||
local filter = RecipientFilter()
|
||||
filter:AddPlayer(ply)
|
||||
|
||||
ply:SetDSP(33, false)
|
||||
ply:EmitSound("tinnitus.mp3", 75, 100, 1, CHAN_AUTO, 0, 0, filter)
|
||||
return false
|
||||
elseif (type == 3) then
|
||||
local use_dsp = 0
|
||||
local snd_file = ""
|
||||
|
||||
if (client_override == 1) then
|
||||
use_dsp = ply:GetInfoNum("cl_tinnitus_custom_dsp", 0)
|
||||
snd_file = ply:GetInfo("cl_tinnitus_custom")
|
||||
else
|
||||
use_dsp = svcustomdsp:GetInt()
|
||||
snd_file = svcustom:GetString()
|
||||
end
|
||||
|
||||
if (snd_file ~= "") then
|
||||
local filter = RecipientFilter()
|
||||
filter:AddPlayer(ply)
|
||||
|
||||
if (use_dsp == 1) then
|
||||
ply:SetDSP(33, false)
|
||||
end
|
||||
|
||||
ply:EmitSound(snd_file, 75, 100, 1, CHAN_AUTO, 0, 0, filter)
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
end
|
||||
end)
|
Loading…
Reference in New Issue
Block a user