• 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 Editing item name in globalevents

Joined
Aug 15, 2014
Messages
143
Reaction score
24
Hello guys. I want to edit my item name after they receive in item shop.
I have a globalevent calling shop.lua that bring the item to player.

Code:
local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
received_item = doPlayerAddItemEx(cid, new_item)
if received_item == RETURNVALUE_NOERROR then

How I do to edit this item name?

Code:
item:setAttribute(ITEM_ATTRIBUTE_NAME, "item test name")
Dont work ;/


Other ex:

Lua:
local item = doCreateItemEx(2160, 1)
doItemSetAttribute(item, ITEM_ATTRIBUTE_NAME, 'test')
item:setDescription("aa")
doPlayerAddItemEx(player, item)

Why this way dont work?
 
Last edited:
Solution
Well you shouldnt be using deprecated functions - doCreateItemEx() returns the uniqueId, not the object itself

This should work as solution:
Lua:
local new_item = Item(doCreateItemEx(itemtogive_id, itemtogive_count))
received_item = doPlayerAddItemEx(cid, new_item:getUniqueId())
new_item:setAttribute(ITEM_ATTRIBUTE_NAME, "Item Name")

Also this check isnt working as expected - condition is always false
Lua:
if received_item == RETURNVALUE_NOERROR then

Because doPlayerAddItemEx returns a boolean, not an error state (number)
If you wonder whats the solution -> stop using those 0.x functions
Well you shouldnt be using deprecated functions - doCreateItemEx() returns the uniqueId, not the object itself

This should work as solution:
Lua:
local new_item = Item(doCreateItemEx(itemtogive_id, itemtogive_count))
received_item = doPlayerAddItemEx(cid, new_item:getUniqueId())
new_item:setAttribute(ITEM_ATTRIBUTE_NAME, "Item Name")

Also this check isnt working as expected - condition is always false
Lua:
if received_item == RETURNVALUE_NOERROR then

Because doPlayerAddItemEx returns a boolean, not an error state (number)
If you wonder whats the solution -> stop using those 0.x functions
 
Solution

Similar threads

Back
Top