• 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 How to make NPCs buy item with charges in the shop list?

Xampy

PHP | SQL | LUA | C++
Joined
Jun 22, 2008
Messages
1,109
Reaction score
17
Hello.

That's my dude, how to make NPCs to buy (from players) items with charges, like eg. the Lightning Amulet (200 charges), I can only sell it if it has 1 charge left.

Help, thanks !
 
Thanks for helping, but it doesn't work. Neither declaring in the .lua script:
shopModule:addBuyableItem({'lightning pendant'}, 7889, 11000, 200, 'lightning pendant')
 
\data\npc\lib\npcsystem\modules.lua, remove red:
Code:
	-- Callback onSell() function. If you wish, you can change certain Npc to use your onSell().
	function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
		local shopItem = nil
		for _, item in ipairs(self.npcHandler.shopItems) do
			if(item.id == itemid[COLOR="Red"][B] and item.subType == subType[/B][/COLOR]) then
				shopItem = item
				break
			end
		end
 
Nope, doesn't work. Tried more different methods, but it doesn't work.
I can only sell it if I say "sell lightning pendant, yes", but I want to sell it via trade-shop.
 
Back
Top