Ir para conteúdo
  • Cadastre-se

(Resolvido)[Pedido] Npc Teleport com Level


Ir para solução Resolvido por Wise,

Posts Recomendados

Olá pessoas do Tibiaking,com! e.e  

 

Estou precisando de um Npc de Teleport com level, que ele só teleport players de level 50+, existem alguns no fórum mais os que eu achei não funcionaram no meu servidor. 

 

Rep+ Pra quem ajudar :D ><

Atensiosamente, Gabriel L.

Link para o post
Compartilhar em outros sites
  • Solução

stranger.lua (data\npc\scripts):

local level = 50
local pos = {x=123, y=456, z=7}

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 talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
    
    if (msgcontains(msg, 'teleport')) then
        talkState[talkUser] = 1
        selfSay('I can teleport you, but you need at least level '..level..' to go. Are you sure you\'re ready?', cid)
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if (getPlayerLevel(cid) >= level) then
            doTeleportThing(cid, pos)
            doSendMagicEffect(pos, CONST_ME_TELEPORT)
            selfSay('Be careful!', cid)
        else
            talkState[talkUser] = 0
            selfSay('I said! You need at least level '..level..' to be teleported. You\'re not ready.', cid)
        end
    elseif (msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
        selfSay('Sure.', cid)
    end
    
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())



 

Stranger.xml (data\npc):

<npc name="Stranger" script="data/npc/scripts/stranger.lua" access="5" lookdir="1">
<health now="1000" max="1000"/>
<look type="129" head="115" body="132" legs="114" feet="95" addons="0"/>
    <parameters>
        <parameter key="message_greet" value="Hey |PLAYERNAME|, I can {teleport} some mortals." />
    </parameters>
</npc>

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

Não testei sou novo nesses bang de script ...

 

carlos.lua

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=1789, y=3667, z=7}, -- Posição
          level = 50, -- Level necessário 
          price = 30 -- Dinheiro cobrado
}
 
function creatureSayCallback(cid, type, msg)
          if(not npcHandler:isFocused(cid)) then
                    return false
          end
          local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

          if msgcontains(msg, 'travel') then
                    selfSay('You are sure you want to go?', cid)
		    talkState[talkUser] = 1
		elseif  msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
                              if getPlayerLevel(cid) >= cfg.level then
                                        if doPlayerRemoveMoney(cid, cfg.price) then
                                                  doTeleportThing(cid, cfg.toPos)
						  talkState[talkUser] = 0
                                        else
                                                  selfSay('You don\'t have enough money.', cid)
                                        end
                              else
                                        selfSay('You need level having above '.. cfg.level ..'.', cid)
                              end
                    elseif msgcontains(msg, 'no') then
                              selfSay('bye', cid)
                    end
          end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

carlos.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Carlos" script="data/npc/scripts/carlos.lua" walkinterval="25" floorchange="0" access="5" level="1" maglevel="1">
          <health now="150" max="150"/>
          <look type="128" head="114" body="12" legs="57" feet="114" addons="0" />
          <parameters>
                    <parameter key="message_greet" value="Hello, |PLAYERNAME|! Would like to {travel} ?"/>
                    <parameter key="message_walkaway" value="Hey, where you go ?"/>
                    <parameter key="message_farewell" value="Bye!"/>
          </parameters>
</npc>

#Edit

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

0hbk.png

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.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo