Yolanda Posted August 17, 2014 Share Posted August 17, 2014 Hello, There is a problem with onMarkerLeave; it doesn't kill the timer nor generates the outputchatbox. So after leaving the marker, I keep earning money. I am desperately looking for some help, could you please tell what is wrong and how to fix it? thank you! ... function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then local timer = unpackTimes() setPedAnimation ( hitElement, "SWORD", "sword_IDLE") -- hitElement is the player outputChatBox("test1", getRootElement(), 0, 255, 255 ) payTimers [ hitElement ] = setTimer ( payPlayer, timer, 0, hitElement) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) function MarkerLeave( leaveElement, matchingDimension ) if getElementType( hitElement ) == "player" then if isTimer(payTimers [ hitElement ]) then killTimer(payTimers [ hitElement ]) payTimers [ hitElement ] = nil outputChatBox("test2", getRootElement(), 0, 255, 255 ) end end end addEventHandler( "onMarkerLeave", myMarker, MarkerLeave ) ... Link to comment
Max+ Posted August 17, 2014 Share Posted August 17, 2014 Hello,There is a problem with onMarkerLeave; it doesn't kill the timer nor generates the outputchatbox. So after leaving the marker, I keep earning money. I am desperately looking for some help, could you please tell what is wrong and how to fix it? thank you! ... function MarkerHit( hitElement, matchingDimension ) if getElementType( hitElement ) == "player" and not isPedInVehicle(hitElement) then local timer = unpackTimes() setPedAnimation ( hitElement, "SWORD", "sword_IDLE") -- hitElement is the player outputChatBox("test1", getRootElement(), 0, 255, 255 ) payTimers [ hitElement ] = setTimer ( payPlayer, timer, 0, hitElement) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) function MarkerLeave( leaveElement, matchingDimension ) if getElementType( hitElement ) == "player" then if isTimer(payTimers [ hitElement ]) then killTimer(payTimers [ hitElement ]) payTimers [ hitElement ] = nil outputChatBox("test2", getRootElement(), 0, 255, 255 ) end end end addEventHandler( "onMarkerLeave", myMarker, MarkerLeave ) ... seriously ? inside the function ( leaveElement ) and the codes using hitElement ? change the leaveElement to hitElement Link to comment
Et-win Posted August 17, 2014 Share Posted August 17, 2014 Not sure if stolen or just released and allowed to use it: https://forum.multitheftauto.com/viewtopic.php?f=91&t=52674 (@ Timers) Link to comment
Yolanda Posted August 17, 2014 Author Share Posted August 17, 2014 Et-win, I am only using those three functions to give the money. My idea is also developing a fishing resource, but based on markers located around the map rather than being present on the sea. Anyway thank you Max+, you pointed it out and it works now Link to comment
Max+ Posted August 17, 2014 Share Posted August 17, 2014 Et-win, I am only using those three functions to give the money. My idea is also developing a fishing resource, but based on markers located around the map rather than being present on the sea. Anyway thank you Max+, you pointed it out and it works now You'r welcome 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