I used this npc script made by Cykotitan, but i want it like if u answer all questions correctly you get an storage.
Script by Cykotitan.
Thanks for ur time, Yours DanneZ.
Script by Cykotitan.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
local conv = {
{
[1] = "What genre are tibia?"
},
{
[1] = "mmorpg"
}
}
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 greetCallback(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
Topic[talkUser] = 0
return true
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
if Topic[talkUser] > 0 then
if msgcontains(msg, conv[2][Topic[talkUser]]) then
local storage = 133341
npcHandler:say("Congratulations, you have answered correctly!", cid)
npcHandler:say("Now go to the leader and get your reward!", cid)
setPlayerStorageValue(cid, storage, 1)
else
npcHandler:say("Sorry, but that wasn't the correct answer.", cid)
end
Topic[talkUser] = 0
elseif msgcontains(msg, "question") then
local random = math.random(#conv[1])
npcHandler:say(conv[1][random], cid)
Topic[talkUser] = random
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thanks for ur time, Yours DanneZ.