Originally Posted by Garkin
So you want allow background audio (so you will hear the sound) when campaign becomes available?
Then you need change function QueueQueue.OnCampaignQueueStateChanged(...) to something like this:
Lua Code:
function QueueQueue.OnCampaignQueueStateChanged(event, campaignId, isGroup, state) QueueQueue.queues[campaignId].state = state -- If entry just became available, play a very noticeable sound. if state == CAMPAIGN_QUEUE_REQUEST_STATE_CONFIRMING and QueueQueue.savedVariables.sound then --enable game sounds if game doesn't have focus if not DoesGameHaveFocus() and GetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO) == "false" then SetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO, "true") EVENT_MANAGER:RegisterForEvent(QueueQueue.name, EVENT_GAME_FOCUS_CHANGED, function(evt, hasFocus) if hasFocus then EVENT_MANAGER:UnregisterForEvent(QueueQueue.name, EVENT_GAME_FOCUS_CHANGED) SetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO, "false") end end) end PlaySound(SOUNDS.LEVEL_UP) end end
|
Thanks for always helping out Garkin.
For anyone else though who tries to use this though, when you set this setting, you can use "true" or "false"
Lua Code:
-- These work:
SetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO, "true")
SetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO, "false")
But GetSetting(..) returns a string of "1" instead of "true" or a "0" instead of "false".
So here you have to use:
Lua Code:
-- But here instead of this:
-- if not DoesGameHaveFocus() and GetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO) == "false" then
-- use this:
if not DoesGameHaveFocus() and GetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO) == "0" then
Or you could just use GetSetting_Bool(..)
Lua Code:
if not (DoesGameHaveFocus() or GetSetting_Bool(SETTING_TYPE_AUDIO, AUDIO_SETTING_BACKGROUND_AUDIO)) then
...
end