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
if msgcontains(msg, 'first') then
if isPremium(cid) == TRUE then
npcHandler:say("Do you want to buy first addons for 1 gp?")
talkState = 1
else
npcHandler:say("You need premium account.")
talkState = 0
end
elseif msgcontains(msg, 'second') then
if isPremium(cid) == TRUE then
npcHandler:say("Do you want to buy second addons for 1 gp")
talkState = 2
else
npcHandler:say("You need premium account.")
talkState = 0
end
elseif msgcontains(msg, 'yes') and talkState == 1 then
if doPlayerRemoveMoney(cid, 1) == 1 then
npcHandler:say("Here you go.")
doPlayerAddOutfit(cid, x , 1)
doPlayerAddOutfit(cid, x , 1) -- copy this line and paste here as many times as there r outfits in x place write the
number of outf.
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
talkState = 0
else
npcHandler:say("You don\'t have enough money.")
talkState = 0
end
elseif msgcontains(msg, 'yes') and talkState == 2 then
if doPlayerRemoveMoney(cid, 1) == 1 then
npcHandler:say("Here you go.")
doPlayerAddOutfit(cid, x , 2)
doPlayerAddOutfit(cid, x , 2) -- copy this line and paste here as many times as there r outfits in x place write the
number of outf.
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
talkState = 0
else
npcHandler:say("You don\'t have enough money.")
talkState = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())