• 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 Shop bug 0.4

furstwin

New Member
Joined
Aug 9, 2007
Messages
486
Reaction score
1
Location
Sweden
I've recently joined a real map project and we have found serval bugs, I've tried to fix the bugs myself without progress, for example you cant buy items when it's coded with lua, eg.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'meat'}, 2666, 5, 'meat')
shopModule:addBuyableItem({'fish'}, 2667, 5, 'fish')
shopModule:addBuyableItem({'salmon'}, 2668, 5, 'salmon')
shopModule:addBuyableItem({'ham'}, 2671, 8, 'ham')
shopModule:addBuyableItem({'dragon ham'}, 2672, 20, 'dragon ham')
shopModule:addBuyableItem({'pear'}, 2673, 4, 'pear')
shopModule:addBuyableItem({'red apple'}, 2674, 3, 'red apple')
shopModule:addBuyableItem({'orange'}, 2675, 10, 'orange')
shopModule:addBuyableItem({'banana'}, 2676, 3, 'banana')
shopModule:addBuyableItem({'blueberry'}, 2677, 1, 'blueberry')
shopModule:addBuyableItem({'cherry'}, 2679, 1, 'cherry')
shopModule:addBuyableItem({'strawberry'}, 2680, 1, 'strawberry')
shopModule:addBuyableItem({'grape'}, 2680, 3, 'grape')
shopModule:addBuyableItem({'melon'}, 2682, 8, 'melon')
shopModule:addBuyableItem({'pumpkin'}, 2683, 10, 'pumpkin')
shopModule:addBuyableItem({'carrot'}, 2684, 3, 'carrot')
shopModule:addBuyableItem({'tomato'}, 2685, 5, 'tomato')
shopModule:addBuyableItem({'corncob'}, 2686, 3, 'corncob')
shopModule:addBuyableItem({'cookie'}, 2687, 2, 'cookie')
shopModule:addBuyableItem({'bread'}, 2689, 4, 'bread')
shopModule:addBuyableItem({'roll'}, 2690, 2, 'roll')
shopModule:addBuyableItem({'brown bread'}, 2691, 3, 'brown bread')
shopModule:addBuyableItem({'egg'}, 2695, 2, 'egg')
shopModule:addBuyableItem({'white mushroom'}, 2787, 6, 'white mushroom')
shopModule:addBuyableItem({'red mushroom'}, 2788, 12, 'red mushroom')
shopModule:addBuyableItem({'brown mushroom'}, 2789, 10, 'brown mushroom')
shopModule:addBuyableItem({'valentine cake'}, 6393, 6, 'valentine cake')
shopModule:addBuyableItem({'cookbook'}, 2347, 150, 'cookbook')

npcHandler:addModule(FocusModule:new())
Code:
[Warning - Leanna] NpcSystem:
ShopModule.onBuy - Item not found on shopItems list

But when the NPC code is:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Galuna" script="data/npc/scripts/default.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="137" head="40" body="96" legs="95" feet="96" addons="0"/>
    <parameters>
        <parameter key="message_greet" value="Oh, please come in, |PLAYERNAME|. What do you need? Distance weapons? I sell lots of them."/>
        <parameter key="message_farewell" value="Good bye."/>
        <parameter key="module_keywords" value="1" />
        <parameter key="keywords" value="job;" />
        <parameter key="keyword_reply1" value="I am the local fletcher. I am selling bows, crossbows, and ammunition. Do you need anything?" />
		<parameter key="module_shop" value="1" />
    	<parameter key="shop_sellable" value="crossbow,2455,230;bow,2456,180" />
		<parameter key="shop_buyable" value="crossbow,2455,600;assassin star,7368,200;bow,2456,400;power bolt,2547,10;burst arrow,2546,25;poison arrow,2545,3;sniper arrow,7364,3;onyx arrow,7365,5;piercing bolt,7363,4;hunting spear,3965,15;royal spear,7378,20;bolt,2543,3;arrow,2544,2;spear,2389,5" />
	</parameters>
</npc>
it work excellent, any idea?

Regards,
Soder.
 
if this doesn't work either, then it's something with your npc system
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'meat'}, 2666, 5, 1, 'meat')
shopModule:addBuyableItem({'fish'}, 2667, 5, 1, 'fish')
shopModule:addBuyableItem({'salmon'}, 2668, 5, 1, 'salmon')
shopModule:addBuyableItem({'ham'}, 2671, 8, 1, 'ham')
shopModule:addBuyableItem({'dragon ham'}, 2672, 20, 1, 'dragon ham')
shopModule:addBuyableItem({'pear'}, 2673, 4, 1, 'pear')
shopModule:addBuyableItem({'red apple'}, 2674, 3, 1, 'red apple')
shopModule:addBuyableItem({'orange'}, 2675, 10, 1, 'orange')
shopModule:addBuyableItem({'banana'}, 2676, 3, 1, 'banana')
shopModule:addBuyableItem({'blueberry'}, 2677, 1, 1, 'blueberry')
shopModule:addBuyableItem({'cherry'}, 2679, 1, 1, 'cherry')
shopModule:addBuyableItem({'strawberry'}, 2680, 1, 1, 'strawberry')
shopModule:addBuyableItem({'grape'}, 2680, 3, 1, 'grape')
shopModule:addBuyableItem({'melon'}, 2682, 8, 1, 'melon')
shopModule:addBuyableItem({'pumpkin'}, 2683, 10, 1, 'pumpkin')
shopModule:addBuyableItem({'carrot'}, 2684, 3, 1, 'carrot')
shopModule:addBuyableItem({'tomato'}, 2685, 5, 1, 'tomato')
shopModule:addBuyableItem({'corncob'}, 2686, 3, 1, 'corncob')
shopModule:addBuyableItem({'cookie'}, 2687, 2, 1, 'cookie')
shopModule:addBuyableItem({'bread'}, 2689, 4, 1, 'bread')
shopModule:addBuyableItem({'roll'}, 2690, 2, 1, 'roll')
shopModule:addBuyableItem({'brown bread'}, 2691, 3, 1, 'brown bread')
shopModule:addBuyableItem({'egg'}, 2695, 2, 1, 'egg')
shopModule:addBuyableItem({'white mushroom'}, 2787, 6, 1, 'white mushroom')
shopModule:addBuyableItem({'red mushroom'}, 2788, 12, 1, 'red mushroom')
shopModule:addBuyableItem({'brown mushroom'}, 2789, 10, 1, 'brown mushroom')
shopModule:addBuyableItem({'valentine cake'}, 6393, 6, 1, 'valentine cake')
shopModule:addBuyableItem({'cookbook'}, 2347, 150, 1, 'cookbook')

npcHandler:addModule(FocusModule:new())
 
Back
Top