• 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 Travel in table

breadmaker

New Member
Joined
Jul 16, 2010
Messages
160
Reaction score
3
Hello.
I need one travel npc.
I want the travel options in table like this:
Thais -- Price: -- Premium:

Thanks in advance.
Breadmaker.
 
For the smart guys that know everything and don't help: Please don't waste your posts here.
 

I've created a file more composite than your idea to my server and will surely help you.
I wrote an guest card to help you, inside of the script. Anyway, questions? post here.

You can see better HERE, in this thread


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
       
	--//////////////////////GUEST CARD//////////////////////--
	-- [City Name]
	-- TALK = switching 1, 2, 3, 4 accoring to the number of cities
	-- COST = How many will costs the travel (gold coins)
	-- LEVEL = level needed to travel with this NPC
	-- STOR = True or False,
	---------[True] if the player needs a certain storage in DATABASE.
	---------[False] if you wanna disable this function.
	-- STORID = In case you put 'True', paste this your StorageID, required to travel.
	-- DESTINATION = X, Y, Z Position of place where will be teleported.
	--//////////////////////GUEST CARD//////////////////////--
	   
	local travels = {
    ["Thais"] = 	{talk=1, cost=350, level=0,  stor=false,  storId=1010, destination={x=100, y=100, z=7}},
    ["Venore"] = 	{talk=2, cost=250, level=10, stor=false,  storId=1010, destination={x=100, y=100, z=7}},
	["Ankrahmun"] = {talk=3, cost=170, level=25, stor=false,  storId=1010, destination={x=100, y=100, z=7}},
	["Port Hope"] = {talk=4, cost=165, level=50, stor=false,  storId=1010, destination={x=100, y=100, z=7}}
    }
       
    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 must got Norseman Mission\'s to travel with me. Hics! Hi ckS ! Hic.', 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())
divisor.png
 
Last edited:
Back
Top