Jump to content

[Help] Alarm sound at midnight


Unwritten

Recommended Posts

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

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 by Zeros
wrapped code
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...