• 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:
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())
wow amazing script ,keep going :cool:
 
@Mera Mero Here is a vocation one... this could be made a little better but it works ;)
Code:
local config = {
   ["city name"] = {vocationid = 2, vocationname = "Druid", location = {x = 1073, y = 1024, z = 4}},
   ["city name"] = {vocationid = 1, vocationname = "Sorcerer", 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 getPlayerVocation(cid) == t.vocationid then
                        npcHandler:say("Well i see since you are a ".. t.vocationname .." i will sail you around the world.", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am so sorry i only take ".. t.vocationname"'s to this location.", cid)
                end
             end
         end    
     elseif tm then
         if getPlayerVocation(cid) == tm.vocationid then
             npcHandler:say("Hmm.. Are you a brave ".. tm.vocationname .."?", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you are not a ".. tm.vocationname .." in fact I'm not sure you are.", 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 getPlayerVocation(cid) == tm.vocationid then
             npcHandler:say("Well i see since you are a ".. tm.vocationname .." i will sail you around the world.", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you are not a ".. tm.vocationname .." in fact I'm not sure you are.", 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 Here is a vocation one... this could be made a little better but it works ;)
Code:
local config = {
   ["city name"] = {vocationid = 2, vocationname = "Druid", location = {x = 1073, y = 1024, z = 4}},
   ["city name"] = {vocationid = 1, vocationname = "Sorcerer", 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 getPlayerVocation(cid) == t.vocationid then
                        npcHandler:say("Well i see since you are a ".. t.vocationname .." i will sail you around the world.", cid)
                        doTeleportThing(cid, t.location)
                    else
                     npcHandler:say("I am so sorry i only take ".. t.vocationname"'s to this location.", cid)
                end
             end
         end   
     elseif tm then
         if getPlayerVocation(cid) == tm.vocationid then
             npcHandler:say("Hmm.. Are you a brave ".. tm.vocationname .."?", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you are not a ".. tm.vocationname .." in fact I'm not sure you are.", 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 getPlayerVocation(cid) == tm.vocationid then
             npcHandler:say("Well i see since you are a ".. tm.vocationname .." i will sail you around the world.", cid)
             doTeleportThing(cid, tm.location)
         else
             npcHandler:say("I am sorry you are not a ".. tm.vocationname .." in fact I'm not sure you are.", 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())
nice work ,but this npc travel without cash? i wanted to add voc with the same one that you posted before voc X travel to X place with id X amount X
and thank you very very much for your helping :oops:
 
so like this @Mera Mero ? :eek:
Code:
local config = {
   ["city 1"] = {vocationid = 2, vocationname = "Druid", amount = 5, itemid = 2157, location = {x = 1073, y = 1024, z = 4}},
   ["city 2"] = {vocationid = 2, vocationname = "Druid", 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) and getPlayerVocation(cid) == t.vocationid then
                        npcHandler:say("You are a ".. t.vocationname .." and 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 are either not a ".. t.vocationname .." or you don't 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 and getPlayerVocation(cid) == tm.vocationid 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) .."! PS! You better be A ".. tm.vocationname .."", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you are either not a ".. tm.vocationname .." or you don't 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) and getPlayerVocation(cid) == tm.vocationid then
             npcHandler:say("You are A ".. tm.vocationname .." and 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 are either not a ".. tm.vocationname .." or you don't 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())
 
so like this @Mera Mero ? :eek:
Code:
local config = {
   ["city 1"] = {vocationid = 2, vocationname = "Druid", amount = 5, itemid = 2157, location = {x = 1073, y = 1024, z = 4}},
   ["city 2"] = {vocationid = 2, vocationname = "Druid", 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) and getPlayerVocation(cid) == t.vocationid then
                        npcHandler:say("You are a ".. t.vocationname .." and 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 are either not a ".. t.vocationname .." or you don't 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 and getPlayerVocation(cid) == tm.vocationid 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) .."! PS! You better be A ".. tm.vocationname .."", cid)
             talkState[talkUser] = 1
             xmsg[cid] = msg
         else
             npcHandler:say("I am sorry you are either not a ".. tm.vocationname .." or you don't 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) and getPlayerVocation(cid) == tm.vocationid then
             npcHandler:say("You are A ".. tm.vocationname .." and 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 are either not a ".. tm.vocationname .." or you don't 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())
oh thx honey ^.^
 
Back
Top