Deepu Posted February 2, 2014 Share Posted February 2, 2014 Look this problem started from yesterday when I do multiple markers this error comes local marker1 = createMarker (x, y, z, "cylinder", 2, 255, 2, 0) thePlayer = getLocalPlayer () function name (hitPlayer, matchingDimension) local marker2 = createMarker(x, y, z, "cylinder", 2, 255, 2, 0) end addEventHandler("onClientMarkerHit", marker1, name) function namer (hitPlayer, matchingDimension) setPlayerHealth(thePlayer, 100) end addEventHandler("onClientMarkerHit", marker2, namer) the warning is that it tells that there is no marker in the script named marker2 Bad Argument at ..... eventhandler expected function at number 2 got nil Please reply as soon as you can and thanks Link to comment
TAPL Posted February 2, 2014 Share Posted February 2, 2014 local marker1 = createMarker(x, y, z, "cylinder", 2, 255, 2, 0) function name(hitPlayer) if hitPlayer == localPlayer then local marker2 = createMarker(x, y, z, "cylinder", 2, 255, 2, 0) addEventHandler("onClientMarkerHit", marker2, namer) end end addEventHandler("onClientMarkerHit", marker1, name) function namer(hitPlayer) if hitPlayer == localPlayer then setElementHealth(hitPlayer, 100) end end Link to comment
Deepu Posted February 2, 2014 Author Share Posted February 2, 2014 TAPL what was the problem? I mean what did I miss out? why was the second marker not functional? Tell in detail please and thanks Link to comment
TAPL Posted February 2, 2014 Share Posted February 2, 2014 setPlayerHealth doesn't exists so you should use setElementHealth. You added the event and attached it to marker2 on the resource start, while marker2 not created yet, that mean marker2 is nil that why you get the warning in the debug. You should add the event when you create the marker or you can also attach the event to root and use: if source == marker2 then Also you should make sure that who hit the marker is the localPlayer. I removed matchingDimension parameter because you're not using it. 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