Ola galera, cabei de fazer um npc de travel que move o player por uma rota determinada no mapa editor! Peguei como base a ideia dos novos npcs de travel da pxg... Vamos la então...
1* Vão na pasta lib/ e criem um arquivo la com o nome Travel.lua, e coloquem isso dentro...
function isPosEqual(pos1, pos2)
if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then
return true
end
return false
end
function isPosInArray(array, pos)
if not next(array) then return false end
for i = 1, #array do
if isPosEqual(pos, array[i]) then
return true
end
end
return false
end
function moveTravel(cid, posFinal, oldPos)
if not isPlayer(cid) then return true end
local pos = getThingPos(cid)
local oldPos = oldPos or {}
if isPosEqual(pos, posFinal) then
moveTravel(cid, {x=0, y=0, z=0}, oldPos)
doRemoveCondition(cid, CONDITION_OUTFIT)
doSendMagicEffect(getThingPos(cid), 21)
mayNotMove(cid, false)
setPlayerStorageValue(cid, 75846, -1)
return true
end
for i = 0, 7 do
local newPos = getPosByDir(pos, i)
if not isPosInArray(oldPos, newPos) and getTileInfo(newPos).nologout then
doTeleportThing(cid, newPos, true)
table.insert(oldPos, pos)
if isPosEqual({x=0, y=0, z=0}, posFinal) then return true end
addEvent(moveTravel, 150, cid, posFinal, oldPos)
return true
end
end
return false
end
2* Vão na pasta npc/ e criem o arquivo .xml do npc... Vou deixar um exemplo aki...
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Nurse Joy" script="Water Travel.lua" walkinterval="350000" floorchange="0" speed="0" lookdir="2">
<health now="150" max="150"/>
<look type="1041" head="10" body="15" legs="20" feet="25"/>
<parameters>
<parameter key="message_greet" value="Hi, you would like to {travel}?."/>
</parameters>
</npc>
3* Vão na pasta npc/scripts/ e criem um arquivo la com o nome Water Travel.lua e colem isso dentro...
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)
posInicial = nil
posFinal = nil
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
---------------------- CONFIGS --------------------------------------
local posis = {
--[pos do npc] = {pos inicial, pos final},
[{x = 988, y = 1067, z = 7}] = {posIni = {x = 987, y = 1069, z = 7}, posFinal = {x = 947, y = 1110, z = 7}},
[{x = 945, y = 1112, z = 7}] = {posIni = {x = 947, y = 1111, z = 7}, posFinal = {x = 986, y = 1069, z = 7}},
[{x = 107, y = 77, z = 7}] = {posIni = {x = 110, y = 78, z = 7}, posFinal = {x = 81, y = 79, z = 7}},
[{x = 84, y = 77, z = 7}] = {posIni = {x = 81, y = 78, z = 7}, posFinal = {x = 110, y = 79, z = 7}},
[{x = 116, y = 60, z = 7}] = {posIni = {x = 119, y = 58, z = 7}, posFinal = {x = 72, y = 59, z = 7}},
[{x = 69, y = 62, z = 7}] = {posIni = {x = 72, y = 60, z = 7}, posFinal = {x = 119, y = 57, z = 7}},
}
for npcPos, pos in pairs(posis) do
if isPosEqual(getThingPos(getNpcCid()), npcPos) then
posInicial = pos.posIni
posFinal = pos.posFinal
break
end
end
if not posInicial then selfSay("A error has occored!", cid) print("A error has occored, npc travel aren't in the correct place!") return false end
local outfit = getPlayerSex(cid) == 0 and {lookType = 1440} or {lookType = 1439} --outfit q o player vai ganhar, a 1* eh female e a 2* eh male
local msg = msg:lower()
------------------------------------------------------------------------------
if msgcontains(msg, 'travel') then
------------------------- Se nao usarem um serv pokemon podem tirar essa parte! -------------------------------------------
local storages = {17000, 63215, 17001, 13008, 5700}
for s = 1, #storages do
if getPlayerStorageValue(cid, storages[s]) >= 1 then
return selfSay("You can't do that while is Flying, Riding, Surfing, Diving or mount a bike!", cid) and true
end
end
if #getCreatureSummons(cid) >= 1 then
return selfSay("Return your pokemon!", cid) and true
end
--------------------------------------------------------------------------------------------------------------------------
selfSay("Are you sure do you want to travel?", cid)
talkState[talkUser] = 1
return true
elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'Yes')) and talkState[talkUser] == 1 then
selfSay("Ok then, good travel!", cid)
doTeleportThing(cid, posInicial, false)
doSendMagicEffect(getThingPos(cid), 21)
mayNotMove(cid, true)
setPlayerStorageValue(cid, 75846, 1)
doSetCreatureOutfit(cid, outfit, -1)
moveTravel(cid, posFinal)
talkState[talkUser] = 0
return true
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Pronto, agora vamos as configurações...
Configuraçoes:
1* Aki vocês configuram as posições dos npcs e as posições iniciais e finais da rota q o player vai seguir:
local posis = {
--[pos do npc] = {pos inicial, pos final},
[{x = 988, y = 1067, z = 7}] = {posIni = {x = 987, y = 1069, z = 7}, posFinal = {x = 947, y = 1110, z = 7}},
[{x = 945, y = 1112, z = 7}] = {posIni = {x = 947, y = 1111, z = 7}, posFinal = {x = 986, y = 1069, z = 7}},
[{x = 107, y = 77, z = 7}] = {posIni = {x = 110, y = 78, z = 7}, posFinal = {x = 81, y = 79, z = 7}},
[{x = 84, y = 77, z = 7}] = {posIni = {x = 81, y = 78, z = 7}, posFinal = {x = 110, y = 79, z = 7}},
[{x = 116, y = 60, z = 7}] = {posIni = {x = 119, y = 58, z = 7}, posFinal = {x = 72, y = 59, z = 7}},
[{x = 69, y = 62, z = 7}] = {posIni = {x = 72, y = 60, z = 7}, posFinal = {x = 119, y = 57, z = 7}},
}
2* Aki vocês configuram a outfit q o player vai ganhar quando começar o travel, podendo ser outfit de moto, carro, kaike e afins:
local outfit = getPlayerSex(cid) == 0 and {lookType = 1440} or {lookType = 1439} --outfit q o player vai ganhar, a 1* eh female e a 2* eh male
3* Caso não usem um servidor de pokemon, podem tirar essa parte...
------------------------- Se nao usarem um serv pokemon podem tirar essa parte! -------------------------------------------
local storages = {17000, 63215, 17001, 13008, 5700}
for s = 1, #storages do
if getPlayerStorageValue(cid, storages[s]) >= 1 then
return selfSay("You can't do that while is Flying, Riding, Surfing, Diving or mount a bike!", cid) and true
end
end
if #getCreatureSummons(cid) >= 1 then
return selfSay("Return your pokemon!", cid) and true
end
--------------------------------------------------------------------------------------------------------------------------
4* Essa é a imagem de como vocês tem q configurar as rotas:

