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

Boat npc

Status
Not open for further replies.

gr33nd3v1l

You see a Green Devil.
Joined
Feb 12, 2008
Messages
140
Reaction score
0
Location
Croatia
Here i am again with my npc errors and mistakes...

I don't know whats the problem now because i have added a million ends where the server requested and it still wants me to 'end' the function :confused:

This is the console:
Code:
[18/02/2008  10:31:48] The Forgotten Server - Version 0.2rc9 (Mystic Spirit).
[18/02/2008  10:31:48] A server developed by Talaturen, Kiper, Kornholijo, Jonern, Lithium & slawkens.
[18/02/2008  10:31:48] Visit our forum for updates, support and resources: http://otland.net/.

[18/02/2008  10:31:48] >> Loading config
[18/02/2008  10:31:48] >> Loading RSA key
[18/02/2008  10:31:48] >> Testing SQL connection... MySQL.
[18/02/2008  10:31:48] >> Loading bans
[18/02/2008  10:31:48] >> Loading vocations
[18/02/2008  10:31:48] >> Loading commands
[18/02/2008  10:31:48] >> Loading items
[18/02/2008  10:31:48] >> Loading script systems
[18/02/2008  10:31:49] >> Loading monsters
[18/02/2008  10:31:49] >> Loading quests
[18/02/2008  10:31:49] >> Loading outfits
[18/02/2008  10:31:49] >> Loading admin protocol config
[18/02/2008  10:31:49] >> Loading experience stages
[18/02/2008  10:31:49] >> Checking world type... PVP
[18/02/2008  10:31:49] >> Loading map
[18/02/2008  10:31:50] > Map size: 1061x1049.
[18/02/2008  10:31:55] > Map loading time: 5.265 seconds.
[18/02/2008  10:31:55] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/boat.lua
[18/02/2008  10:31:55] data/npc/scripts/boat.lua:33: 'end' expected (to close 'function' at line 18) near 'elseif'
[18/02/2008  10:31:55] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/boat.lua
[18/02/2008  10:31:55] data/npc/scripts/boat.lua:33: 'end' expected (to close 'function' at line 18) near 'elseif'
[18/02/2008  10:31:55] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/boat.lua
[18/02/2008  10:31:55] data/npc/scripts/boat.lua:33: 'end' expected (to close 'function' at line 18) near 'elseif'
[18/02/2008  10:31:55] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/boat.lua
[18/02/2008  10:31:55] data/npc/scripts/boat.lua:33: 'end' expected (to close 'function' at line 18) near 'elseif'
[18/02/2008  10:32:04] >> Loading raids
[18/02/2008  10:32:04] >> All modules has been loaded, server starting up...
[18/02/2008  10:32:06] >> Genesis Server Online!

