• 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 with storage config

Pitufo™

InfinityOT.com
Joined
Feb 14, 2008
Messages
1,438
Reaction score
10
Location
Mexico, Cuernavaca
I made this because of requests, so enjoy it. :D

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

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 travels = {
	["gengia"] = {talk=1, cost=0, level=0, stor=true, storId=34343, destination={x=34472, y=32697, z=6}},
	["pyre"] = {talk=2, cost=0, level=0, stor=false, storId=43433, destination={x=33623, y=4003, z=6}}
	}
	
	for k, v in pairs(travels) do
		if(msgcontains(msg, k)) then
			if v.stor then
				if getPlayerStorageValue(cid, v.storId) > 0 then
					selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
					talkState[talkUser] = v.talk
				else
				selfSay('You are not able to travel to this place?', cid)
				talkState[talkUser] = 0	
				end
			else
			selfSay('Do you want to travel to '..k..' for '..v.cost..' gold coins?', cid)
			talkState[talkUser] = v.talk
			end		
		elseif(msgcontains(msg, 'yes') and talkState[talkUser] == v.talk) then
				if getPlayerLevel(cid) >= v.level then
					if(doPlayerRemoveMoney(cid, v.cost) == TRUE) then
						doTeleportThing(cid, v.destination, FALSE)
						selfSay('Traveled to '..k..'.', cid)
					else
					selfSay('Sorry, you don\'t have enough gold coins.', cid)
					end
				else
				selfSay('Sorry, you don\'t have enough level.', cid)
				end	
		talkState[talkUser] = 0
		elseif(msgcontains(msg, 'no') and isInArray({v.talk}, talkState[talkUser]) == TRUE) then
			talkState[talkUser] = 0
			selfSay('Ok then.', cid)
		end
	end	

	return true
end

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

If you whant to enter a new travel just add a new line in the table of "travel":

Lua:
	local travels = {
	["gengia"] = {talk=1, cost=0, level=0, stor=true, storId=34343, destination={x=34472, y=32697, z=6}},
	["pyre"] = {talk=2, cost=0, level=0, stor=false, storId=43433, destination={x=33623, y=4003, z=6}}
	}

You can config(cost, level, stor, storId and destination).
[] Brackets = The message you wll tell to the npc.
Talk = For each travel you add you most add +1
Level = Level to be able to travel
Stor = true/false
StorId = You only need to config this if "Stor" is equal true.
Destination = The destination to be traveled.

Rep++ Ofc!
 
Rep ++

GREAT WORK, VERY NICE!

---Edit//
maybe can you edit, and add an talkaction, and use this to an VERY NICE VIP SYSTEM:
{when player "click to use on item" player get X storage value per X days, and when end this X days, player goto new position: free city, and get new town {1} free city~
or other talkaction

/addstorage NAME, DAYS
/removestorage NOME, Days
{When end storage player directioned to free temple, and get this to new town}

Maybe u understand me? :D
 
Last edited:
Back
Top