0.4
Bom dia galera, eu preciso de ajuda em um npc de task.
Ele é bem simples, você fala as palavras, ele te da a storage, no creaturescripts pega a storage e conta os monstros na tabela, ai ele te da a storage maior e quando voltar pro npc, ele te da a recompensa. Até ai funciona 100%, o problema é que eu queria colocar pra esse npc dar 2 tasks, quando o player terminar uma, ele pode pegar outra com o mesmo npc. (Lembrando que se eu fizer 2 npcs, funciona normal, mas eu queria fazer em um só)
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local quest = 845710
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)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
npcHandler:say("OK2", cid)
talkState[talkUser] = 2
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then
npcHandler:say("OK3", cid)
setPlayerStorageValue(cid, quest, 2)
setPlayerStorageValue(cid, 12672, 1)
talkState[talkUser] = 0
elseif msgcontains(msg, "quest1") then
local str = getPlayerStorageValue(cid, quest)
if(str < 2) then
npcHandler:say("OK1", cid)
talkState[talkUser] = 1
return true
elseif(str == 2) then
npcHandler:say("OK4", cid)
elseif(str == 3) then
npcHandler:say("Finish", cid)
setPlayerStorageValue(cid, quest, 4)
setPlayerStorageValue(cid, 555140, 4)
elseif(str == 4) then
npcHandler:say("Over", cid)
end
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
local keywordHandler2 = keywordHandler:new()
local npcHandler2 = npcHandler:new(keywordHandler2)
NpcSystem.parseParameters(npcHandler2)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg2) npcHandler:onCreatureSay(cid, type, msg2) end
function onThink() npcHandler:onThink() end
local talkState2 = {}
local quest2 = 685740
function creatureSayCallback2(cid, type, msg2)
local talkUser2 = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(not npcHandler:isFocused(cid)) then
return false
elseif msgcontains(msg2, "yes") and talkState2[talkUser2] == 1 then
npcHandler:say("sim2", cid)
talkState2[talkUser2] = 2
elseif msgcontains(msg2, "yes") and talkState2[talkUser2] == 2 then
npcHandler:say("Sim3", cid)
setPlayerStorageValue(cid, quest2, 2)
talkState2[talkUser2] = 0
elseif msgcontains(msg2, "quest2") then
local str2 = getPlayerStorageValue(cid, 555140)
if(str2 == 1) then
local stro = getPlayerStorageValue(cid, quest2)
if(stro < 2) then
npcHandler:say("Sim", cid)
talkState2[talkUser2] = 1
return true
elseif(stro == 2) then
npcHandler:say("Sim4", cid)
elseif(stro == 3) then
npcHandler:say("Sim5!", cid)
setPlayerStorageValue(cid, quest2, 4)
elseif(stro == 4) then
npcHandler:say("Over2", cid)
end
talkState2[talkUser2] = 0
else
npcHandler:say("Nop", cid)
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback2)
npcHandler:addModule(FocusModule:new())
Eu tentei fazer isso, que foi colocar 2x o script dele da task e mudar algumas coisas, colocando um "2" na frente. O problema é que ele só reconhece a segunda task, ou seja, a "quest2". Se falar "quest1", ele não diz nada e não da nem um erro no console.
Alguém sabe como colocar 2 tasks nesse npc?
Obrigado.