This is my npc script;
Code:
Anselth_pos = {x= 507, y= 857, z= 6}
Revansith_pos = {x= 820, y= 686, z= 6}
Karnak_pos = {x= 593, y= 700, z= 6}
Snowmoore_pos = {x= 951, y= 616, z= 6}
Island_pos = {x= 593, y= 700, z= 6}
Darthmoore_pos = {x= 918, y= 950, z= 6}
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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end
		addon_need_premium = 'Sorry, you need a premium account to get addons.'
		addon_have_already = 'Sorry, you already have this addon.'
		addon_have_not_items = 'Sorry, you don\'t have these items.'
		addon_give = 'Here you are.'
		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'anselth') then
			if isPremium(cid) then
				if player_money >= 1500 then 
				selfSay('Do you want to go to Anselth for 1500 gold pieces?')
					talk_state = 1
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if player_money >= 1500 then
				if doPlayerRemoveMoney(cid,1500) == 1 then
				doTeleportThing(cid, Anselth_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'revansith') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Castle Revansith for 1400 gold pieces?')
					talk_state = 2
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Revansith_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'karnak') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Karnak for 1400 gold pieces?')
					talk_state = 3
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 3 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Karnak_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'snowmoore') then
			if isPremium(cid) then
				if player_money >= 1000 then 
				selfSay('Do you want to go to Snowmoore for 1000 gold pieces?')
					talk_state = 4
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 4 then
			talk_state = 0
			if player_money >= 1000 then
				if doPlayerRemoveMoney(cid,1000) == 1 then
				doTeleportThing(cid, Snowmoore_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'island') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Island for 1400 gold pieces?')
					talk_state = 5
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 5 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Island_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'darthmoore') then
			if isPremium(cid) then
				if player_money >= 0 then 
				selfSay('Are you serious? You want me to take you to Darthmoore?')
					talk_state = 6
				else
					selfSay('You are completely broke my man.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 6 then
			talk_state = 0
			if player_money >= 0 then
				selfSay('This IS Darthmoore you fool!')
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ confirm negative ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 38) then
			selfSay('Ok then.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

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

Code:
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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end
		addon_need_premium = 'Sorry, you need a premium account to get addons.'
		addon_have_already = 'Sorry, you already have this addon.'
		addon_have_not_items = 'Sorry, you don\'t have these items.'
		addon_give = 'Here you are.'
		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
		
		------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'anselth') then
			if isPremium(cid) then
				if player_money >= 1500 then 
				selfSay('Do you want to go to Anselth for 1500 gold pieces?')
					talk_state = 1
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if player_money >= 1500 then
				if doPlayerRemoveMoney(cid,1500) == 1 then
				doTeleportThing(cid, Anselth_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'revansith') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Castle Revansith for 1400 gold pieces?')
					talk_state = 2
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Revansith_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'karnak') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Karnak for 1400 gold pieces?')
					talk_state = 3
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 3 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Karnak_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'snowmoore') then
			if isPremium(cid) then
				if player_money >= 1000 then 
				selfSay('Do you want to go to Snowmoore for 1000 gold pieces?')
					talk_state = 4
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 4 then
			talk_state = 0
			if player_money >= 1000 then
				if doPlayerRemoveMoney(cid,1000) == 1 then
				doTeleportThing(cid, Snowmoore_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'island') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Island for 1400 gold pieces?')
					talk_state = 5
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 5 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Island_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'darthmoore') then
			if isPremium(cid) then
				if player_money >= 0 then 
				selfSay('Are you serious? You want me to take you to Darthmoore?')
					talk_state = 6
				else
					selfSay('You are completely broke my man.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 6 then
			talk_state = 0
			if player_money >= 0 then
				selfSay('This IS Darthmoore you fool!')
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ confirm negative ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 38) then
			selfSay('Ok then.')
			talk_state = 0
		end
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end
end
end
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Yeah but how will he know where to teleport the player if i remove the _pos, don't they mark where will it teleport them to? I added that myself so im not sure if i done it properly

And i got this

[18/02/2008 12:01:32] Warning: [NpcScript::NpcScript] Can not load script. data/npc/scripts/boat.lua
[18/02/2008 12:01:32] data/npc/scripts/boat.lua:21: 'end' expected (to close 'function' at line 6) near 'elseif'
 
and this

Code:
Anselth_pos = {x= 507, y= 857, z= 6}
Revansith_pos = {x= 820, y= 686, z= 6}
Karnak_pos = {x= 593, y= 700, z= 6}
Snowmoore_pos = {x= 951, y= 616, z= 6}
Island_pos = {x= 593, y= 700, z= 6}
Darthmoore_pos = {x= 918, y= 950, z= 6}
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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end
		addon_need_premium = 'Sorry, you need a premium account to get addons.'
		addon_have_already = 'Sorry, you already have this addon.'
		addon_have_not_items = 'Sorry, you don\'t have these items.'
		addon_give = 'Here you are.'
		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'anselth') then
			if isPremium(cid) then
				if player_money >= 1500 then 
				selfSay('Do you want to go to Anselth for 1500 gold pieces?')
					talk_state = 1
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if player_money >= 1500 then
				if doPlayerRemoveMoney(cid,1500) == 1 then
				doTeleportThing(cid, Anselth_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'revansith') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Castle Revansith for 1400 gold pieces?')
					talk_state = 2
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Revansith_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'karnak') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Karnak for 1400 gold pieces?')
					talk_state = 3
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 3 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Karnak_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'snowmoore') then
			if isPremium(cid) then
				if player_money >= 1000 then 
				selfSay('Do you want to go to Snowmoore for 1000 gold pieces?')
					talk_state = 4
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 4 then
			talk_state = 0
			if player_money >= 1000 then
				if doPlayerRemoveMoney(cid,1000) == 1 then
				doTeleportThing(cid, Snowmoore_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'island') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Island for 1400 gold pieces?')
					talk_state = 5
				else
					selfSay('You don't seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 5 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Island_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'darthmoore') then
			if isPremium(cid) then
				if player_money >= 0 then 
				selfSay('Are you serious? You want me to take you to Darthmoore?')
					talk_state = 6
				else
					selfSay('You are completely broke my man.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 6 then
			talk_state = 0
			if player_money >= 0 then
				selfSay('This IS Darthmoore you fool!')
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ confirm negative ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 38) then
			selfSay('Ok then.')
			talk_state = 0
		end
		end
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end
end
end

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


