S3M Posted January 18, 2015 Share Posted January 18, 2015 Hi there, What is the reason that i dont see the "Can't jump right now" outputChatBox in chat when timer cooldown is on? Script is working fine, only i missed the message. cooldown = {} function createRamp ( player, command ) local vehicle = getPedOccupiedVehicle ( player ) if vehicle and not isTimer( cooldown[player] ) then local x, y, z = getElementPosition ( player ) local theVehicle = getPedOccupiedVehicle ( player ) local a,b,r = getVehicleRotation ( theVehicle ) x = x - math.sin ( math.rad(r) ) * 18 y = y + math.cos ( math.rad(r) ) * 18 ramp = createObject ( 3080, x, y, z, 0, 0, r ) setTimer(destroyElement, 5000, 1, ramp ) if isTimer( cooldown[player] ) then [color=#BF0000]outputChatBox( "Can't jump right now, wait few seconds then try again.", player, 255, 0, 0 ) [/color]else outputChatBox( "Jump set!!", player, 0, 255, 0 ) cooldown[player] = setTimer( function() end, 10000, 1 ) end end end addCommandHandler ( "r", createRamp ) addCommandHandler ( "j", createRamp ) Thx Link to comment
novo Posted January 18, 2015 Share Posted January 18, 2015 The message isn't being shown because the if statement rejects the subsequent execution, as it will only be executed in case "not isTimer" returns true and once you set this timer, it will return false. You can do it as I did instead. cooldown = {} function createRamp ( player, command ) local vehicle = getPedOccupiedVehicle ( player ) if vehicle and not isTimer( cooldown[player] ) then local x, y, z = getElementPosition ( player ) local theVehicle = getPedOccupiedVehicle ( player ) local a,b,r = getVehicleRotation ( theVehicle ) x = x - math.sin ( math.rad(r) ) * 18 y = y + math.cos ( math.rad(r) ) * 18 ramp = createObject ( 3080, x, y, z, 0, 0, r ) setTimer(destroyElement, 5000, 1, ramp ) outputChatBox( "Jump set!!", player, 0, 255, 0 ) cooldown[player] = setTimer( function() end, 10000, 1 ) else outputChatBox( "Can't jump right now, wait few seconds then try again.", player, 255, 0, 0 ) end end addCommandHandler ( "r", createRamp ) addCommandHandler ( "j", createRamp ) Link to comment
S3M Posted January 18, 2015 Author Share Posted January 18, 2015 hmm grrr I am angry at myself because I had not seen this option, i tried many options, but this option I've overlooked. Thx novo. Link to comment
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