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

[request] Npc that tp's you...

brendan2

Sensation black
Joined
Feb 19, 2009
Messages
507
Reaction score
1
A npc that tp's you to a location but you have to give x items...
like 10 furs 100k and fire sword or w.e
 
Last edited:
if you use a boat npc you can edit it to take money


save in data\npc\scripts\ "teleportnpc.lua"

and make an npc or edit one and use that script
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="[COLOR="Red"]NPC NAME[/COLOR]" script="data/npc/scripts/TP/[COLOR="Red"]teleportnpc.lua[/COLOR]" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="129" head="19" body="69" legs="107" feet="50" addons="0"/>
    <parameters>
        <parameter key="message_greet" value="Welcome on board, Sir |PLAYERNAME|. Where can I sail you today?"/>
        <parameter key="message_farewell" value="Good bye. Recommend us if you were satisfied with our service."/>
    </parameters>
</npc>

Code:
local keywordHandler = KeywordHandler:new()
        local npcHandler = NpcHandler:new(keywordHandler)
        NpcSystem.parseParameters(npcHandler)
        
        
        
        -- OTServ event handling functions start
        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
        -- OTServ event handling functions end
        
        
        -- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
        
	local travelNode = keywordHandler:addKeyword({'[COLOR="Red"]name of place want him to take players[/COLOR]'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to [COLOR="Red"]name of place want him to take players[/COLOR]'})
        	travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = [COLOR="Red"]level needed[/COLOR], cost = [COLOR="Red"]ammount of gp[/COLOR], destination = {x=[COLOR="Red"]posx[/COLOR], y=[COLOR="Red"]posY[/COLOR], z=[COLOR="Red"]pos Z[/COLOR]} })
        	travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Then stay here!'})
        
        keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to Ab\'dendriel, Thais, Venore and Edron.'})
        keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am the captain of this ship.'})
        keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can only take you to Ab\'dendriel, Thais, Venore and Edron.'})
        -- Makes sure the npc reacts when you say hi, bye etc.
        npcHandler:addModule(FocusModule:new())

edit all the sections in red to set cost, destination, level, outfit for the npc and his name and what he says.
 
Use search dumbass

Code:
local focuses = {}
local playerInfos = {}

local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end

local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end

end

local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v) == TRUE) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

local function removeInfo(cid)
    for i, v in pairs(playerInfos) do
        if(v.player == cid) then
            table.remove(playerInfos, i)
            break
        end
    end
end

local function findInfo(cid)
    for i, v in pairs(playerInfos) do
        if(v.player == cid) then
            return v
        end
    end
end

function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Damn land lovers...")
        removeFocus(cid)
        if(isPlayer(cid) == TRUE) then --Be sure he's online
            closeShopWindow(cid)
        end
    end
end
local function getPlayerMoney(cid)
    return ((getPlayerItemCount(cid, 2160) * 10000) +
    (getPlayerItemCount(cid, 2152) * 100) +
    getPlayerItemCount(cid, 2148))
end



