Vi que bastante gente estava com problemas nesse sistema de task, e como coloquei o meu pra funcionar vou compartilhar com vocês.
Npc de task [Que faz apenas uma vez]
Citarlocal 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)
if(not npcHandler:isFocused(cid)) then
return false
endlocal talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local task = {
["Sr.Cartter [History]"] = {{"Pidgey", 3}, {"Rattata", 3}},
}
if getPlayerStorageValue(cid, 300003) == 1 then --- Storage pra não fazer de novo
selfSay("Voce ja e um fez minha quest hoje!", cid)
return true
endif msgcontains(msg, 'sim senhor') or msgcontains(msg, 'Sim senhor') then
if isMyTaskComplete(cid, getNpcCid()) then
selfSay("Muito bom, logo voce sabera a utilidade desta berry!", cid)
doPlayerAddExperience(cid, 1500) --exp
doPlayerAddItem(cid, 11448, 1) --premio
local sto = getMyTaskSto(cid, getNpcCid())
setPlayerStorageValue(cid, sto, -1)
setPlayerStorageValue(cid, 300003, 1) --- Storage pra não fazer de novo
talkState[talkUser] = 0
return true
else
selfSay("Vejo que falta confianca e coragem em voce assim como todos os outros jovens treinadores, aqui tenho uma rarissima berry que podera ajudar seu Pokemon, mas para que eu possa te da-la voce tera que provar que a merece... Derrote {3 Pidgeys e 3 Rattatas}, voce pode fazer isto?", cid)
talkState[talkUser] = 2
end
elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'Sim')) and talkState[talkUser] == 2 then
if getMyTaskSto(cid, getNpcCid()) ~= -1 then
selfSay("Va terminar a quest!", cid)
talkState[talkUser] = 0
return true
end
local sto = getFreeTaskStorage(cid)
if sto == -1 then
selfSay("Voce nao pode pegar mais quests! Pois ja tem o numero "..(maxTasks).." de quest!", cid)
talkState[talkUser] = 0
return true
end
selfSay("Excelente... Faca o seu melhor!", cid)
setStorageArray(cid, sto, task)
talkState[talkUser] = 0
return true
endreturn true
endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Npc de task diaria
Citarlocal 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)
if(not npcHandler:isFocused(cid)) then
return false
endlocal talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local stg = 300003 -- storage para não fazer a quest de novo
local task = {
["Sr.Cartter [History]"] = {{"Pidgey", 3}, {"Rattata", 3}},
}
if getPlayerStorageValue(cid, stg) > os.time() then
selfSay("Voce ja e um fez minha quest hoje!", cid)
return true
endif msgcontains(msg, 'sim senhor') or msgcontains(msg, 'Sim senhor') then
if isMyTaskComplete(cid, getNpcCid()) then
selfSay("Muito bom, logo voce sabera a utilidade desta berry!", cid)
doPlayerAddExperience(cid, 1500) --exp
doPlayerAddItem(cid, 11448, 1) --premio
local sto = getMyTaskSto(cid, getNpcCid())
setPlayerStorageValue(cid, stg, os.time() + 1*24*60*60)
talkState[talkUser] = 0
return true
else
selfSay("Vejo que falta confianca e coragem em voce assim como todos os outros jovens treinadores, aqui tenho uma rarissima berry que podera ajudar seu Pokemon, mas para que eu possa te da-la voce tera que provar que a merece... Derrote {3 Pidgeys e 3 Rattatas}, voce pode fazer isto?", cid)
talkState[talkUser] = 2
end
elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'Yes')) and talkState[talkUser] == 2 then
if getMyTaskSto(cid, getNpcCid()) ~= -1 then
selfSay("Va terminar a quest!", cid)
talkState[talkUser] = 0
return true
end
local sto = getFreeTaskStorage(cid)
if sto == -1 then
selfSay("Voce nao pode pegar mais quests! Pois ja tem o numero "..(maxTasks).." de quest!", cid)
talkState[talkUser] = 0
return true
end
selfSay("Excelente... Faca o seu melhor!", cid)
setStorageArray(cid, sto, task)
talkState[talkUser] = 0
return true
endreturn true
endnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Eu apenas editei, o script não foi feito completamente por mim. Espero que seja útil ^^