Skip to content

Commit

Permalink
chore: remove interact-sound functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ChatDisabled committed Dec 12, 2023
1 parent ce0c66e commit 87f34d1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 125 deletions.
95 changes: 0 additions & 95 deletions client/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ lib.registerMenu({
{label = 'Open Inventory'},
{label = 'Give Clothing Menu'},
{label = 'Give Item'},
{label = 'Play Sound'},
{label = 'Mute'}
}
}, function(selected)
Expand All @@ -300,100 +299,6 @@ lib.registerMenu({
end
ExecuteCommand('giveitem ' .. selectedPlayer.id .. ' ' .. dialog[1] .. ' ' .. dialog[2])
elseif selected == 4 then
local sounds = lib.callback.await('qbx_admin:server:getSounds', false)
if not sounds then
lib.showMenu('qbx_adminmenu_player_extra_menu', MenuIndexes.qbx_adminmenu_player_extra_menu)
return
end

for i = 1, #sounds do
lib.setMenuOptions('qbx_adminmenu_play_sounds_menu', {label = sounds[i], description = 'Press enter to play this sound', args = {sounds[i]}, close = false}, i + 2)
end

lib.showMenu('qbx_adminmenu_play_sounds_menu', MenuIndexes.qbx_adminmenu_play_sounds_menu)
elseif selected == 5 then
exports['pma-voice']:toggleMutePlayer(selectedPlayer.id)
end
end)

local volume = {1, 0.1}
local radius = {1, 10}

lib.registerMenu({
id = 'qbx_adminmenu_play_sounds_menu',
title = 'Play Sounds',
position = 'top-right',
onClose = function(keyPressed)
closeMenu(false, keyPressed, 'qbx_adminmenu_player_extra_menu')
end,
onSelected = function(selected)
MenuIndexes.qbx_adminmenu_play_sounds_menu = selected
end,
onSideScroll = function(_, scrollIndex, args)
if args == 'volume' then
if scrollIndex == 11 then return end
volume[2] = scrollIndex / 10
lib.setMenuOptions('qbx_adminmenu_play_sounds_menu', {label = 'Volume', args = {'volume'}, values = {'0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0', 'input'}, defaultIndex = scrollIndex, close = false}, 1)
elseif args == 'radius' then
if scrollIndex == 11 then return end
radius[2] = scrollIndex * 10
lib.setMenuOptions('qbx_adminmenu_play_sounds_menu', {label = 'Radius', args = {'radius'}, values = {'10', '20', '30', '40', '50', '60', '70', '80', '90', '100', 'input'}, defaultIndex = scrollIndex, close = false}, 2)
end
end,
options = {
{label = 'Volume', description = 'Volume to play the sound at', args = {'volume'}, values = {'0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0', 'input'}, defaultIndex = volume[1], close = false},
{label = 'Radius', description = 'The higher this number, the further away the sound can be heard from', args = {'radius'}, values = {'10', '20', '30', '40', '50', '60', '70', '80', '90', '100', 'input'}, defaultIndex = radius[1], close = false}
}
}, function(_, scrollIndex, args)
if args[1] == 'volume' then
if scrollIndex ~= 11 then return end
lib.hideMenu(false)
local dialog = lib.inputDialog('Set Volume Manually', {'Volume (0.00 - 1.00'})
if not dialog or not dialog[1] or dialog[1] == '' or not tonumber(dialog[1]) then
Wait(200)
lib.showMenu('qbx_adminmenu_play_sounds_menu', MenuIndexes.qbx_adminmenu_play_sounds_menu)
return
end

local result = tonumber(dialog[1])

if result < 0 or result > 1 then
exports.qbx_core:Notify('The number has to be between 0.00 and 1.00', 'error')
Wait(200)
lib.showMenu('qbx_adminmenu_play_sounds_menu', MenuIndexes.qbx_adminmenu_play_sounds_menu)
return
end

volume[2] = result --[[@as number]]
lib.setMenuOptions('qbx_adminmenu_play_sounds_menu', {label = 'Volume', args = {'volume'}, values = {'0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0', 'input'}, defaultIndex = scrollIndex, close = false}, 1)
Wait(200)
lib.showMenu('qbx_adminmenu_play_sounds_menu', MenuIndexes.qbx_adminmenu_play_sounds_menu)
return
elseif args[1] == 'radius' then
if scrollIndex ~= 11 then return end
lib.hideMenu(false)
local dialog = lib.inputDialog('Set Radius Manually', {'Radius (1 - 100'})
if not dialog or not dialog[1] or dialog[1] == '' or not tonumber(dialog[1]) then
Wait(200)
lib.showMenu('qbx_adminmenu_play_sounds_menu', MenuIndexes.qbx_adminmenu_play_sounds_menu)
return
end

local result = tonumber(dialog[1])

if result < 1 or result > 100 then
exports.qbx_core:Notify('The number has to be between 1 and 100', 'error')
Wait(200)
lib.showMenu('qbx_adminmenu_play_sounds_menu', MenuIndexes.qbx_adminmenu_play_sounds_menu)
return
end

radius[2] = result --[[@as number]]
lib.setMenuOptions('qbx_adminmenu_play_sounds_menu', {label = 'Radius', args = {'radius'}, values = {'10', '20', '30', '40', '50', '60', '70', '80', '90', '100', 'input'}, defaultIndex = scrollIndex, close = false}, 2)
Wait(200)
lib.showMenu('qbx_adminmenu_play_sounds_menu', MenuIndexes.qbx_adminmenu_play_sounds_menu)
return
end

TriggerServerEvent('InteractSound_SV:PlayWithinDistance', radius[2], args[1], volume[2])
end)
7 changes: 0 additions & 7 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
Config = {}

if lib.context == 'server' then
Config.SoundScriptName = 'interact-sound'
Config.SoundPath = '/client/html/sounds'
end

Config.Linux = false

Config.Commands = {
['usemenu'] = 'mod',
['noclip'] = 'mod',
Expand Down
23 changes: 0 additions & 23 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local isFrozen = {}
local sounds = {}

--- Checks if the source is inside of the target's routingbucket
--- if not set the source's routingbucket to the target's
Expand Down Expand Up @@ -212,14 +211,6 @@ lib.callback.register('qbx_admin:server:clothingMenu', function(source, target)
return true
end)

lib.callback.register('qbx_admin:server:getSounds', function(source)
if not exports.qbx_core:HasPermission(source, Config.Events['play sounds']) then
exports.qbx_core:Notify(source, Lang:t('error.no_perms'), 'error')
return
end
return sounds
end)

lib.callback.register('qbx_admin:server:canUseMenu', function(source)
if not exports.qbx_core:HasPermission(source, Config.Events['usemenu']) then
exports.qbx_core:Notify(source, Lang:t('error.no_perms'), 'error')
Expand All @@ -233,17 +224,3 @@ lib.callback.register('qbx_admin:server:spawnVehicle', function(source, model)
local hash = joaat(model)
return SpawnVehicle(source, hash, nil, true)
end)

CreateThread(function()
local path = GetResourcePath(Config.SoundScriptName)
local directory = ('%s%s'):format(path:gsub('//', '/'), Config.SoundPath)
if not Config.Linux then
for filename in io.popen(('dir "%s" /b'):format(directory)):lines() do
sounds[#sounds + 1] = filename:match('(.+)%..+$')
end
else
for filename in io.popen(('ls "%s" /b'):format(directory)):lines() do
sounds[#sounds + 1] = filename:match('(.+)%..+$')
end
end
end)

0 comments on commit 87f34d1

Please sign in to comment.