Azaroth Posted August 18, 2012 Posted August 18, 2012 Hello. I used dbPoll to get checkpoint model from database, but it works only to line: 7. Tried with outputChatBox(posX). local ColSphere = getElementsByType ( "colshape" ) for theKey,Sphere in ipairs(ColSphere) do if isElementWithinColShape ( source, Sphere ) then local posX, posY, posZ = getElementPosition ( Sphere ) local query = dbQuery( connection, "SELECT * FROM pickups WHERE posX="..posX ) local result, numrows, errmsg = dbPoll ( query, -1 ) if numrows > 0 then for result, row in pairs ( result ) do for column, value in pairs ( row ) do end outputChatBox(row["model"]) end end end end
Dev Posted August 18, 2012 Posted August 18, 2012 Paste your /debugscript, also if possible give us a screenshot of your database.
Azaroth Posted August 18, 2012 Author Posted August 18, 2012 I can't use /debugscript. Incorrect client type for this command
AMARANT Posted August 18, 2012 Posted August 18, 2012 That means that you are not admin and have no right for this command. But anyway debugscript won't help you because your code is not client-side. I suppose you can't get a result in your function because of connection value returns false. In order to open a query to database you have to start a connection with it.
Azaroth Posted August 18, 2012 Author Posted August 18, 2012 Server is connected to database. Other queries works.
Azaroth Posted August 18, 2012 Author Posted August 18, 2012 It works without if, but I need to use that... Is there another way to get values from database? if isElementWithinColShape ( source, Sphere ) then
Flaker Posted August 18, 2012 Posted August 18, 2012 At first give us full code... For example, what is source in ur code? and also try this: local query = dbQuery( connection, "SELECT * FROM pickups WHERE posX="..tostring(posX) )
Azaroth Posted August 18, 2012 Author Posted August 18, 2012 Oh... My first post is wrong... Was thinking about something else and wrote bad post. I want to get positions to teleport from database. function Enter() local ColSphere = getElementsByType ( "colshape" ) for i, Sphere in ipairs(ColSphere) do local positionX, positionY, positionZ = getElementPosition ( Sphere ) tempSphere = createColSphere ( positionX, positionY, positionZ, 2 ) if isElementWithinColShape ( source, tempSphere ) then local query = dbQuery( connection, "SELECT * FROM pickups WHERE posX="..tostring(positionX) ) local result, numrows, errmsg = dbPoll ( query, -1 ) for result, row in pairs ( result ) do setElementPosition(source, row["posX"], row["posY"], row["posZ"]) outputChatBox(row["posX"]) end end end end addEvent( "Enterb", true ) addEventHandler( "Enterb", getRootElement(), Enter)
Flaker Posted August 18, 2012 Posted August 18, 2012 strange code... What is source? And why u warp source many times? What this code should do? also, result array should be parse with ipairs() for i, row in ipairs ( result ) do setElementPosition(source, row["posX"], row["posY"], row["posZ"]) outputChatBox(row["posX"]) end
Azaroth Posted August 19, 2012 Author Posted August 19, 2012 Source - player who clicked lalt. This code gets values from selected row from database, but here it didn't work.
Azaroth Posted August 19, 2012 Author Posted August 19, 2012 I think that there is a problem with Query, because when I write another Query then it works. local query = dbQuery(connection, "SELECT * FROM `pickups` WHERE `UID`=40" Works. local query = dbQuery(connection, "SELECT * FROM `pickups` WHERE `posX`=?", tostring(positionX)) Didn't work...
Azaroth Posted August 19, 2012 Author Posted August 19, 2012 Solved. Query can't SELECT Float values.
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