Unwritten Posted August 19, 2022 Share Posted August 19, 2022 Hello everyone, I am trying to create a mod that sounds a global alarm to all online players at midnight and if they are inside a house or car the sound is reduced as it normally happens in the game, I am seeing these two codes but They are not working for me and I would also like them to work together, I am learning modding little by little since I am new to the subject, thanks in advance. local OnEveryHour(player, x, y) local hour = getGameTime():getHour(); if hour == 24 then getSoundManager():PlaySound("music1", false, 10.0); end end Events.EveryHours.Add(OnEveryHour); ------------------------------------------------------ module Base { sound music1 { category = music1, loop = false, is3D = true, clip { file = media/sound/music1.ogg, distanceMax = 1500, volume = 1, } } } Link to comment Share on other sites More sharing options...
Hugo Qwerty Posted August 19, 2022 Share Posted August 19, 2022 Never done anything with sound, but for info there is the EveryDays event that runs at midnight. Maybe add a print statement to check the event code is actually running - print( "It is midnight") https://pzwiki.net/wiki/Modding:Lua_Events/EveryDays Link to comment Share on other sites More sharing options...
Zeros Posted August 19, 2022 Share Posted August 19, 2022 (edited) I've not tested it yet but you can try this to play your sound. local soundManager = getSLSoundManager() local soundList = soundManager:getStorySounds() for i=0, soundList:size() - 1 do --print(soundList[i]:getName()) if (soundList[i]:getName() == "filename_maybe") then soundList[i]:playSound() end end --[[ -- There's two more sound managers available but I haven't look check any of it yet. getWorldSoundManager() getSoundManager() --]] Edited August 19, 2022 by Zeros wrapped code Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now