Mr.unpredictable. Posted July 12, 2017 Share Posted July 12, 2017 (edited) Hey guys i am touching lua after a long time and facing a minor issue with tables solved the problem here is that only the last marker from the table triggers the serverevent and other marker doesn't do anything Edited July 12, 2017 by Mr.unpredictable. Link to comment
#BrosS Posted July 12, 2017 Share Posted July 12, 2017 local mm1 = {} local mm2 = {} local m1 = { [1] = {2491,-1665,12}, [2] = {2491,-1687,12} } local m2 = { [1] = {2497,-1665,12}, [2] = {2497,-1687,12} } for _,v in ipairs(m1) do mar = createMarker ( v[1],v[2],v[3], "cylinder",5.1,12,7,77,153) mm1[mar] = true end for _,d in ipairs(m2) do mar2 = createMarker ( d[1],d[2],d[3], "cylinder",5.1,100,6,77,153) mm2[mar2] = true end function sveven ( hitPlayer, matchingDimension ) if (mm1[source] and matchingDimension and hitPlayer == localPlayer ) then triggerServerEvent("event1", localPlayer) elseif (mm2[source] and matchingDimension and hitPlayer == localPlayer ) then triggerServerEvent("even2", localPlayer) end end addEventHandler("onClientMarkerHit", resourceRoot, sveven) Link to comment
pa3ck Posted July 12, 2017 Share Posted July 12, 2017 And the explanation: since you have more than one marker positions, if you run the loop number of times, the variable mar and mar2 will be replaced with the newly created marker, since a variable can have only one value, the values will be overridden. To fix that, you'll need to use tables, the way it's been done above. Link to comment
Mr.unpredictable. Posted July 12, 2017 Author Share Posted July 12, 2017 Solved Thanks 8 minutes ago, pa3ck said: And the explanation: since you have more than one marker positions, if you run the loop number of times, the variable mar and mar2 will be replaced with the newly created marker, since a variable can have only one value, the values will be overridden. To fix that, you'll need to use tables, the way it's been done above. thanks man it really helped 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