Jump to content

timers


[DMC]

Recommended Posts

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

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

:arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow::arrow:

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

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

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