Fortera Global
Intermediate OT User
- Joined
- Nov 20, 2015
- Messages
- 1,180
- Solutions
- 2
- Reaction score
- 117
I'm trying to make sure the item has the weight attribute and I did not succeed
tfs 1,2
Code:
attempt to call method 'hasAttribute' (a nil value)
tfs 1,2
Lua:
function onSay(player, words, param)
local itemType = ItemType(param)
if itemType:getId() == nil then
player:sendTextMessage(MESSAGE_INFO_DESCR, "There is no item with that name.")
return false
end
-- PROBLEM IS HERE hasAttribute
if itemType and not itemType:hasAttribute(ITEM_ATTRIBUTE_WEIGHT) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot add this item.")
return false
end
if itemType:getId() == 0 then
itemType = ItemType(tonumber(param))
if itemType:getName() == '' and itemType:getId() == '' then
player:sendTextMessage(MESSAGE_INFO_DESCR, "There is no item with that name.")
return false
end
end
return false
end