• 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!

SQL SELECT help

babalow

Nobody o/
Joined
Nov 7, 2007
Messages
393
Reaction score
1
Location
Brazil
Im trying to make a quest system.. so I made this function..
PHP:
function getQuestStorage(cid, name)
local player = getPlayerGUID(cid)
local quest = db.getResult("SELECT `storage` FROM `quests` WHERE `name` ='"..name.."' and `player_id` ='"..player.."';")
return quest:getDataInt("storage")
end
but I need this to return -1 if the row doesnt exist.

I'm getting this error:
PHP:
[26/03/2009 12:22:21] Lua Script Error: [TalkAction Interface] 
[26/03/2009 12:22:21] data/talkactions/scripts/custom/test.lua:onSay
[26/03/2009 12:22:21] data/lib/database.lua:39: [Result:getDataInt]: Result not set!
[26/03/2009 12:22:21] stack traceback:
[26/03/2009 12:22:21] [C]: in function 'error'
[26/03/2009 12:22:21] data/lib/database.lua:39: in function <data/lib/database.lua:37>
[26/03/2009 12:22:21] (tail call): ?
[26/03/2009 12:22:21] data/talkactions/scripts/custom/test.lua:3: in function <data/talkactions/scripts/custom/test.lua:1>
anyway.. test.lua
PHP:
function onSay(cid, words, param)
doPlayerSendTextMessage(cid,19,"".. getQuestStorage(cid, name) .."")
return TRUE
end

Example:
Table quests is empty.
execute: getQuestStorage(cid, quest_name)
if player got this quest return storage value. else return -1.

I know my English is sux.. I''m learning. Hope someone understand it.
 
Yeah you explained it very well, your english isn't that bad :thumbup:

I believe this will help:

You need to do check before:
Code:
return quest:getDataInt("storage")

add
Code:
if(quest:getID() == -1) then
		return -1
end
 
Back
Top