No4NaMe Posted March 13, 2018 Share Posted March 13, 2018 function Nightmare() local hour,minutes = getTime() if hour == 06 and minutes == 0 then local sound = playSound("day.mp3") else if hour == 12 and minutes == 0 then local sound = playSound("day.mp3") else if hour == 15 and minutes == 0 then local sound = playSound("night.mp3") else if hour == 20 and minutes == 0 then local sound = playSound("night.mp3") --setSoundVolume(sound,50.0) end end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),Nightmare) setTimer(sound, 12000,0) end end end Tell me what's wrong with this script, at the specified time the music does not want to play! Link to comment
kamyrdol32 Posted March 13, 2018 Share Posted March 13, 2018 function Nightmare() local hour,minutes = getTime() if hour == 06 and minutes == 0 then local sound = playSound("day.mp3") elseif hour == 12 and minutes == 0 then local sound = playSound("day.mp3") elseif hour == 15 and minutes == 0 then local sound = playSound("night.mp3") elseif hour == 20 and minutes == 0 then local sound = playSound("night.mp3") --setSoundVolume(sound,50.0) end end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),Nightmare) setTimer(sound, 12000,0) Link to comment
DNL291 Posted March 13, 2018 Share Posted March 13, 2018 function Nightmare() setTimer(sound, 900,0) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),Nightmare) function sound() local hour,minutes = getTime() if hour == 06 and minutes == 0 then playSound("day.mp3") elseif hour == 12 and minutes == 0 then playSound("day.mp3") elseif hour == 15 and minutes == 0 then playSound("night.mp3") elseif hour == 20 and minutes == 0 then playSound("night.mp3") --setSoundVolume(sound,50.0) end end Try it. Link to comment
MrBiG Posted March 14, 2018 Share Posted March 14, 2018 On ١٣/٣/٢٠١٨ at 04:44, No4NaMe said: Tell me what's wrong with this script, at the specified time the music does not want to play! function Nightmare( ) local hour,minutes = getTime( ) if ( hour >= 6 ) and ( hour < 12 ) then local sound = playSound ( "day.mp3" ) elseif ( hour >= 12 ) and ( hour < 15 ) then local sound = playSound ( "day.mp3" ) elseif ( hour >= 15 ) and ( hour < 20 ) then local sound = playSound ( "night.mp3" ) elseif ( hour >= 20 ) and ( hour < 24 ) then local sound = playSound ( "night.mp3" ) end setTimer(function() if ( isElement ( sound ) ) then destroyElement ( sound ) end end , 3000 , 1 ) end addEventHandler ( "onClientResourceStart" , resourceRoot , Nightmare ) 20 hours ago, DNL291 said: function Nightmare() setTimer(sound, 900,0) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),Nightmare) function sound() local hour,minutes = getTime() if hour == 06 and minutes == 0 then playSound("day.mp3") elseif hour == 12 and minutes == 0 then playSound("day.mp3") elseif hour == 15 and minutes == 0 then playSound("night.mp3") elseif hour == 20 and minutes == 0 then playSound("night.mp3") --setSoundVolume(sound,50.0) end end Try it. how the sound will start? 1 Link to comment
No4NaMe Posted March 15, 2018 Author Share Posted March 15, 2018 10 hours ago, Debo15 said: function Nightmare( ) local hour,minutes = getTime( ) if ( hour >= 6 ) and ( hour < 12 ) then local sound = playSound ( "day.mp3" ) elseif ( hour >= 12 ) and ( hour < 15 ) then local sound = playSound ( "day.mp3" ) elseif ( hour >= 15 ) and ( hour < 20 ) then local sound = playSound ( "night.mp3" ) elseif ( hour >= 20 ) and ( hour < 24 ) then local sound = playSound ( "night.mp3" ) end setTimer(function() if ( isElement ( sound ) ) then destroyElement ( sound ) end end , 3000 , 1 ) end addEventHandler ( "onClientResourceStart" , resourceRoot , Nightmare ) how the sound will start? no work Link to comment
No4NaMe Posted March 15, 2018 Author Share Posted March 15, 2018 and function playTimeSound() local hour, minutes = getTime() if hour == 06 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/day.mp3",true) elseif hur == 12 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/day.mp3",true) elseif hour == 15 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/day.mp3",true) elseif hour == 20 and minutes == 0 then local timesound = playSound(":DayZ/sounds/ambience/night.mp3",true) setSoundVolume(timesound,gameplayVariables["ambiencesoundvolume"]) end end addEventHandler("onClientRender", getRootElement(), playTimeSound ) no work Link to comment
MrBiG Posted March 15, 2018 Share Posted March 15, 2018 4 hours ago, No4NaMe said: no work Write meta script here Link to comment
No4NaMe Posted March 15, 2018 Author Share Posted March 15, 2018 3 minutes ago, Debo15 said: Write meta script here <meta> <!-- sounds folder --> <script src="sounds_c.lua" type="client" cache="false" /> <file type="client" src="day.mp3" /> <file type="client" src="night.mp3" /> </meta> Link to comment
No4NaMe Posted March 15, 2018 Author Share Posted March 15, 2018 36 minutes ago, Debo15 said: Write meta script here how to do that at a certain time the sound was turned off ? Link to comment
MrBiG Posted March 15, 2018 Share Posted March 15, 2018 3 hours ago, No4NaMe said: my code is work in my pc Link to comment
No4NaMe Posted March 15, 2018 Author Share Posted March 15, 2018 19 hours ago, Debo15 said: function Nightmare( ) local hour,minutes = getTime( ) if ( hour >= 6 ) and ( hour < 12 ) then local sound = playSound ( "day.mp3" ) elseif ( hour >= 12 ) and ( hour < 15 ) then local sound = playSound ( "day.mp3" ) elseif ( hour >= 15 ) and ( hour < 20 ) then local sound = playSound ( "night.mp3" ) elseif ( hour >= 20 ) and ( hour < 24 ) then local sound = playSound ( "night.mp3" ) end setTimer(function() if ( isElement ( sound ) ) then destroyElement ( sound ) end end , 3000 , 1 ) end addEventHandler ( "onClientResourceStart" , resourceRoot , Nightmare ) how the sound will start? no works Link to comment
Spc Posted March 15, 2018 Share Posted March 15, 2018 (edited) local sound function playBackgroundSound() if sound and isElement(sound) then stopSound(sound) end local hour,minutes = getTime( ) if hour >= 6 and hour < 12 then sound = playSound ( "day.mp3" ) elseif ( hour >= 12 ) and ( hour < 15 ) then sound = playSound ( "day.mp3" ) elseif ( hour >= 15 ) and ( hour < 20 ) then sound = playSound ( "night.mp3" ) elseif ( hour >= 20 ) and ( hour < 24 ) then sound = playSound ( "night.mp3" ) end end setTimer(playBackgroundSound, 600000, 0) setTimer(playBackgroundSound, 500, 1) Try. Edited March 15, 2018 by Spc Link to comment
No4NaMe Posted March 16, 2018 Author Share Posted March 16, 2018 12 hours ago, Spc said: local sound function playBackgroundSound() if sound and isElement(sound) then stopSound(sound) end local hour,minutes = getTime( ) if hour >= 6 and hour < 12 then sound = playSound ( "day.mp3" ) elseif ( hour >= 12 ) and ( hour < 15 ) then sound = playSound ( "day.mp3" ) elseif ( hour >= 15 ) and ( hour < 20 ) then sound = playSound ( "night.mp3" ) elseif ( hour >= 20 ) and ( hour < 24 ) then sound = playSound ( "night.mp3" ) end end setTimer(playBackgroundSound, 600000, 0) setTimer(playBackgroundSound, 500, 1) Try. and no work Just now, No4NaMe said: and no work and weather sound my code work local weathersounds = { --":DayZ/sounds/ambience/thunder.mp3", ":DayZ/sounds/ambience/crow.mp3", } function WeatherSound() if PlayWeatherSound and isElement(PlayWeatherSound) then stopSound(PlayWeatherSound) end local weatherID = getWeather() if weatherID == 4 or weatherID == 7 or weatherID == 12 or weatherID == 15 then local PlayWeatherSound = playSound(weathersounds[math.random(1,#weathersounds)]) setSoundVolume(PlayWeatherSound,gameplayVariables["ambiencesoundvolume"]) end end addEventHandler ("onClientRender",resourceRoot,WeatherSound) setTimer(WeatherSound,70000,0) Link to comment
No4NaMe Posted March 16, 2018 Author Share Posted March 16, 2018 Please help me, give me work code night sound and day Link to comment
Spc Posted March 16, 2018 Share Posted March 16, 2018 The sound is added to the meta? Maybe file is broken or you pasting this code to the server-side. The script must be on client-side. Link to comment
No4NaMe Posted March 16, 2018 Author Share Posted March 16, 2018 2 hours ago, Spc said: The sound is added to the meta? Maybe file is broken or you pasting this code to the server-side. The script must be on client-side. everything is done correctly some code works, and the one that needs to stop after the specified time does not work Link to comment
No4NaMe Posted March 18, 2018 Author Share Posted March 18, 2018 On 15.03.2018 at 21:51, Spc said: local sound function playBackgroundSound() if sound and isElement(sound) then stopSound(sound) end local hour,minutes = getTime( ) if hour >= 6 and hour < 12 then sound = playSound ( "day.mp3" ) elseif ( hour >= 12 ) and ( hour < 15 ) then sound = playSound ( "day.mp3" ) elseif ( hour >= 15 ) and ( hour < 20 ) then sound = playSound ( "night.mp3" ) elseif ( hour >= 20 ) and ( hour < 24 ) then sound = playSound ( "night.mp3" ) end end setTimer(playBackgroundSound, 600000, 0) setTimer(playBackgroundSound, 500, 1) Try. sound is played once, not by time Link to comment
Spc Posted March 18, 2018 Share Posted March 18, 2018 (edited) 3 hours ago, No4NaMe said: sound is played once, not by time local sound local time = 0 function playBackgroundSound() local hour,minutes = getTime( ) if hour >= 6 and hour < 12 then if time == 0 or (time ~= 1 and isElement(sound)) then stopSound(sound) sound = playSound ( "day.mp3",true ) end time = 1 elseif ( hour >= 12 ) and ( hour < 15 ) then if time == 0 or (time ~= 1 and isElement(sound)) then stopSound(sound) sound = playSound ( "day.mp3",true ) end time = 1 elseif ( hour >= 15 ) and ( hour < 20 ) then if time == 0 or (time ~= 2 and isElement(sound)) then stopSound(sound) sound = playSound ( "night.mp3",true ) end time = 2 elseif ( hour >= 20 ) and ( hour < 24 ) then if time == 0 or (time ~= 2 and isElement(sound)) then stopSound(sound) sound = playSound ( "night.mp3",true ) end time = 2 end end setTimer(playBackgroundSound, 600000, 0) setTimer(playBackgroundSound, 500, 1) Try it. Edited March 18, 2018 by Spc Link to comment
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