ST

[Resolvido] NPC Item For Teleport

Por Step Records, 03 de nov. de 2018 em Resolvidos

8
1.5k
03 de novembro de 2018 às 09:42

Hello, I would need a NPC script that can teleport us to a given place for the position. However, try or make sure you have a teleport

MarshmelloM
03 de novembro de 2018 às 13:04
3 horas atrás, Step Records disse:
Versão do Servidor: TFS - 0.3.4
Tipo de Script: npc

Olá, eu precisaria de um script NPC que possa nos teletransportar para um determinado local para a posição. No entanto, tente ou certifique-se de ter um teleport

 

Let me see if I understand, you want a script that the player is teleported to an X position?

Ayron5A
03 de novembro de 2018 às 19:22
9 horas atrás, Step Records disse:
Versão do Servidor: TFS - 0.3.4
Tipo de Script: npc

Hello, I would need a NPC script that can teleport us to a given place for the position. However, try or make sure you have a teleport

Good friend, I do not quite understand what you're looking for.
But I'll try to help you by what I understood in the title of the topic.

Go into data/ npc / scripts and create an itemtravel.lua file and dump it in:

Spoiler
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local pos = {x=152,y=58,z=7} -------------- position where the player will be taken
local itemid = 2468 ----------------- Id of the item to be removed from the player

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("Can I take you to this place for a "..getItemNameById(itemid).." item, speak {travel} if you want to travel", cid)
       talkState[cid] = 0
   elseif msgcontains(msg, 'travel') then
      if doPlayerRemoveItem(cid, itemid, 1) then
       selfSay("Good trip.", cid)
    doTeleportThing(cid, pos)
    else
    selfSay("You do not have the required item.", cid)
    end
    end
    return TRUE   
    end


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

 

Then go back and create a NOMEDONPC.xml file and put it in:

Spoiler
<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="Hi. For more information on my services, speak {offer}." />
               <parameter key="message_farewell" value="Bye." />
               <parameter key="message_walkaway" value="Bye." />
       </parameters>
</npc>

 

 

DO NOT FORGET TO CONFIGURE PLAYER DESTINY AND ITEMID ON SCRIPT ....


This script is set to remove the item from the player when it is teleported, but if you want the player to keep the item, let me know.
I hope this helps. ^^

04 de novembro de 2018 às 19:22
23 horas atrás, Sepulturaa disse:

Good friend, I do not quite understand what you're looking for.
But I'll try to help you by what I understood in the title of the topic.

Go into data/ npc / scripts and create an itemtravel.lua file and dump it in:

  Mostrar conteúdo oculto

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local pos = {x=152,y=58,z=7} -------------- position where the player will be taken
local itemid = 2468 ----------------- Id of the item to be removed from the player

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("Can I take you to this place for a "..getItemNameById(itemid).." item, speak {travel} if you want to travel", cid)
       talkState[cid] = 0
   elseif msgcontains(msg, 'travel') then
      if doPlayerRemoveItem(cid, itemid, 1) then
       selfSay("Good trip.", cid)
    doTeleportThing(cid, pos)
    else
    selfSay("You do not have the required item.", cid)
    end
    end
    return TRUE   
    end


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

 

Then go back and create a NOMEDONPC.xml file and put it in:

  Mostrar conteúdo oculto

<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="Hi. For more information on my services, speak {offer}." />
               <parameter key="message_farewell" value="Bye." />
               <parameter key="message_walkaway" value="Bye." />
       </parameters>
</npc>

 

 

DO NOT FORGET TO CONFIGURE PLAYER DESTINY AND ITEMID ON SCRIPT ....


This script is set to remove the item from the player when it is teleported, but if you want the player to keep the item, let me know.
I hope this helps. ^^

[04/11/2018 22:18:42] [Error - LuaScriptInterface::loadFile] data/npc/scripts/shiny.lua:5: unexpected symbol near 'ď'
[04/11/2018 22:18:42] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/shiny.lua
[04/11/2018 22:18:42] data/npc/scripts/shiny.lua:5: unexpected symbol near 'ď'

Ayron5A
04 de novembro de 2018 às 21:11
Melhor resposta
1 hora atrás, Step Records disse:

[04/11/2018 22:18:42] [Error - LuaScriptInterface::loadFile] data/npc/scripts/shiny.lua:5: unexpected symbol near 'ď'
[04/11/2018 22:18:42] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/shiny.lua
[04/11/2018 22:18:42] data/npc/scripts/shiny.lua:5: unexpected symbol near 'ď'

Use this one, I've tested it now and it's 100%

 

travel.lua

05 de novembro de 2018 às 12:15

It's Okay Thanks for help my friedns :)

Ayron5A
05 de novembro de 2018 às 13:31
1 hora atrás, Step Records disse:

It's Okay Thanks for help my friedns :)

you are welcome
mark as best answer
Good luck in your project ^^

2 semanas depois...
MarshmelloM
18 de novembro de 2018 às 16:35
A questão neste tópico de suporte foi respondida e/ou o autor do tópico resolveu o problema. Este tópico está fechado e foi movido para Suporte - Resolvidos. Se você tiver outras dúvidas, crie um novo tópico.