Apply
In Progress
Negotiations
Finished

Budget

$10.00

Category

Applications

3

Views

414
Description

Heya,


I made an addon that plays a song when the user first joins the server. Below is my function. This function is called on PlayerInitialSpawn (and also tried with InitPostEntity), but both cause the same issue: The sound is MAXED at 100% before currentSoundChannel:SetVolume(0) can be set... Very strange bug / issue with gmod? Idk how to resolve without spending hours looking into this. Im hoping someone has already fixed it and can help. Thanks, -Murlock


    function PlayRandomSong()
        local songs = {
            "sound/vehicles_radio/vietnamfm/animalplace.mp3",
            "sound/vehicles_radio/vietnamfm/animalsun.mp3",
            "sound/vehicles_radio/vietnamfm/boots.mp3",
            "sound/vehicles_radio/vietnamfm/worth.mp3",
            "sound/vehicles_radio/vietnamfm/reaper.mp3",
            "sound/vehicles_radio/vietnamfm/onions.mp3"
        }
    
        local randomSong = songs[math.random(#songs)]
    
        sound.PlayFile(randomSong, "", function(station)
            if IsValid(station) then
                currentSoundChannel = station
                currentSoundChannel:SetVolume(0)
                currentSoundChannel:Play()
                currentSoundChannel:SetVolume(0)

                timer.Create("FadeInTimer", 1, 25, function()
                    if IsValid(currentSoundChannel) then
                        local currentVolume = currentSoundChannel:GetVolume()
                        currentSoundChannel:SetVolume(math.min(currentVolume + 0.04, 0.25))
                    else
                        timer.Remove("FadeInTimer")
                    end
                end)
            else
                print("Failed to play song: " .. randomSong)
            end
        end)
    end
DUE DATE
License
MIT License
Search products...