• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Boat NPCs doesn't work!

Laur1

Banned User
Joined
Jun 14, 2009
Messages
399
Reaction score
110
Location
Finland/Jyväskylä
Hello! All the other NPCs and even travelling between for example Cormaya and Eremo's island works fine, but the main boat NPCs are somehow bugged.

It answers the greet message, like it should but after that, nothing. I don't use any kind of VIP system but the script checks if the player is VIP, for some reason. I tried to remove that function but the NPC stopped answering in anything after that :)

1jrknd.jpg


Here's the NPC script:
Code:
dofile(getDataDir() .. 'global/greeting.lua')

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

function greetCallback(cid)
    if getPlayerSex(cid) == 1 then
    npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Sir ".. getPlayerName(cid) ..".")
    return true
    else
    npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Madam ".. getPlayerName(cid) ..".")
    return true
    end 
end 

npcHandler:setCallback(CALLBACK_GREET, greetCallback)

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Captain Bluebear from the Royal Tibia Line."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am the captain of this sailing-ship."})
keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am the captain of this sailing-ship."})
keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
keywordHandler:addKeyword({'line'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
keywordHandler:addKeyword({'company'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
keywordHandler:addKeyword({'route'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "We can transport everything you want."})
keywordHandler:addKeyword({'passenger'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "We would like to welcome you on board."})
keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
keywordHandler:addKeyword({'town'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
keywordHandler:addKeyword({'go'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
keywordHandler:addKeyword({'ice'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
keywordHandler:addKeyword({'senja'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
keywordHandler:addKeyword({'folda'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
keywordHandler:addKeyword({'vega'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm not sailing there. This route is afflicted by a ghostship! However I've heard that Captain Fearless from Venore sails there."})
keywordHandler:addKeyword({'darama'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm not sailing there. This route is afflicted by a ghostship! However I've heard that Captain Fearless from Venore sails there."})
keywordHandler:addKeyword({'ghost'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Many people who sailed to Darashia never returned because they were attacked by a ghostship! I'll never sail there!"})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "This is Thais. Where do you want to go?"})

function creatureSayCallback(cid, type, msg)
    if(npcHandler.focus ~= cid) then
        return false
    end
     
    local carlin = {x=32387,y=31821,z=6, stackpos=0}
    local abdendriel = {x=32733,y=31668,z=6, stackpos=0}
    local edron = {x=33175,y=31764,z=6, stackpos=0}
    local venore = {x=32954,y=32023,z=6, stackpos=0}
    local porthope = {x=32530,y=32784,z=6, stackpos=0}
 
-- Carlin
if msgcontains(msg, 'carlin') then
    if isPlayerVip(cid) == TRUE then
        npcHandler:say('Do you seek a passage to Carlin for free?')
        talk_state = 1
        town_boat = carlin
    else
        npcHandler:say('Do you seek a passage to Carlin for 110 gold?')
        talk_state = 1
        price = 110
        town_boat = carlin
    end
 
-- Ab'Dendriel
elseif msgcontains(msg, 'ab\'dendriel') then
    if isPlayerVip(cid) == TRUE then
        npcHandler:say('Do you seek a passage to Ab\'Dendriel for free?')
        talk_state = 1
        town_boat = abdendriel
    else
        npcHandler:say('Do you seek a passage to Ab\'Dendriel for 130 gold?')
        talk_state = 1
        price = 130
        town_boat = abdendriel
    end
 
-- Edron
elseif msgcontains(msg, 'edron') then
    if isPlayerVip(cid) == TRUE then
        npcHandler:say('Do you seek a passage to Edron for free?')
        talk_state = 1
        town_boat = edron
    else
        npcHandler:say('Do you seek a passage to Edron for 160 gold?')
        talk_state = 1
        price = 160
        town_boat = edron
    end
 
-- Venore
elseif msgcontains(msg, 'venore') then
    if isPlayerVip(cid) == TRUE then
        npcHandler:say('Do you seek a passage to Venore for free?')
        talk_state = 1
        town_boat = venore
    else
        npcHandler:say('Do you seek a passage to Venore for 170 gold?')
        talk_state = 1
        price = 170
        town_boat = venore
    end
 
-- Port Hope
elseif msgcontains(msg, 'port hope') then
    if isPlayerVip(cid) == TRUE then
        npcHandler:say('Do you seek a passage to Port Hope for free?')
        talk_state = 1
        town_boat = porthope
    else
        npcHandler:say('Do you seek a passage to Port Hope for 160 gold?')
        talk_state = 1
        price = 160
        town_boat = porthope
    end
 
-- Confirm Yes or No
elseif msgcontains(msg, 'yes') and talk_state == 1 then
    if isPremium(cid) == TRUE then
        if getTilePzInfo(getPlayerPosition(cid)) == 1 then
            if getPlayerMoney(cid) >= price or isPlayerVip(cid) == TRUE then
                if isPlayerVip(cid) == TRUE then
                    selfSay('Set the sails!')
                    doTeleportThing(cid, town_boat)
                    doSendMagicEffect(getCreaturePosition(cid), 10)
                    talk_state = 0
                else
                    selfSay('Set the sails!')
                    doPlayerRemoveMoney(cid, price)
                    doTeleportThing(cid, town_boat)
                    doSendMagicEffect(getCreaturePosition(cid), 10)
                    talk_state = 0
                end
            else
                npcHandler:say('You don\'t have enough money.')
                talk_state = 0
            end
        else
            npcHandler:say('First get rid of those blood stains! You are not going to ruin my vehicle!')
            talk_state = 0
        end
    else
        npcHandler:say('I\'m sorry, but you need a premium account in order to travel onboard our ships.')
        talk_state = 0
    end
elseif msgcontains(msg, 'no') and talk_state == 1 then
    npcHandler:say('We would like to serve you some time.')
    talk_state = 0 
end
 
    return TRUE
end

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

I have tried to replace Captain Bluebear scripts with Pemaret and Eremo's ones and searched for this forum to an answer so solve this case. I would really appreciate any assistance.

An image from npchandler.lua:

2uf7s4j.jpg
 
Last edited:
Remove
Code:
if isPlayerVip(cid) == TRUE then
     npcHandler:say('Do you seek a passage to Carlin for free?')
     talk_state = 1
     town_boat = carlin
else

end
So you only have this under the msgcontains line.
Code:
npcHandler:say('Do you seek a passage to Carlin for 110 gold?')
talk_state = 1
price = 110
town_boat = carlin
Same goes for the other cities.
 
Since you're not using the VIP system you can remove those:
Code:
 if isPlayerVip(cid) == TRUE then
lines
Also remember to remove else's / end's too

If we take a look at this
Code:
  if isPlayerVip(cid) == TRUE then
                    selfSay('Set the sails!')
                    doTeleportThing(cid, town_boat)
                    doSendMagicEffect(getCreaturePosition(cid), 10)
                    talk_state = 0
                else
                    selfSay('Set the sails!')
                    doPlayerRemoveMoney(cid, price)
                    doTeleportThing(cid, town_boat)
                    doSendMagicEffect(getCreaturePosition(cid), 10)
                    talk_state = 0
                end
You can see that it starts with "if" therefore it must end with "end"
Since you don't need the
Code:
 if isPlayerVip(cid) == TRUE then
You can remove everything from that IF to the next END

-- Venore
Code:
-- Port Hope
elseif msgcontains(msg, 'port hope') then
npcHandler:say('Do you seek a passage to Port Hope for free?')
talk_state = 1
town_boat = porthope
else  <-- without if nothing "else" will happen
npcHandler:say('Do you seek a passage to Venore for 170 gold?')
talk_state = 1
price = 170
town_boat = venore
end

Example:
-- Port Hope
elseif msgcontains(msg, 'port hope') then
npcHandler:say('Do you seek a passage to Port Hope for free?')
talk_state = 1
town_boat = porthope

elseif something else
asddasdas


This post is very useful http://otland.net/threads/scripting-guide.74030/#post758243
 
Back
Top