Jump to content

Disco Time with "Timer" ! Plz help


novo

Recommended Posts

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

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
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 :D

Edited by Guest
Link to comment

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...