Ir para conteúdo
  • Cadastre-se

(Resolvido)[URGENTE] NPC


Ir para solução Resolvido por lucasromero,

Posts Recomendados

Queria um NPC que teleporta um player pra uma determinada posição(AVAH, JURA?) eu até tenho um NPC assim mais ele só teleporta pra um lugar só, eu queria um NPC que desse pra escolher qual lugar o player quer, mais ou menos assim:  

 

Player: Hi 

Npc: Aonde voce quer ir, Saffron , Cerulean, Celadon , Vermilion ou Lavender ? 

Player: Saffron 

Npc: Tem certeza que quer ir pra Saffron? 

Player: Yes 

Npc: Pronto voce esta em Saffron. 

 

_____________________________________ 

Só isso, quem puder ajudar dou Rep+ e pra quem tentar ajudar também dou Rep+ por que oque vale é a intensão  :D e.e 

Agradeço a todos;;;;

Atensiosamente, Gabriel L.

Link para o post
Compartilhar em outros sites

Cara é só pegar algum NPC do Global (aqueles que fica nos navios) e você vai trocando os nomes da cidades no arquivo .xml e tal.

Não vai cair sua mão.

Conlheça o projeto:

QtzGx2h.png

Link para o post
Compartilhar em outros sites

Cara é só pegar algum NPC do Global (aqueles que fica nos navios) e você vai trocando os nomes da cidades no arquivo .xml e tal.

Não vai cair sua mão.

Pode me mandar um NPC desse? ;-; 

Atensiosamente, Gabriel L.

Link para o post
Compartilhar em outros sites

toma o lua para o npc.

 

mystic = {x=1447, y=1504, z=7}
enigma = {x=942, y=980, z=6}
liberty = {x=495, y=1669, z=7}
folda = {x=267, y=349, z=6}
premmy = {x=1150, y=1478, z=7}
tiquanda = x=1081, y=1291, z=7}
local price = 100   -- preço da viagem para qualquer cidade
 
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
 
 
function onThingMove(creature, thing, oldpos, oldstackpos, cid, item, frompos, item2, topos)
 
end
 
 
function onCreatureAppear(creature)
 
end
 
 
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
 
 
function onCreatureTurn(creature)
 
end
 
 
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
 
 
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hiho ' .. getCreatureName(cid) .. '! Can I take you to, enigma city, mystic island, liberty bay, premmy city, folda, tiquanda. To go where they want?. Pointing out that travel costs 50 gps.')
focus = cid
talk_start = os.clock()
 
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')
 
elseif focus == cid then
talk_start = os.clock()
 
if msgcontains(msg, 'mystic island') then
if(doPlayerRemoveMoney(cid, price) == TRUE) then
doTeleportThing(cid,mystic)
doSendMagicEffect(mystic,10)
selfSay("Let's GO")
focus = 0
talk_start = 0
else
selfSay("Sorry, you don\'t have enough money.")
end
 
elseif msgcontains(msg, 'enigma') then
if(doPlayerRemoveMoney(cid, price) == TRUE) then
doTeleportThing(cid,enigma)
doSendMagicEffect(enigma,10)
selfSay("Let's GO")
focus = 0
talk_start = 0
else
selfSay("Sorry, you don\'t have enough money.")
end
 
elseif msgcontains(msg, 'liberty bay') then
if(doPlayerRemoveMoney(cid, price) == TRUE) then
doTeleportThing(cid,liberty)
doSendMagicEffect(liberty,10)
selfSay("Let's GO")
focus = 0
talk_start = 0
else
selfSay("Sorry, you don\'t have enough money.")
end
 
elseif msgcontains(msg, 'folda') then
if(doPlayerRemoveMoney(cid, price) == TRUE) then
doTeleportThing(cid,folda)
doSendMagicEffect(folda,10)
selfSay("Let's GO")
focus = 0
talk_start = 0
else
selfSay("Sorry, you don\'t have enough money.")
end
 
elseif msgcontains(msg, 'premmy city') then
if(doPlayerRemoveMoney(cid, price) == TRUE) then
doTeleportThing(cid,premmy)
doSendMagicEffect(premmy,10)
selfSay("Let's GO")
focus = 0
talk_start = 0
else
selfSay("Sorry, you don\'t have enough money.")
end
 
elseif msgcontains(msg, 'tiquanda') then
if(doPlayerRemoveMoney(cid, price) == TRUE) then
doTeleportThing(cid,tiquanda)
doSendMagicEffect(tiquanda,10)
selfSay("Let's GO")
focus = 0
talk_start = 0
else
selfSay("Sorry, you don\'t have enough money.")
end
 
 
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Bye ' .. creatureGetName(cid) .. ', go back.')
focus = 0
talk_start = 0
 
elseif msg ~= "" then
selfSay('how? I do not understand!')
talk_state = 0
end
end
end
 
function onCreatureChangeOutfit(creature)
end
 
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next please!!...')
end
focus = 0
talk_start = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good Bye')
focus = 0
talk_start = 0
end
end
end 

Editado por kbpaulo (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Solução

NPC.xml

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Alakazam" script="data/npc/scripts/viajar.lua" walkinterval="1000" speed="0" floorchange="0">
<health now="100" max="100"/>
<look type="135" head="19" body="113" legs="95" feet="115" addons="0"/>
<parameters>
<parameter key="message_greet" value="Aonde voce quer ir, Saffron, Cerulean, Cleadon, Vermilion ou Lavender?" />
</parameters>
</npc>

 

NPC/script/viajar.lua
 

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 travelNode = keywordHandler:addKeyword({'Saffron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voçê deseja ir a Saffron?'})
    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, level = 1, cost = 0, destination = {x=564, y=1145, z=7} })
    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Bye.'})

local travelNode = keywordHandler:addKeyword({'Cerulean'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voçê deseja ir a Cerulean?'})
    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, level = 1, cost = 0, destination = {x=1149, y=1218, z=7} })
    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Bye.'})

local travelNode = keywordHandler:addKeyword({'Celadon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voçê deseja ir a Celadon?'})
    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, level = 1, cost = 0, destination = {x=1015, y=906, z=7} })
    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Bye.'})

local travelNode = keywordHandler:addKeyword({'Vermilion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voçê deseja ir a Vermilion?'})
    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 1, cost = 0, destination = {x=972, y=1430, z=7} })
    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Bye.'})

local travelNode = keywordHandler:addKeyword({'Lavender'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Voçê deseja ir a lavender?'})
    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 1, cost = 0, destination = {x=912, y=1179, z=7} })
    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Bye.'})
    
-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

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