Jump to content

Mysql table


kuba90pl

Recommended Posts

Hey i got prob:

my code:

function stworzElementyDomu() 
local query = dbQuery( arp_db, "SELECT * FROM house") 
local result, numrows, errmsg = dbPoll ( query, -1 ) 
    if numrows > 0 then 
        for i,dom in ipairs (result) do 
            createObject(1239,result[i][1],result[i][2],result[i][3]) 
            outputChatBox("tworze") 
        end 
    end 
end 
addEventHandler("onResourceStart",root,stworzElementyDomu) 

its output error: createObject[expected number at argument @2 , got nil]

my mysql syntax:

17NER.jpg

i want to get ox,oy,oz and create there object for every house.Help please.

edit. fixed already. close please this thread.

Link to comment

Try maybe i wrong...

function stworzElementyDomu( ) 
    local query = dbQuery( arp_db, "SELECT * FROM house" ) 
    local result, numrows, errmsg = dbPoll ( query, -1 ) 
    if numrows > 0 then 
        for i = 1,#result do 
            if result[i]["ox"] and result[i]["oy"] and result[i]["oz"] then 
                createObject( 1239,result[i]["ox"],result[i]["oy"],result[i]["oz"] ) 
                outputChatBox( "tworze" ) 
            end  
        end 
    end 
    dbFree( query ) 
end 
addEventHandler( "onResourceStart",resourceRoot,stworzElementyDomu ) 

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...