eXecuteR Posted April 23, 2014 Share Posted April 23, 2014 sorry if i wrote this topic in the wronge section i made a function in clientside which its include arrays, how would i save those arrays to SQL(Create SQL) function arrays() Markers_Pos = { x_pos = {}, y_pos = {}, z_pos = {} } Markers = {} end arrays() i = i + 1 for k,v in pairs(Markers) do local Get_x, Get_y, Get_z = getElementPosition(v) Markers_Pos.x_pos[i] = Get_x Markers_Pos.y_pos[i] = Get_y Markers_Pos.z_pos[i] = Get_z end Link to comment
-ffs-AbodyRulez Posted April 26, 2014 Share Posted April 26, 2014 Use toJSON with these positions, better then an array for each Link to comment
tosfera Posted April 26, 2014 Share Posted April 26, 2014 I would've done it like this, but there are more ways leading to Rome. ^^ local markers = { }; addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), function () local markerData = -- your sql query for i, m in ipairs ( markerData ) do table.insert ( markers, { [ "x" ] = markerData [ "x" ], [ "y" ] = markerData [ "y" ], [ "z" ] = markerData [ "z" ], [ "type" ] = markerData [ "type" ], [ "size" ] = markerData [ "size" ], [ "r" ] = markerData [ "r" ], [ "g" ] = markerData [ "g" ], [ "b" ] = markerData [ "b" ], [ "a" ] = markerData [ "a" ] } ); createMarker ( markerData [ "x" ], markerData [ "y" ], markerData [ "z" ], markerData [ "type" ], markerData [ "size" ], markerData [ "r" ], markerData [ "g" ], markerData [ "b" ], markerData [ "a" ] ); end end ); function addMarker ( x, y, z, type, size, r, g, b, a ) table.insert ( markers, { [ "x" ] = x, [ "y" ] = y, [ "z" ] = z, [ "type" ] = type, [ "size" ] = size, [ "r" ] = r, [ "g" ] = g, [ "b" ] = b, [ "a" ] = a } ); -- insert your marker into the database. end addCommandHandler ( "addMarker", addMarker ); Link to comment
eXecuteR Posted April 26, 2014 Author Share Posted April 26, 2014 Thx u alot i appreciate 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