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 onPlayerEndTrade(cid) npcHandler:onPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:onPlayerCloseChannel(cid) end
local talk = {}
local config = {
storage = 130030,
level = 130
}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
talk[cid] = talk[cid] or 0
if msgcontains(msg, "level") and talk[cid] == 0 then
if getPlayerLevel(cid) >= 130 then
selfSay("Sorry, but you can only use this below level 120..", cid)
return true
end
if getPlayerStorageValue(cid, config.storage) >= 1 then
selfSay("You already used this service", cid)
return true
end
selfSay("Do you want to level up to 130 for 1kk gold?", cid)
talk[cid] = 1
elseif talk[cid] == 1 then
if msgcontains(msg, 'yes') then
if not(doPlayerRemoveMoney(cid, 1000000)) then
selfSay("You need to pay 1kk..", cid)
talk[cid] = 0
return true
end
selfSay('Here you are.. level 130!', cid)
setPlayerStorageValue(cid, config.storage, 1)
local expNeeded = getExperienceForLevel(config.level) - getPlayerExperience(cid)
if expNeeded > 0 then
doPlayerAddExperience(cid, expNeeded)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
end
else
selfSay("maybe later..", cid)
end
talk[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())