• 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 Setting Item Attribute

A Dirty Rag

Active Member
Joined
Mar 31, 2014
Messages
147
Reaction score
32
I'm trying to change the attribute of an item that each player will permanently have and the attribute needs to be different for each player based on certain parameters. I was trying to get a basic script working by adding this to login.lua, but it's not working could anyone point me in the right direction? TFS 1.0


See my last post before trying to fix V
Code:
    local item = getPlayerItemById(cid, true, 5954)
    doSetItemText(item.uid, "testing")

also tried this

Code:
    local item = getPlayerItemById(cid, true, 5954)
    item.uid:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "testing")
 
Last edited:
I believe I have had the same problem. Maybe try:
Code:
local itemUID = doCreateItemEx(5954, 1)
doPlayerAddItemEx(cid, itemUID, true)
doSetItemText(itemUID, "testing")

If you want to replace the item you would have to add: doPlayerRemoveItem(cid, 5954, 1) in the beginning.
 
Ok well I almost have it working I got this to work:

Code:
    local itemUID = doCreateItemEx(5954, 1)
    local item = Item(itemUID)
    item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, getCreatureName(cid))
    doPlayerAddItemEx(cid, itemUID, true)

But how do I do the same thing to an item the player already has? I tried:
Code:
getPlayerItemById(cid, deepSearch, itemId, ...)

If I do local itemUID = getPlayerItemById(cid, true, 5954) it doesn't work, have no idea what the function actually returns.
Also what is the difference between doPlayerAddItem() and doPlayerAddItemEx()?
 
Last edited:
Code:
local p = Player(cid)
local item = p:addItem(5954, 1)
item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, p:getName())

Try that.
 
Back
Top