Jump to content

isTimer bug ?


RekZ

Recommended Posts

 
addEventHandler("onPlayerCommand", getRootElement(), function(cmd)
 if cmd = "timer" then
  if ( isElement(timer) and isTimer(timer)) then
   killTimer(timer)
   outputChatBox( "off!" )
  else
   timer = setTimer( function , 60000, 0)
   outputChatBox( "on!" )
  end
 end
end
 -- Result always ON
  
addEventHandler("onPlayerCommand", getRootElement(), function(cmd)
 if cmd = "timer" then
  if (isTimer(timer)) then
   killTimer(timer)
   outputChatBox( "off!" )
  else
   timer = setTimer( function , 60000, 0)
   outputChatBox( "on!" )
  end
 end
end
  
 -- Result always OFF

when i add "isElement" i get alwais ON and when i use only "isTimer" i get always OFF , i cant see what is my problem.

 

 

Link to comment
myTimers = { };

addEventHandler ( 'onPlayerCommand', root, function ( cmd )
    if ( cmd == 'timer' ) then
        if ( isTimer ( myTimers [ source ] ) ) then
            killTimer ( myTimers [ source ] )
     	   myTimers [ source ] = nil
            outputChatBox ( 'off!', source, 255, 0, 0, true )
        else
            myTimers [ source ] = setTimer ( function ( ) end, 60000, 0 )
            outputChatBox ( 'on!', source, 0, 255, 0, true )
        end
    end
end )

 

Edited by #,+( _xiRoc[K]; >
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...