[DMC] Posted July 2, 2010 Share Posted July 2, 2010 hey all i need help with timers, varez recently helped me with a sound script and i tried making a timer so it stop after 28 sec but its not working so i was wondering if someone ccould help me or post a example Link to comment
50p Posted July 2, 2010 Share Posted July 2, 2010 setTimer( stopSound, 28000, 1, yourSoundElementReturnedFrom_playSound ); Link to comment
dzek (varez) Posted July 2, 2010 Share Posted July 2, 2010 your sound was exactly 28 sec long. just don't loop it!! click on function below to get help: playSound Link to comment
[DMC] Posted July 2, 2010 Author Share Posted July 2, 2010 (edited) srry i made a mistake its not the sound i wanna stop but this, srry for wasting time Edited July 4, 2010 by Guest Link to comment
[DMC] Posted July 2, 2010 Author Share Posted July 2, 2010 (edited) its that the music stops at 28 sec but the sky/veh colors dont , those 2 timers up are for random colors Edited July 4, 2010 by Guest Link to comment
Castillo Posted July 3, 2010 Share Posted July 3, 2010 Do you know about the EDIT button? ok next time use it Link to comment
dzek (varez) Posted July 3, 2010 Share Posted July 3, 2010 addCommandHandler("mario", function () -- btw: i dont see a point in this, first one will be enough, you are probably not able to see the effect of 2nd one setTimer( randomVehColors, 250, 0 ) -- this is fired up every 250ms, you want to stop it after 28000ms, so 28000/250 = you want to execute it 112 times, so replace that zero number with 112 setTimer( randomVehColors, 500, 0 ) -- if you really need to leave it there, set times to repeat = 56 end) Link to comment
[DMC] Posted July 4, 2010 Author Share Posted July 4, 2010 i tried it at something else and it failed again... i dont see whats wrong:S everything seems ok to me it shows the image but it doesnt dissapear after 28sec function displayPic() NavmanPlate = guiCreateStaticImage(0, 0, 3.248333333333, 0.548333333333, 'files/funny.png', true, nil) guiMoveToBack( NavmanPlate ) end addCommandHandler ( "mario", displayPic ) function Timer() setTimer( displayPic, 28000, 0 ) end Link to comment
Lordy Posted July 4, 2010 Share Posted July 4, 2010 Here is what happens if someone writes /mario - It looks for command handler /mario and which function should it call now - finds function displayPic - creates NavmanPlate image - moves it to back And nothing else happens. If you want it to hide after 28 seconds, you need to call the hiding function with a timer. For example function displayPic() if not navmanPlate then -- a little protection against creating multiple instances of the same image. Create a new image only if there is none created navmanPlate = guiCreateStaticImage(0, 0, 3.248333333333, 0.548333333333, 'files/funny.png', true, nil) -- create it else -- if one is already created, just set it visible guiSetVisible(navmanPlate,true) end guiMoveToBack(navmanPlate) -- move back setTimer(guiSetVisible,28000,1,navmanPlate,false) -- calls guiSetVisible(navmanPlate,false) in 28 seconds. end addCommandHandler("mario",displayPic) 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