AlvarO Posted March 22, 2020 Posted March 22, 2020 I'm trying to add onClientRender event to a function for 5 seconds. When these 5 seconds has gone I want to remove it. This is what i made timer_1 = setTimer(showRadioSongName, 5000, 1) timer_11 = setTimer ( function() addEventHandler("onClientRender", getRootElement(), showRadioSongName) end, 5000, 1 ) if not isTimer(timer_1) and isTimer( timer_11 ) then killTimer( timer_1 ) killTimer( timer_11 ) removeEventHandler("onClientRender", getRootElement(), showRadioSongName) end
The_GTA Posted March 22, 2020 Posted March 22, 2020 Hello AlvarO, do you want it like this? timer_1 = setTimer(showRadioSongName, 5000, 1) addEventHandler("onClientRender", getRootElement(), showRadioSongName) timer_11 = setTimer ( function() removeEventHandler("onClientRender", getRootElement(), showRadioSongName) end, 5000, 1 ) if not isTimer(timer_1) and isTimer( timer_11 ) then killTimer( timer_11 ) end By the way... What is the showRadioSongName function doing? It is a function that draws dx on the screen? Why are you doing line 1? - Martin
AlvarO Posted March 22, 2020 Author Posted March 22, 2020 Hello, what I'm trying to do is output the songname of an internet radio. showRadioSongname function is for show the message
The_GTA Posted March 22, 2020 Posted March 22, 2020 1 minute ago, AlvarO said: Hello, what I'm trying to do is output the songname of an internet radio. showRadioSongname function is for show the message Then I recommend just doing it like this: addEventHandler("onClientRender", root, showRadioSongName) setTimer( function() removeEventHandler("onClientRender", root, showRadioSongName) end, 5000, 1 ) This way showRadioSongName is executed for 5 seconds inside onClientRender and is removed after that.
The_GTA Posted March 22, 2020 Posted March 22, 2020 6 minutes ago, AlvarO said: Thanks!! Glad to help you! By the way, nice toilet roll avatar. I think it fits very much into today's times 1
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