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

(Talkaction) Command "/i" that sets item name.

Oneda

Aspiring Spriter
Joined
Dec 3, 2013
Messages
159
Solutions
2
Reaction score
104
Location
Brazil
Hello there!

I would like to request the /i command to be modified, to when it creates the item, it would set the name or the description of the item to:

In case of description: Created by ..playername..
In case of name: Created ..itemname..

Would appreciate if someone could help me with that.

Att, Oneda.
 
Open your data/talkactions/scripts/createitem.lua and before these two last lines of the script:
Code:
    return true
end

Add one of those codes:
Version A:
Code:
    doSetItemSpecialDescription(item, "Created by " ..getCreatureName(cid)..".")

This will overwrite the oryginal description.

Version B:
If you would like to add date and time when item was created use this line instead:
Code:
    doSetItemSpecialDescription(item, "Created by " ..getCreatureName(cid).." on " ..os.date("%c"))

Version C:
Changes the name to example: You see a blue robe, created by Andu...
Code:
setItemName(item, getItemName(item).. ", created by " ..getCreatureName(cid).." on " ..os.date("%c").. ".")
 
Last edited:
Mmmmh... Got this error here:

Code:
[17/04/2014 05:15:20] [Error - TalkAction Interface]
[17/04/2014 05:15:20] data/talkactions/scripts/createitem.lua:onSay
[17/04/2014 05:15:20] Description:
[17/04/2014 05:15:20] data/talkactions/scripts/createitem.lua:46: attempt to call global 'doSetItemDescription' (a nil value)
[17/04/2014 05:15:20] stack traceback:
[17/04/2014 05:15:20]    data/talkactions/scripts/createitem.lua:46: in function <data/talkactions/scripts/createitem.lua:1>

TFS 0.3.6, Distro from a Baiak Yourots 8.6
 
Use this createitem.lua:

Code:
function onSay(cid, words, param)
    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 tmp = getCreaturePosition(cid)

    local id = tonumber(t[1])
    if(not id) then
        id = getItemIdByName(t[1], FALSE)
        if(id == LUA_ERROR) 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]) == TRUE) then
        if(t[4] and getBooleanFromString(t[4]) == TRUE) then
            tmp = getPlayerLookPos(cid)
        end
      
        ret = doTileAddItemEx(tmp, 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

    doSendMagicEffect(tmp, CONST_ME_MAGIC_RED)
    doSetItemSpecialDescription(item, "Created by " ..getCreatureName(cid).." on " ..os.date("%c").. ".")
    --setItemName(item, getItemName(item).. ", created by " ..getCreatureName(cid).." on " ..os.date("%c").. ".")
    return true
end
 
Now it creates the item, but it shows the text as if it was a normal text (so everyone can see it), and wouldn't set the desc (same error)

Altho now on line 42.

Code:
[17/04/2014 05:47:57] data/talkactions/scripts/createitem.lua:42: attempt to call global 'doSetItemSpecialDescription' (a nil value)
 
It works for me without any errors. Try to chane item with item.uid but I don't think this will solve the problem.
 
Yeah nvm, I think its just my server libs or distro fucking me up, not the first script i get nil values... Thank you anyways dude! ♥
 
Back
Top