• 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!

I need help with the Boat script.

Status
Not open for further replies.

Richey

Twifysoft
Joined
Mar 19, 2008
Messages
987
Reaction score
2
Location
Sweden, Stockholm
Hello, the problem is when someone says "hi" it responds and everything, but if you try to travel somewhere he doesnt respond agian.

However, the "bring me to" code works perfect, buy only if you walk up to the npc and say "bring me to venore" if you greet him before you say something he will not help you at all :(

I would really appreciate if someone could solve this problem for me :)

The script is for TFS (2.0 i think) 8.22 client.

Here is the code, it's a little big:
Code:
local focus = 0 
local talk_start = 0 
local target = 0 
local following = false 
local attacking = false 

function onThingMove(creature, thing, oldpos, oldstackpos) 

end 


function onCreatureAppear(creature) 

end 


function onCreatureDisappear(cid, pos) 
      if focus == cid then 
          selfSay('Good bye then.') 
          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 
        if isPremium(cid) then 
            selfSay('Hello, ' .. getCreatureName(cid) .. '. Welcome to my ship!.') 
            focus = cid 
            talk_start = os.clock() 
        else 
            selfSay('Sorry, only premium players can travel on my boat.') 
            focus = 0 
            talk_start = 0 
        end 

      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
          selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.') 

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

      elseif msgcontains(msg, 'bring me to goroma') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x = 31994, y = 32565, z = 6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to carlin') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32387, y=31821, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to ab dendriel') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32734, y=31668, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to liberty bay') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32285, y=32891, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to thais') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32310, y=32210, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to darashia') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=33289, y=32480, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 
      elseif focus == cid then 
        talk_start = os.clock() 

      elseif msgcontains(msg, 'bring me to edron') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=33173, y=31764, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to port hope') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32527, y=32784, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to ankrahmun') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=33092, y=32883, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to svargrond') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32431, y=31162, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

      elseif msgcontains(msg, 'bring me to venore') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32952, y=32022, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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

            if msgcontains(msg, 'travel') or msgcontains(msg, 'passage') then 
                    selfSay('I can take you to Carlin, Ab dendriel, Thais, Svargrond, Ankrahmun, Darashia, Venore, Port Hope, Goroma, Liberty Bay and Edron.') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            if msgcontains(msg, 'goroma') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x = 31994, y = 32565, z = 6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'carlin') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32387, y=31821, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'liberty bay') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32285, y=32891, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'ab dendriel') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32734, y=31668, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'thais') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32310, y=32210, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'darashia') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=33289, y=32480, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'edron') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=33173, y=31764, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end     

            elseif msgcontains(msg, 'port hope') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32527, y=32784, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'ankrahmun') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=33092, y=32883, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

            elseif msgcontains(msg, 'svargrond') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32431, y=31162, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end     

            elseif msgcontains(msg, 'venore') then 
            if doPlayerRemoveMoney(cid, 0) == TRUE then 
                    doTeleportThing(cid, {x=32952, y=32022, z=6}, FALSE) 
                    selfSay('Let\'s go!') 
                    focus = 0 
                    talk_start = 0 
                else 
                    selfSay('Sorry, you don\'t have enough money.') 
                end 

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


function onCreatureChangeOutfit(creature) 

end 


function onThink() 
    if focus > 0 then  
end 

      if (os.clock() - talk_start) > 30 then 
          if focus > 0 then 
              selfSay('Good bye...') 
          end 
              focus = 0 
      end 
    if focus ~= 0 then 
         if getDistanceToCreature(focus) > 5 then 
             selfSay('Good bye then.') 
             focus = 0 
         end 
     end 
end
 
Last edited:
Status
Not open for further replies.
Back
Top