Azaroth
Members-
Posts
18 -
Joined
-
Last visited
Everything posted by Azaroth
-
Solved. Query can't SELECT Float values.
-
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...
-
Source - player who clicked lalt. This code gets values from selected row from database, but here it didn't work.
-
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)
-
MySQL Pobieranie wartości pola z tabelki.
Azaroth replied to Azaroth's topic in Pomoc ze skryptami i programowaniem w Lua
Ok. Udało mi się pobrać, ale mam inny problem... Próbuję pobrać dane pickup'a z bazy danych, który jest w tym samym miejscu co sfera. 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 -
It works without if, but I need to use that... Is there another way to get values from database? if isElementWithinColShape ( source, Sphere ) then
-
Server is connected to database. Other queries works.
-
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
-
MySQL Pobieranie wartości pola z tabelki.
Azaroth replied to Azaroth's topic in Pomoc ze skryptami i programowaniem w Lua
Nie działa. Wartość zmiennej to nil... Wiki też dużo nie mówi jak pobrać wartość. -
It's connected with mysql_connect. handler = mysql_connect("localhost", "root", "pass", "multi theft auto") @EDIT: Ok. Connected with DbConnect and got values with dbPoll, but I don't understand that dbPoll. Can someone explain me how it works? local query = dbQuery( connection, "SELECT * FROM pickups WHERE UID="..i) local result, numrows, errmsg = dbPoll ( query, -1 ) if numrows > 0 then for result, row in pairs ( result ) do -- by using a second loop (use it if you want to get the values of all columns the query selected): for column, value in pairs ( row ) do -- column = the mysql column of the table in the query -- value = the value of that column in this certain row end -- or without a second loop (use it if you want to handle every value in a special way): outputChatBox ( row["column"] ) -- it will output the value of the column "column" in this certain row end end
-
local query = dbQuery( handler, "SELECT * FROM pickups" ) It's not working. I get warning: Bad argument @ 'dbQuery' [Expected db-connection at argument 1, got userdata]
-
It's SQL, not MySQL. Will it work?
-
Hello. How to get value from MySQL Databasa? I tried mysql_query and mysql_fetch_field. mysql_query returns: MySQL result (#32) and mysql_fetch_field return field name.
-
Hello. I have problem with guiSetText. It didn't want to change text of label. I want to change it on button click. Label: gui["Otherl"] = guiCreateLabel(10, 225, 50, 15, "Other:", false, gui["_root"]) guiLabelSetHorizontalAlign(gui["Otherl"], "left", false) guiLabelSetVerticalAlign(gui["Otherl"], "center") Button: gui["MyPos"] = guiCreateButton(300, 45, 70, 20, "MyPos", false, gui["_root"]) if on_MyPos_clicked then addEventHandler("onClientGUIClick", gui["MyPos"], MyPosition, false) end Function: function on_MyPos_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end guiSetText ( gui["Otherl"], "text" ) end