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

Solved Getting concatenate error on dbGetResult query

Ecstacy

Mothafuckaaa
Joined
Dec 26, 2008
Messages
3,836
Reaction score
108
Location
The Netherlands
Hey,

I'm trying to retrieve an INT value out of my database, though when I use it in a string I get the following error:
http://piclair.com/mcvo9

If anyone could help me how to fix it, it would be much apprecitated!

Script:
Code:
function onSay(cid,words,param)
    local uid = getPlayerGUID(cid)
    local stats = {
        getCreatureHealth(cid),
        getCreatureMaxHealth(cid),
        getPlayerMana(cid),
        getPlayerMaxMana(cid),
    }

    local r_amount = db.getResult("SELECT `rebirth` FROM `players` WHERE id='"..uid.."'") --[[ Rebirths ]]

    local text = "----------------\nCurrent statistics\n----------------\n\n"
    text = text..'Current Health: '..stats[1]..'\n'
    text = text..'Maximum Health: '..stats[2]..'\n\n'
    text = text..'Current Mana: '..stats[3]..'\n'
    text = text..'Maxiumum Mana: '..stats[4]..'\n\n'
    text = text..'Rebirth Amount: '..r_amount

    doShowTextDialog(cid,2463,text)
return TRUE
end
 
Last edited:
Code:
function onSay(cid,words,param)
     local uid = getPlayerGUID(cid)
     local stats = {
       getCreatureHealth(cid),
       getCreatureMaxHealth(cid),
       getPlayerMana(cid),
       getPlayerMaxMana(cid),
     }

     local r_amount = db.getResult("SELECT `rebirth` FROM `players` WHERE id='"..uid.."'") --[[ Rebirths ]]
     local ramount = r_amount:getDataInt("rebirth")

     local text = "----------------\nCurrent statistics\n----------------\n\n"
     text = text..'Current Health: '..stats[1]..'\n'
     text = text..'Maximum Health: '..stats[2]..'\n\n'
     text = text..'Current Mana: '..stats[3]..'\n'
     text = text..'Maxiumum Mana: '..stats[4]..'\n\n'
     text = text..'Rebirth Amount: '..ramount

     doShowTextDialog(cid,2463,text)
     return true
end
 
try this:
Code:
function onSay(cid,words,param)
   local uid = getPlayerGUID(cid)
   local r_amount = db.getResult("SELECT `rebirth` FROM `players` WHERE id='"..uid.."'") --[[ Rebirths ]]
   local ramount = r_amount:getDataInt("rebirth")
   local text = ""
   local createText =
   {
     {"----------------\nCurrent statistics\n----------------\n"},
     {"Current Health:", getCreatureHealth(cid)},
     {"Maximum Health:", getCreatureMaxHealth(cid)},
     {"Current Mana:", getPlayerMana(cid)},
     {"Maximum Mana:", getPlayerMaxMana(cid)},
     {"Rebirth Amount:", ramount}
   }
  
   for k,v in pairs(createText) do
     text = text .."".. v[2] == nil and v[1] .."\n" or v[1] .." ".. v[2] .."\n"
   end
   doShowTextDialog(cid,2463,text)
   return true
end
so it's easier for you to add more functions and text if needed :p
 
Aah that looks alot cleaner, have to get used to LUA again after stopping for ~a year, lol.
Thank you :)

EDIT:

Oh I'm getting this error:
http://piclair.com/810zc

on this part
Code:
for k,v in pairs(createText) do
     text = text .."".. v[2] == nil and v[1] .."\n" or v[1] .." ".. v[2] .."\n"
   end

EDIT2:
fixed it
Code:
for k,v in pairs(createText) do
     if(v[2] == nil) then
        text = text.. v[1]..'\n'
     else
        text = text.. v[1]..' '..v[2]..'\n'
     end
   end
 
Last edited:
Back
Top