Hello,
I make one npc and and with help of all the menbers i make my npc in lua..but now i have other problem and doubt, but npc have to words to player can say..transport and rent...but rent work fine i dont know how add other word in npc.. look my script to understand more..
I make one npc and and with help of all the menbers i make my npc in lua..but now i have other problem and doubt, but npc have to words to player can say..transport and rent...but rent work fine i dont know how add other word in npc.. look my script to understand more..
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local storage = 18600;
local startTime = os.time()
local talkState = {}
local newpos = {}
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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'rent') then
selfSay('Do you want to rent a horse for one day at a price of 500 gold?', cid)
end
if msgcontains(msg, 'yes') then
if not getPlayerMount(cid, 25) then
if doPlayerRemoveMoney(cid, 500) then
doPlayerAddMount(cid,25)
setPlayerStorageValue(cid, storage, startTime)
selfSay('I\'ll give you one of our experienced ones. Take care! Look out for low hanging branches.', cid)
else
selfSay('Sorry, you are too poor. I\d rent one to you for free but I\m afraid you might be desperate enough to eat the horse, sorry.', cid)
end
else
selfSay('You already have this mount.', cid)
end
end
end
function talk(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
selfSay('We can bring you to Thais with one of our coaches for 125 gold. Are you interested?', cid)
if msgcontains(msg, 'yes') then
elseif doPlayerRemoveMoney(cid, 125) then
doTeleportThing(cid, newpos)
else
selfSay('You don\'t have enough money.', cid)
end
end
node1 = keywordHandler:addKeyword({'transport'}, talk, {})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())