Jump to content

Timing


Forrest

Recommended Posts

Note I didn't create the variables for the waypoints for you. This is just a basic script idea. You'll have to tweak it but I hope you get the general idea.

local seconds = 0 
  
function leaveCol () 
    -- When you leave the colshape the timer 'timer' starts. 
    timer = setTimer(seconds_function, 1000, 0) 
end 
addEventHandler("onColShapeLeave", getRootElement(), leaveCol) 
  
function seconds_function () 
    -- The timer triggers function 'seconds_function' infinitely each second so you basically simulate a stopwatch. 
    seconds = seconds + 1 
end 
  
function hitCol (hitCol, matchingDimension) 
    -- So if the element is in the same dimension as the colShape waypoint and the waypoint that was hit is the next waypoint it kills and resets the timer and stopwatch. 
    if matchingDimension == true and hitCol == nextWaypoint then 
        -- Resets the timer back to 0 and outputs the time taken to reach the waypoint in the chatbox towards the source player. 
        outputChatBox(seconds, source) 
        killTimer(timer) 
        resetTimer(timer) 
        -- Resets the stopwatch to 0. 
        seconds = 0 
    end 
end 
addEventHandler("onColShapeHit", getRootElement(), hitCol) 

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