if not Config.Sounds then return end SoundEnabled = true RegisterCommand("togglesound", function() SoundEnabled = not SoundEnabled if SoundEnabled then Notification(i18n.t("sound_enabled"), "success") Debug("SoundEnabled was set to true") else Notification(i18n.t("sound_disabled"), "info") Debug("SoundEnabled was set to false") end end, false) RegisterNetEvent("advancedgarages:client:PlayOnOne") AddEventHandler("advancedgarages:client:PlayOnOne", function() if not SoundEnabled then return end local randomSound = Config.SoundFiles[math.random(#Config.SoundFiles)] SendNUIMessage({ action = "playSound", data = { soundName = randomSound, soundVolume = Config.SoundVolume } }) end) RegisterNetEvent("advancedgarages:client:Stop") AddEventHandler("advancedgarages:client:Stop", function() SendNUIMessage({ action = "stopSound" }) end) function PlaySound(soundName) SendNUIMessage({ action = "playSound", data = { soundName = soundName, soundVolume = 0.4 } }) end