Para fazer as rotas usem a ferramenta 'No-Logout' do mapa editor... lembrando que as posições finais tambem tem que ter o piso no-logout!
Podem fazer a rota como quiserem, mas por favor, nao tentem 'forçar' o script.
Importante: O npc tem q tar imóvel, ele n pode se mover da posição que foi colocada na tabela no script Water Travel.lua!
Importante: Esse script foi inicialmente feito para travels na agua, mas eu testei aki e da pra fazer rotas na terra normalmente!
Importante: Quem for usar num servidor pokemon olhem o spoiler abaixo:
1* Vão no arquivo actions/scripts/goback.lua e achem essa parte...
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 then return true end
e deixem assim...
if getPlayerStorageValue(cid, 17000) >= 1 or getPlayerStorageValue(cid, 17001) >= 1 or getPlayerStorageValue(cid, 63215) >= 1 or getPlayerStorageValue(cid, 75846) >= 1 then return true end
2* Vão no arquivo movements/scripts/surf.lua e logo abaixo dessa linha:
function onStepIn(cid, item, position, fromPosition)
coloquem isso..
if getPlayerStorageValue(cid, 75846) >= 1 then return true end
3* Caso usem a barra de pokemons do kpdo:
vão em lib/some functions.lua e achem isso...
function doGoPokemon(cid, item)
e façam a mesma coisa do '1*' ali emcima.
Espero que gostem, qualquer duvida ou bug podem postar aki, Vlw!












