• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua plz fix my DB Query

LUA:
function onSay(cid)
nick = db.query("SELECT `name` FROM `players`, ORDER BY `level` LIMIT 1;")
print("The best player is ".. nick.. "")
return true
end

LUA:
function onSay(cid)
nick = db.query("SELECT `name` FROM `players` ORDER BY `level` WHERE `vocation` = 4 OR `vocation` = 8 LIMIT 1;")
print("The best knight is ".. nick .. "")
return true
end
 
LUA:
function onSay(cid)
local res = db.query("SELECT `name` FROM `players`, ORDER BY `level` LIMIT 1;")
if res:getID() ~= -1 then
print("The best player is ".. res:getDataString("name").. "")
res:free()
end
return true
end

LUA:
function onSay(cid)
local res = db.query("SELECT `name` FROM `players` ORDER BY `level` WHERE `vocation` = 4 OR `vocation` = 8 LIMIT 1;")
if res:getID() ~= -1 then
print("The best knight is ".. res:getDataString("name") .. "")
res:free()
end
return true
end
 
@satni
not work...
@up

[9:48:51.015] [Error - TalkAction Interface]
[9:48:51.015] data/talkactions/scripts/testy.lua:onSay
[9:48:51.015] Description:
[9:48:51.015] data/talkactions/scripts/testy.lua:3: attempt to index local 'res' (a boolean value)
[9:48:51.015] stack traceback:
[9:48:51.015] data/talkactions/scripts/testy.lua:3: in function <data/talkactions/scripts/testy.lua:1>

but working:
Code:
function onSay(cid)
print(db.getResult("SELECT `name` FROM `players` ORDER BY `level` DESC LIMIT 1"):getDataString("name"))
return true
end
thx solved
 
Last edited:
Back
Top