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

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,838
Solutions
18
Reaction score
617
Location
Poland
Hello.
I need one simply npc for travel but its not common traveling npc.

I want do something like this:
- You cannot travel to places what you not discover yet, so example: if you wanna travel to Thais you must visit travel npc in thais - he will give you storage after saying "hi" first time to him.
After that visit you can travel to Thais (you "unlocked" Thais)

Anyone can make templates of these (2) NPC`s for me?

Thanks in advance,
Fresh.
 
I haven't scripted in a very long time so I'm not that up to scratch. I'm not sure if this scripts going to work but it could provide a framework for improvement. I only did the main one where you talk to teleport. (Not the one to get storage's, (easily done)).

Also, sorry if the tabbing isn't great either :p
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 onPlayerEndTrade(cid)				npcHandler:onPlayerEndTrade(cid)			end
function onPlayerCloseChannel(cid)			npcHandler:onPlayerCloseChannel(cid)		end
	function creatureSayCallback(cid, type, msg)
 
			if (not npcHandler:isFocused(cid)) then
				return false
			end	 
local t = {
	[1] = {town = "Thais", storage = 1000, pos = {x = 1000, y = 1000, z = 7}},
	[2] = {town = "Carlin", storage = 1000, pos = {x = 1000, y = 1000, z = 7}},
	[3] = {town = "Venore", storage = 1000, pos = {x = 1000, y = 1000, z = 7}},
	[4] = {town = "Edron", storage = 1000, pos = {x = 1000, y = 1000, z = 7}}
}
	
	
if msgcontains(msg, 'information') then
	npcHandler:say('I can fast travel you to any place you have visited before! Such as:', cid) 
	for i = 1, #t do
	npcHandler:say('Name: " .. t[i].town .. ".', cid) 
	end
	
	if msgcontains(msg, ' " .. t[1].town .. "') then
	npcHandler:say('Are you sure you want to travel to " .. t[1].town .. "?', cid) 
	talkState[talkUser] = 2
	end
	if msgcontains(msg, 'yes') and 	talkState[talkUser] == 2 then
	if getCreatureCondition(cid, CONDITION_INFIGHT) == true then
		     return npcHandler:say('Talk to me when you are less violent.', cid) 
		  end
		  if not isPremium(cid) then
			 return npcHandler:say('This is a premium service!', cid) 
		  end
	if 	getPlayerStorageValue(uid, t[1].storage) == false then
		return npcHandler:say('You must visit the areas first!', cid) 
		end
	else		  
	doTeleportThing(cid, t[1].pos)
	end


if msgcontains(msg, ' " .. t[2].town .. "') then
	npcHandler:say('Are you sure you want to travel to " .. t[2].town .. "?', cid) 
	talkState[talkUser] = 3
	end
	if msgcontains(msg, 'yes') and 	talkState[talkUser] == 3 then
	if getCreatureCondition(cid, CONDITION_INFIGHT) == true then
		     return npcHandler:say('Talk to me when you are less violent.', cid) 
		  end
		  if not isPremium(cid) then
			 return npcHandler:say('This is a premium service!', cid) 
		  end
	if 	getPlayerStorageValue(uid, t[2].storage) == false then
		return npcHandler:say('You must visit the areas first!', cid) 
		end
	else		  
	doTeleportThing(cid, t[2].pos)
	end


if msgcontains(msg, ' " .. t[3].town .. "') then
	npcHandler:say('Are you sure you want to travel to " .. t[3].town .. "?', cid) 
	talkState[talkUser] = 4
	end
	if msgcontains(msg, 'yes') and 	talkState[talkUser] == 4 then
	if getCreatureCondition(cid, CONDITION_INFIGHT) == true then
		     return npcHandler:say('Talk to me when you are less violent.', cid) 
		  end
		  if not isPremium(cid) then
			 return npcHandler:say('This is a premium service!', cid) 
		  end
	if 	getPlayerStorageValue(uid, t[3].storage) == false then
		return npcHandler:say('You must visit the areas first!', cid) 
		end
	else		  
	doTeleportThing(cid, t[3].pos)
	end


if msgcontains(msg, ' " .. t[4].town .. "') then
	npcHandler:say('Are you sure you want to travel to " .. t[4].town .. "?', cid) 
	talkState[talkUser] = 5
	end
	if msgcontains(msg, 'yes') and 	talkState[talkUser] == 5 then
	if getCreatureCondition(cid, CONDITION_INFIGHT) == true then
		     return npcHandler:say('Talk to me when you are less violent.', cid) 
		  end
		  if not isPremium(cid) then
			 return npcHandler:say('This is a premium service!', cid) 
		  end
	if 	getPlayerStorageValue(uid, t[4].storage) == false then
		return npcHandler:say('You must visit the areas first!', cid) 
		end
	else		  
	doTeleportThing(cid, t[4].pos)
	return true
	end
	end
npcHandler:addModule(FocusModule:new())
 
Optus, nice script but that wont work...

This works perfectly but you just need the npc to give the storage.
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

local choose = {}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	local t = {
		[1] = {town = "Thais", storage = 1000, pos = {x = 1000, y = 1000, z = 7}},
		[2] = {town = "Carlin", storage = 1001, pos = {x = 1000, y = 1000, z = 7}},
		[3] = {town = "Venore", storage = 1002, pos = {x = 1000, y = 1000, z = 7}},
		[4] = {town = "Edron", storage = 1003, pos = {x = 1000, y = 1000, z = 7}}
	}
 
	if(msgcontains(msg, 'information')) then
		npcHandler:say('I can fast travel you to any place you have visited before! Such as:', cid) 
		local text = "# - Town"
		for i = 1, table.maxn(t) do
			text = text .. "\n{" .. i .. "}  -  " .. t[i].town .. (getPlayerStorageValue(cid, t[i].storage) > 0 and " [Visited]" or "")
		end
		npcHandler:say(text, cid) 
		talkState[talkUser] = 1
	elseif(t[tonumber(msg)] and talkState[talkUser] == 1) then
		msg = tonumber(msg)
		npcHandler:say("Are you sure you want to travel to " .. t[msg].town .. "?", cid) 
		talkState[talkUser] = 2
		choose[cid] = msg
		
	elseif(msgcontains(msg, 'yes') and 	talkState[talkUser] == 2) then
		if(getCreatureCondition(cid, CONDITION_INFIGHT) == false) then
			if(isPremium(cid)) then
				if(getPlayerStorageValue(cid, t[choose[cid]].storage) > 0) then
					npcHandler:say("Have a good trip!", cid) 
					doTeleportThing(cid, t[choose[cid]].pos)	
				else
					npcHandler:say('You must visit the areas first!', cid) 
				end
			else
				return npcHandler:say('This is a premium service!', cid) 
			end
		else
			npcHandler:say('Talk to me when you are less violent.', cid) 
		end
	end
		
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Oh i see, i will learn from your script :)

Optus, nice script but that wont work...

This works perfectly but you just need the npc to give the storage.
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

local choose = {}

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    local t = {
        [1] = {town = "Thais", storage = 1000, pos = {x = 1000, y = 1000, z = 7}},
        [2] = {town = "Carlin", storage = 1001, pos = {x = 1000, y = 1000, z = 7}},
        [3] = {town = "Venore", storage = 1002, pos = {x = 1000, y = 1000, z = 7}},
        [4] = {town = "Edron", storage = 1003, pos = {x = 1000, y = 1000, z = 7}}
    }
 
    if(msgcontains(msg, 'information')) then
        npcHandler:say('I can fast travel you to any place you have visited before! Such as:', cid) 
        local text = "# - Town"
        for i = 1, table.maxn(t) do
            text = text .. "\n{" .. i .. "}  -  " .. t[i].town .. (getPlayerStorageValue(cid, t[i].storage) > 0 and " [Visited]" or "")
        end
        npcHandler:say(text, cid) 
        talkState[talkUser] = 1
    elseif(t[tonumber(msg)] and talkState[talkUser] == 1) then
        msg = tonumber(msg)
        npcHandler:say("Are you sure you want to travel to " .. t[msg].town .. "?", cid) 
        talkState[talkUser] = 2
        choose[cid] = msg
        
    elseif(msgcontains(msg, 'yes') and     talkState[talkUser] == 2) then
        if(getCreatureCondition(cid, CONDITION_INFIGHT) == false) then
            if(isPremium(cid)) then
                if(getPlayerStorageValue(cid, t[choose[cid]].storage) > 0) then
                    npcHandler:say("Have a good trip!", cid) 
                    doTeleportThing(cid, t[choose[cid]].pos)    
                else
                    npcHandler:say('You must visit the areas first!', cid) 
                end
            else
                return npcHandler:say('This is a premium service!', cid) 
            end
        else
            npcHandler:say('Talk to me when you are less violent.', cid) 
        end
    end
        
    return true
end

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