Hello thank for point me out where i should lookyes, there is onTradeRequest event, that you can use to prevent trading an item
btw hello me from the past, how you been? XD
--function Player:onTradeRequest(target, item)
-- if hasEventCallback(EVENT_CALLBACK_ONTRADEREQUEST) then
-- return EventCallback(EVENT_CALLBACK_ONTRADEREQUEST, self, target, item)
-- end
-- return true
--end
function Player:onTradeRequest(target, item)--function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder) --agregado bloqueo de items con aid 9552
if item.actionid == 9502 then
self:sendCancelMessage('You cannot trade this object.')
return false
end
return true
end
would it prevent items from being trade? @Sarah Wesker edited.How about blocking a square area withisInRange
?
LUA:local protectedArea = { from = Position(3197, 1807, 7), to = Position(3198, 1811, 7) } local ec = EventCallback function ec.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder) if fromPosition.x == CONTAINER_POSITION then fromPosition = item:getTopParent():getPosition() end if fromPosition:isInRange(protectedArea.from, protectedArea.to) then player:sendTextMessage(MESSAGE_INFO_DESCR, "iwi") return false end return true end ec:register(-666)
check the publication again and you will find the solution for the TradesHello thank for point me out where i should look
i did the same thing as peonso said ontraderequest, does not work, have it enabled in events.xml
Edit was enabling wron event this solved my issue
LUA:--function Player:onTradeRequest(target, item) -- if hasEventCallback(EVENT_CALLBACK_ONTRADEREQUEST) then -- return EventCallback(EVENT_CALLBACK_ONTRADEREQUEST, self, target, item) -- end -- return true --end function Player:onTradeRequest(target, item)--function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, toCylinder) --agregado bloqueo de items con aid 9552 if item.actionid == 9502 then self:sendCancelMessage('You cannot trade this object.') return false end return true end
Post automatically merged:
would it prevent items from being trade? @Sarah Wesker edited.