Ir para conteúdo
  • Cadastre-se

(Resolvido)NPC Travel TFS 1.0


Ir para solução Resolvido por Wakon,

Posts Recomendados

Olá, gostaria de uma ajudinha aqui, eu tenho um npc e não to conseguindo adicionar, um "back" para ele voltar para o templo.

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
 
local cfg = {
			toPos = {x=964, y=1025, z=14},
			level = 1,
			Storage = 25747
}
 
function creatureSayCallback(cid, type, msg)
          if(not npcHandler:isFocused(cid)) then
                    return false
          end
          local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
		  local player = Player(cid)
 
          if msgcontains(msg, 'bosses') then
                    selfSay('There are some undead below, you agree to be teleported there?', cid)
                    talkState[talkUser] = 1
          elseif talkState[talkUser] == 1 then
                    if msgcontains(msg, 'yes') then
						if player:getStorageValue(cfg.Storage) > 0 then
										selfSay('You\'ve done it.', cid)
									return FALSE
								end
                              if getPlayerLevel(cid) >= cfg.level then
                                                  doTeleportThing(cid, cfg.toPos)
                                                  talkState[talkUser] = 0
                                        else
                                        selfSay('Only players level ' ..cfg.level.. ' can pass.', cid)
									end
								end
						if msgcontains(msg, 'no') and talkState[talkUser] == 1 then
                              selfSay('Okay, you\'re a smart and probably know the face of danger that exists there.', cid)
							  talkState[talkUser] = 0
                    end
          end
 end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o post
Compartilhar em outros sites
  • Solução

Tenta assim:

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
 
local cfg = {
	toPos = {x=964, y=1025, z=14},
	level = 1,
	Storage = 25747,
	temploPos = {x = 444, y = 444, z = 7}
}
 
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local player = Player(cid)
 
    if msgcontains(msg, 'bosses') then
        selfSay('There are some undead below, you agree to be teleported there?', cid)
        talkState[talkUser] = 1
    elseif talkState[talkUser] == 1 then
        if msgcontains(msg, 'yes') then
			if player:getStorageValue(cfg.Storage) > 0 then
				selfSay('You\'ve done it.', cid)
				return FALSE
			end
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(cid, cfg.toPos)
            talkState[talkUser] = 0
        else
            selfSay('Only players level ' ..cfg.level.. ' can pass.', cid)
		end
	end
		if msgcontains(msg, 'no') and talkState[talkUser] == 1 then
            selfSay('Okay, you\'re a smart and probably know the face of danger that exists there.', cid)
			talkState[talkUser] = 0
        end
    elseif msgcontains(msg, 'back') then
       doTeleportThing(cid, cfg.temploPos)
    end
 end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o post
Compartilhar em outros sites

 

Tenta assim:

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
 
local cfg = {
	toPos = {x=964, y=1025, z=14},
	level = 1,
	Storage = 25747,
	temploPos = {x = 444, y = 444, z = 7}
}
 
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
    return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local player = Player(cid)
 
    if msgcontains(msg, 'bosses') then
        selfSay('There are some undead below, you agree to be teleported there?', cid)
        talkState[talkUser] = 1
    elseif talkState[talkUser] == 1 then
        if msgcontains(msg, 'yes') then
			if player:getStorageValue(cfg.Storage) > 0 then
				selfSay('You\'ve done it.', cid)
				return FALSE
			end
        if getPlayerLevel(cid) >= cfg.level then
            doTeleportThing(cid, cfg.toPos)
            talkState[talkUser] = 0
        else
            selfSay('Only players level ' ..cfg.level.. ' can pass.', cid)
		end
	end
		if msgcontains(msg, 'no') and talkState[talkUser] == 1 then
            selfSay('Okay, you\'re a smart and probably know the face of danger that exists there.', cid)
			talkState[talkUser] = 0
        end
    elseif msgcontains(msg, 'back') then
       doTeleportThing(cid, cfg.temploPos)
    end
 end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

desculpe pela demora, estava no quartel, testei aqui e funcionou perfeitamente, obrigado :)

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.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo