Ir para conteúdo

Featured Replies

Postado

Eu criei um npc de quest que da um storage pro player, ai ativa a quest normalmente, só que se o player voltar e falar denovo com o npc recebe novamente o storage e reinicia a quest. Eu tentei adicionar um storage no firstitems e colocar pro npc checar se o player tem o storage, ele só vai ter quando criar uma conta nova, pq dps que ele abre o bau, o storage é setado pra -1. Só que não ta funcionando, nao sei pq, de vez em quando funciona, outras vezes não.

Firstitems:

local firstItems =

{

2460,

2465,

2531,

2554,

2120,

2643,

2478

}

function onLogin(cid)

if getPlayerStorageValue(cid, 30001) == -1 then

for i = 1, table.maxn(firstItems) do

doPlayerAddItem(cid, firstItems, 1)

end

local bag = doPlayerAddItem(cid, 1988, 1)

local voca = getPlayerVocation(cid)

if voca == 1 then

doPlayerAddItem(cid, 2190, 1)

doAddContainerItem(bag, 7620, 5)

doPlayerAddItem(cid, 2152, 10)

elseif voca == 2 then

doPlayerAddItem(cid, 2182, 1)

doAddContainerItem(bag, 7620, 5)

doPlayerAddItem(cid, 2152, 10)

elseif voca == 3 then

doPlayerAddItem(cid, 2389, 1)

doAddContainerItem(bag, 7618, 5)

doPlayerAddItem(cid, 2152, 10)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Os trainers se encontram a Nordeste na cidade.')

elseif voca == 4 then

doPlayerAddItem(cid, 8602, 1)

doPlayerAddItem(cid, 8601, 1)

doPlayerAddItem(cid, 2439, 1)

doAddContainerItem(bag, 7618, 5)

doPlayerAddItem(cid, 2152, 10)

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Os trainers se encontram a Nordeste na cidade.')

end

setPlayerStorageValue(cid, 30001, 1)

setPlayerStorageValue(cid, 96745, 1)

end

return TRUE

end

NPC:

Quote

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)

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

--[[

REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!

]]--

local boromir = 4001

local boromir2 = 4002

local boromir3 = 4003

if (getPlayerStorageValue(cid, 96745) == 1) and msgcontains(msg, 'portao') then

npcHandler:say("Você terá que matar um guarda e abrir o portão, acha que consegue?", cid)

talkState[talkUser] = 0

elseif (getPlayerStorageValue(cid, 96745) == 1) and msgcontains(msg, 'yes') then

setPlayerStorageValue(cid, boromir, 1)

setPlayerStorageValue(cid, boromir2, 1)

setPlayerStorageValue(cid, boromir3, 1)

npcHandler:say("Quando abrir o portão, desça as escadas e vá procurar por Heller, ele lhe dará as próximas instruções.", cid)

talkState[talkUser] = 0

else

npcHandler:say("Estou muito ferido e não posso mais lutar, você terá que ir sozinho.", cid)

talkState[talkUser] = 0

end

return TRUE

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

E não da erro nenhum no console, o script ta funcionando, só parece que não ta checando corretamente. Alguem sabe o que pode ser e como arrumar? Rep +

Postado



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 onPlayerEndTrade(cid)                npcHandler:onPlayerEndTrade(cid)            end

function onPlayerCloseChannel(cid)            npcHandler:onPlayerCloseChannel(cid)        end


function onCreatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then

        return false

    end


    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


    local storages = {[1] = 4001, [2] = 4002, [3] = 4003}


    if talkState[talkUser] == 0 then

        if msgcontains(msg, "portao") then

            if getCreatureStorage(cid, 96745) == -1 then

                selfSay("Você terá que matar um guarda para abrir o portão, acha que é capaz?", cid)

                talkState[talkUser] = 1

            else

                selfSay("Estou muito ferido e não posso mais lutar, você terá que ir sozinho.", cid)

                talkState[talkUser] = 0

            end

        end

    elseif talkState[talkUser] == 1 then

        if msgcontains(msg, "yes") then

            selfSay("Quando abrir o portão, desça as escadas e fale com Heller, ele lhe dará as próximas instruções.", cid)

            for _, storage in ipairs(storages) do

                doCreatureSetStorage(cid, storage, 1)

            end

            doCreatureSetStorage(cid, 96745, 1)

            talkState[talkUser] = 0

        elseif msgcontains(msg, "no" then

            selfSay("Tudo bem. Se mudar de ideia, volte a falar comigo.", cid)

            npcHandler:releaseFocus(cid)

        end

    end

    return true

end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)

npcHandler:addModule(FocusModule:new())

Acho que a construção do NPC estava problemática. Retire as linhas de código que mudam o storage do firstitems.lua.

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo