• 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!

Item not able to trade.

Lua:
local itemsnoTrade = {2160}


function onTradeRequest(cid, target, item, targetItem)
	
	if (isInArray(itemsnoTrade, item.itemid) or itemsnoTrade[1] == item.itemid) then
			doPlayerSendCancel (cid, "You can't trade this item.")
		return false
	end

	return true
end

XML:
 <event type="traderequest" name="tradeRequest" event="script" value="trade.lua"/>

login.lua
Lua:
registerCreatureEvent(cid, "tradeRequest")
 
Last edited:
yes i know i added like this:

login.lua
Code:
registerCreatureEvent(cid, "tradeRequest")

creaturescript.xml

Code:
 <event type="traderequest" name="tradeRequest" event="script" value="trade.lua"/>


trade.lua
Code:
local itemsnoTrade = {2160}
 
 
function onTradeRequest(cid, target, item, targetItem)
 
	if (isInArray(itemsnoTrade, item.itemid)) then
			doPlayerSendCancel (cid, "You can't trade this item.")
		return false
	end
 
	return true
end


when i log in its not reading this ;s
 
Try debug this, example:
Lua:
local itemsnoTrade = {2160}
 
function onTradeRequest(cid, target, item, targetItem)
	print(cid, target, item, targetItem)
	if (isInArray(itemsnoTrade, item.itemid)) then
		print(item.itemid)
		doPlayerSendCancel (cid, "You can't trade this item.")
		return false
	end

	return true
end

@down return equal break
 
Last edited:
no, if you put return false at end always will return false and you won't make trade with any item, it must return false only if the item is in the array of the items that can't be traded and don't let make the request.
btw, what distro are you using?
 
try adding more items in this line:
Lua:
local itemsnoTrade = {2160, 2148, 2132}
i don't know why don't check if is inArrray when there is only an value in the array
 
it is the same, the only problem is the function isInArray() in the distro tfs 0.3.6pl1 , don't check the values in the array if the array has only one value, updated main post
 
Maybe he should rewrite old isInArray. Try add this to libary:
Lua:
function isInArray(element, array)
	for _, value in ipairs(array) do
		if (value == element) then return true end
	end
	
	return false
end
 
Back
Top