Thivenin Posted August 7, 2013 Share Posted August 7, 2013 hai, I wanna start a marker when the player hit the marker "startMarker" and stop it and tell you our time startMarker = createMarker ( -5475, 2376, 15, "checkpoint", 8, 250, 0, 0, 255 ) finishMarker = createMarker ( -5460, 2376, 15, "checkpoint", 8, 250, 0, 0, 255 ) local seconds = 0 function startRace () if ( markerHit == startMarker ) then timer = setTimer(seconds_function, 1000, 0) end end addEventHandler("onMarkerHit", getRootElement(), startRace) function seconds_function () seconds = seconds + 1 end function finishRace (MarkerHit, matchingDimension) if matchingDimension == true and markerHit == finishMarker then outputChatBox(seconds, source) killTimer(timer) resetTimer(timer) seconds = 0 end end addEventHandler("onMarkerHit", getRootElement(), finishRace) I found 2 function in this forum and edited a bit, I haven't got any error Link to comment
3tibe511 Posted August 7, 2013 Share Posted August 7, 2013 i dont understand you what you want to make the marker to do? Link to comment
Thivenin Posted August 7, 2013 Author Share Posted August 7, 2013 oops I failed, I meant start a time when we hit startMarker and stop that time when we hit finishMarker Link to comment
Solstice. Posted August 7, 2013 Share Posted August 7, 2013 That script is a server-side script. Link to comment
HunT Posted August 7, 2013 Share Posted August 7, 2013 Can u use missionTimer for this,is really easy to make. Link to comment
tosfera Posted August 10, 2013 Share Posted August 10, 2013 What they are all trying to say; trigger a client sided function to start and cancel the timer. Else everyone will get the timer (cause its server sided) you could try this, please note that I haven't tested it! server startMarker = createMarker ( -5475, 2376, 15, "checkpoint", 8, 250, 0, 0, 255 ) function startRace () if ( markerHit == startMarker ) then triggerClientEvent( "startRace", hitElement, hitElement ); end end addEventHandler("onMarkerHit", getRootElement(), startRace) client addEvent("startRace", true); addEventHandler("startRace", root, function ( source ) seconds = 0; finishMarker = createMarker ( -5460, 2376, 15, "checkpoint", 8, 250, 0, 0, 255 ) countSecondsTimer = setTimer( countSeconds, 1000, 0 -- s;) --> end ); function countSeconds() seconds = seconds + 1 end addEventHandler("onClientMarkerHit", finishMarker, function ( hitElement ) if ( ( source == finishMarker ) and ( hitElement = getLocalPlayer() ) ) then killTimer ( countSecondsTimer ); destroyElement ( finishMarker ); seconds = 0; end end ); 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