Dimos7 Posted June 6, 2016 Posted June 6, 2016 Try that not tested local spots = { { 2490.173828125, -1670.1630859375, 12.3 }, { 2492.6298828125, -1675.1650390625, 12.3 } } for k,v in ipairs( spots ) do marker = createMarker ( v[1],v[2],v[3], "Cylinder", 1, 255, 255, 255, 100 ) end function MarkerHit ( hitPlayer, matchingDimension ) if (hitPlayer == localPlayer) then if isPedInVehicle(hitPlayer) then return; end guiSetVisible(window, true) showCursor(true) setElementData( localPlayer, 'm', { source_ = source, pos = {getElementPosition (source) } } ) end end addEventHandler ( "onClientMarkerHit", marker, MarkerHit )
ViRuZGamiing Posted June 6, 2016 Posted June 6, 2016 for k,v in ipairs( spots ) do marker = createMarker ( v[1],v[2],v[3], "Cylinder", 1, 255, 255, 255, 100 ) addEventHandler ("onClientMarkerHit", marker, MarkerHit ) end
ViRuZGamiing Posted June 6, 2016 Posted June 6, 2016 Try that not testedlocal spots = { { 2490.173828125, -1670.1630859375, 12.3 }, { 2492.6298828125, -1675.1650390625, 12.3 } } for k,v in ipairs( spots ) do marker = createMarker ( v[1],v[2],v[3], "Cylinder", 1, 255, 255, 255, 100 ) end function MarkerHit ( hitPlayer, matchingDimension ) if (hitPlayer == localPlayer) then if isPedInVehicle(hitPlayer) then return; end guiSetVisible(window, true) showCursor(true) setElementData( localPlayer, 'm', { source_ = source, pos = {getElementPosition (source) } } ) end end addEventHandler ( "onClientMarkerHit", marker, MarkerHit ) This won't work since the event would only be attached to the last marker, the variable 'marker' gets overwritten every iteration.
Bean666 Posted June 6, 2016 Author Posted June 6, 2016 for k,v in ipairs( spots ) do marker = createMarker ( v[1],v[2],v[3], "Cylinder", 1, 255, 255, 255, 100 ) addEventHandler ("onClientMarkerHit", marker, MarkerHit ) end i did this all over before, but it only works in the first marker of the table. all i want is the MarkerHit function will only work in the "spots" table markers.
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