function msgcontains(txt, str)
    return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
    ----------------------CONFIG SECTION-----------------------
    --This is all you have to edit to add an new destination --
    --REMEMEBER TO USE ALL LOWER CASE LETTERS FOR TOWN NAMES!--
    --Breakdown:
    --["City Name"] = {cost=costToGo, position=locationOnTheMap}
    local cities = {["bayou"] = {cost=150, position={x=1965,y=2028,z=6}}, 
            ["andros"] = {cost=50, position={x=1048,y=1023,z=6}}}
    --Breakdown:
    --["city name"] = {itemId=ItemRequiredToGo, count=numberOfThatItemNeeded, remove=removeItemOrNot(1 yes, 0 no), position=locationOnTheMap}
    local citiesItemOnly = {["itemlandia"] = {itemId=2667, count=0, remove=0, position={x=1992,y=1979,z=6}}}
    --Breakdown:
    --["city name"] = {storage=StorageLocation, value=numberNeededInLocation, cost=costInGold(set 0 if no money is need), position=locationOnTheMap}
    local citiesQuestOnly = {["rarelandia"] = {storage=8118, value=1, cost=0, position={x=965,y=429,z=6}}}
    --Cites he tells about when asked for options/places
    --Example: { "City 1", "City 2", "City 3"}
    local places = {"The Bayou", "Andros"}
    --------------------END CONFIG SECTION--------------------
   
    local msg = string.lower(msg)
    local questVal = getPlayerStorageValue(cid, 1003)
    if((msg == "hi") and getDistanceTo(cid) < 4 and not (isFocused(cid))) then
        selfSay("Welcome to my ship, ".. getCreatureName(cid) ..".", cid, TRUE)
        addFocus(cid)
    elseif (isFocused(cid)) then
        if msgcontains(msg, 'job') then
            selfSay("I'm the owner and Captain of this boat.", cid)
        elseif msgcontains(msg, 'name') then
            selfSay("They call me Nikolas.", cid)
        elseif msgcontains(msg, 'offer') or msgcontains(msg, 'places') or msgcontains(msg, 'place') or msgcontains(msg, 'town') or msgcontains(msg, 'towns') or msgcontains(msg, 'destinations') or msgcontains(msg, 'destination') or msgcontains(msg, 'offers') or msgcontains(msg, 'travel') then
            local str = "I can take you to "
            if #places == 1 then
                str = str .. places[1]
            else
                for i=1,#places do
                    if i == #places then
                        str = str .. "or " .. places[i]
                    else
                        str = str .. places[i] .. ", "
                    end
                end
            end
            str = str .. ". Where would you like to go?"
            selfSay(str, cid)
        elseif msgcontains(msg, 'yes') then
            local sailInfo = findInfo(cid)
            if sailInfo ~= null then
                if isPzLocked(cid) then
                    selfSay("You may not board my ship with that blood on you.", cid)
                    removeInfo(cid)
                end
                if sailInfo.info.itemId ~= null then
                    if getPlayerItemCount(cid,sailInfo.info.itemId) < sailInfo.info.count then
                        local str = "You don't have the required item"
                        if sailInfo.info.count > 1 then str = str + "s" end
                        str = str + " to go!!"
                        selfSay(str, cid)
                        removeInfo(cid)
                        return
                    end
                    if sailInfo.info.remove == 1 then doPlayerRemoveItem(cid, sailInfo.info.itemId, sailInfo.info.count) end
                    selfSay("Off you go!", cid)
                    doSendMagicEffect(getCreaturePosition(cid), 10)
                    doTeleportThing(cid, sailInfo.info.position)
                    doSendMagicEffect(sailInfo.info.position, 10)
                    removeInfo(cid)
                    removeFocus(cid)
                else
                    if getPlayerMoney(cid) >= sailInfo.info.cost then
                        doPlayerRemoveMoney(cid, sailInfo.info.cost)
                        selfSay("Off you go!", cid)
                        doSendMagicEffect(getCreaturePosition(cid), 10)
                        doTeleportThing(cid, sailInfo.info.position)
                        doSendMagicEffect(sailInfo.info.position, 10)
                        removeInfo(cid)
                        removeFocus(cid)
                    else
                        selfSay("You don't have enough money!!", cid)
                        removeInfo(cid)
                    end
                end
            else
                selfSay("Yes, what?", cid)
            end
        elseif msgcontains(msg, 'no') then
            local sailInfo = findInfo(cid)
            if sailInfo ~= null then
                selfSay("Then I won't be taking you!", cid)
                removeInfo(cid)
            else
                selfSay("No, what?", cid)
            end
        elseif msgcontains(msg, 'bye') then
            selfSay("Bye, and good luck.", cid, TRUE)
            closeShopWindow(cid)
            removeFocus(cid)
            removeInfo(cid)
        else
            for k,v in pairs(cities) do
                if msgcontains(msg, k) then
                    selfSay("It costs " .. v.cost .. " gold to travel to" .. k .. ". Do you want me to take you to ".. k .. "?", cid)
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
            for k,v in pairs(citiesItemOnly) do
                if msgcontains(msg, k) then
                    selfSay("You need to have " .. v.count .. " of the following item: " .. getItemName(v.itemId) .. " for me to take you. Do you want me to take you to ".. k .. "?", cid)
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
            for k,v in pairs(citiesQuestOnly) do
                if msgcontains(msg, k) then
                    if getPlayerStorageValue(cid, v.storage) ~= v.value then
                        selfSay("I'm sorry, I cannot take you there.",cid)
                        return
                    end
                    if v.cost > 0 then
                        selfSay("It costs " .. v.cost .. " soul orbs to travel to" .. k .. ". Do you want me to take you to ".. k .. "?", cid)
                    else
                        selfSay("Do you want me to take you to ".. k .. "?", cid)
                    end
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
        end
    end
