Jump to content

SQL question


eXecuteR

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...