Jump to content

marker problem


tim260

Recommended Posts

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

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 by Guest
Link to comment

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

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