• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua NPC Problem No Teleportiing (Safari Zone)

Friizee

Member
Joined
Jul 26, 2008
Messages
193
Reaction score
5
Hi all,

I have a NPC Safari Zone (Tibia TFS) doesn't that teleports me to the area Safari zone

This is NPC
Code:
local zone = {x=2195, y=1797, z=4} --- Posicion que el npc debe llevar al jugador ( la posicion de la entrada a saffari zone ).
local storage = 20000 ---Storage value que entrrgara al player ( debe ser el mismo k las talkactions  y movements ).
local steps = 600 ---El número de pasos que el jugador tiene que estar en la zona safari. ( segun tu mapa que le pongas a saffari zone )
local cost = 20  ---Precio por cada paso.
---------------------------------------fin de Configuracion--------------------------------------
local pay = cost * steps ---No Editar
local focus = 0 -- No Editar
local talk_start = 0 -- No Editar
local target = 0 -- No Editar
local following = false -- No Editar
local attacking = false -- No Editar

function getPlayerMoney(cid)
gold = getPlayerItemCount(cid,2148)
plat = getPlayerItemCount(cid,2152)*100
crys = getPlayerItemCount(cid,2160)*10000
money = gold + plat + crys
return money
end

function onThingMove(creature, thing, oldpos, oldstackpos)
end

function onCreatureAppear(creature)
end

function onCreatureDisappear(cid, pos)
     if focus == cid then
          selfSay('Adioz, Vuelve pronto.')
          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('Hola ' .. getCreatureName(cid) .. '! Yo te puedo llevar a la zona safari.')
        focus = cid
        talk_start = os.clock()

     elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
        selfSay('Disculpe, ' .. getCreatureName(cid) .. '! Puedo hablar con usted en un minuto.')

   elseif focus == cid then
      talk_start = os.clock()

      if msgcontains(msg, 'safari') then
         selfSay('¿Deseas comprar ' .. steps ..' pasos en la saffari zone por ' .. pay ..' GPS?')
         talk_state = 1

      
      elseif talk_state == 1 then
         if msgcontains(msg, 'yes') then
            if getPlayerMoney(cid) >= pay then
               setPlayerStorageValue(cid,storage,0)
               doTeleportThing(cid, zone)
               doSendMagicEffect(zone,10)
               doPlayerRemoveMoney(cid,pay) 

            else
               selfSay('No tienes dinero para comprar esa cantidad de pasos.')
            end
          end
         talk_state = 0

         
      elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
         selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
         focus = 0
         talk_start = 0
      end
   end
end


function onCreatureChangeOutfit(creature)
end

function onThink()
   doNpcSetCreatureFocus(focus)
   if (os.clock() - talk_start) > 30 then
        if focus > 0 then
           selfSay('Siguiente porfabor...')
        end
           focus = 0
     end
    if focus ~= 0 then
       if getDistanceToCreature(focus) > 5 then
          selfSay('Adioz, vuelve pronto.')
          focus = 0
       end
    end
end

Please help me


I think the teleport function is that this bad, it's evolution
which is the tfs?

Regards!:w00t:

REP++

- - - Updated - - -

BUMP
 
Last edited:
Code:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
        
        
        
        -- OTServ event handling functions start
        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
        -- OTServ event handling functions end
        
        
        -- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
 

	local travelNode = keywordHandler:addKeyword({'safari'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to safari for 20 gold coins?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 20, destination = {x=2195, y=1797, z=4} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
        


        keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the captain of this ship.'})
		keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the captain of this ship.'})
       

        npcHandler:addModule(FocusModule:new())
;P
 
- - - Updated - - -

Code:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
        
        
        
        -- OTServ event handling functions start
        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
        -- OTServ event handling functions end
        
        
        -- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
 

	local travelNode = keywordHandler:addKeyword({'safari'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to safari for 20 gold coins?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 20, destination = {x=2195, y=1797, z=4} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
        


        keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the captain of this ship.'})
		keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the captain of this ship.'})
       

        npcHandler:addModule(FocusModule:new())
;P

the idea is:
npc selling steps for xx coin and teleport, this npc only teleport no selling steps :c

please help me

srry for my bad english

- - - Updated - - -

BUMP!
 
Last edited:
try this
LUA:
local zone = {x=2195, y=1797, z=4} --- Posicion que el npc debe llevar al jugador ( la posicion de la entrada a saffari zone ).
local storage = 20000 ---Storage value que entrrgara al player ( debe ser el mismo k las talkactions  y movements ).
local steps = 600 ---El número de pasos que el jugador tiene que estar en la zona safari. ( segun tu mapa que le pongas a saffari zone )
local cost = 20  ---Precio por cada paso.
---------------------------------------fin de Configuracion--------------------------------------
local pay = cost * steps ---No Editar
local focus = 0 -- No Editar
local talk_start = 0 -- No Editar
local target = 0 -- No Editar
local following = false -- No Editar
local attacking = false -- No Editar

function getPlayerMoney(cid)
gold = getPlayerItemCount(cid,2148)
plat = getPlayerItemCount(cid,2152)*100
crys = getPlayerItemCount(cid,2160)*10000
money = gold + plat + crys
return money
end

function onThingMove(creature, thing, oldpos, oldstackpos)
end

function onCreatureAppear(creature)
end

function onCreatureDisappear(cid, pos)
     if focus == cid then
          selfSay('Adioz, Vuelve pronto.')
          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('Hola ' .. getCreatureName(cid) .. '! Yo te puedo llevar a la zona safari.')
        focus = cid
        talk_start = os.clock()

     elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
        selfSay('Disculpe, ' .. getCreatureName(cid) .. '! Puedo hablar con usted en un minuto.')

   elseif focus == cid then
      talk_start = os.clock()

      if msgcontains(msg, 'safari') then
         selfSay('¿Deseas comprar ' .. steps ..' pasos en la saffari zone por ' .. pay ..' GPS?')
         talk_state = 1

      
      elseif talk_state == 1 then
         if msgcontains(msg, 'yes') then
            if getPlayerMoney(cid) >= pay then
               setPlayerStorageValue(cid,storage,0)
               doTeleportThing(cid,zone)
               doSendMagicEffect(zone,10)
               doPlayerRemoveMoney(cid,pay) 

            else
               selfSay('No tienes dinero para comprar esa cantidad de pasos.')
            end
          end
         talk_state = 0

         
      elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
         selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
         focus = 0
         talk_start = 0
      end
   end
end


function onCreatureChangeOutfit(creature)
end

function onThink()
   doNpcSetCreatureFocus(focus)
   if (os.clock() - talk_start) > 30 then
        if focus > 0 then
           selfSay('Siguiente porfabor...')
        end
           focus = 0
     end
    if focus ~= 0 then
       if getDistanceToCreature(focus) > 5 then
          selfSay('Adioz, vuelve pronto.')
          focus = 0
       end
    end
end
 
Back
Top