end

function onPlayerCloseChannel(cid)
    if(isFocused(cid)) then
        selfSay("Take Care.")
        closeShopWindow(cid)
        removeFocus(cid)
        removeInfo(cid)
    end
end

function onThink()
    for i, focus in pairs(focuses) do
        if(isCreature(focus) == FALSE) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Good Bye.", cid)
                closeShopWindow(focus)
                removeFocus(focus)
                removeInfo(cid)
            end
        end
    end
    lookAtFocus()
end
 
Use search dumbass

Code:
local focuses = {}
local playerInfos = {}

local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end

local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end

end

local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v) == TRUE) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

local function removeInfo(cid)
    for i, v in pairs(playerInfos) do
        if(v.player == cid) then
            table.remove(playerInfos, i)
            break
        end
    end
end

local function findInfo(cid)
    for i, v in pairs(playerInfos) do
        if(v.player == cid) then
            return v
        end
    end
end

function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Damn land lovers...")
        removeFocus(cid)
        if(isPlayer(cid) == TRUE) then --Be sure he's online
            closeShopWindow(cid)
        end
    end
end
local function getPlayerMoney(cid)
    return ((getPlayerItemCount(cid, 2160) * 10000) +
    (getPlayerItemCount(cid, 2152) * 100) +
    getPlayerItemCount(cid, 2148))
end