P.s why are u maiking an boat npc on the hard way? there are 2 easy ways.. check this thread
http://otland.net/showthread.php?t=1039&highlight=examples
 
Last edited:
Why you dont use boat npc with parameters in 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>
here you change the city names, pos, price: "cityName,XXX,XXX,X,price"
Code:
         <parameter key="travel_destinations" value="derelin,1294,429,6,119;farda,865,251,6,123;taqinata,868,690,6,134" />
and 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())
Have a nice day
 
Thanks, i will try it with the parameters.

So far i found out that sometimes npc's dont respond or an error pops out in my server when i use parameters so i decided to do it the hard way but this way i am sure i know what my npc script looks like and what i can do with it.

Oh, and i managed to fix it myself in the end =)

Code:
Anselth_pos = {x= 507, y= 857, z= 6}
Revansith_pos = {x= 820, y= 686, z= 6}
Karnak_pos = {x= 593, y= 700, z= 6}
Snowmoore_pos = {x= 951, y= 616, z= 6}
Island_pos = {x= 593, y= 700, z= 6}
Darthmoore_pos = {x= 918, y= 950, z= 6}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end
		addon_need_premium = 'Sorry, you need a premium account to get addons.'
		addon_have_already = 'Sorry, you already have this addon.'
		addon_have_not_items = 'Sorry, you don\'t have these items.'
		addon_give = 'Here you are.'
		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys
------------------------------------------------ destination ------------------------------------------------
		if msgcontains(msg, 'anselth') then
			if isPremium(cid) then
				if player_money >= 1500 then 
				selfSay('Do you want to go to Anselth for 1500 gold pieces?')
					talk_state = 1
				else
					selfSay('You don\'t seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			talk_state = 0
			if player_money >= 1500 then
				if doPlayerRemoveMoney(cid,1500) == 1 then
				doTeleportThing(cid, Anselth_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'revansith') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Castle Revansith for 1400 gold pieces?')
					talk_state = 2
				else
					selfSay('You don\'t seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Revansith_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'karnak') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Karnak for 1400 gold pieces?')
					talk_state = 3
				else
					selfSay('You don\'t seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 3 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Karnak_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'snowmoore') then
			if isPremium(cid) then
				if player_money >= 1000 then 
				selfSay('Do you want to go to Snowmoore for 1000 gold pieces?')
					talk_state = 4
				else
					selfSay('You don\'t seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 4 then
			talk_state = 0
			if player_money >= 1000 then
				if doPlayerRemoveMoney(cid,1000) == 1 then
				doTeleportThing(cid, Snowmoore_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'island') then
			if isPremium(cid) then
				if player_money >= 1400 then 
				selfSay('Do you want to go to Fort Island for 1400 gold pieces?')
					talk_state = 5
				else
					selfSay('You don\'t seem to have enough money to pay for the trip.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 5 then
			talk_state = 0
			if player_money >= 1400 then
				if doPlayerRemoveMoney(cid,1400) == 1 then
				doTeleportThing(cid, Island_pos)
				end
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ destination ------------------------------------------------
		elseif msgcontains(msg, 'darthmoore') then
			if isPremium(cid) then
				if player_money >= 0 then 
				selfSay('Are you serious? You want me to take you to Darthmoore?')
					talk_state = 6
				else
					selfSay('You are completely broke my man.')
					talk_state = 0
				end
			else
				selfSay(addon_need_premium)
				talk_state = 0
			end
------------------------------------------------ confirm ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 6 then
			talk_state = 0
			if player_money >= 0 then
				selfSay('This IS Darthmoore you fool!')
			else
				selfSay(addon_have_not_items)
			end
------------------------------------------------ confirm negative ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 38) then
			selfSay('Ok then.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true		
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Works perfectly ^^
 
Status
Not open for further replies.
Back
Top