coloca pro npc fazer a checagem antes de remover !
6
1.1k
info
Grupo: Conde
Registrado: 18/01/12
Posts: 988
Reputação: +327
Gênero: Masculino
Char no Tibia: Xerife Woody

05 de março de 2014 às 20:11
info
Grupo: Campones
Registrado: 06/02/14
Posts: 48
Reputação: +9
Char no Tibia: Qarioman Erucasmius

05 de março de 2014 às 20:35
nao deu
e pior se fizer isso a quest da como feita soh de fla com ele
o problema eh q ele tira os itens mesmo nao estando com todos
05 de março de 2014 às 20:58
Tenta:
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 stg = 15333 -- storage para falar com o npc
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local it = {2152, 10}
local ids = {{12188, 50}, {12170, 50}, {12161, 50}}
local check = 0
if msgcontains(msg, 'mission') then
if getPlayerStorageValue(cid, stg) >= 1 or getPlayerLevel(cid) > 100 then
selfSay("Sorry, you already completed this mission or not have the necessary level to make this task!", cid)
talkState[talkUser] = 0
else
selfSay("Ooooh good! I'm looking for some rare items... They are: 50 ruby, 50 water pendant e 100 water gem. Do you have these items?", cid)
talkState[talkUser] = 1
end
end
---------------------------------------------------------
if (msgcontains(msg, "yes") or msgcontains(msg, "sim")) and talkState[talkUser] == 1 then
for i = 1, #ids do
local item = ids[i]
if getPlayerItemCount(cid, item[1]) >= item[2] then
check = check + 1
end
end
if check == #ids then
for i = 1, #ids do
local item = ids[i]
doPlayerRemoveItem(cid, item[1], item[2])
end
selfSay("Thank you!", cid)
setPlayerStorageValue(cid, stg, 1) -- para ele nao fazer a missao novamente
doPlayerAddExperience(cid,120000) -- experiencia
doPlayerAddItem(cid, it[1], it[2])
else
selfSay("Sorry, but you don't have one of these items.", cid)
talkState[talkUser] = 0
end
elseif (msgcontains(msg, "no") or msgcontains(msg, "nao")) and talkState[talkUser] == 1 then
selfSay("Good bye '..getCreatureName(cid)..'.", cid)
talkState[talkUser] = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
info
Grupo: Campones
Registrado: 06/02/14
Posts: 48
Reputação: +9
Char no Tibia: Qarioman Erucasmius

05 de março de 2014 às 21:13
Muito obrigado novamente Zipter98 (y)
ja é segunda vês q me ajuda, fico te devendo
testei aqui e funcionou, mesmo estando com todos os itens incompletos, ele nao remove os que eu tenho
resolvido !




info
Grupo: Campones
Registrado: 06/02/14
Posts: 48
Reputação: +9
Char no Tibia: Qarioman Erucasmius
Eae Galera !!
Estou com um erro bem chatinho em um dos npc,
o npc pega os itens mesmo NAO estando com a quantidade certa, que seria 50 pros 3 itens
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 stg = 15333 -- storage para falar com o npc local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local it = {2152, 10} if msgcontains(msg, 'mission') then if getPlayerStorageValue(cid, stg) >= 1 or getPlayerLevel(cid) > 100 then selfSay("Sorry, you already completed this mission or not have the necessary level to make this task!", cid) talkState[talkUser] = 0 else selfSay("Ooooh good! I'm looking for some rare items... They are: 50 ruby, 50 water pendant e 100 water gem. Do you have these items?", cid) talkState[talkUser] = 1 end end --------------------------------------------------------- if (msgcontains(msg, "yes") or msgcontains(msg, "sim")) and talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, 12188, 50) and doPlayerRemoveItem(cid, 12170, 50) and doPlayerRemoveItem(cid, 12161, 50) == true then selfSay("Thank you!", cid) setPlayerStorageValue(cid, stg, 1) -- para ele nao fazer a missao novamente doPlayerAddExperience(cid,120000) -- experiencia doPlayerAddItem(cid, it[1], it[2]) else selfSay("Sorry, but you don't have one of these items.", cid) talkState[talkUser] = 0 end elseif (msgcontains(msg, "no") or msgcontains(msg, "nao")) and talkState[talkUser] == 1 then selfSay("Good bye '..getCreatureName(cid)..'.", cid) talkState[talkUser] = 0 end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())Editado Março 5 por edu6279