Jump to content

[HELP]Executing function once with handler


darul360

Recommended Posts

Hi, i have a trouble with my fuction . It's simply trigerred by hiting marker but the clue is that i want it to be trigerred ONLY ONCE like "onceTrigerredonMarkerHit".
My code as an example  :

marker2=createMarker(3399.2,-1899.2,30.1,"corona",2,0,0,255,0)
tr1=createVehicle(584,3357.5,-1956.8,31.29,0,0,90)
tr2=createVehicle(515,3347.2,-1957,31.29,0,0,90)

function open_smashb()
...
function m()
...
blowVehicle(tr)
blowVehicle(tr2)
end
setTimer(m,2000,1)
end
	addEventHandler("onMarkerHit", marker2, open_smashb) 


 

Link to comment
marker2=createMarker(3399.2,-1899.2,30.1,"corona",2,0,0,255,0)
tr1=createVehicle(584,3357.5,-1956.8,31.29,0,0,90)
tr2=createVehicle(515,3347.2,-1957,31.29,0,0,90)
local markeractive = false

function m()
  blowVehicle(tr)
  blowVehicle(tr2)
  local markeractive = true
end

function open_smashb()
  if not markeractive then
    setTimer(m,2000,1)
  end
end
addEventHandler("onMarkerHit", marker2, open_smashb) 

 

  • Like 1
  • Thanks 1
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...