Postado Julho 24, 2022 2 anos Boa Tarde TibiaKing!!! Bom estou precisando arrumar um script, não deve ser muito difícil !! (pra quem sabe !) Quem poder ajudar já agradeço. Resumindo apartir do momento que falo Travel, Yes para o npc ele me teleporta para posicao inicial me transformando(LookType) e precisa me levar até o destino final. (posFinal) até ai tudo bem problema que ele comeca a funcionar e me leva para lugar aleatorio e fica parado lá imovel. ( não da erro na Distro ) Apenas fico parado na LookType de barco. Uso tfs 0.4 8.60 local posis = { --[pos do npc] = {pos inicial, pos final}, [{x = 115, y = 143, z = 10}] = {posIni = {x = 114, y = 134, z = 10}, posFinal = {x = 76, y = 134, z = 10}}, [{x = 74, y = 132, z = 10}] = {posIni = {x = 76, y = 134, z = 10}, posFinal = {x = 95, y = 147, z = 10}}, } é um NPC .LUA DO NPC Spoiler 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 = 115, y = 143, z = 10}] = {posIni = {x = 114, y = 134, z = 10}, posFinal = {x = 76, y = 134, z = 10}}, [{x = 74, y = 132, z = 10}] = {posIni = {x = 76, y = 134, z = 10}, posFinal = {x = 95, y = 147, z = 10}}, } 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 = 880} or {lookType = 880} --outfit q o player vai ganhar, a 1* eh female e a 2* eh male local msg = msg:lower() ------------------------------------------------------------------------------ if msgcontains(msg, 'travel') then 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()) LIB - TRAVEL.LUA Spoiler 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 ,XML Spoiler <?xml version="1.0" encoding="UTF-8"?> <npc name="Nave" script="viaja.lua" walkinterval="350000" floorchange="0" speed="0" lookdir="2"> <health now="150" max="150"/> <look type="881" head="10" body="15" legs="20" feet="25"/> <parameters> <parameter key="message_greet" value="Hi, you would like to {travel}?."/> </parameters> </npc>
Postado Julho 24, 2022 2 anos Este tópico foi movido para a seção de Suporte Otserv. 29 minutos atrás, Maniaco disse: até ai tudo bem problema que ele comeca a funcionar e me leva para lugar aleatorio e fica parado lá imovel. ( não da erro na Distro ) Apenas fico parado na LookType de barco. cara eu fraguei +/- a idéia, você consegue fazer um video explicando como está, e como deveria funcionar? ou alguma imagem que exemplifique pf?
Postado Julho 25, 2022 2 anos Autor Em 24/07/2022 em 18:19, FeeTads disse: Este tópico foi movido para a seção de Suporte Otserv. cara eu fraguei +/- a idéia, você consegue fazer um video explicando como está, e como deveria funcionar? ou alguma imagem que exemplifique pf? @FeeTads Video: Spoiler 20220725_183650.mp4 Editado Julho 25, 2022 2 anos por Maniaco (veja o histórico de edições)
Postado Julho 28, 2022 2 anos Solução Em 25/07/2022 em 18:40, Maniaco disse: @FeeTads Video: Ocultar conteúdo 20220725_183650.mp4 4 MB · 0 downloads Salve demorou mas consegui achar ta ai bro é um MOD okCrie um arquivo na pasta mod e coloque esse código Spoiler <?xml version="1.0" encoding="UTF-8"?> <mod name="BoatSystem" enabled="yes" author="MatheusMkalo" forum="XTibia.com"> <config name="BoatSystemLib"><![CDATA[ mydirs= { [1] = {type = 1, ids = {3587, 3590, 3591}, xy = {0, -1}}, [2] = {type = 2, ids = {3592, 3595, 3596}, xy = {1, 0}}, [3] = {type = 1, ids = {3587, 3590, 3591}, xy = {0, 1}}, [4] = {type = 2, ids = {3592, 3595, 3596}, xy = {-1, 0}} } allids = {3587, 3590, 3591, 3592, 3595, 3596} function newEndb(endb, dir) local xx = endb.x local yy = endb.y for i = 1, #dir do xx = xx+mydirs[dir[i]].xy[1] yy = yy+mydirs[dir[i]].xy[2] end return {x=xx, y=yy, z=endb.z} end function doMoveBoat(post, dir, cid) local newboat = {} for i,s in ipairs(post) do local backu = getThingPos(s) doRemoveItem(s, 1) doCreateItem(mydirs[dir].ids[i], 1, {x=backu.x+mydirs[dir].xy[1], y=backu.y+mydirs[dir].xy[2], z=backu.z}) table.insert(newboat, getThingFromPos({x=backu.x+mydirs[dir].xy[1], y=backu.y+mydirs[dir].xy[2], z=backu.z, stackpos=1}).uid) end if mydirs[dir].type ~= post.type and mydirs[dir].type == 1 then doCreateItem(getThing(newboat[1]).itemid, 1, {x=getThingPos(newboat[1]).x+1, y=getThingPos(newboat[1]).y-1, z=getThingPos(newboat[1]).z}) doRemoveItem(newboat[1], 1) doCreateItem(getThing(newboat[3]).itemid, 1, {x=getThingPos(newboat[3]).x-1, y=getThingPos(newboat[3]).y+1, z=getThingPos(newboat[3]).z}) doRemoveItem(newboat[3], 1) elseif mydirs[dir].type ~= post.type and mydirs[dir].type == 2 then doCreateItem(getThing(newboat[1]).itemid, 1, {x=getThingPos(newboat[1]).x-1, y=getThingPos(newboat[1]).y+1, z=getThingPos(newboat[1]).z}) doRemoveItem(newboat[1], 1) doCreateItem(getThing(newboat[3]).itemid, 1, {x=getThingPos(newboat[3]).x+1, y=getThingPos(newboat[3]).y-1, z=getThingPos(newboat[3]).z}) doRemoveItem(newboat[3], 1) end if cid then doTeleportThing(cid, {x=getCreaturePosition(cid).x+mydirs[dir].xy[1], y=getCreaturePosition(cid).y+mydirs[dir].xy[2], z=getCreaturePosition(cid).z}, false) end end function getPosBoat(cid, pos) local pcid = not pos and getCreaturePosition(cid) or pos local check = getThingFromPos({x=pcid.x, y=pcid.y, z=pcid.z, stackpos=1}).itemid == mydirs[1].ids[2] and 1 or 2 if check == 1 then return {getThingFromPos({x=pcid.x, y=pcid.y-1, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x, y=pcid.y, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x, y=pcid.y+1, z=pcid.z, stackpos=1}).uid, type = check} elseif check == 2 then return {getThingFromPos({x=pcid.x-1, y=pcid.y, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x, y=pcid.y, z=pcid.z, stackpos=1}).uid, getThingFromPos({x=pcid.x+1, y=pcid.y, z=pcid.z, stackpos=1}).uid, type = check} end return false end function reverse(t) local result = {} for i = #t, 1, -1 do table.insert(result, t[i] == 1 and 3 or t[i] == 2 and 4 or t[i] == 3 and 1 or t[i] == 4 and 2) end return result end ]]></config> <movevent type="StepIn" actionid="6616" event="script"><![CDATA[ domodlib("BoatSystemLib") local t = {4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2} local postart = {x=968, y=1001, z=7, stackpos=1} local posback = {x=994, y=978, z=7, stackpos=1} local delay = 350 if toPosition.x == posback.x and toPosition.y == posback.y then doCreatureSetNoMove(cid, true) for i = 1, #reverse(t) do addEvent(function() doMoveBoat(getPosBoat(cid), reverse(t)[i], cid) end, i*delay) end addEvent(doCreatureSetNoMove, delay*#reverse(t)+100, cid, false) addEvent(function() doItemSetAttribute(getThingFromPos(postart).uid, "aid", 6616) end, delay*#t+100) elseif toPosition.x == postart.x and toPosition.y == postart.y then doCreatureSetNoMove(cid, true) for i = 1, #t do addEvent(function() doMoveBoat(getPosBoat(cid), t[i], cid) end, i*delay) end addEvent(doCreatureSetNoMove, delay*#t+100, cid, false) addEvent(function() doItemSetAttribute(getThingFromPos(posback).uid, "aid", 6616) end, delay*#t+100) end ]]></movevent> <movevent type="StepIn" actionid="6617" event="script"><![CDATA[ domodlib("BoatSystemLib") if not isInArray(allids, getThingFromPos({x=toPosition.x, y=toPosition.y, z=toPosition.z, stackpos=1}).itemid) then doTeleportThing(cid, fromPosition, false) end ]]></movevent> </mod> Agora as configurações local t = {4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2} local postart = {x=968, y=1001, z=7, stackpos=1} local posback = {x=994, y=978, z=7, stackpos=1} local delay = 350 No local t, sao todas as direçoes que o barco vai andar, em sentido horario: 1 = norte 2 = leste 3 = sul 4 = oeste No local postart eh a posiçao que o meio do barco vai estar quando ele estiver indo para algum lugar. No local posback eh a posiçao que o meio do barco vai estar quando ele estiver voltando. O delay eh o tempo em milesegundos que demora pra o barco andar. Adicionando no Map editor: Faça 3 sqms do id 4820. Adicione o actionid 6617 nesses sqms. Faça 3 ids de barco, voce escolhe se eh o virado para cima ou para o lado. Bote o actionid 6616 no meio do barco. OBS: PONHA OS SQMS DA ROTA PARA NAO PODER LOGA SE ALGUEM LOGA NO BARCO VAI DAR BUG @Maniaco Editado Agosto 2, 2022 2 anos por LeoTK (veja o histórico de edições) Compre seus Scripts Agora totalmente seguro e de forma rápida, aceitamos também encomendas. discord.gg/phJZeHa2k4 Projeto ATS (Naruto) Informações Abaixo Facebook Youtube Discord Tutoriais / Conteúdos Clique Aqui
Postado Julho 28, 2022 2 anos Autor 1 minuto atrás, LeoTK disse: Isso é apenas um teleport do player para uma área e change outfit para mudar para a outfit da nave ai o player anda até os locais que estiver e depois remove o change outfit voltando a outfit que o player estava antes... Problema que ele simplesmente não vai para o lugar certo '0'
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.