Ir para conteúdo
  • Cadastre-se

(Resolvido)Npc que libera passagem de barco


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

  • Respostas 6
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

NPC 1   npcquest.lua     NPC 2   npctravel.lua         Edite as falas, posições, nomes, etc, como quiser, apenas coloquei esses para te servir como base.  

Posted Images

31 minutos atrás, Messe disse:

To com esse problema

image.thumb.png.edd8e912750ebd2baecefe27685fa158.png

 

A versão do tfs do cara é 1.x, a sua é diferente. Usa essa:

 

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local npcTopic = {}

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

local item = {2160, 1} --id do item, quantidade

function creatureSayCallback(cid, type, msg)
    local msg = string.lower(msg)
    if not npcHandler:isFocused(cid) then
        if isInArray({"hi", "hello"}, msg) then
            npcHandler:addFocus(cid)
            if getPlayerStorageValue(cid, 56787) == -1 then
                if getPlayerStorageValue(cid, 56788) == -1 then
                    npcHandler:say("Hi, "..getPlayerName(cid).."! There is a lost secret inside a chest at this jungle. If you bring to me I can indicate you a trip with an old friend. Do you accept?", cid)
                    npcTopic[cid] = 1
                else
                    npcHandler:say("Hi, ".. getPlayerName(cid) .."! Did you finished the quest?", cid)
                    npcTopic[cid] = 2
                end
            else
                npcHandler:say("I have already talked to my friend about you.", cid)
                npcTopic[cid] = 0
                npcHandler:releaseFocus(cid)
            end
        else
            return false
        end
    elseif msgcontains(msg, "yes") and npcTopic[cid] == 1 then
        setPlayerStorageValue(cid, 56788, 1)
        npcHandler:say("Ok, now I will wait for you. Be careful!", cid)
        npcTopic[cid] = 0
        npcHandler:releaseFocus(cid)
    elseif msgcontains(msg, "yes") and npcTopic[cid] == 2 then
        if doPlayerRemoveItem(cid, item[1], item[2]) then
            setPlayerStorageValue(cid, 56787, 1)
            npcHandler:say("Thanks! Now I will indicate you to a friend.", cid)
            npcTopic[cid] = 0
        else
            npcHandler:say("Sorry but you don't have the items I need.", cid)
            npcTopic[cid] = 0
        end
    elseif msgcontains(msg, "no") and npcTopic[cid] == 2 then
        npcHandler:say("Ok, I will wait a bit more.", cid)
        npcTopic[cid] = 0
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye.", cid)
        npcHandler:releaseFocus(cid)
    else
        npcHandler:say("What?", cid)
        npcTopic[cid] = 0
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 

 

Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local npcTopic = {}

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

local cities = {
["kazordoon"] = {x = 1, y = 1, z = 1},
["mines"] = {x = 1, y = 1, z = 1},
["dwarf cave"] = {x = 1, y = 1, z = 1},
["beregar"] = {x = 1, y = 1, z = 1},
["farmine"] = {x = 1, y = 1, z = 1}
}

function creatureSayCallback(cid, type, msg)
    local msg = string.lower(msg)
    if not npcHandler:isFocused(cid) then
        if isInArray({"hi", "hello"}, msg) then
            npcHandler:addFocus(cid)
            if getPlayerStorageValue(cid, 56787) == 1 then
                local text = ""
                for city, pos in pairs(cities) do
                    text = text .. "{" .. city .."}, "
                end
                npcHandler:say("Hi, "..getPlayerName(cid).."! Dwarfer is an old and dear friend and talked about you. I can travel you to "..text.."where do you wanna go?", cid)
                npcTopic[cid] = 1
            else
                npcHandler:say("I have never heard your name before. Sorry, but I travel with people only with good indications.", cid)
                npcTopic[cid] = 0
                npcHandler:releaseFocus(cid)
            end
        else
            return false
        end
    elseif cities[msg] and npcTopic[cid] == 1 then
        doTeleportThing(cid, cities[msg])
        doSendMagicEffect(cities[msg], CONST_ME_TELEPORT)
        npcHandler:say("Sure, brave adventurer!", cid)
        npcTopic[cid] = 0
        npcHandler:releaseFocus(cid)
    elseif not cities[msg] and npcTopic[cid] == 1 then
        npcHandler:say("I am not travelling to this place. You can try another.", cid)
        npcTopic[cid] = 0
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye.", cid)
        npcHandler:releaseFocus(cid)
    else
        npcHandler:say("What?", cid)
        npcTopic[cid] = 0
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
            

 

 

Contato:

 

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96845
    Tópicos
    519598
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo