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

Solved NPC - Travel - Bring me to... cant get it to teleport.

RosOT

Who am i?
Joined
Feb 12, 2013
Messages
714
Reaction score
137
Location
Canada
@Limos Your the best i awaken you~

Cant get the script to teleport the player it stoped working after i added the table / config not sure what im doing wrong but yeah just a test script atm would like to have it working.

Code:
local table = {
  ["spot 1"] = { cost = 250, location = {x = 1112, y = 999, z = 5}},
  ["spot 2"] = { cost = 50000, location = {x = 1112, y = 999, z = 5}}
}


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)                          npcHandler:eek:nCreatureAppear(cid)                        end
function onCreatureDisappear(cid)                       npcHandler:eek:nCreatureDisappear(cid)                     end
function onCreatureSay(cid, type, msg)                  npcHandler:eek:nCreatureSay(cid, type, msg)                end
function onThink()                                      npcHandler:eek:nThink()                                    end
function creatureSayCallback(cid, type, msg)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
      local t = table[msg]  
    if(msgcontains(msg, 'bring me to '.. msg ..'')) then
        if getPlayerMoney(cid) >= t.cost then
            npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
            doTeleportThing(cid, t.location)         
        elseif getPlayerMoney(cid) <= t.cost then
            npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. t.cost .." gold coins to travel.", cid)
        end
     
    elseif(msgcontains(msg, ''.. msg ..'')) then
        if getPlayerMoney(cid) >= t.cost then
            npcHandler:say("Do you want to goto ".. msg .." for ".. t.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
            talkState[talkUser] = 1         
        elseif getPlayerMoney(cid) <= t.cost then
            npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. t.cost .." gold coins to travel.", cid)
        end     
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if doPlayerRemoveMoney(cid, t.cost) == true then
            npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
            doTeleportThing(cid, t.location)
            talkState[talkUser] = 0
        else
            npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. t.cost .." gold coins to travel.", cid)
            talkState[talkUser] = 0
        end
    elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
        npcHandler:say("Ok.", cid)
        talkState[talkUser] = 0
    end
    return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
The problem is that table[msg] changes doesn't apply very well in the script:

The first statement:
Code:
if(msgcontains(msg, 'bring me to '.. msg ..'')) then
table[msg] = table['bring me to spot 1'], but in your table it only lists 'spot 1' -- > error msg
The second statement:
Code:
elseif(msgcontains(msg, ''.. msg ..'')) then
table[msg] = table['spot 1'], works fine --> npc responds

However now when you say "yes":
table[msg] = table['yes'], --> error, not in table

That's the best I could explain with my limited knowledge, I hope it is correct and could be of some help.
 
The problem is that table[msg] changes doesn't apply very well in the script:

The first statement:
Code:
if(msgcontains(msg, 'bring me to '.. msg ..'')) then
table[msg] = table['bring me to spot 1'], but in your table it only lists 'spot 1' -- > error msg
The second statement:
Code:
elseif(msgcontains(msg, ''.. msg ..'')) then
table[msg] = table['spot 1'], works fine --> npc responds

However now when you say "yes":
table[msg] = table['yes'], --> error, not in table

That's the best I could explain with my limited knowledge, I hope it is correct and could be of some help.

Everything works fine except when it trys to call the location of the x y z ... it loads the price and the other table things when calling the table name.

Current Messages.
Code:
02:30 Riptide [10]: hi
02:30 Captain Jack: Welcome on board, Sir Riptide. I can take you to dellbridge.
02:30 Riptide [10]: dellbridge
02:30 Captain Jack: I am sorry you have 0 gold coins and it t.cost's 250 gold coins to travel.
02:30 Riptide [10]: yes
 
One reason might be that you should not name a table table.
If that does not help specify where your script fails to "call the lcoation of x y z" and if there are any errors or which exact part is not working.
 
Code:
local config = {
   ["spot 1"] = {cost = 250, location = {x = 1112, y = 999, z = 5}},
   ["spot 2"] = {cost = 50000, location = {x = 1112, y = 999, z = 5}}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState, xmsg = {}, {}

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)

     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

     local tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                 if doPlayerRemoveMoney(cid, t.cost) then
                     npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
                     doTeleportThing(cid, t.location)
                 else
                     npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it costs ".. t.cost .." gold coins to travel.", cid)
                 end
             end
         end
     elseif tm then
         if getPlayerMoney(cid) >= tm.cost then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. tm.cost .." gold coins to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
         if doPlayerRemoveMoney(cid, tm.cost) == true then
             npcHandler:say("You paid ".. tm.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. cost[cid] .." gold coins to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Code:
local config = {
   ["spot 1"] = {cost = 250, location = {x = 1112, y = 999, z = 5}},
   ["spot 2"] = {cost = 50000, location = {x = 1112, y = 999, z = 5}}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState, xmsg = {}, {}

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 tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                 if getPlayerMoney(cid) >= t.cost then
                     npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
                     doTeleportThing(cid, t.location)
                 else
                     npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it costs ".. t.cost .." gold coins to travel.", cid)
                 end
             end
         end
     elseif tm then
         if getPlayerMoney(cid) >= tm.cost then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. tm.cost .." gold coins to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
         if doPlayerRemoveMoney(cid, tm.cost) == true then
             npcHandler:say("You paid ".. tm.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. cost[cid] .." gold coins to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
mm but i need to change this id of money i mean i need to use another cash id like 2157 something like this
 
Change doPlayerRemoveMoney to doPlayerRemoveItem and getPlayerMoney to getPlayerItemCount and compare it with the amount instead of cost.
 
That was rude of me to not post the update script.
  • Updated
  • It will now not let anyone with skull or anyone who has attacked a skulled played.
  • It will now work with saying "Bring me to Town name" without saying hi
  • I would also like to thank [B]@Limos[/B] For helping with this.
EXAMPLE - INGAME CHAT
  • 06:26 Captain Satan: Welcome on board, Sir Justin. I can take you to city 1, city 2, city 3.
  • 06:26 Justin [8]: city 1
  • 06:26 Captain Satan: Do you want to go to city 1 for 500 gold coins? ... you do have 417000 gold coins!
  • 06:26 Justin [8]: yes
  • 06:26 Captain Satan: You paid 500 gold coins to travel and you have 416500 gold coins left in your backpack
  • 06:26 Justin [8]: bye
  • 06:26 Captain Satan: Good bye, Justin!
  • 06:26 Justin [8]: bring me to city 1
  • 06:26 Captain Satan: You paid 500 gold coins to travel and you have 416000 gold coins left in your backpack
  • 06:26 Justin [8]: bring me to city 1
  • 06:26 Captain Satan: Hah, Seems like you got blood on your hands you shall not sail with me.
  • 06:26 Justin [8]: hi
  • 06:26 Captain Satan: Welcome on board, Sir Justin. I can take you to city 1, city 2, city 3.
  • 06:27 Justin [8]: city 1
  • 06:27 Captain Satan: Do you want to go to city 1 for 500 gold coins? ... you do have 416000 gold coins!
  • 06:27 Justin [8]: yes
  • 06:27 Captain Satan: Hah, Seems like you got blood on your hands you shall not sail with me.


Code:
-- Town name, Price, x.pos, y.pox, z.pos --
local config = {
   ["Put a city name"] = {cost = 100, location = {x = 0000, y = 0000, z = 0}},
   ["Put a city name"] = {cost = 100, location = {x = 0000, y = 0000, z = 0}}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState, xmsg = {}, {}
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
                    if doPlayerRemoveMoney(cid, t.cost) then
                        npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it costs ".. t.cost .." gold coins to travel.", cid)
                end
             end
         end    
     elseif tm then
         if getPlayerMoney(cid) >= tm.cost then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. tm.cost .." gold coins to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
         if doPlayerRemoveMoney(cid, tm.cost) == true then
             npcHandler:say("You paid ".. tm.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. cost[cid] .." gold coins to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
That was rude of me to not post the update script.
  • Updated
  • It will now not let anyone with skull or anyone who has attacked a skulled played.
  • It will now work with saying "Bring me to Town name" without saying hi
  • I would also like to thank [B]@Limos[/B] For helping with this.
EXAMPLE - INGAME CHAT
  • 06:26 Captain Satan: Welcome on board, Sir Justin. I can take you to city 1, city 2, city 3.
  • 06:26 Justin [8]: city 1
  • 06:26 Captain Satan: Do you want to go to city 1 for 500 gold coins? ... you do have 417000 gold coins!
  • 06:26 Justin [8]: yes
  • 06:26 Captain Satan: You paid 500 gold coins to travel and you have 416500 gold coins left in your backpack
  • 06:26 Justin [8]: bye
  • 06:26 Captain Satan: Good bye, Justin!
  • 06:26 Justin [8]: bring me to city 1
  • 06:26 Captain Satan: You paid 500 gold coins to travel and you have 416000 gold coins left in your backpack
  • 06:26 Justin [8]: bring me to city 1
  • 06:26 Captain Satan: Hah, Seems like you got blood on your hands you shall not sail with me.
  • 06:26 Justin [8]: hi
  • 06:26 Captain Satan: Welcome on board, Sir Justin. I can take you to city 1, city 2, city 3.
  • 06:27 Justin [8]: city 1
  • 06:27 Captain Satan: Do you want to go to city 1 for 500 gold coins? ... you do have 416000 gold coins!
  • 06:27 Justin [8]: yes
  • 06:27 Captain Satan: Hah, Seems like you got blood on your hands you shall not sail with me.


Code:
-- Town name, Price, x.pos, y.pox, z.pos --
local config = {
   ["Put a city name"] = {cost = 100, location = {x = 0000, y = 0000, z = 0}},
   ["Put a city name"] = {cost = 100, location = {x = 0000, y = 0000, z = 0}}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState, xmsg = {}, {}
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
                    if doPlayerRemoveMoney(cid, t.cost) then
                        npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it costs ".. t.cost .." gold coins to travel.", cid)
                end
             end
         end   
     elseif tm then
         if getPlayerMoney(cid) >= tm.cost then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. tm.cost .." gold coins to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
         if doPlayerRemoveMoney(cid, tm.cost) == true then
             npcHandler:say("You paid ".. tm.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. cost[cid] .." gold coins to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
doesn't work o_O
Code:
-- Town name, Price, x.pos, y.pox, z.pos --
local config = {
   ["Dreams City"] = {cost = 100, location = {x = 1000, y = 1000, z = 7}},
   ["Put a city name"] = {cost = 100, location = {x = 0000, y = 0000, z = 0}}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState, xmsg = {}, {}
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
     local tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
                    if doPlayerRemoveMoney(cid, t.cost) then
                        npcHandler:say("You paid ".. t.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it costs ".. t.cost .." gold coins to travel.", cid)
                end
             end
         end       
     elseif tm then
         if getPlayerMoney(cid) >= tm.cost then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.cost .." gold coins? ... you do have ".. getPlayerMoney(cid) .." gold coins!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. tm.cost .." gold coins to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
         if doPlayerRemoveMoney(cid, tm.cost) == true then
             npcHandler:say("You paid ".. tm.cost .." gold coins to travel and you have ".. getPlayerMoney(cid) .." gold coins left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerMoney(cid) .." gold coins and it t.cost's ".. cost[cid] .." gold coins to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@Mera Mero
Dreams City change it to dreams city [lowercase letters]
stand by npc and say "bring me to dreams city"
or
hi > dreams city > yes

{if it errors please post the error}
 
here is one that takes item, amount.
Code:
-- Town name, Price, x.pos, y.pox, z.pos --
local config = {
   ["city 1"] = {amount = 5, itemid = 2157, location = {x = 1073, y = 1024, z = 4}},
   ["city 2"] = {amount = 5, itemid = 2157, location = {x = 0000, y = 0000, z = 0}}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState, xmsg = {}, {}
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
                    if doPlayerRemoveItem(cid, t.itemid, t.amount) then
                        npcHandler:say("You paid ".. t.amount .." ".. getItemNameById(t.itemid) .." to travel and you have ".. getPlayerItemCount(cid, t.itemid) .." ".. getItemNameById(t.itemid) .." left in your backpack", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am sorry you have ".. getPlayerItemCount(cid, t.itemid) .." ".. getItemNameById(t.itemid) .." and it costs ".. t.amount .." ".. getItemNameById(t.itemid) .." to travel.", cid)
                end
             end
         end    
     elseif tm then
         if getPlayerItemCount(cid, tm.itemid) >= tm.amount then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.amount .." ".. getItemNameById(tm.itemid) .."? ... you do have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .."!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." and it costs ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
         if doPlayerRemoveItem(cid, tm.itemid, tm.amount) then
             npcHandler:say("You paid ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel and you have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." and it costs ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
here is one that takes item, amount.
Code:
-- Town name, Price, x.pos, y.pox, z.pos --
local config = {
   ["city 1"] = {amount = 5, itemid = 2157, location = {x = 1073, y = 1024, z = 4}},
   ["city 2"] = {amount = 5, itemid = 2157, location = {x = 0000, y = 0000, z = 0}}
}

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState, xmsg = {}, {}
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)
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
     local tm = config[msg:lower()]
     if msgcontains(msg, "bring me to") then
         for mes, t in pairs(config) do
             if msgcontains(msg, mes) then
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
                    if doPlayerRemoveItem(cid, t.itemid, t.amount) then
                        npcHandler:say("You paid ".. t.amount .." ".. getItemNameById(t.itemid) .." to travel and you have ".. getPlayerItemCount(cid, t.itemid) .." ".. getItemNameById(t.itemid) .." left in your backpack", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am sorry you have ".. getPlayerItemCount(cid, t.itemid) .." ".. getItemNameById(t.itemid) .." and it costs ".. t.amount .." ".. getItemNameById(t.itemid) .." to travel.", cid)
                end
             end
         end   
     elseif tm then
         if getPlayerItemCount(cid, tm.itemid) >= tm.amount then
             npcHandler:say("Do you want to go to ".. msg .." for ".. tm.amount .." ".. getItemNameById(tm.itemid) .."? ... you do have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .."!", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." and it costs ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel.", cid)
         end
     elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
         local tm = config[xmsg[cid]:lower()]
                if isPlayerPzLocked(cid) == true then
                    doPlayerSendTextMessage(cid,MESSAGE_STATUS_SMALL,"Those hands look pretty bloody")
                    npcHandler:say("Hah, Seems like you got blood on your hands you shall not sail with me.", cid)
                    return false
                end
         if doPlayerRemoveItem(cid, tm.itemid, tm.amount) then
             npcHandler:say("You paid ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel and you have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." left in your backpack", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you have ".. getPlayerItemCount(cid, tm.itemid) .." ".. getItemNameById(tm.itemid) .." and it costs ".. tm.amount .." ".. getItemNameById(tm.itemid) .." to travel.", cid)
         end
         talkState[talkUser] = 0
     elseif msgcontains(msg, "no") and talkState[talkUser] > 0 then
         npcHandler:say("Ok.", cid)
         talkState[talkUser] = 0
     end
     return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
thanks but i already made it before :p
 
Back
Top