Ir para conteúdo
  • 0

Erro Npc Quest


edu6279

Pergunta

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 por edu6279
Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

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())

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...