Jump to content

Taczman

Members
  • Posts

    2
  • Joined

  • Last visited

Taczman's Achievements

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody.

I ordered some spaghetti with marinara sauce and I got egg noodles and ketchup. I'm an average nobody. (2/54)

1

Reputation

  1. Hi! Thats working properly! Thank you so much!
  2. Hello guys! I have a problem with converting dbQuery result. I am trying to ask the database if a colum true or false. I can extract the value in a table with dbPoll, and it frees up the Query as well, but when I try to convert the table value to boolean value it always return nil. I have tryed dbExec, but it gives back true as long as the connection is alive. My main goal is to get a boolean value in a variable. Do you know the solution? This code gives me a table local connection = exports.dm_mysql:getConnection() function onJoin() local serial = getPlayerSerial(source) local ipadress = getPlayerIP(source) local serialcheck = dbQuery(connection, "SELECT banned FROM accounts WHERE serial = ?", serial) local result = dbPoll(serialcheck, -1) outputChatBox(tostring(result), source) end addEventHandler("onPlayerJoin", root, onJoin) [2021-07-26 15:22:32] [Output] : table: 04470BF8 When I try to extract tha value from the table with the default script, that is in the dbPoll description on MTA:wiki, it gives me nil, doesn't metter if the database store value of 1 ore 0. function onJoin() local serial = getPlayerSerial(source) local ipadress = getPlayerIP(source) local serialcheck = dbQuery(connection, "SELECT banned FROM accounts WHERE serial = ?", serial) local result = dbPoll(serialcheck, -1) outputChatBox(tostring(result), source) if result then for _, row in ipairs ( 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 (tostring(row["column"]), source) -- it will output the value of the column "column" in this certain row end end end addEventHandler("onPlayerJoin", root, onJoin) [2021-07-26 15:35:01] [Output] : nil I had to convert the output to string, because I got warning for bad argument, that it gives me back nil value. [2021-07-26 15:34:21] WARNING: dm_accounts\sourceS.lua:21: Bad argument @ 'outputChatBox' [Expected string at argument 1, got nil]
×
×
  • Create New...