Mann56 Posted August 13, 2015 Posted August 13, 2015 Hey guys, I might seem a noob but i can't get the co-ordinates out of the table to create a marker. Server file : markercords = { {1945.20874, -1778.62756, 13.39060}, {1944.33765, -1773.98657, 13.39060}, {1944.09851, -1771.35437, 13.39060}, {1944.29260, -1767.30762, 13.38281}, } addEventHandler("onResourceStart",resourceRoot, function () for i , marker in pairs(markercords) do createMarker(markercords,"cylinder",2,255,255,0,100) end end ) The problem is that when i execute the code, all three cords, go in one argument, i tried with x,y and z variables too but of no use : < Please help
ParadoxTR Posted August 13, 2015 Posted August 13, 2015 Try it. markercords = { {1945.20874, -1778.62756, 13.39060}, {1944.33765, -1773.98657, 13.39060}, {1944.09851, -1771.35437, 13.39060}, {1944.29260, -1767.30762, 13.38281} } addEventHandler("onResourceStart",resourceRoot, function () for i , marker in pairs(markercords) do createMarker(markercords,"cylinder",2,255,255,0,100) end end )
KariiiM Posted August 13, 2015 Posted August 13, 2015 It should works. local markercords = { [1]={1945.20874, -1778.62756, 13.39060}, [2]={1944.33765, -1773.98657, 13.39060}, [3]={1944.09851, -1771.35437, 13.39060}, [4]={1944.29260, -1767.30762, 13.38281} } addEventHandler("onResourceStart",resourceRoot, function () for i=1, #markercords do local x , y , z = markercords[i][1], markercords[i][2], markercords[i][3] local Marker = createMarker(x , y , z,"cylinder",2,255,255,0,100) end end)
undefined Posted August 13, 2015 Posted August 13, 2015 markercords = { {1945.20874, -1778.62756, 13.39060}, {1944.33765, -1773.98657, 13.39060}, {1944.09851, -1771.35437, 13.39060}, {1944.29260, -1767.30762, 13.38281}, } addEventHandler("onResourceStart",resourceRoot, function() for i, pos in ipairs(markercords) do local x,y,z = unpack(pos) createMarker(x,y,z,"cylinder",2,255,255,0,100) end end)
znajder Posted August 13, 2015 Posted August 13, 2015 what? Try this code local markercords={ {1945.20874, -1778.62756, 13.39060}, {1944.33765, -1773.98657, 13.39060}, {1944.09851, -1771.35437, 13.39060}, {1944.29260, -1767.30762, 13.38281} } addEventHandler("onResourceStart", resourceRoot, function() for i, data in pairs(markercords) do local marker=createMarker(data[1], data[2], data[3], "cylinder", 2, 255, 255, 0, 100) end end)
KariiiM Posted August 13, 2015 Posted August 13, 2015 (edited) markercords = { {1945.20874, -1778.62756, 13.39060}, {1944.33765, -1773.98657, 13.39060}, {1944.09851, -1771.35437, 13.39060}, {1944.29260, -1767.30762, 13.38281}, } addEventHandler("onResourceStart",resourceRoot, function() for i, pos in ipairs(markercords) do local x,y,z = unpack(pos) createMarker(x,y,z,"cylinder",2,255,255,0,100) end end) and what's wrong with mine? local markercords = { [1]={1945.20874, -1778.62756, 13.39060}, [2]={1944.33765, -1773.98657, 13.39060}, [3]={1944.09851, -1771.35437, 13.39060}, [4]={1944.29260, -1767.30762, 13.38281} } addEventHandler("onResourceStart",resourceRoot, function () for i=1, #markercords do local x , y , z = markercords[i][1], markercords[i][2], markercords[i][3] local Marker = createMarker(x , y , z,"cylinder",2,255,255,0,100) end end) Edited August 13, 2015 by Guest
undefined Posted August 13, 2015 Posted August 13, 2015 Mine and yours code aren't wrong. My code is only short and useful.
KariiiM Posted August 13, 2015 Posted August 13, 2015 Also,another way local markercords = { [1]={mx=1945.20874, my=-1778.62756, mz=13.39060}, [2]={mx=1944.33765, my=-1773.98657, mz=13.39060}, [3]={mx=1944.09851, my=-1771.35437, mz=13.39060}, [4]={mx=1944.29260, my=-1767.30762, mz=13.38281} } addEventHandler("onResourceStart",resourceRoot, function () for index, data in pairs(markercords) do local marker = createMarker(data.mx, data.my, data.mz-1, "cylinder", 2, 255, 255, 0, 100) end end)
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