kuba90pl Posted February 4, 2012 Posted February 4, 2012 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: i want to get ox,oy,oz and create there object for every house.Help please. edit. fixed already. close please this thread.
Kenix Posted February 4, 2012 Posted February 4, 2012 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 )
H5N1 Posted February 4, 2012 Posted February 4, 2012 That would be better: for k,v in ipairs(result) do v["lx"] etc... 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