By tutumelo, 20 de mai. de 2013 in Tutoriais para Iniciantes
info
Group: Artesão
Joined: 26/02/13
Posts: 102
Reputation: +6
Tibia Character: Tutumelo
--Tutorial criando ncp de teleport--
1° va em data/ncp/scripts.
2° crie um arquivo.lua.
3° bote isso no arquivos
local keywordHandler =KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local pos = {x=152,y=58,z=7} --->e o lugar que ele teletransporta veja isso o rme local itemid = 2468 -->e o id do dinheiro ou de um iten que ele da em troka o teleport. 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 if msgcontains(msg, "offer") or msgcontains(msg, "help") then selfSay("Eu posso te levar a TAL lugar por um "..getItemNameById(itemid).." item, fale {travel} se quizer viajar.", cid) talkState[cid] = 0 elseif msgcontains(msg, 'travel') then if doPlayerRemoveItem(cid, itemid, 1) then selfSay("Boa viagem.", cid) doTeleportThing(cid, pos) else selfSay("Voce nao tem o item nescessario.", cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=152,y=58,z=7} --->e o lugar que ele teletransporta veja isso o rme
local itemid = 2468 -->e o id do dinheiro ou de um iten que ele da em troka o teleport.
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
if msgcontains(msg, "offer") or msgcontains(msg, "help") then
selfSay("Eu posso te levar a TAL lugar por um "..getItemNameById(itemid).." item, fale {travel} se quizer viajar.", cid)
talkState[cid] = 0
elseif msgcontains(msg, 'travel') then
if doPlayerRemoveItem(cid, itemid, 1) then
selfSay("Boa viagem.", cid)
doTeleportThing(cid, pos)
else
selfSay("Voce nao tem o item nescessario.", cid)
return TRUE
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Faça outro arquivo.lua mais esse e pra fazer com o nome do ncp:
<npc name="NOMEDONPC" script="data/npc/scripts/itemtravel.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola. Para mais informacoes de meus servicos diga {offer}." />
<parameter key="message_farewell" value="Tchau." />
<parameter key="message_walkaway" value="Tchau." />
</parameters>
</npc>
Espero ter ajudado flw
Edited Maio 20 by tutumelo
info
Group: Artesão
Joined: 26/02/13
Posts: 102
Reputation: +6
Tibia Character: Tutumelo
--Tutorial criando ncp de teleport--
1° va em data/ncp/scripts.
2° crie um arquivo.lua.
3° bote isso no arquivos
Faça outro arquivo.lua mais esse e pra fazer com o nome do ncp:
<npc name="NOMEDONPC" script="data/npc/scripts/itemtravel.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola. Para mais informacoes de meus servicos diga {offer}." />
<parameter key="message_farewell" value="Tchau." />
<parameter key="message_walkaway" value="Tchau." />
</parameters>
</npc>
Espero ter ajudado flw
Edited Maio 20 by tutumelo