function msgcontains(txt, str)
    return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
    ----------------------CONFIG SECTION-----------------------
    --This is all you have to edit to add an new destination --
    --REMEMEBER TO USE ALL LOWER CASE LETTERS FOR TOWN NAMES!--
    --Breakdown:
    --["City Name"] = {cost=costToGo, position=locationOnTheMap}
    local cities = {["bayou"] = {cost=150, position={x=1965,y=2028,z=6}}, 
            ["andros"] = {cost=50, position={x=1048,y=1023,z=6}}}
    --Breakdown:
    --["city name"] = {itemId=ItemRequiredToGo, count=numberOfThatItemNeeded, remove=removeItemOrNot(1 yes, 0 no), position=locationOnTheMap}
    local citiesItemOnly = {["itemlandia"] = {itemId=2667, count=0, remove=0, position={x=1992,y=1979,z=6}}}
    --Breakdown:
    --["city name"] = {storage=StorageLocation, value=numberNeededInLocation, cost=costInGold(set 0 if no money is need), position=locationOnTheMap}
    local citiesQuestOnly = {["rarelandia"] = {storage=8118, value=1, cost=0, position={x=965,y=429,z=6}}}
    --Cites he tells about when asked for options/places
    --Example: { "City 1", "City 2", "City 3"}
    local places = {"The Bayou", "Andros"}
    --------------------END CONFIG SECTION--------------------
   
    local msg = string.lower(msg)
    local questVal = getPlayerStorageValue(cid, 1003)
    if((msg == "hi") and getDistanceTo(cid) < 4 and not (isFocused(cid))) then
        selfSay("Welcome to my ship, ".. getCreatureName(cid) ..".", cid, TRUE)
        addFocus(cid)
    elseif (isFocused(cid)) then
        if msgcontains(msg, 'job') then
            selfSay("I'm the owner and Captain of this boat.", cid)
        elseif msgcontains(msg, 'name') then
            selfSay("They call me Nikolas.", cid)
        elseif msgcontains(msg, 'offer') or msgcontains(msg, 'places') or msgcontains(msg, 'place') or msgcontains(msg, 'town') or msgcontains(msg, 'towns') or msgcontains(msg, 'destinations') or msgcontains(msg, 'destination') or msgcontains(msg, 'offers') or msgcontains(msg, 'travel') then
            local str = "I can take you to "
            if #places == 1 then
                str = str .. places[1]
            else
                for i=1,#places do
                    if i == #places then
                        str = str .. "or " .. places[i]
                    else
                        str = str .. places[i] .. ", "
                    end
                end
            end
            str = str .. ". Where would you like to go?"
            selfSay(str, cid)
        elseif msgcontains(msg, 'yes') then
            local sailInfo = findInfo(cid)
            if sailInfo ~= null then
                if isPzLocked(cid) then
                    selfSay("You may not board my ship with that blood on you.", cid)
                    removeInfo(cid)
                end
                if sailInfo.info.itemId ~= null then
                    if getPlayerItemCount(cid,sailInfo.info.itemId) < sailInfo.info.count then
                        local str = "You don't have the required item"
                        if sailInfo.info.count > 1 then str = str + "s" end
                        str = str + " to go!!"
                        selfSay(str, cid)
                        removeInfo(cid)
                        return
                    end
                    if sailInfo.info.remove == 1 then doPlayerRemoveItem(cid, sailInfo.info.itemId, sailInfo.info.count) end
                    selfSay("Off you go!", cid)
                    doSendMagicEffect(getCreaturePosition(cid), 10)
                    doTeleportThing(cid, sailInfo.info.position)
                    doSendMagicEffect(sailInfo.info.position, 10)
                    removeInfo(cid)
                    removeFocus(cid)
                else
                    if getPlayerMoney(cid) >= sailInfo.info.cost then
                        doPlayerRemoveMoney(cid, sailInfo.info.cost)
                        selfSay("Off you go!", cid)
                        doSendMagicEffect(getCreaturePosition(cid), 10)
                        doTeleportThing(cid, sailInfo.info.position)
                        doSendMagicEffect(sailInfo.info.position, 10)
                        removeInfo(cid)
                        removeFocus(cid)
                    else
                        selfSay("You don't have enough money!!", cid)
                        removeInfo(cid)
                    end
                end
            else
                selfSay("Yes, what?", cid)
            end
        elseif msgcontains(msg, 'no') then
            local sailInfo = findInfo(cid)
            if sailInfo ~= null then
                selfSay("Then I won't be taking you!", cid)
                removeInfo(cid)
            else
                selfSay("No, what?", cid)
            end
        elseif msgcontains(msg, 'bye') then
            selfSay("Bye, and good luck.", cid, TRUE)
            closeShopWindow(cid)
            removeFocus(cid)
            removeInfo(cid)
        else
            for k,v in pairs(cities) do
                if msgcontains(msg, k) then
                    selfSay("It costs " .. v.cost .. " gold to travel to" .. k .. ". Do you want me to take you to ".. k .. "?", cid)
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
            for k,v in pairs(citiesItemOnly) do
                if msgcontains(msg, k) then
                    selfSay("You need to have " .. v.count .. " of the following item: " .. getItemName(v.itemId) .. " for me to take you. Do you want me to take you to ".. k .. "?", cid)
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
            for k,v in pairs(citiesQuestOnly) do
                if msgcontains(msg, k) then
                    if getPlayerStorageValue(cid, v.storage) ~= v.value then
                        selfSay("I'm sorry, I cannot take you there.",cid)
                        return
                    end
                    if v.cost > 0 then
                        selfSay("It costs " .. v.cost .. " soul orbs to travel to" .. k .. ". Do you want me to take you to ".. k .. "?", cid)
                    else
                        selfSay("Do you want me to take you to ".. k .. "?", cid)
                    end
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
        end
    end
end

function onPlayerCloseChannel(cid)
    if(isFocused(cid)) then
        selfSay("Take Care.")
        closeShopWindow(cid)
        removeFocus(cid)
        removeInfo(cid)
    end
end

