local talkState = {}
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local player = Player(cid)
if(msgcontains(msg, 'soul')) then
if player:getMoney() > 500 then
selfSay('do you want to buy 10 soul points for 500 gp?', cid)
talkState[talkUser] = 1
else
selfSay('sorry you need atleast 500 gps.', cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if player:getMoney() > 500 then
player:removeMoney(500)
player:addSoul(soulChange)
selfSay('You have bought 10 soul points.', cid)
talkState[talkUser] = 0
else
selfSay('sorry you need atleast 500 gps.', cid)
end
end
return false
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())