Ir para conteúdo
  • 0

Npc Quest


Gabrielkss

Pergunta

5 respostass a esta questão

Posts Recomendados

  • 0


local options = {

--["option"] = key,

--Ex.:

["task_1"] = 9230,

["task_2"] = 9321,

["quest"] = 9322,

}

 

local choose_more_times = true --True se puder escolher mais de uma opção, false caso contrário.

 

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

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)

msg = msg:lower()

if(not npcHandler:isFocused(cid)) then

return false

end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

 

if msgcontains(msg, "quest") or msgcontains(msg, "help") or msgcontains(msg, "options") then

local option_table = {}

for option, key in pairs(options) do

if not choose_more_times and getPlayerStorageValue(cid, key) > -1 then

return selfSay("You already have chosen your option.", cid)

end

option_table[#option_table + 1] = option

end

selfSay("I have "..#option_table.." options for you. Which one do you choose? {"..table.concat(option_table, ",").."}", cid)

talkState[talkUser] = 1

elseif talkState[talkUser] == 1 then

if options[msg] then

selfSay("Ok, you chose "..msg.."!", cid)

setPlayerStorageValue(cid, options[msg], 1)

talkState[talkUser] = 0

else

selfSay("I didn't give you this option. Please, tell me a valid one.", cid)

end

else

selfSay("Sorry, I didn't understand what you said.", cid)

talkState[talkUser] = 0

end

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Editado por zipter98
Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...