function onThink()
    for i, focus in pairs(focuses) do
        if(isCreature(focus) == FALSE) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Good Bye.", cid)
                closeShopWindow(focus)
                removeFocus(focus)
                removeInfo(cid)
            end
        end
    end
    lookAtFocus()
end
what is this i don't even
 
Im asking how do I turn
PHP:
evel = level needed, cost = ammount of gp, destination = {x=posx, y=posY, z=pos Z} })

I dont want cost to be gold but multiple things like vampire dust and demonic essences
 
Use search dumbass

Code:
local focuses = {}
local playerInfos = {}

local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end

local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end

end

local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v) == TRUE) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

local function removeInfo(cid)
    for i, v in pairs(playerInfos) do
        if(v.player == cid) then
            table.remove(playerInfos, i)
            break
        end
    end
end

local function findInfo(cid)
    for i, v in pairs(playerInfos) do
        if(v.player == cid) then
            return v
        end
    end
end

function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Damn land lovers...")
        removeFocus(cid)
        if(isPlayer(cid) == TRUE) then --Be sure he's online
            closeShopWindow(cid)
        end
    end
end
local function getPlayerMoney(cid)
    return ((getPlayerItemCount(cid, 2160) * 10000) +
    (getPlayerItemCount(cid, 2152) * 100) +
    getPlayerItemCount(cid, 2148))
end



