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

Lua Bring Me To -Town- Function

Arcadius

Banned User
Joined
Sep 11, 2014
Messages
60
Reaction score
1
Location
Developing
Distro: OTHire

Anyone know how to add "Please bring me to" a boat NPC to allow people to just run up, say "please bring me to carlin" if someone is already talking to the npc, it will auto check if the player has the money then sends them to the city. Otherwise, sending the "You do not have enough money" message.

Example I found that doesn't work:
"Please bring me to …" method:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

local t = {
    {'Carlin', {x=32387, y=31820, z=6}},
    {'Ab\'dendriel', {x=32734, y=31668, z=6}},
    {'Edron', {x=33173, y=31764, z=6}},
    {'Venore', {x=32954, y=32022, z=6}},
    {'Port Hope', {x=32527, y=32784, z=6}},
    {'Svargrond', {x=32341, y=31108, z=6}},
    {'Yalahar', {x=32816, y=31272, z=6}},
    {'Darashia', {x=33289, y=32480, z=6}},
    {'Ankrahmun', {x=33092, y=32883, z=6}},
    {'Goroma', {x=32161, y=32557, z=6}},
    {'sail', 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Svargrond, Yalahar, Darashia, Ankrahmun or Goroma?'},
    {'job', 'I am the captain of this ship.'},
    {'captain', 'I am the captain of this ship.'}
}

for i = 1, #t do
    local v = t
    if type(v[2]) == 'table' then
        keywordHandler:addKeyword({'please bring me to ' .. v[1]:lower()}, StdModule.travel, {npcHandler = npcHandler, level = 0, cost = 0, destination = v[2]})
        local k = keywordHandler:addKeyword({v[1]:lower()}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to sail to ' .. v[1] .. ' for free?'})
        k:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, level = 0, cost = 0, destination = v[2]})
        k:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'We would like to serve you some time.'})
    else
        keywordHandler:addKeyword({v[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = v[2]})
    end
end

t = nil
npcHandler:addModule(FocusModule:new())

"Hi -> Town name" method:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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

local t = {
    {'Carlin', {x=32387, y=31820, z=6}},
    {'Ab\'dendriel', {x=32734, y=31668, z=6}},
    {'Edron', {x=33173, y=31764, z=6}},
    {'Venore', {x=32954, y=32022, z=6}},
    {'Port Hope', {x=32527, y=32784, z=6}},
    {'Svargrond', {x=32341, y=31108, z=6}},
    {'Yalahar', {x=32816, y=31272, z=6}},
    {'Darashia', {x=33289, y=32480, z=6}},
    {'Ankrahmun', {x=33092, y=32883, z=6}},
    {'Goroma', {x=32161, y=32557, z=6}},
    {'sail', 'Where do you want to go? To Carlin, Ab\'Dendriel, Edron, Venore, Port Hope, Svargrond, Yalahar, Darashia, Ankrahmun or Goroma?'},
    {'job', 'I am the captain of this ship.'},
    {'captain', 'I am the captain of this ship.'}
}

for i = 1, #t do
    local v = t
    if type(v[2]) == 'table' then
        keywordHandler:addKeyword({v[1]:lower()}, StdModule.travel, {npcHandler = npcHandler, level = 0, cost = 0, destination = v[2]})
    else
        keywordHandler:addKeyword({v[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = v[2]})
    end
end

t = nil
npcHandler:addModule(FocusModule:new())

Any help is appreciated.
 
Last edited:
Did you include lua and quote tags inside the script itself? :eek:

llook closer ok xD
Code:
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

There is eeks :P

change for this
Code:
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
 
Already did that in the actual script, I changed those and it doesnt work on OTHire. I just quoted his post this time since I deleted the script since yesterday when I tried it.

to the top
 
Last edited by a moderator:
Back
Top