• 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 Player can sell "special" items...

Nesaj

New Member
Joined
Apr 10, 2008
Messages
126
Reaction score
0
Well, I have a forge system on my server and players can use it to upgrade their equips... But now some players are selling their forged items on the npc (by mistake). Is there a way to check if the item being sold has an actiond id (so I can give the player an error message if he tries to sell a forged item)?
 
/data/npc/lib/npcsystem/npchandler.lua

Search for function NpcHandler:eek:nSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)

And replace the whole funciton with the one below, not tested so i don't grantuee that it works, but no harm in trying i guess :)

Lua:
function NpcHandler:onSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
		local callback = self:getCallback(CALLBACK_ONSELL)
		if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
			if(self:processModuleCallback(CALLBACK_ONSELL, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
				--
			end
		end
		if(itemid.actionid == ACTION_ID_OF_FORGED_ITEMS_HERE) then
			doPlayerSendCancel(cid, "You can't sell forged items!")
			return false
		end
	end

if having any actionid at all:
Lua:
function NpcHandler:onSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
		local callback = self:getCallback(CALLBACK_ONSELL)
		if(callback == nil or callback(cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
			if(self:processModuleCallback(CALLBACK_ONSELL, cid, itemid, subType, amount, ignoreCap, inBackpacks)) then
				--
			end
		end
		if(itemid.actionid > 0) then
			doPlayerSendCancel(cid, "You can't sell forged items!")
			return false
		end
	end
 
Last edited:
Thx for the help but it don't worked...
I changed > Callback onSell() function. < on modules.lua
for x=1,10 do
local k = getPlayerSlotItem(cid, x)
if k.itemid == itemid and k.actionid == 1 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You can't sell forged items!")
return false
end
end
That's the best solution till now.
 
Back
Top