Kayan
Active Member
Hello :huh:
Here are my Npc of Potions and Fluids i have a problem with him
see my script
Apparently he is not nor has an error
But the times you ask for a bp of health delivery Potion he bp of a mana Potion or another
What I mean that sometimes he delivers the wrong item
Anyone can see that there is something wrong in the script, that's all right by min x.x
Anybody can help, i didn't know what's error
Here are my Npc of Potions and Fluids i have a problem with him
see 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
-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true,
text = 'I sell fluids and potions. Do you need?'})
keywordHandler:addKeyword({'potions'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true,
text = 'I sell all potions. Do you need'})
keywordHandler:addKeyword({'fluids'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true,
text = 'I sell all fuids. Do you need'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true,
text = 'I am the owner of the potions,fluids shop of the Raduk.'})
keywordHandler:addKeyword({'quest'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true,
text = 'I cannot help you in that area, son.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true,
text = 'I cannot help you in that area, son.'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true,
text = 'My name is Justic.'})
function returnVials(cid, message, keywords, parameters, node)
if(npcHandler.focus ~= cid) then
return false
end
local amount = removePlayerItemsWithCharges(cid, parameters.itemid, parameters.charges)
if(amount <= 0) then
npcHandler:say('You do not have any.')
else
local price = amount*parameters.cost
if(doPlayerAddMoney(cid, price) == LUA_NO_ERROR) then
npcHandler:say('Here are your reward of ' .. price .. ' gold coins. It was a pleasure doing business with you.')
else
error('[Error] returnVials:', 'Could not give ' .. price .. ' gold coins to player ' .. getPlayerName(cid))
end
end
npcHandler:resetNpc()
return true
end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'water'}, 2260, 8, 1, 'vial of water')
shopModule:addBuyableItem({'blood'}, 2006, 15, 2, 'vial of blood')
shopModule:addBuyableItem({'beer'}, 2006, 12, 3, 'vial of beer')
shopModule:addBuyableItem({'slime'}, 2006, 12, 4, 'vial of slime')
shopModule:addBuyableItem({'lemonade'}, 2006, 8, 5, 'vial of lemonade')
shopModule:addBuyableItem({'milk'}, 2006, 12, 6, 'vial of milk')
shopModule:addBuyableItem({'oil'}, 2006, 20, 11, 'vial of oil')
shopModule:addBuyableItem({'urine'}, 2006, 10, 13, 'vial of urine')
shopModule:addBuyableItem({'coconut milk'}, 2006, 25, 14, 'vial of coconut milk')
shopModule:addBuyableItem({'wine'}, 2006, 6, 15, 'vial of wine')
local node = keywordHandler:addKeyword({'vial'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to return all your empty vials for 10 gold coins each?'})
node:addChildKeyword({'yes'}, returnVials, {itemid = 2006, charges = 0, cost = 10})
node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Allright then.'})
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
if msgcontains(msg, 'bp of strong health potion') then
selfSay('Do you want buy backpack of strong health potion for 2200 golds?')
talk_state = 1
elseif msgcontains(msg, 'bp of strong mana potion') then
selfSay('Do you want buy backpack of strong mana potion for 1600 golds?')
talk_state = 2
elseif msgcontains(msg, 'bp of great mana potion') then
selfSay('Do you want buy great mana potion for 2400 golds?')
talk_state = 3
elseif msgcontains(msg, 'bp of great health potion')then
selfSay('Do you want buy backpack of great health potion for 5000 golds?')
talk_state = 4
elseif msgcontains(msg, 'bp of health potion')then
selfSay('Do you want buy backpack of health potion for 1000 golds?')
talk_state = 5
elseif msgcontains(msg, 'bp of mana potion') then
selfSay('Do you want buy backpack of mana potion for 1200 golds?')
talk_state = 6
----------------------------------------------- confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
buyContainer(cid,2000,7588,1,2200)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 2 then
buyContainer(cid,2001,7589,1,1600)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 3 then
buyContainer(cid,2001,7590,1,2400)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 4 then
buyContainer(cid,2000,7591,1,5000)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 5 then
buyContainer(cid,2000,7618,1,1000)
talk_state = 0
elseif msgcontains(msg, 'yes') and talk_state == 6 then
buyContainer(cid,2000,7620,1,1200)
talk_state = 0
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 7) then
selfSay('Ok than.')
talk_state = 0
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)
npcHandler:addModule(FocusModule:new())
Apparently he is not nor has an error
But the times you ask for a bp of health delivery Potion he bp of a mana Potion or another
What I mean that sometimes he delivers the wrong item
Anyone can see that there is something wrong in the script, that's all right by min x.x
Anybody can help, i didn't know what's error
