Jump to content

Missing outputChatBox


S3M

Recommended Posts

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 :wink:

Link to comment

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

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