• 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 Request! Npc boat function please bring me..

Dart

New Member
Joined
Jul 21, 2008
Messages
10
Reaction score
0
I use this script in npc boat
PHP:
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({'goroma'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Goroma for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=883, y=1835, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})

      local travelNode = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Carlin for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=729, y=639, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
	local travelNode = keywordHandler:addKeyword({'ab dendriel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Ab dendriel for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=1078, y=487, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
	local travelNode = keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Thais for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=654, y=1029, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
	local travelNode = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Darashia for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=1632, y=1299, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
	local travelNode = keywordHandler:addKeyword({'edron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Edron for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=1518, y=582, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
	local travelNode = keywordHandler:addKeyword({'port hope'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Port Hope for free'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 160, destination = {x=874, y=1603, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
	local travelNode = keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Ankrahmun for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=1434, y=1702, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})

	local travelNode = keywordHandler:addKeyword({'svargrond'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Svarground for free ?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=455, y=107, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})

	local travelNode = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to Venore for free?'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, cost = 0, destination = {x=1299, y=841, z=6} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
        keywordHandler:addKeyword({'hi'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to Carlin, Ab dendriel, Thais, Svargrond, Ankrahmun, Darashia, Venore, Port Hope, Goroma and Edron.'})
        keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the captain of this ship.'})
        keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can only take you to Carlin, Ab dendriel, Thais, Ankrahmun, Darashia, Svargrond, Port Hope, Goroma and Edron.'})
        -- Makes sure the npc reacts when you say hi, bye etc.
        npcHandler:addModule(FocusModule:new())



and i dont know how to make this function... anyone can help me ?
 
Yes, true I need a help...But now I have a second preoblem, I get the script
PHP:
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 = 883, y = 1835, 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=729, y=639, 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=1078, y=487, 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=654, y=1029, 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=1632, y=1299, 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=1518, y=582, 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=874, y=1603, 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=1434, y=1702, 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=455, y=107, 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=1299, y=841, 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 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 = 883, y = 1835, 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=729, y=639, 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=1078, y=487, 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=654, y=1029, 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=1632, y=1299, 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=1518, y=582, 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=874, y=1603, 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=1434, y=1702, 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=455, y=107, 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=1299, y=841, 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


the function bring me to work, but function "hi" ---> "thais" ---> "yes" dont work plx help me !
 
Back
Top