Forrest Posted August 6, 2013 Share Posted August 6, 2013 Right, basically I want to count the time between 2 points, probably col rectangles. So as I leave the first one the time obviously counts up from 0 to whatever it hits as I pass the second point. How would I go about doing it? Thanks. Link to comment
xXMADEXx Posted August 6, 2013 Share Posted August 6, 2013 I don't understand what your trying to do.. Link to comment
Forrest Posted August 6, 2013 Author Share Posted August 6, 2013 Right, imagine a drag race. You start at the start line, and it times your driving up until you hit the finish line and then hands you your time. I need to do that. Link to comment
Solstice. Posted August 6, 2013 Share Posted August 6, 2013 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
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