• 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 ".. getitemname .."??

Imfreezing

Krossa Kapitalismen
Joined
Jun 7, 2012
Messages
1,009
Solutions
1
Reaction score
88
Location
Edron
hello there, I modify some scripts and i stumbled upon this error,
it45aq_UP.png

i do use 0.4
this is what i have modified
Code:
function onSay(cid, words, param, channel)
    if(param == '') then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
        return true
    end

    local t = string.explode(param, ",")
    local ret = RETURNVALUE_NOERROR
    local pos = getCreaturePosition(cid)

    local id = tonumber(t[1])
    if(not id) then
        id = getItemIdByName(t[1], false)
        if(not id) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.")
            return true
        end
    end

    local amount = 100
    if(t[2]) then
        amount = t[2]
    end

    local item = doCreateItemEx(id, amount)
    if(t[3] and getBooleanFromString(t[3])) then
        if(t[4] and getBooleanFromString(t[4])) then
            pos = getCreatureLookPosition(cid)
        end

        ret = doTileAddItemEx(pos, item)
    else
        ret = doPlayerAddItemEx(cid, item, true)
    end

    if(ret ~= RETURNVALUE_NOERROR) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Couldn't add item: " .. t[1])
        return true
    end

    doDecayItem(item)
    if(not isPlayerGhost(cid)) then
    doWriteLogFile("data/logs/items.txt", "[".. os.date('%d %B %y - %H:%M') .."] ".. getCreatureName(cid) .." has created item ".. t[1] ..".")
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You Spawned a ".. getItemName(cid) .. "!")
        doSendMagicEffect(pos, CONST_ME_MAGIC_RED)
    end

    return true
end
Code:
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You Spawned a ".. getItemName(cid) .. "!")
Yeah and i do have the lib added
Code:
-- MY LIBS
function getItemName(item)
return item.uid > 0 and getItemNameById(item) or false
end
events = {}
thanks alot for any help :D
 
Use itemid instead of cid, so t[1], you can also use getItemInfo(t[1]).name or getItemNameById(t[1]).
Like this?
Code:
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You Spawned a ".. getItemNameById(t[1]) .. "!")
py_2dUeTi.png
 
Back
Top