RekZ Posted October 13, 2017 Posted October 13, 2017 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.
Rockyz Posted October 13, 2017 Posted October 13, 2017 (edited) 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 October 13, 2017 by #,+( _xiRoc[K]; >
RekZ Posted October 13, 2017 Author Posted October 13, 2017 MTA server dont recognize the timer. Quote Bad argument @ 'killTimer' [Expected lua-timer at argument 1, got nil]
Rockyz Posted October 13, 2017 Posted October 13, 2017 show me your codes because i tried it and its working 2
Scripting Moderators thisdp Posted October 14, 2017 Scripting Moderators Posted October 14, 2017 (edited) Because timer is not an element. isElement(timer) always returns false. Edited October 14, 2017 by thisdp
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