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

NPC Best travel NPC

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Have you noted that some times you want to travel to thais, but you got travelled to carlin? Well this happens because the NPC system doesn't check who says what... So it sux a little... I decided to make my own travel NPC system... How it works? You say hi, then the city and you got teleported inmediatly and the NPC stops talking you.

Important: You can't travel if you attacked a player, but if you were attacked by a player, monsters or maybe run into a field, you will be able to travel.

Here is the script:

Lua:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
 
 
 
 
        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	  
 
			if msgcontains(msg, 'thais') and not isPlayerPzLocked(cid) then
				if doPlayerRemoveMoney(cid, 100) == true then
					doTeleportThing(cid,{x=32311, y=32210, z=6})
					self:releaseFocus(cid)					
				else
					npcHandler:say('You don\'t have enought money to travel!', cid) 
					self:releaseFocus(cid)
				end
			end	
 
			if msgcontains(msg, 'carlin') and not isPlayerPzLocked(cid) then
				if doPlayerRemoveMoney(cid, 100) == true then
					doTeleportThing(cid,{x=32387, y=31821, z=6})
					self:releaseFocus(cid)					
				else
					npcHandler:say('You don\'t have enought money to travel!', cid) 
					self:releaseFocus(cid)
				end
			end			
 
			if isPlayerPzLocked(cid) then
					npcHandler:say('You can\'t travel, you have pz!', cid) 
			end
 
		return true
	end		
 
		npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
		keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to all places: {thais}, {carlin}.'})
 
		npcHandler:addModule(FocusModule:new())

Note:
The cost is 100 gps, you can change it where it says doPlayerRemoveMoney(cid, 100).
To change the position of where you are teleported, change {x=32387, y=31821, z=6}.
To change the name of the city that you are going to travel, change msgcontains(msg, 'carlin')

You can copy and create more cities to travel, example:
Lua:
if msgcontains(msg, 'NEW_CITY') and not isPlayerPzLocked(cid) then
				if doPlayerRemoveMoney(cid, 550) == true then
					doTeleportThing(cid,{x=X, y=Y, z=Z})
					self:releaseFocus(cid)					
				else
					npcHandler:say('You don\'t have enought money to travel!', cid) 
					self:releaseFocus(cid)
				end
			end

Quite simple, quite cool.
 
Last edited:
Ah, forgot that... I use the system without using money xD

Edited: Now post actualized... Now removes money and a simple explication on how to create more travel points and how to configure them.
 
Last edited:
1. Learn to use tables.
2. Learn to use elseifs.
3. Learn to tab your code.

One of worst I've seen.

Thanks for tips, if you could teach how, maybe creating the script again, would be nice.
I don't have much time so I don't know much about LUA and I don't have the opportunity to learn more, I just did something that works great... Just see this: I don't have your knowledge but I can make things work, just check my ot mtibia.cl :)

Maybe you have the knowledge to program, but I have the intelligence to make things work better...

You will see, here in this world exist three types of guys: the ones that doesn't do any stuff, the guys that know how to program all stuff, and the guys who thinks on how stuff should work... And the last ones take a call for the second one to make the stuff... You will note that the thirth are called boss, and the second are called employees... So here Im the boss and you are the employee maybe?
 
Last edited:
Thanks for tips, if you could teach how, maybe creating the script again, would be nice.
I don't have much time so I don't know much about LUA and I don't have the opportunity to learn more, I just did something that works great... Just see this: I don't have your knowledge but I can make things work, just check my ot mtibia.cl :)

Maybe you have the knowledge to program, but I have the intelligence to make things work better...

You will see, here in this world exist three types of guys: the ones that doesn't do any stuff, the guys that know how to program all stuff, and the guys who thinks on how stuff should work... And the last ones take a call for the second one to make the stuff... You will note that the thirth are called boss, and the second are called employees... So here Im the boss and you are the employee maybe?

No, since he's not working for you(?
 
Note: Since I added this script on my server, no one had claimed about boat NPCs, it is a real good solution... Or maybe a good solution having the confirmation part, would be having talkstate.
 
here my error!

[4/12/2011 19:42:10] [Error - NpcScript Interface]
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:eek:nCreatureSay
[4/12/2011 19:42:10] Description:
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:19: attempt to index global 'self' (a nil value)
[4/12/2011 19:42:10] stack traceback:
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:19: in function 'callback'
[4/12/2011 19:42:10] data/npc/lib/npcsystem/npchandler.lua:382: in function 'onCreatureSay'
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:7: in function <data/npc/scripts/viajar.lua:7>
 
here my error!

[4/12/2011 19:42:10] [Error - NpcScript Interface]
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:eek:nCreatureSay
[4/12/2011 19:42:10] Description:
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:19: attempt to index global 'self' (a nil value)
[4/12/2011 19:42:10] stack traceback:
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:19: in function 'callback'
[4/12/2011 19:42:10] data/npc/lib/npcsystem/npchandler.lua:382: in function 'onCreatureSay'
[4/12/2011 19:42:10] data/npc/scripts/viajar.lua:7: in function <data/npc/scripts/viajar.lua:7>


same!!! i have this errors in shell but script work good in game!!

any idea??
thanks
 
Lua:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
 
 
 
 
        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      
 
            if msgcontains(msg, 'thais') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32310, y=32209, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
 
            if msgcontains(msg, 'carlin') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32387, y=31820, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end
            
            if msgcontains(msg, 'ab\'dendriel') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32734, y=31668, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'edron') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=33173, y=31764, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'venore') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32954, y=32022, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'port hope') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32527, y=32784, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'svargrond') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32341, y=31108, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'liberty bay') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32285, y=32892, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'yalahar') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32816, y=31272, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end                        

            if msgcontains(msg, 'cormaya') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=33287, y=31955, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    

            if msgcontains(msg, 'kazordoon') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32658, y=31958, z=15})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    

            if msgcontains(msg, 'ankrahmun') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=33092, y=32883, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'darashia') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=33289, y=32481, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'farmine') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=413, y=760, z=10})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
			
			if msgcontains(msg, 'fibula') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32189, y=32474, z=7})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
            
            if msgcontains(msg, 'goroma') and not isPlayerPzLocked(cid) then
                if doPlayerRemoveMoney(cid, 0) == true then
                    doTeleportThing(cid,{x=32161, y=32558, z=6})
                    npcHandler:releaseFocus(cid)                    
                else
                    npcHandler:say('You don\'t have enought money to travel!', cid) 
                    npcHandler:releaseFocus(cid)
                end
            end    
			
            if isPlayerPzLocked(cid) then
                    npcHandler:say('You can\'t travel, you have pz!', cid) 
            end
 
        return true
    end        
 
        npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
        keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to all places: {thais}, {carlin}.'})
 
        npcHandler:addModule(FocusModule:new())

this work perfectly
 
Haha best travel npc? nice joke!

27th September 2011:
1. Learn to use tables.
2. Learn to use elseifs.
3. Learn to tab your code.

One of worst I've seen.

Today is 28 May


hmmm and still u can't use tables and elseifs?

trololo
 
u mad? xD

Yeah, since he is posting my scripts... What a faggot.

Haha best travel npc? nice joke!

27th September 2011:


Today is 28 May


hmmm and still u can't use tables and elseifs?

trololo

If you can't see why this is the best travel NPC, then it seems that you have fixed the NPC known bug for travel (just using talkstate), if you don't, then you have never played a well war OT or you dont have a good one.
As name says: best travel NPC system, not optimized travel NPC system, start getting a better reading comprehension, lol.
 
oh the best because you remove talkstates? woooow....... i feel respect to you now woooofff
 
Back
Top