local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 greet(cid) talkState[cid] = 0 return true end
function getNpcName() return getCreatureName(getNpcId()) 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_gold = getPlayerItemCount(cid,2148)
local player_plat = getPlayerItemCount(cid,2152)*100
local player_crys = getPlayerItemCount(cid,2160)*10000
local player_money = player_gold + player_plat + player_crys
if msgcontains(msg, "name") then
selfSay("My name is " .. getNpcName() .. ".", cid)
elseif msgcontains(msg, "help") then
selfSay("Keywords available: name, help, promotion, premium, experience.", cid)
-- Promotion
elseif msgcontains(msg, "promotion") and getPlayerPromotionLevel(cid) < 1 then
selfSay("I can promote you for 15 million gold peices. Would you like to receive your promotion?", cid)
talkState[talkUser] = 1
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 and player_money >= 15000000 then
doPlayerRemoveMoney(cid, 15000000)
doPlayerSetPromotionLevel(cid, getPlayerPromotionLevel(cid) + 1)
selfSay("Congratulations! You have been promoted to ".. getPlayerVocationName(cid) .."!", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 and player_money < 15000000 then
selfSay("You do not have enough gold to complete this transaction.", cid)
talkState[talkUser] = 0
-- Premium
elseif msgcontains(msg, "premium") then
selfSay("I will trade 100 soul orbs for 20 days of premium. Would you like to do that?", cid)
talkState[talkUser] = 2
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 and getPlayerItemCount(cid, 5944) >= 100 then
doPlayerRemoveItem(cid, 5944, 100)
doPlayerAddPremiumDays(cid, 20)
selfSay("Congratulations! You have received 20 days of premium!", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 and getPlayerItemCount(cid, 5944) < 100 then
selfSay("You do not have enough soul orbs to complete this transaction.", cid)
talkState[talkUser] = 0
-- Experience
elseif msgcontains(msg, "experience") then
selfSay("I will trade 100 soul orbs for 1 million experience. Would you like to do that?", cid)
talkState[talkUser] = 3
elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 and getPlayerItemCount(cid, 5944) >= 100 then
doPlayerRemoveItem(cid, 5944, 100)
doPlayerAddExperience(cid, 1000000)
selfSay("Congratulations! You have received 1 million experience!", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 and getPlayerItemCount(cid, 5944) < 100 then
selfSay("You do not have enough soul orbs to complete this transaction.", cid)
talkState[talkUser] = 0
-- If they say something other then yes
elseif msgcontains(msg, "") and talkState[talkUser] >= 1
selfSay("No then.", cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())