Hiro Posted March 20, 2012 Share Posted March 20, 2012 I made a little script that when a player hits the marker he gets a message about spraying grafitty, gives him money and the marker gets destroyed. My only problem is that i want to create like 30 of them and i dont want to copy them 30 times.. local myMarker = createMarker ( 588.2734375, -1532.080078125, 14.239238739014, "cylinder",1.7, 255, 0, 0, 100, source ) local x = createMarker ( 568.921875, -1360.4970703125, 13.930986404419, "cylinder",1.7, 255, 0, 0, 100, source ) function info(myMarker) triggerClientEvent(myMarker,"aoutput",myMarker,"Informatie","Ai gasit un grafiti ascuns si ai primit 100 lei felicitari, poti spreia peste sau pleca mai departe.") end addEventHandler ( "onMarkerHit", myMarker, info ) addEventHandler ( "onMarkerHit", x, info ) function MarkerHit( thePlayer, matchingDimension, theCost ) exports.global:giveMoney(thePlayer, 1000) destroyElement ( myMarker ) end function z( thePlayer, matchingDimension, theCost ) exports.global:giveMoney(thePlayer, 1000) destroyElement ( x ) end addEventHandler( "onMarkerHit", x, z) addEventHandler( "onMarkerHit", myMarker, MarkerHit ) Link to comment
Aibo Posted March 20, 2012 Share Posted March 20, 2012 local myMarkers = { { 588.2734375, -1532.080078125, 14.239238739014, "cylinder", 1.7, 255, 0, 0, 100, source }, { 568.921875, -1360.4970703125, 13.930986404419, "cylinder", 1.7, 255, 0, 0, 100, source }, -- you can add more } for i, markerData in ipairs(myMarkers) do addEventHandler("onMarkerHit", createMarker(unpack(markerData)), myMarkerHit) end function myMarkerHit(player) triggerClientEvent(player, "aoutput", player, "Informatie", "Ai gasit un grafiti ascuns si ai primit 100 lei felicitari, poti spreia peste sau pleca mai departe.") exports.global:giveMoney(player, 1000) removeEventHandler("onMarkerHit", source, myMarkerHit) destroyElement(source) end Link to comment
Hiro Posted March 20, 2012 Author Share Posted March 20, 2012 It worked but it had some errors the function mymarker didn't see the mymarkerhit, there was a comma wrong ,and when u enter one it destroys all. I fixed it.. local myMarkers = { { 560.3447265625, -1362.291015625, 15.174007415771, "cylinder", 1.7, 255, 0, 0, 100, source }, { 561.8369140625, -1356.1865234375, 15.113132476807, "cylinder", 1.7, 255, 0, 0, 100, source } -- you can add more } function myMarkerHit(player) triggerClientEvent(player, "aoutput", player, "Informatie", "Ai gasit un grafiti ascuns si ai primit 100 lei felicitari, poti spreia peste sau pleca mai departe.") exports.global:giveMoney(player, 1000) --removeEventHandler("onMarkerHit", source, myMarkerHit) destroyElement(source) end for i, markerData in ipairs(myMarkers) do addEventHandler("onMarkerHit", createMarker(unpack(markerData)), myMarkerHit) end Thanks btw. Link to comment
Aibo Posted March 20, 2012 Share Posted March 20, 2012 yea, i placed the handler before the function. my bad. as for comma, it is not wrong. and it shouldnt delete all, try disabling event propagating in handler. 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