é o seguinte, tenho um NPC de TASK, mas se tu tiver muitos itens ele da o premio varias vezes... quero apenas q ele de o premio 1x e depois não dê mais !
SCRIPT DELE
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)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
msg = string.lower(msg)
---------
local need = {
{id = 2092, qt = 1}, --diamond
}
local rewards = {
{id = 14252, qt = 1}, --mega Stone
{id = 12618, qt = 20}, --booststone
}
local stoFinish = 92119
---------
if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then
if getPlayerStorageValue(cid, stoFinish) >= 99 then
selfSay("Sorry, you already had done this quest.", cid)
talkState[talkUser] = 0
return true
end
selfSay("Olá meu amigo, sou o NPC de trocas, me dê 1 Bone Chave e lhe darei 1 Mega Stone ! Diga YES para trocarmos",cid)
talkState[talkUser] = 1
return true
elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') and talkState[talkUser] == 1 then
if getPlayerItemCount(cid, need[1].id) < need[1].qt then
selfSay("Você não me trouxe a Bone Chave...", cid)
selfSay("Lembre-se, eu preciso de 1 Bone Chave...", cid)
talkState[talkUser] = 0
return true
end
local sto = getFreeTaskStorage(cid)
if sto == -1 then
selfSay("Você não pode fazer essa TASK NoVamente VocÊ ja fez o max de "..(maxTasks).." tasks!", cid)
talkState[talkUser] = 0
return true
end
for i = 1, #need do
doPlayerRemoveItem(cid, need[i].id, need[i].qt)
end
for i = 1, #rewards do
doPlayerAddItem(cid, rewards[i].id, rewards[i].qt)
doPlayerAddExperience(cid, 0)
end
selfSay("Obrigado, tchau!", cid)
setPlayerStorageValue(cid, stoFinish, 1)
talkState[talkUser] = 0
return true
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Pergunta
fawkz12 7
é o seguinte, tenho um NPC de TASK, mas se tu tiver muitos itens ele da o premio varias vezes... quero apenas q ele de o premio 1x e depois não dê mais !
SCRIPT DELE
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) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid msg = string.lower(msg) --------- local need = { {id = 2092, qt = 1}, --diamond } local rewards = { {id = 14252, qt = 1}, --mega Stone {id = 12618, qt = 20}, --booststone } local stoFinish = 92119 --------- if msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then if getPlayerStorageValue(cid, stoFinish) >= 99 then selfSay("Sorry, you already had done this quest.", cid) talkState[talkUser] = 0 return true end selfSay("Olá meu amigo, sou o NPC de trocas, me dê 1 Bone Chave e lhe darei 1 Mega Stone ! Diga YES para trocarmos",cid) talkState[talkUser] = 1 return true elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') and talkState[talkUser] == 1 then if getPlayerItemCount(cid, need[1].id) < need[1].qt then selfSay("Você não me trouxe a Bone Chave...", cid) selfSay("Lembre-se, eu preciso de 1 Bone Chave...", cid) talkState[talkUser] = 0 return true end local sto = getFreeTaskStorage(cid) if sto == -1 then selfSay("Você não pode fazer essa TASK NoVamente VocÊ ja fez o max de "..(maxTasks).." tasks!", cid) talkState[talkUser] = 0 return true end for i = 1, #need do doPlayerRemoveItem(cid, need[i].id, need[i].qt) end for i = 1, #rewards do doPlayerAddItem(cid, rewards[i].id, rewards[i].qt) doPlayerAddExperience(cid, 0) end selfSay("Obrigado, tchau!", cid) setPlayerStorageValue(cid, stoFinish, 1) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())Link para o comentário
https://xtibia.com/forum/topic/239920-erro-fazer-task-denovo/Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados