Jump to content

[HELP] onMarkerLeave


Yolanda

Recommended Posts

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
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, 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 :P

Link to comment
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 :P

You'r welcome

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