• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC Boat NPC - Table - Features

Gabriel Tibiano

New Member
Joined
Nov 21, 2009
Messages
420
Reaction score
4
Well, i'm here to post a script that i'm use in my OTServer, and it's really works perfectly with his functions.
PS: You can easily configure this NPC reading the GUEST CARD that located inside the .lua script

Features:
  1. Costs = How many will costs the travel (gold coins)
  2. Level = level needed to travel with this NPC
  3. Storage = True or False,
    • -[True] if the player needs a certain storage in DATABASE.
    • -[False] if you wanna disable this function.
  4. StorageID = In case you put 'True', paste this your StorageID, required to travel.
  5. Destination = X, Y, Z Position of place where will be teleported.



Data/NPC/Barrack Stanchion.xml​
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Barrack Stanchion" script="data/npc/scripts/boatnpc.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="155" head="60" body="115" legs="12" feet="0" addons="2"/>
	<parameters>
		<parameter key="message_greet" value="Hello Sir |PLAYERNAME|, welcome on board." />
		<parameter key="message_farewell" value="Good bye. Come back when you want to sail." />
		<parameter key="message_idletimeout" value="Hello? Are you there? Good Bye then." />
		<parameter key="message_walkaway" value="Good bye. Recommend us if you were satisfied with our service." />
		<parameter key="message_alreadyfocused" value="Hey? I\'m here." />
	</parameters>
</npc>


Data/NPC/scripts/boatnpc.lua​
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	--//////////////////////GUEST CARD//////////////////////--
	-- [City Name]
	-- TALK = switching 1, 2, 3, 4 accoring to the number of cities
	-- COST = How many will costs the travel (gold coins)
	-- LEVEL = level needed to travel with this NPC
	-- STOR = True or False,
	---------[True] if the player needs a certain storage in DATABASE.
	---------[False] if you wanna disable this function.
	-- STORID = In case you put 'True', paste this your StorageID, required to travel.
	-- DESTINATION = X, Y, Z Position of place where will be teleported.
	--//////////////////////GUEST CARD//////////////////////--
 
	local travels = {
    ["Thais"] = {talk=1, cost=350, level=0,  stor=false,  storId=1010, destination={x=100, y=100, z=7}},
    ["Venore"] = {talk=2, cost=250, level=10, stor=false,  storId=1010, destination={x=100, y=100, z=7}},
	["Ankrahmun"] = {talk=3, cost=170, level=25, stor=false,  storId=1010, destination={x=100, y=100, z=7}},
	["Port Hope"] = {talk=4, cost=165, level=50, stor=false,  storId=1010, destination={x=100, y=100, z=7}}
    }
 
    for k, v in pairs(travels) do
        if(msgcontains(msg, k)) then
            if v.stor then
                if getPlayerStorageValue(cid, v.storId) > 0 then
                    selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                    talkState[talkUser] = v.talk
                    else
                        selfSay('You must got Norseman Mission\'s to travel with me. Hics! Hi ckS ! Hic.', cid)
                        talkState[talkUser] = 0
                    end
                    else
                        selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
                        talkState[talkUser] = v.talk
                    end            
                elseif(msgcontains(msg, 'yes') and talkState[talkUser] == v.talk) then
                                if getPlayerLevel(cid) >= v.level then
                                        if(doPlayerRemoveMoney(cid, v.cost) == TRUE) then
                                                doTeleportThing(cid, v.destination, FALSE)
                                                selfSay('Traveled to '..k..'.', cid)
                                        else
                                        selfSay('Sorry, you don\'t have enough gold coins.', cid)
                                        end
                                else
                                selfSay('Sorry, you don\'t have enough level.', cid)
                                end    
                talkState[talkUser] = 0
                elseif(msgcontains(msg, 'no') and isInArray({v.talk}, talkState[talkUser]) == TRUE) then
                        talkState[talkUser] = 0
                        selfSay('Ok then.', cid)
                end
        end    
 
        return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
divisor.png
 
keep it up! make some more npc, and can you maybe try to do grizzly adams??? thanks and goodbye!
 
Back
Top