Keep in mind, players can still take the item by using
Browse Field
and moving the item from there if you use that method.
What I would do is add an actionId to the item and then add something like this into
data/scripts
:
Lua:
local actionId = 13366
local blockMove = EventCallback
blockMove.onMoveItem = function(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
if item.actionid == actionId then
return RETURNVALUE_NOTPOSSIBLE
end
return RETURNVALUE_NOERROR
end
blockMove:register()
--------------------------------------------------------
local blockTrade = EventCallback
function blockTrade.onTradeRequest(player, target, item)
if item.actionid == actionId then
player:sendCancelMessage("You can not trade this item.")
return false
end
return true
end
blockTrade:register()
Remember to enable
onTradeRequest
in
data/events/events.xml
by changing
enabled="0"
to
enabled="1"
.
And this will only hinder the player from moving or attempting to trade the item, I can't think of other ways to take the item right now, but they will still be able to use the items, and use with etc...