Jump to content

timers


[DMC]

Recommended Posts

Posted

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

logo_left.png
Posted

your sound was exactly 28 sec long. just don't loop it!!

click on function below to get help:

playSound

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted (edited)

srry i made a mistake its not the sound i wanna stop xD

but this, srry for wasting time

Edited by Guest
logo_left.png
Posted (edited)

its that the music stops at 28 sec but the sky/veh colors dont xD, those 2 timers up are for random colors :mrgreen:

Edited by Guest
logo_left.png
Posted

Do you know about the EDIT button? ok next time use it :D

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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

logo_left.png
Posted

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)

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