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

Lua Load player.items from database into lua code

8408323

Hoster
Joined
Mar 6, 2009
Messages
432
Reaction score
26
Hello, I'm creating a new thread about the same script as earlier, though now there are some progress, and there's only one little thing missing. Which doesn't work correctly. When I execute the script, I get this error in database
Code:
attempt to concatenate global 'name' <a nil value>
The script I'm executing looks like this
Code:
function getItemsInContainer(cont, sep)
    local text = ""
    local tsep = ""
    local count = ""
    for i=1, sep do
        tsep = tsep.."-"
    end
    tsep = tsep..">"
    for i=0, getContainerSize(cont.uid)-1 do
        local item = getContainerItem(cont.uid, i)
        if isContainer(item.uid) == FALSE then
            if item.type > 1 then
                count = " ("..item.type.."x)"
            end
            text = text.."\n"..tsep..getItemName(item.itemid)..""..count.." ("..item.itemid..")"
        else
            if getContainerSize(item.uid) > 0 then
                text = text.."\n"..tsep..getItemName(item.itemid).." ("..item.itemid..")"
                text = text..getItemsInContainer(item, sep+2)..""
            else
                text = text.."\n"..tsep..getItemName(item.itemid).." ("..item.itemid..")"
            end
        end
    end
    return text
end

function onSay(cid, words, param)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return false
    end
    local slotName = {"Head", "Amulet", "Backpack", "Armor", "Right Hand", "Left Hand", "Legs", "Feet", "Ring", "Ammo Slot"}
    local t = param:split(', ')
        if getPlayerGroupId(cid) >= 3 then
            id = getItemIdByName(t[1])
            if not id then
                doPlayerSendCancel(cid, "The "..t[1].." not exist. ")
                return false
            end
            local resultID = db.storeQuery("SELECT name FROM players WHERE id IN (SELECT player_id FROM player_items WHERE itemtype = ".. id.. ");")
            local msg = "Search results by item ".. getItemName(id) .." in your database:\n\n"
            if resultID then
                while true do
                    local name = result:getDataString(resultID, 'name')
                    msg = msg .. 'name' .."\n"
                    if not resultID then
                        break
                    end
                end
            else
                msg = msg .. "The item was not found in any player."
            end
            doShowTextDialog(cid, id, msg)
        end
    end
    return true
end
And the line where the problem still exist is
Code:
msg = msg .. 'name' .."\n"
I guess there is something wrong in this part of the script:
Code:
local resultID = db.storeQuery("SELECT name FROM players WHERE id IN (SELECT player_id FROM player_items WHERE itemtype = ".. id.. ");")
since
Code:
msg = msg .. 'name' .."\n"
should work with TFS 1.0 that I'm using.
 
Back
Top