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
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if(npcHandler.focus ~= cid) then
return false
end
rand = math.random(1,10)
if msgcontains(msg, 'crap') then
selfSay('Are u sure you want to go to crap, for 1gp?')
destination = {x=741, y=935, z=7}
cost = 1
talk_state = 1
elseif msgcontains(msg, 'lol') then
selfSay('Are u sure you want to go to lol, for 1gp?')
destination = {x=753, y=936, z=7}
cost = 1
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if rand <= 1 then
if doPlayerRemoveMoney(cid, cost) == TRUE then
if doTeleportThing(cid,destination, 0) then
else
if doTeleportThing(cid,{x=749, y=940, z=7}, 0) then
else
selfSay("You don't have enough money.")
talk_state = 0
end
end
elseif msgcontains(msg, 'no') and talk_state == 1 then
selfSay("Then not.")
talk_state = 0
end
end
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())