misterman66 Posted July 31, 2016 Posted July 31, 2016 Why is this being triggered before the addEventHandler is being triggered? function MarkerHit() destroyElement(injured) destroyElement(marker1) destroyElement(blipp) end It is just automatically destroying the elements before the marker is being hit!
Bonsai Posted July 31, 2016 Posted July 31, 2016 Where is the handler? Most likely not bound to a specific marker, but all markers.
misterman66 Posted July 31, 2016 Author Posted July 31, 2016 Where is the handler?Most likely not bound to a specific marker, but all markers. Here it is, function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if ( ambVehicle[getElementModel ( source )] ) and ( ambSkin[getElementModel ( thePlayer )] ) then outputChatBox ( "RADIO: An accident has happened, all units respond!", client, 0, 0, 200) injured = createPed (233, 1203, -1520, 14) setPedAnimation(injured, "CRACK" ,"crckidle2", 150000000, true) blipp = createBlipAttachedTo(injured, 22) local marker1 = createMarker(500.03125, -1319.93359375, 14.099959373474, "cylinder", .5, 0, 222, 0, 100) attachElements (marker1, injured) addEventHandler( "onMarkerHit", marker1, MarkerHit ) end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) function MarkerHit() destroyElement(injured) destroyElement(marker1) destroyElement(blipp) end
John Smith Posted July 31, 2016 Posted July 31, 2016 I'm guessing that it's because the ped you're attaching the marker to is triggering onMarkerHit because marker gets positioned right where that ped is. To avoid this use a check in MarkerHit function: function MarkerHit(hitElement) if hitElement ~= injured then destroyElement(injured) destroyElement(marker1) destroyElement(blipp) end end
misterman66 Posted August 2, 2016 Author Posted August 2, 2016 I'm guessing that it's because the ped you're attaching the marker to is triggering onMarkerHit because marker gets positioned right where that ped is. To avoid this use a check in MarkerHit function: function MarkerHit(hitElement) if hitElement ~= injured then destroyElement(injured) destroyElement(marker1) destroyElement(blipp) end end Perfect, thank you!
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