Jump to content

timer :S


kevin11

Recommended Posts

hey i wanna stop this at 28 seconds but it doesnt work adn doesnt give any error

function randomVehColors()
for i, car in ipairs( getElementsByType( "vehicle" ) ) do
local color = {}
	color[1] = math.random(0,126) -- random from 0 to 126, because colors is from 0 to 126
	color[2] = math.random(0,126)
	color[3] = math.random(0,126)
	color[4] = math.random(0,126) -- we take 4 random numbers because setVehicleColor have parameters with 4 colors
setVehicleColor ( car, color[1], color[2], color[3], color[4] ) -- setting color to vehicle
setSkyGradient(math.random(1, 255) ,math.random(1, 255) ,math.random(1, 255) ,math.random(1, 255) ,math.random(1, 255) ,math.random(1, 255))
end
end
 
addCommandHandler("command",
function () 
setTimer( randomVehColors, 500, 0 )
end)

Edited by Guest
Link to comment

What's the point of 2 timers?

Just use one and for the last parameter use a number of how many times you want the timer to call the randomVehColors function... If your timer has interval of 250 then set 3rd param to 112

(1000 / 250 = 4 * 28 = 112)

If it's 500 then use 56

(1000 / 500 = 2 * 28 = 56)

Link to comment
no i mean that carcolors/skygradient stops after 28sec :oops:
hey i wanna stop this at 28 seconds

Remove 1 timer and try again... There is no point of having 2 timers which execute the same function every half second at the same time.

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...