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

[NPC] Boat Script

Henkieman

New Member
Joined
May 28, 2007
Messages
36
Reaction score
0
Hello lets start:


First we make the Boatnpc:
Save this as boat man.xml in data/npc

Code:
<?xml version="1.0"?>

<npc name="Boat Man" script="data/npc/scripts/boatman.lua" access="3" monster="1" speed="50" level="100" maglevel="100" exp="0" pushable="0" lookdir="0">
<mana now="100" max="100"/>
<health now="100" max="100"/>
<look type="134" head="78" body="61" legs="52" feet="114" corpse="2276"/>
<attack type="melee" damage="10"/> 
</npc>


Than we will add the script:
Save this as boatman.lua in data/npc/scripts

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 ' .. creatureGetName(cid) .. '! I can take you to New Island (100gps), Thais (100gps), Venore (100gps), Dessert (100gps), Vilesta (100gps), Ankrahmun (100gps) or Port Hope (100gps). Where do you want to go?')
			focus = cid
			talk_start = os.clock()
		else
			selfSay('Sorry, only premium players can travel by boat.')
			focus = 0
			talk_start = 0
		end

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

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

		if msgcontains(msg, 'vilesta') then
			if pay(cid,50) then
				selfSay('Let's go!')
				travel(cid, 810, 884, 7)
				focus = 0
				talk_start = 0
			else
				selfSay('Sorry, you don't have enough money.')
			end

		elseif msgcontains(msg, 'dessert') then
			if pay(cid,50) then
				selfSay('Let's go!')
				travel(cid, 810, 884, 7)
				focus = 0
				talk_start = 0
			else
				selfSay('Sorry, you don't have enough money.')
			end

		elseif msgcontains(msg, 'new island') then
			if pay(cid,50) then
				selfSay('Let's go!')
				travel(cid, 1483, 2834, 6)
				focus = 0
				talk_start = 0
			else
				selfSay('Sorry, you don't have enough money.')
			end

		elseif msgcontains(msg, 'thais') then
			if pay(cid,50) then
				selfSay('Let's go!')
				travel(cid, 387, 1354, 6)
				focus = 0
				talk_start = 0
			else
				selfSay('Sorry, you don't have enough money.')
			end

		elseif msgcontains(msg, 'venore') then
			if pay(cid,50) then
				selfSay('Let's go!')
				travel(cid, 1137, 880, 6)
				focus = 0
				talk_start = 0
			else
				selfSay('Sorry, you don't have enough money.')
			end

		elseif msgcontains(msg, 'ankrahmun') then
			if pay(cid,50) then
				selfSay('Let's go!')
				travel(cid, 1532, 1012, 6)
				focus = 0
				talk_start = 0
			else
				selfSay('Sorry, you don't have enough money.')
			end

		elseif msgcontains(msg, 'port hope') then
			if pay(cid,50) then
				selfSay('Let's go!')
				travel(cid, 1543, 1388, 6)
				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, ' .. creatureGetName(cid) .. '!')
			focus = 0
			talk_start = 0
		end
	end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Next Please...')
  		end
  			focus = 0
  	end
	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
end


Than u need to change the city names change vilesta to your city name

Code:
if msgcontains(msg, 'vilesta') then



Than u need to change your travel coordinates change this to where he need to travel


Code:
travel(cid, 810, 884, 7)

Any questions? Bugs report? add me on msn [email protected]


Enjoy!
 
RE: Boat Script

Uhm i made it=[
Yes i no and i made the script it isen't old really
 
RE: Boat Script

Where's the 'travel' function?
 
RE: Boat Script

It's probably in Evolutions or some copy&paste distro. :(, although you can use something like,
selfSay('/send name pos')
I don't remember it exactly tough.
 
RE: Boat Script

Henkieman said:
Talaturen said:
Where's the 'travel' function?


What u mean?

You're using a 'travel' function, which is not included by default in OtServ Distros, so if you really made this script you should know that you've made a 'travel' function, or the OtServ Distro you're using has the function hardcoded.

Kornholijo said:
It's probably in Evolutions or some copy&paste distro. :(, although you can use something like,
selfSay('/send name pos')
I don't remember it exactly tough.

That will just make the NPC say '/send name pos'.
 
Use Talaturens Boat script. Is much more fun. I use it on my server. Players love to actually 'ride' the boats.
 
to bad that it's the old npc system =(

here

boat.xml
Code:
<npc name="Captain Steven" script="data/npc/scripts/travel.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/>
	<parameters>
		<parameter key="module_travel" value="1" />
		<parameter key="travel_destinations" value="derelin,1294,429,6,119;farda,865,251,6,123;taqinata,868,690,6,134" />
		
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="job;name;offer;help;mission;quest" />
		<parameter key="keyword_reply1" value="I am the captain of this ship." />
		<parameter key="keyword_reply2" value="My name is Steven. Why do you ask?" />
		<parameter key="keyword_reply3" value="I offer only the possability to travel to far away cities on this continent." />
		<parameter key="keyword_reply4" value="Do I look like a helpful guy to you?" />
		<parameter key="keyword_reply5" value="What are you talking about?" />
		<parameter key="keyword_reply6" value="Hum. I'll tell you what! If you come back in a month or so I might be able to help you with that my friend." />
	</parameters>
</npc>


travel.lua
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



-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

If you want more examples check this thread
http://otland.net/showthread.php?t=1039&highlight=boat.xml
 
what is this mean

Code:
<npc name="Captain Steven" script="data/npc/scripts/travel.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/>
	<parameters>
		<parameter key="module_travel" value="1" />
		<parameter key="travel_destinations" value="derelin,1294,429,6,[U]119[/U];farda,865,251,6,[U]123[/U];taqinata,868,690,6,[U]134[/U]" />
		
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="job;name;offer;help;mission;quest" />
		<parameter key="keyword_reply1" value="I am the captain of this ship." />
		<parameter key="keyword_reply2" value="My name is Steven. Why do you ask?" />
		<parameter key="keyword_reply3" value="I offer only the possability to travel to far away cities on this continent." />
		<parameter key="keyword_reply4" value="Do I look like a helpful guy to you?" />
		<parameter key="keyword_reply5" value="What are you talking about?" />
		<parameter key="keyword_reply6" value="Hum. I'll tell you what! If you come back in a month or so I might be able to help you with that my friend." />
	</parameters>
</npc>
 
what is this mean

Code:
<npc name="Captain Steven" script="data/npc/scripts/travel.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/>
	<parameters>
		<parameter key="module_travel" value="1" />
		<parameter key="travel_destinations" value="derelin,1294,429,6,[U]119[/U];farda,865,251,6,[U]123[/U];taqinata,868,690,6,[U]134[/U]" />
		
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="job;name;offer;help;mission;quest" />
		<parameter key="keyword_reply1" value="I am the captain of this ship." />
		<parameter key="keyword_reply2" value="My name is Steven. Why do you ask?" />
		<parameter key="keyword_reply3" value="I offer only the possability to travel to far away cities on this continent." />
		<parameter key="keyword_reply4" value="Do I look like a helpful guy to you?" />
		<parameter key="keyword_reply5" value="What are you talking about?" />
		<parameter key="keyword_reply6" value="Hum. I'll tell you what! If you come back in a month or so I might be able to help you with that my friend." />
	</parameters>
</npc>

THE UNDERLINED
 
When i go to the npc and tell him hi - name of the city and then i say "yes" he doesn't respond.
 
Back
Top