• 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] Got problems with Potion NPC

LoveSong

New Member
Joined
Dec 16, 2007
Messages
185
Reaction score
0
Hello! I've got a Problem with my Potion NPC!
He sells all potion(normal potion, strong and great)

But the problem is everytime when i say:

Buy srtong potion or buy great poition he says:

Want to buy 1 health potion or want to buy 1 mana potion?


He dont sells the strong and great potions...
How i can fix that?

Here is my Script:

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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
-- OTServ old functions end 

local shopModule = ShopModule:new() 
npcHandler:addModule(shopModule) 
 
shopModule:addSellableItem({'vial'}, 2006, 10, 'vial')
shopModule:addSellableItem({'flask'}, 2006, 10, 'flask') 

shopModule:addBuyableItem({'shovel'}, 2554, 45, 'shovel') 
shopModule:addBuyableItem({'torch'}, 2050, 2, 'torch') 
shopModule:addBuyableItem({'rope'}, 2120, 50, 'rope') 
shopModule:addBuyableItem({'pick'}, 2553, 120, 'pick') 
shopModule:addBuyableItem({'brown backpack'}, 1988, 20, 'brown backpack')
shopModule:addBuyableItem({'green backpack'}, 1998, 20, 'green backpack')

shopModule:addBuyableItem({'mana potion'}, 7620, 50, 'mana potion')
shopModule:addBuyableItem({'stong mana potion'}, 7589, 150, 'strong mana potion')
shopModule:addBuyableItem({'great mana potion'}, 7590, 250, 'great mana potion')
shopModule:addBuyableItem({'health potion'}, 7618, 50, 'health potion')
shopModule:addBuyableItem({'strong health potion'}, 7588, 150, 'strong health potion')
shopModule:addBuyableItem({'great health potion'}, 7591, 250, 'great health potion')
                    

npcHandler:addModule(FocusModule:new())
Please help me
 
Last edited by a moderator:
Fixed:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
-- OTServ old functions end 

local shopModule = ShopModule:new() 
npcHandler:addModule(shopModule) 
 
shopModule:addSellableItem({'vial'}, 2006, 10, 'vial')
shopModule:addSellableItem({'flask'}, 2006, 10, 'flask') 

shopModule:addBuyableItem({'shovel'}, 2554, 45, 'shovel') 
shopModule:addBuyableItem({'torch'}, 2050, 2, 'torch') 
shopModule:addBuyableItem({'rope'}, 2120, 50, 'rope') 
shopModule:addBuyableItem({'pick'}, 2553, 120, 'pick') 
shopModule:addBuyableItem({'brown backpack'}, 1988, 20, 'brown backpack')
shopModule:addBuyableItem({'green backpack'}, 1998, 20, 'green backpack')


shopModule:addBuyableItem({'stong mana potion'}, 7589, 150, 'strong mana potion')
shopModule:addBuyableItem({'great mana potion'}, 7590, 250, 'great mana potion')
shopModule:addBuyableItem({'mana potion'}, 7620, 50, 'mana potion')
shopModule:addBuyableItem({'great health potion'}, 7591, 250, 'great health potion')
shopModule:addBuyableItem({'strong health potion'}, 7588, 150, 'strong health potion')
shopModule:addBuyableItem({'health potion'}, 7618, 50, 'health potion')                

npcHandler:addModule(FocusModule:new())
 
Now?
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
-- OTServ old functions end 

local shopModule = ShopModule:new() 
npcHandler:addModule(shopModule) 
 
shopModule:addSellableItem({'vial'}, 2006, 10, 'vial')
shopModule:addSellableItem({'flask'}, 2006, 10, 'flask') 

shopModule:addBuyableItem({'shovel'}, 2554, 45, 'shovel') 
shopModule:addBuyableItem({'torch'}, 2050, 2, 'torch') 
shopModule:addBuyableItem({'rope'}, 2120, 50, 'rope') 
shopModule:addBuyableItem({'pick'}, 2553, 120, 'pick') 
shopModule:addBuyableItem({'brown backpack'}, 1988, 20, 'brown backpack')
shopModule:addBuyableItem({'green backpack'}, 1998, 20, 'green backpack')


