local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function ExpBackNormal_EndVoucher(cid, bonus)
local rates = math.abs(getPlayerRates(cid)[8] - bonus)
doPlayerSetExperienceRate(cid, rates)
doCreatureSetStorage(cid, 3024776, -1)
doCreatureSetStorage(cid, 3024777, -1)
return true
end
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 price = 0
if msgcontains(msg:lower(), "basic exp booster") then
price = getPlayerLevel(cid) * 350
selfSay("Do you want the basic exp booster (15% bonus, 2 hours) for ".. price .." gold coins?", cid)
talkState[talkUser] = 1
elseif msgcontains(msg:lower(), "strong exp booster") then
price = 5
selfSay("Do you want the strong exp booster (30% bonus, 2 hours) for ".. price .." donate coins?", cid)
talkState[talkUser] = 3
elseif msgcontains(msg:lower(), "great exp booster") then
price = 15
selfSay("Do you want the great exp booster (50% bonus, 2 hours) for ".. price .." donate coins?", cid)
talkState[talkUser] = 4
elseif msgcontains(msg:lower(), "yes") then
-- gps
if talkState[talkUser] == 1 then
if(doPlayerRemoveMoney(cid, price)) then
local exhaustedvoucher = 3024775
local time = 3024776
local bonusMultiplier = 3024777
if(os.time() < getCreatureStorage(cid, exhaustedvoucher)) then
selfSay("You can only use it once every 20 hours! You will be able to use this item again on: " .. os.date("%B", getPlayerStorageValue(cid, exhaustedvoucher)) .. "-" .. os.date("%d", getPlayerStorageValue(cid, exhaustedvoucher)) .. "-" .. os.date("%Y", getPlayerStorageValue(cid, exhaustedvoucher)) .. " " .. os.date("%X", getPlayerStorageValue(cid, exhaustedvoucher)) .. ".")
return true
end
local bonus = 0.15
local rates = getPlayerRates(cid)[8] + bonus
doPlayerSetExperienceRate(cid, rates)
addEvent(ExpBackNormal_EndVoucher, 7200000, cid, bonus) -- 2 hours
doCreatureSetStorage(cid, exhaustedvoucher, os.time() + (20*60*60*1000)) -- 24 hours
doCreatureSetStorage(cid, time, os.time() + 7200000)
doCreatureSetStorage(cid, bonusMultiplier, bonus)
doSendMagicEffect(getCreaturePosition(cid), 14)
selfSay("Here you are... 2 hours of 15% exp bonus!", cid)
talkState[talkUser] = 0
else
selfSay("You dont have ".. price .." coins", cid)
talkState[talkUser] = 0
end
-- tokens
elseif talkState[talkUser] > 1 then
local tokenid = 6527
local ItemID = 0
if(Topic[cid] == 3) then -- strong exp booster
price = 5
ItemID = 11401
elseif(Topic[cid] == 4) then -- great exp booster
price = 15
ItemID = 11402
end
if getPlayerItemCount(cid, tokenid) < price then
selfSay('Sorry, you don\'t have enough tokens.', cid)
return 1
end
doPlayerRemoveItem(cid, tokenid, price)
doPlayerAddItem(cid, ItemID, 1)
selfSay('Here you are.', cid)
talkState[talkUser] = 0
end
end
end -- fim function
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())