Hello everyone, I've done a script, but it doesn't really work and I am not sure why :/ How it works? It should add items to trade item list if player tell 'hi' and have quest done or if player say other word ;D This is my code:
What exacly does not work? When I put
Into my XML, it says that he has nothing to trade (after -> MagicWord -> trade or hi (with quest) -> trade), when I leave XML without this parameter it doesn't do anything when I say 'trade' I don't really know NPC Systems, so I beg you for help
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local storvalue = 17000
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return FALSE
end
if msgcontains(msg, 'MagicWord') then
setPlayerStorageValue(cid, storvalue, 1)
npcHandler:say('So, you know about MagicWord... Ahh... You disturbed my reading! Anyway, what do you want? Some items for me?', cid)
shopModule:addSellableItem({'Springsprout Rod'},8912,8000,'Springsprout Rod')
shopModule:addSellableItem({'Underworld Rod'},8910,15000,'Underworld Rod')
shopModule:addSellableItem({'Wand of Starstorm'},8920,7500,'Wand of Starstorm')
shopModule:addSellableItem({'Wand of Voodoo'},8922,13750,'Wand of Voodoo')
shopModule:addSellableItem({'Ferumbars' Hat'},5903,1500000,'Ferumbars' Hat')
shopModule:addSellableItem({'Helmet of the Deep'},5461,5000,'Helmet of the Deep')
shopModule:addSellableItem({'Batwing Hat'},10016,1500,'Batwing Hat')
shopModule:addSellableItem({'Yalahari Mask'},9778,65000,'Yalahari Mask')
shopModule:addSellableItem({'Dwarven Helmet'},2502,245000,'Dwarven Helmet')
shopModule:addSellableItem({'Beholder Helmet'},3972,32000,'Beholder Helmet')
shopModule:addSellableItem({'Skull Helmet'},5741,35000,'Skull Helmet')
shopModule:addSellableItem({'Horned Helmet'},2496,2250000,'Horned Helmet')
shopModule:addSellableItem({'Witchhunter's Cloak'},8821,11000,'Witchhunter's Cloak')
shopModule:addSellableItem({'Dragon Robe'},8867,19500,'Dragon Robe')
shopModule:addSellableItem({'Greenwood Coat'},8869,13000,'Greenwood Coat')
shopModule:addSellableItem({'Robe of the Underworld'},8890,25000,'Robe of the Underworld')
shopModule:addSellableItem({'Crystalline Armor'},8878,15700,'Crystalline Armor')
shopModule:addSellableItem({'Divine Plate'},8885,34000,'Divine Plate')
shopModule:addSellableItem({'Frozen Plate'},8887,32500,'Frozen Plate')
shopModule:addSellableItem({'Skullcracker Armor'},8889,31500,'Skullcracker Armor')
shopModule:addSellableItem({'Dragon Scale Mail'},2492,38000,'Dragon Scale Mail')
shopModule:addSellableItem({'Magic Plate Armor'},2472,230000,'Magic Plate Armor')
shopModule:addSellableItem({'Yalahari Armor'},9776,120000,'Yalahari Armor')
shopModule:addSellableItem({'Yalahari Leg Piece'},9777,70000,'Yalahari Leg Piece')
shopModule:addSellableItem({'Golden Legs'},2470,65000,'Golden Legs')
shopModule:addSellableItem({'Spellbook of Dark Mysteries'},8918,65000,'Spellbook of Dark Mysteries')
shopModule:addSellableItem({'Spellbook of Prophecies'},8904,44200,'Spellbook of Prophecies')
shopModule:addBuyableItem({'Helmet of the Deep'},5461,12000,'Helmet of the Deep')
end
if msgcontains(msg, 'hi') then
if (getPlayerStorageValue(cid, storvalue) == 1) then
npcHandler:say('It\'s you again, what can I do for you?.', cid)
shopModule:addSellableItem({'Springsprout Rod'},8912,8000,'Springsprout Rod')
shopModule:addSellableItem({'Underworld Rod'},8910,15000,'Underworld Rod')
shopModule:addSellableItem({'Wand of Starstorm'},8920,7500,'Wand of Starstorm')
shopModule:addSellableItem({'Wand of Voodoo'},8922,13750,'Wand of Voodoo')
shopModule:addSellableItem({'Ferumbars' Hat'},5903,1500000,'Ferumbars' Hat')
shopModule:addSellableItem({'Helmet of the Deep'},5461,5000,'Helmet of the Deep')
shopModule:addSellableItem({'Batwing Hat'},10016,1500,'Batwing Hat')
shopModule:addSellableItem({'Yalahari Mask'},9778,65000,'Yalahari Mask')
shopModule:addSellableItem({'Dwarven Helmet'},2502,245000,'Dwarven Helmet')
shopModule:addSellableItem({'Beholder Helmet'},3972,32000,'Beholder Helmet')
shopModule:addSellableItem({'Skull Helmet'},5741,35000,'Skull Helmet')
shopModule:addSellableItem({'Horned Helmet'},2496,2250000,'Horned Helmet')
shopModule:addSellableItem({'Witchhunter's Cloak'},8821,11000,'Witchhunter's Cloak')
shopModule:addSellableItem({'Dragon Robe'},8867,19500,'Dragon Robe')
shopModule:addSellableItem({'Greenwood Coat'},8869,13000,'Greenwood Coat')
shopModule:addSellableItem({'Robe of the Underworld'},8890,25000,'Robe of the Underworld')
shopModule:addSellableItem({'Crystalline Armor'},8878,15700,'Crystalline Armor')
shopModule:addSellableItem({'Divine Plate'},8885,34000,'Divine Plate')
shopModule:addSellableItem({'Frozen Plate'},8887,32500,'Frozen Plate')
shopModule:addSellableItem({'Skullcracker Armor'},8889,31500,'Skullcracker Armor')
shopModule:addSellableItem({'Dragon Scale Mail'},2492,38000,'Dragon Scale Mail')
shopModule:addSellableItem({'Magic Plate Armor'},2472,230000,'Magic Plate Armor')
shopModule:addSellableItem({'Yalahari Armor'},9776,120000,'Yalahari Armor')
shopModule:addSellableItem({'Yalahari Leg Piece'},9777,70000,'Yalahari Leg Piece')
shopModule:addSellableItem({'Golden Legs'},2470,65000,'Golden Legs')
shopModule:addSellableItem({'Spellbook of Dark Mysteries'},8918,65000,'Spellbook of Dark Mysteries')
shopModule:addSellableItem({'Spellbook of Prophecies'},8904,44200,'Spellbook of Prophecies')
shopModule:addBuyableItem({'Helmet of the Deep'},5461,12000,'Helmet of the Deep')
else
npcHandler:say('Psssssh... I am reading.', cid)
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
What exacly does not work? When I put
Code:
<parameters>
<parameter key="module_shop" value="1"/>
</parameters>