novo Posted September 27, 2011 Share Posted September 27, 2011 Hi, I tryed to make a disco time with timer, i want to see efects and listen the song for just ** seconds. I tryed to make it, but idk what is wrong. Here is my code: addCommandHandler ( "party", setTimer(300,46), function () local sound = playSound("disco_pogo.mp3") setSoundVolume(sound, 0.5) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local color = {} color[1] = math.random(0,255) color[2] = math.random(0,255) color[3] = math.random(0,255) color[4] = math.random(0,255) setVehicleColor ( car, color[1], color[2], color[3], color[4] ) setSkyGradient ( math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255) ) setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) setTimer(yo,300,46) end end end ) Plz help ! Link to comment
BorderLine Posted September 27, 2011 Share Posted September 27, 2011 I dont know if i wrong but in the settimer you need put the name of fuction for set timer in this case you put setTimer(yo,300,46) and the name of your fuction dont have name function () local sound = playSound("disco_pogo.mp3") maybe could be better if you separate the diferents funtions, playsound, randomsky, randomwater and randomcolourcar and put same comand for all Link to comment
TAPL Posted September 27, 2011 Share Posted September 27, 2011 (edited) addCommandHandler ( "party", function () setTimer(xxx,300,46) end) function xxx() local sound = playSound("disco_pogo.mp3") setSoundVolume(sound, 0.5) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local color = {} color[1] = math.random(0,255) color[2] = math.random(0,255) color[3] = math.random(0,255) color[4] = math.random(0,255) setVehicleColor ( car, color[1], color[2], color[3], color[4] ) setSkyGradient ( math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255) ) setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) end end or addCommandHandler ( "party", function () function xxx() local sound = playSound("disco_pogo.mp3") setSoundVolume(sound, 0.5) for i, car in ipairs( getElementsByType( "vehicle" ) ) do local color = {} color[1] = math.random(0,255) color[2] = math.random(0,255) color[3] = math.random(0,255) color[4] = math.random(0,255) setVehicleColor ( car, color[1], color[2], color[3], color[4] ) setSkyGradient ( math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255) ) setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) end end setTimer(xxx,300,46) end) both code work Edited September 27, 2011 by Guest Link to comment
novo Posted September 27, 2011 Author Share Posted September 27, 2011 Okay ty for help me Link to comment
novo Posted September 27, 2011 Author Share Posted September 27, 2011 Now i need help with "PlaySound" it says attempts to call global (a nil value) plz help ? Link to comment
TAPL Posted September 27, 2011 Share Posted September 27, 2011 (edited) make it client-side not server-side ^^ Edited September 27, 2011 by Guest Link to comment
novo Posted September 27, 2011 Author Share Posted September 27, 2011 I made it client-side, but now the songs start and start and start, not just 1 song, there are a lot of song playing at same time lol ! Plz help ? D: Link to comment
TAPL Posted September 27, 2011 Share Posted September 27, 2011 try this lol addCommandHandler ( "party", function () local sound = playSound("disco_pogo.mp3") setSoundVolume(sound, 0.5) function xxx() for i, car in ipairs( getElementsByType( "vehicle" ) ) do local color = {} color[1] = math.random(0,255) color[2] = math.random(0,255) color[3] = math.random(0,255) color[4] = math.random(0,255) setVehicleColor ( car, color[1], color[2], color[3], color[4] ) setSkyGradient ( math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255), math.random (0,255) ) setWaterColor(math.random (0,255), math.random (0,255), math.random (0,255)) end end setTimer(xxx,300,46) 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