tim260 Posted March 6, 2012 Share Posted March 6, 2012 As its a long time ago i did this i dont know what im doing wrong anymore myMarker = createMarker( 1478.336, 2647.9533691406, 55.8359375, 'cylinder', 2.0, 0, 0, 255, 150 ) function markerHit ( element, dimension ) setElementPosition ( element, 287.85568, 1820.85620, 17.64063 ) end addEventHandler ( 'onmyMarkerHit', myMarker, MarkerHit ) somethign with the expected argument 3 got nil Link to comment
Evil-Cod3r Posted March 6, 2012 Share Posted March 6, 2012 myMarker = createMarker( 1478.336, 2647.9533691406, 55.8359375, 'cylinder', 2.0, 0, 0, 255, 150 ) function markerHit ( element, dimension ) setElementPosition ( element, 287.85568, 1820.85620, 17.64063 ) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) Link to comment
tim260 Posted March 6, 2012 Author Share Posted March 6, 2012 myMarker = createMarker( 1478.336, 2647.9533691406, 55.8359375, 'cylinder', 2.0, 0, 0, 255, 150 ) function markerHit ( element, dimension ) setElementPosition ( element, 287.85568, 1820.85620, 17.64063 ) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) nothing is changed Link to comment
Evil-Cod3r Posted March 6, 2012 Share Posted March 6, 2012 (edited) Try This myMarker = createMarker( 1478.336, 2647.9533691406, 55.8359375, 'cylinder', 2.0, 0, 0, 255, 150 ) function MarkerHit ( hitPlayer, matchingDimension ) if getElementType( hitPlayer ) == "player" then setElementPosition ( hitPlayer, 287.85568, 1820.85620, 17.64063 ) end end addEventHandler ( "onClientMarkerHit", getRootElement(), myMarker, MarkerHit ) Updated !! Edited March 6, 2012 by Guest Link to comment
tim260 Posted March 6, 2012 Author Share Posted March 6, 2012 somethign with the expected argument 3 got nil Link to comment
Kenix Posted March 6, 2012 Share Posted March 6, 2012 Correct Client. myMarker = createMarker( 1478.336, 2647.9533691406, 55.8359375, 'cylinder', 2.0, 0, 0, 255, 150 ) addEventHandler ( 'onClientMarkerHit', myMarker, function( hitPlayer, matchingDimension ) setElementPosition ( hitPlayer, 287.85568, 1820.85620, 17.64063 ) end ) Evil-Cod3r,Your code wrong. addEventHandler ( "onClientMarkerHit", getRootElement(), myMarker, MarkerHit ) 3 argument is addEventHandler function-handler NOT ELEMENT, next arguments wrong. 1 argument in function-handler onClientMarkerHit is element player. if getElementType( hitPlayer ) == "player" then Why you need check it?If hit element is player always. tim260 myMarker = createMarker( 1478.336, 2647.9533691406, 55.8359375, 'cylinder', 2.0, 0, 0, 255, 150 ) function markerHit ( element, dimension ) setElementPosition ( element, 287.85568, 1820.85620, 17.64063 ) end addEventHandler ( 'onmyMarkerHit', myMarker, MarkerHit ) It's wrong because lua is case sensitive. Correct: myMarker = createMarker( 1478.336, 2647.9533691406, 55.8359375, 'cylinder', 2.0, 0, 0, 255, 150 ) function markerHit ( element, dimension ) setElementPosition ( element, 287.85568, 1820.85620, 17.64063 ) end addEventHandler ( 'onmyMarkerHit', myMarker, markerHit ) Example: nCount = 1 print( nCount ) --> 1 print( NCount ) --> nil 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