Jump to content

[HELP] Use of timer


joao1234

Recommended Posts

Posted

hey guys i just need a simple explanation... Im trying to do when a player clicks on a button(staticimage) he can use it again after 1 hour. Any ideas to do that?

Posted
function showClientImage() 
   imgButton = guiCreateStaticImage( 20, 200, 100, 100, "imagename.png", false ) 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage ) 
  
function onImgClick(button, state, absoluteX, absoluteY) 
  if (source == imgButton) then 
     ---your code 
     destroyElement(imgButton) 
     setTimer(showClientImage, 60000, 1) 
   end 
end 
addEventHandler ("onClientGUIClick", getRootElement(), onImgClick) 

or without destroy image

function showClientImage() 
   imgButton = guiCreateStaticImage( 20, 200, 100, 100, "imagename.png", false ) 
   addEventHandler ("onClientGUIClick", getRootElement(), onImgClick)  
end 
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage ) 
  
function onImgClick(button, state, absoluteX, absoluteY) 
  if (source == imgButton) then 
     ---your code 
     removeEventHandler ("onClientGUIClick", getRootElement(), onImgClick) 
     setTimer(function()  
        addEventHandler ("onClientGUIClick", getRootElement(), onImgClick)  
     end, 60000, 1) 
   end 
end 

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