function msgcontains(txt, str)
    return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
    ----------------------CONFIG SECTION-----------------------
    --This is all you have to edit to add an new destination --
    --REMEMEBER TO USE ALL LOWER CASE LETTERS FOR TOWN NAMES!--
    --Breakdown:
    --["City Name"] = {cost=costToGo, position=locationOnTheMap}
    local cities = {["bayou"] = {cost=150, position={x=1965,y=2028,z=6}}, 
            ["andros"] = {cost=50, position={x=1048,y=1023,z=6}}}
    --Breakdown:
    --["city name"] = {itemId=ItemRequiredToGo, count=numberOfThatItemNeeded, remove=removeItemOrNot(1 yes, 0 no), position=locationOnTheMap}
    local citiesItemOnly = {["itemlandia"] = {itemId=2667, count=0, remove=0, position={x=1992,y=1979,z=6}}}
    --Breakdown:
    --["city name"] = {storage=StorageLocation, value=numberNeededInLocation, cost=costInGold(set 0 if no money is need), position=locationOnTheMap}
    local citiesQuestOnly = {["rarelandia"] = {storage=8118, value=1, cost=0, position={x=965,y=429,z=6}}}
    --Cites he tells about when asked for options/places
    --Example: { "City 1", "City 2", "City 3"}
    local places = {"The Bayou", "Andros"}
    --------------------END CONFIG SECTION--------------------
   
    local msg = string.lower(msg)
    local questVal = getPlayerStorageValue(cid, 1003)
    if((msg == "hi") and getDistanceTo(cid) < 4 and not (isFocused(cid))) then
        selfSay("Welcome to my ship, ".. getCreatureName(cid) ..".", cid, TRUE)
        addFocus(cid)
    elseif (isFocused(cid)) then
        if msgcontains(msg, 'job') then
            selfSay("I'm the owner and Captain of this boat.", cid)
        elseif msgcontains(msg, 'name') then
            selfSay("They call me Nikolas.", cid)
        elseif msgcontains(msg, 'offer') or msgcontains(msg, 'places') or msgcontains(msg, 'place') or msgcontains(msg, 'town') or msgcontains(msg, 'towns') or msgcontains(msg, 'destinations') or msgcontains(msg, 'destination') or msgcontains(msg, 'offers') or msgcontains(msg, 'travel') then
            local str = "I can take you to "
            if #places == 1 then
                str = str .. places[1]
            else
                for i=1,#places do
                    if i == #places then
                        str = str .. "or " .. places[i]
                    else
                        str = str .. places[i] .. ", "
                    end
                end
            end
            str = str .. ". Where would you like to go?"
            selfSay(str, cid)
        elseif msgcontains(msg, 'yes') then
            local sailInfo = findInfo(cid)
            if sailInfo ~= null then
                if isPzLocked(cid) then
                    selfSay("You may not board my ship with that blood on you.", cid)
                    removeInfo(cid)
                end
                if sailInfo.info.itemId ~= null then
                    if getPlayerItemCount(cid,sailInfo.info.itemId) < sailInfo.info.count then
                        local str = "You don't have the required item"
                        if sailInfo.info.count > 1 then str = str + "s" end
                        str = str + " to go!!"
                        selfSay(str, cid)
                        removeInfo(cid)
                        return
                    end
                    if sailInfo.info.remove == 1 then doPlayerRemoveItem(cid, sailInfo.info.itemId, sailInfo.info.count) end
                    selfSay("Off you go!", cid)
                    doSendMagicEffect(getCreaturePosition(cid), 10)
                    doTeleportThing(cid, sailInfo.info.position)
                    doSendMagicEffect(sailInfo.info.position, 10)
                    removeInfo(cid)
                    removeFocus(cid)
                else
                    if getPlayerMoney(cid) >= sailInfo.info.cost then
                        doPlayerRemoveMoney(cid, sailInfo.info.cost)
                        selfSay("Off you go!", cid)
                        doSendMagicEffect(getCreaturePosition(cid), 10)
                        doTeleportThing(cid, sailInfo.info.position)
                        doSendMagicEffect(sailInfo.info.position, 10)
                        removeInfo(cid)
                        removeFocus(cid)
                    else
                        selfSay("You don't have enough money!!", cid)
                        removeInfo(cid)
                    end
                end
            else
                selfSay("Yes, what?", cid)
            end
        elseif msgcontains(msg, 'no') then
            local sailInfo = findInfo(cid)
            if sailInfo ~= null then
                selfSay("Then I won't be taking you!", cid)
                removeInfo(cid)
            else
                selfSay("No, what?", cid)
            end
        elseif msgcontains(msg, 'bye') then
            selfSay("Bye, and good luck.", cid, TRUE)
            closeShopWindow(cid)
            removeFocus(cid)
            removeInfo(cid)
        else
            for k,v in pairs(cities) do
                if msgcontains(msg, k) then
                    selfSay("It costs " .. v.cost .. " gold to travel to" .. k .. ". Do you want me to take you to ".. k .. "?", cid)
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
            for k,v in pairs(citiesItemOnly) do
                if msgcontains(msg, k) then
                    selfSay("You need to have " .. v.count .. " of the following item: " .. getItemName(v.itemId) .. " for me to take you. Do you want me to take you to ".. k .. "?", cid)
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
            for k,v in pairs(citiesQuestOnly) do
                if msgcontains(msg, k) then
                    if getPlayerStorageValue(cid, v.storage) ~= v.value then
                        selfSay("I'm sorry, I cannot take you there.",cid)
                        return
                    end
                    if v.cost > 0 then
                        selfSay("It costs " .. v.cost .. " soul orbs to travel to" .. k .. ". Do you want me to take you to ".. k .. "?", cid)
                    else
                        selfSay("Do you want me to take you to ".. k .. "?", cid)
                    end
                    if findInfo(cid) then removeInfo(cid) end
                    local stuff = {player=cid, info=v}
                    table.insert(playerInfos, stuff)
                    return
                end
            end
        end
    end
end

function onPlayerCloseChannel(cid)
    if(isFocused(cid)) then
        selfSay("Take Care.")
        closeShopWindow(cid)
        removeFocus(cid)
        removeInfo(cid)
    end
end

function onThink()
    for i, focus in pairs(focuses) do
        if(isCreature(focus) == FALSE) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Good Bye.", cid)
                closeShopWindow(focus)
                removeFocus(focus)
                removeInfo(cid)
            end
        end
    end
    lookAtFocus()
end
Code:
for i, v in pairs(focuses) do
should be
Code:
for i, v in [B]ipairs(focuses) do[/B]
well depends on wat will u insert in the table 'focuses'
Code:
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end

end
no loop to break, shud break after the 'end' of the 'if'(depends also)
for now ;d
 
Back
Top