Ir para conteúdo

Featured Replies

Postado

Olá, gostaria de ajuda para fazer com que meu NPC cheque se o personagem possuir o addon X, caso não possua, não poderá viajar.

Seria assim:

 

Greetings:

Olá, com meu barco você pode {viajar} para Golduck e caçar caninos extremamente fortes! Mas para isso, você precisará {provar} que é capaz de sobreviver por lá.

 

  • Caso o player possua o addon e use o comando {viajar}, ele é teleportado para a ilha.
  • Caso o player não possua o addon e use o comando {viajar}, ele é respondido com a seguinte mensagem:

        "Você ainda não provou ser capaz de sobreviver naquele frio. Ainda deseja saber como {provar} isto?"

 

  • Caso o player use o comando {provar}, ele é respondido com a seguinte mensagem(no greetings e na ocasião anterior):

         "Para sobreviver naquelas terras frias, você precisará de uma roupa especial. Meu amigo Joe pode te ajudar com isso."

 

O addon é o Norseman e o tipo de viagem é a seguinte:

local freyaKeyword = keywordHandler:addKeyword({'viajar'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = 580, msg = "Boa caçada, irmão.", destination = Position(360, 1853, 7)})

580gps e apenas para VIPs.

 

 

 

Pesquisando consegui solucionar meu problema. Podem fechar o tópico.

 

Master yourself, master the enemy.

  • 2 weeks later...
Postado

Bom você disse addon, mas acho que quis dizer outfit.

Fiz uma implementação do que você queria, caso tenha algum erro ou queira algo mais é só falar.

 

Demonstração (Exibe que a conta não é Premium, mas ela é)

 

Spoiler

NPC_outfit_travel.thumb.gif.257f19cc7b59c238931887b1a3ca8e2b.gif

 

Script

 

Spoiler

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

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 node2 = keywordHandler:addKeyword({'provar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Para sobreviver naquelas terras frias, você precisará de uma roupa especial. Meu amigo Joe pode te ajudar com isso.'})

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    
    local player = Player(cid)

    if not player:isPlayer() then
        return false
    end

    if msgcontains(msg, "viajar") then
        if player:getPremiumDays() < 1 then
            npcHandler:say("Você precisa ser premium.", cid)
            return false
        end

        if not player:hasOutfit(251) and not player:hasOutfit(252) then
            npcHandler:say("Você ainda não provou ser capaz de sobreviver naquele frio. Ainda deseja saber como {provar} isto?", cid)
            return false
        end

        if player:removeMoney(580) then
            npcHandler:say("Boa caçada, irmão.", cid)
            npcHandler:releaseFocus(cid)
            player:teleportTo(Position(109, 360, 6))
        end
    end

    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Olá, com meu barco você pode {viajar} para Golduck e caçar caninos extremamente fortes! Mas para isso, você precisará {provar} que é capaz de sobreviver por lá.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Postado
Em 24/12/2017 em 13:17, Skydrowz disse:

Pesquisando consegui solucionar meu problema. Podem fechar o tópico.

 

 

Se quiser sua dúvida tirada, mande PM com os links, e não com a dúvida (outros podem ter a mesma dúvida, e o fórum serve para ser usado).

 

Tópicos:


 

yNlhRVC.png

 

55px-Judo_yellow_belt.svg.png

  • 5 years later...
Postado

Esse codigo nao esta funcionando. O que tem de errado?

 

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

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 function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    
    local player = Player(cid)

    if not player:isPlayer() then
        return false
    end

    if msgcontains(msg, "sail") then

        if player:hasOutfit(153) and player:hasOutfit(157) then
            npcHandler:say("Voce não pode, voce é da classe X.", cid)
            return false
        end

        if player:removeMoney(50) then
            npcHandler:say("Good luck.", cid)
            npcHandler:releaseFocus(cid)
            player:teleportTo(Position(144, 1252, 6))
        end
    end

    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Olá, com meu barco você pode {sail} para x.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Postado
10 horas atrás, Vorkhon disse:

Esse codigo nao esta funcionando. O que tem de errado?

 



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

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 function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    
    local player = Player(cid)

    if not player:isPlayer() then
        return false
    end

    if msgcontains(msg, "sail") then

        if player:hasOutfit(153) and player:hasOutfit(157) then
            npcHandler:say("Voce não pode, voce é da classe X.", cid)
            return false
        end

        if player:removeMoney(50) then
            npcHandler:say("Good luck.", cid)
            npcHandler:releaseFocus(cid)
            player:teleportTo(Position(144, 1252, 6))
        end
    end

    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Olá, com meu barco você pode {sail} para x.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

if player:hasOutfit(153) and player:hasOutfit(157) then

Troca pra 

 

if not player:hasOutfit(153) and not player:hasOutfit(157) then

 

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

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 function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    
    local player = Player(cid)

    if not player:isPlayer() then
        return false
    end

    if msgcontains(msg, "sail") then
        if player:hasOutfit(153) and player:hasOutfit(157) then
			if player:removeMoney(50) then
				npcHandler:say("Good luck.", cid)
				npcHandler:releaseFocus(cid)
				player:teleportTo(Position(32227, 31756, 7))
			else
				npcHandler:say("Nao tem dinheiro.", cid)
				npcHandler:releaseFocus(cid)
			end
		else
			npcHandler:say("Voce não pode, voce é da classe X.", cid)
			npcHandler:releaseFocus(cid)
		end
	end
	
    return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Olá, com meu barco você pode {sail} para x.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Editado por Fabi Marzan (veja o histórico de edições)

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