off Posted September 7, 2013 Share Posted September 7, 2013 Well, as this in the title, I want the sound (music) start only after the midnight (in game). Should I use "playSound" and what else? Link to comment
Blaawee Posted September 7, 2013 Share Posted September 7, 2013 getTime -- Or getRealTime Link to comment
off Posted September 7, 2013 Author Share Posted September 7, 2013 getTime -- Or getRealTime But how can I use it to do what I want? Link to comment
Blaawee Posted September 8, 2013 Share Posted September 8, 2013 (edited) Here's an example for real time addEventHandler( 'onClientRender', root, function ( ) local realtime = getRealTime(); local Hour = realtime.hour; local Minutes = realtime.minute; if Hour == 20 and Minutes = 0 then -- Do something, like you want to play sound : playSound( ... ); end end ); and example for game time addEventHandler( 'onClientRender', root, function ( ) local Hour, Minutes = getTime(); if Hour == 20 and Minutes = 0 then -- Do something, like you want to play sound : playSound( ... ); end end ); Edited September 8, 2013 by Guest Link to comment
off Posted September 8, 2013 Author Share Posted September 8, 2013 Hold on, did not work! See how it is: addEventHandler( 'onClienRender', root, function ( ) local Hour, Minutes = getTime(); if Hour == 6 and Minutes = 0 then playSound("sounds/Morning.mp3"); setSoundVolume(sound, 50.0) end end function ( ) local Hour, Minutes = getTime(); if Hour == 12 and Minutes = 0 then playSound("sounds/Day.mp3"); setSoundVolume(sound, 50.0) end end function ( ) local Hour, Minutes = getTime(); if Hour == 15 and Minutes = 0 then playSound("sounds/Dusk.mp3"); setSoundVolume(sound, 50.0) end end function ( ) local Hour, Minutes = getTime(); if Hour == 20 and Minutes = 0 then playSound("sounds/Night.mp3"); setSoundVolume(sound, 50.0) end end ); Link to comment
WASSIm. Posted September 8, 2013 Share Posted September 8, 2013 addEventHandler( 'onClienRender', root, function ( ) local Hour, Minutes = getTime() if Hour == 6 and Minutes == 0 then local sound = playSound("sounds/Morning.mp3") setSoundVolume(sound, 50.0) elseif Hour == 12 and Minutes == 0 then local sound = playSound("sounds/Day.mp3") setSoundVolume(sound, 50.0) elseif Hour == 15 and Minutes == 0 then local sound = playSound("sounds/Dusk.mp3") setSoundVolume(sound, 50.0) elseif Hour == 20 and Minutes == 0 then local sound = playSound("sounds/Night.mp3") setSoundVolume(sound, 50.0) end end ) Link to comment
off Posted September 8, 2013 Author Share Posted September 8, 2013 Well, still not working. Link to comment
Blaawee Posted September 8, 2013 Share Posted September 8, 2013 Change ' onClienRender ' to ' onClientRender ' Link to comment
off Posted September 8, 2013 Author Share Posted September 8, 2013 Change ' onClienRender ' to ' onClientRender ' what? Link to comment
WASSIm. Posted September 8, 2013 Share Posted September 8, 2013 addEventHandler( 'onClientRender', root, function ( ) local Hour, Minutes = getTime() if Hour == 6 and Minutes == 0 then local sound = playSound("sounds/Morning.mp3") setSoundVolume(sound, 50.0) elseif Hour == 12 and Minutes == 0 then local sound = playSound("sounds/Day.mp3") setSoundVolume(sound, 50.0) elseif Hour == 15 and Minutes == 0 then local sound = playSound("sounds/Dusk.mp3") setSoundVolume(sound, 50.0) elseif Hour == 20 and Minutes == 0 then local sound = playSound("sounds/Night.mp3") setSoundVolume(sound, 50.0) end end ) 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