Godely
Member
- Joined
- Aug 19, 2007
- Messages
- 233
- Reaction score
- 16
Code:
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
--function
local perguntas = {'Ok, so answer me: What the name of the mountain that we are? Derzi Mountain, Deg\'Hills, Den Hills or Dex\'Hills.', 'Ok. What the name of the dungeon on west of Dargor. West Drafia, West Dradia, West Drefia, Old West.', 'The last question is: What the name of the biggest place of wyverns? Wyverns Mountain, Wyverns Camp, Wyverns Fortress, Wyverns Castle.'}
function confirmAction(cid, message, keywords, parameters)
if(cid ~= npcHandler.focus) then
return false
end
action = parameters.id
if action == 1 then
if doPlayerRemoveMoney(cid, 1000) == TRUE then
selfSay('Let\'s go to the first question, are you ready?')
return true
else
selfSay("You don\'t have any money!")
return false
end
elseif action == 2 then
questao = parameters.questao
selfSay(perguntas[questao])
return true
elseif action == 3 then
questao = parameters.questao
if questao == 3 then
selfSay('Right! Ready for the last question?')
else
selfSay('Correctly! Ready for the next question?')
end
selfSay('Chega aqui?')
return true
elseif action == 4 then
selfSay('Correctly! Now, open the wooden coffin on your left.')
setPlayerStorageValue(cid,2113,1)
return true
end
return false
end
local node = keywordHandler:addKeyword({'key'}, StdModule.say, {npcHandler = npcHandler, text = 'Do you want the permission to take the key? If you answer my questions correctly, you will can open the wooden coffin. But beware with your money.'}, true)
local node2 = node:addChildKeyword({'yes'}, confirmAction, {id = 1})
node:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'Ok then!'}, true)
local node3 = node2:addChildKeyword({'yes'}, confirmAction, {id = 2, questao = 1})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'Ok then!'}, true)
node3:addChildKeyword({'Derzi Mountain'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
local node4 = node3:addChildKeyword({'Deg\'Hills'}, confirmAction, {id = 3, questao = 2})
node3:addChildKeyword({"Dex'Hills"}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
node3:addChildKeyword({'Den Hills'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
node4:addChildKeyword({'West Drafia'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
local node5 = node4:addChildKeyword({'West Drefia'}, confirmAction, {id = 3, questao = 3})
node4:addChildKeyword({'West Dradia'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
node4:addChildKeyword({'Old West'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
node5:addChildKeyword({'West Drafia'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
node5:addChildKeyword({'West Drefia'}, confirmAction, {id = 4})
node5:addChildKeyword({'West Dradia'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
node5:addChildKeyword({'Old West'}, StdModule.say, {npcHandler = npcHandler, text = 'Wrong!'}, true)
npcHandler:addModule(FocusModule:new())
This script is not totally working. I hope someone helps me to find the bug, 'cause after that I'm gonna post on the board.
PS.: this script is about a NPC that asks you 3 questions. If you get the 3 right, he gives you the permission to get a key on a chest (by adding a storage value)
See ya