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

Npc that buys stackable items?

F

Forsakenfate

Guest
Hello I'm working on a proffession system in my server. It is nearly done but my npc doesn't seem to work. he only buys the items per 1, so if you have a stack of 100 herbs, you have to click 100 times.. Does anyone know what I have to change in these scripts to just sell 100 at once?

Proffession npc:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ankorah" script="data/npc/scripts/default.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="80" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
<parameter key="module_shop" value="2"/>
<parameter key="shop_buyable" value="Scythe,2550,200;Iron hammer,2422,200;Pick,2553,200"/>
<parameter key="shop_sellable" value="Fern,2801,30;Powder herb,2803,50;Shadow herb,2804,50;Stone herb,2799,50;Sling herb,2802,75;Star herb,2800,100;Blood herb,2798,250;Troll greens,2805,500;Marijuana,5953,1000"/>
</parameters>
</npc>

Default.lua:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

npcHandler:addModule(FocusModule:new())


Someone knows what I did wrong? Reply please ^^
 
Last edited by a moderator:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ankorah" script="data/npc/scripts/default.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="80" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
<parameter key="module_shop" value="2"/>
<parameter key="shop_buyable" value="Scythe,2550,200,1;Iron hammer,2422,200,1;Pick,2553,200"/>
<parameter key="shop_sellable" value="Fern,2801,30,1;Powder herb,2803,50,1;Shadow herb,2804,50,1;Stone herb,2799,50,1;Sling herb,2802,75,1;Star herb,2800,100,1;Blood herb,2798,250,1;Troll greens,2805,500,1;Marijuana,5953,1000,1"/>
</parameters>
</npc>
try this
 
Thanks for your reply Bogart, I tried it but still the same problem, he says 'you dont have this item' when i sell the whole stack. And now the names of the items turned into a '1'.
 
try editing your modules.lua
Code:
	function ShopModule:addSellableItem(names, itemid, cost, realName)
		if(SHOPMODULE_MODE ~= SHOPMODULE_MODE_TALK) then
			[B][COLOR="red"]local v = getItemInfo(itemid)[/COLOR][/B]
			local item = {
				id = itemid,
				buy = -1,
				sell = cost,
				subType = [B][COLOR="red"](v.stackable or v.charges > 0) and 0 or[/COLOR][/B] 1,
				name = realName or [B][COLOR="red"]v.name[/COLOR][/B]
			}
this usually isn't enough for your problem
 
Last edited:
Thanks for responding, it didn't work it crashed my server instead.
My Callback, onSell script in modules.lua is:

function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
if(self.npcHandler.shopItems[itemid] == nil) then
error("[ShopModule.onSell]", "items[itemid] == nil")
return false
end

Seems like such a small problem, Tho it looks harder then building an atom bomb o_o
 
Back
Top