shopModule:addBuyableItem({'stong mana potion'}, 7589, 150, 'strong mana potion')
shopModule:addBuyableItem({'great mana potion'}, 7590, 250, 'great mana potion')
shopModule:addBuyableItem({'great health potion'}, 7591, 250, 'great health potion')
shopModule:addBuyableItem({'strong health potion'}, 7588, 150, 'strong health potion')
shopModule:addBuyableItem({'health potion'}, 7618, 50, 'health potion')                
shopModule:addBuyableItem({'mana potion'}, 7620, 50, 'mana potion')
npcHandler:addModule(FocusModule:new())
 
Look:

This is My NPC:

August.xml
PHP:
<npc name="August" script="data/npc/scripts/GeneralGreatKingdom.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="133" head="39" body="95" legs="0" feet="39" addons="1"/>
	<parameters>
		    <parameter key="message_greet" value="Welcome |PLAYERNAME|! I got plenty of general items!" />
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="quest;help;item;general" />
		<parameter key="keyword_reply1" value="I would advice a pick." />
		<parameter key="keyword_reply2" value="Im at your service, any items?" />
		<parameter key="keyword_reply3" value="Lets see, where should I start? Torch, rope, shovel, pick, brown backpack, blue backpack, red backpack and different bps of health aswell as mana potions, please read the blackboard. I guess thats all. Oh! I will also buy back empty vials." />
		<parameter key="keyword_reply4" value="Lets see, where should I start? Torch, rope, shovel, pick, brown backpack, blue backpack, red backpack and different bps of health aswell as mana potions, please read the blackboard. I guess thats all. Oh! I will also buy back empty vials." />
	</parameters>
</npc>


And this is your script:

GeneralGreatKingdom.lua

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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
-- OTServ old functions end 

local shopModule = ShopModule:new() 
npcHandler:addModule(shopModule) 
 
shopModule:addSellableItem({'vial'}, 2006, 10, 'vial')
shopModule:addSellableItem({'flask'}, 2006, 10, 'flask') 

shopModule:addBuyableItem({'shovel'}, 2554, 45, 'shovel') 
shopModule:addBuyableItem({'torch'}, 2050, 2, 'torch') 
shopModule:addBuyableItem({'rope'}, 2120, 50, 'rope') 
shopModule:addBuyableItem({'pick'}, 2553, 120, 'pick') 
shopModule:addBuyableItem({'brown backpack'}, 1988, 20, 'brown backpack')
shopModule:addBuyableItem({'green backpack'}, 1998, 20, 'green backpack')

shopModule:addBuyableItem({'mana potion'}, 7620, 50, 'mana potion')
shopModule:addBuyableItem({'stong mana potion'}, 7589, 150, 'strong mana potion')
shopModule:addBuyableItem({'great mana potion'}, 7590, 250, 'great mana potion')
shopModule:addBuyableItem({'health potion'}, 7618, 50, 'health potion')
shopModule:addBuyableItem({'strong health potion'}, 7588, 150, 'strong health potion')
shopModule:addBuyableItem({'great health potion'}, 7591, 250, 'great health potion')
                    

npcHandler:addModule(FocusModule:new())
 
That's because you've spelled it wrong in the script, let me correct it:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
-- OTServ old functions end 

local shopModule = ShopModule:new() 
npcHandler:addModule(shopModule) 
 
shopModule:addSellableItem({'vial'}, 2006, 10, 'vial')
shopModule:addSellableItem({'flask'}, 2006, 10, 'flask') 

shopModule:addBuyableItem({'shovel'}, 2554, 45, 'shovel') 
shopModule:addBuyableItem({'torch'}, 2050, 2, 'torch') 
shopModule:addBuyableItem({'rope'}, 2120, 50, 'rope') 
shopModule:addBuyableItem({'pick'}, 2553, 120, 'pick') 
shopModule:addBuyableItem({'brown backpack'}, 1988, 20, 'brown backpack')
shopModule:addBuyableItem({'green backpack'}, 1998, 20, 'green backpack')


shopModule:addBuyableItem({'strong mana potion'}, 7589, 150, 'strong mana potion')
shopModule:addBuyableItem({'great mana potion'}, 7590, 250, 'great mana potion')
shopModule:addBuyableItem({'great health potion'}, 7591, 250, 'great health potion')
shopModule:addBuyableItem({'strong health potion'}, 7588, 150, 'strong health potion')
shopModule:addBuyableItem({'health potion'}, 7618, 50, 'health potion')                
shopModule:addBuyableItem({'mana potion'}, 7620, 50, 'mana potion')
npcHandler:addModule(FocusModule:new())
 
Back
Top