Bean666 Posted February 21, 2021 Share Posted February 21, 2021 Hello, how do I define a position in the table , regarding the marker, whatever marker i go i always get to be on the last x,y,z on the table, how do I fix this. Markers = { [1] = { 2104.484375, 900.0869140625, 10.8203125 }, [2] = { 2103.78125, 898.1884765625, 20.021923065186 } } destination = { [1] = { 2109.7099609375, 898.2939453125, 20.085845947266, 184.77 }, [2] = { 2102.515625, 901.998046875, 10.8203125, 13.2 } } function onstart() for i, m in ipairs(Markers) do themarker = createMarker ( m[1], m[2], m[3]-1, "cylinder", 2, 25, 205, 100, 150 ) end end addEventHandler("onClientResourceStart", getRootElement(), onstart) addEventHandler ( "onClientMarkerHit", resourceRoot, function(hitPlayer) if ( hitPlayer == localPlayer ) and getElementType(hitPlayer) == "player" then for _, l in ipairs ( destination ) do setElementPosition ( hitPlayer, l[1], l[2], l[3]) end end end) Link to comment
Tekken Posted February 21, 2021 Share Posted February 21, 2021 Add this at the top of the script local markerTable = {}; Replace this themarker = createMarker ( m[1], m[2], m[3]-1, "cylinder", 2, 25, 205, 100, 150 ) with this markerTable[#markerTable + 1] = createMarker ( m[1], m[2], m[3]-1, "cylinder", 2, 25, 205, 100, 150 ) and this addEventHandler ( "onClientMarkerHit", resourceRoot, function(hitPlayer) if ( hitPlayer == localPlayer ) and getElementType(hitPlayer) == "player" then for i = 1, #markerTable do if source == markerTable[i] then local x, y, z = unpack(destination[i]); setElementPosition(hitPlayer, x, y, z); end end end end); --You should make sure that you have as many destinations as markers not to get errors, keep in minde this is a sipmle way around it can be done way better! 1 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