Arcadius
Banned User
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:
"Hi -> Town name" method:
[/QUOTE]
[/code]
Any help is appreciated.
Example I found that doesn't work:
Code:
[QUOTE="Cykotitan, post: 1167804, member: 18868"]"Please bring me to …" method:
[code=lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
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())
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
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())
[/code]
Any help is appreciated.