Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- local talktopic, amount, playerLevel = {30}, {60}, {90}
- local str = ""
- --Config
- local highLevelPrice = 20000 --(Real Tibia Price: 20000) price for players level 120+, per blessing
- local lowLevelPrice = 2000 --(Real Tibia Price: 2000) price for players level 30 and lower, per blessing
- local pricePerLevel = 200 --(Real Tibia Price: 200) this price only applies to players between level 30 & 120, formula=((pricePerLevel*playerLevel)+lowLevelPrice)
- --Text
- local text = "Do you want to buy embrace of tibia for " --leave this unfinished (it will add the price to the end)
- local thankyou = "You have bought my blessings for " --leave this unfinished (it will add the price to the end)
- local help = "I can give you my blessings for a low price of gold. Blessings will protect you from losing items on death and reduce the amount of levels you lose when you die."
- local already = "You already have my blessings."
- local nomoney = "You don\'t have enough money for my blessings."
- 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 greetCallback(cid)
- local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- talktopic[talkUser], amount[talkUser], playerLevel[talkUser] = 0, 0, 0
- return true
- end
- function creatureSayCallback(cid, type, msg)
- talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- playerLevel[talkUser] = getPlayerLevel(cid)
- amount[talkUser] = 0
- if (getPlayerBlessing(cid,5)
- ) then
- npcHandler:say(already, cid)
- return false
- else
- if playerLevel[talkUser] < 30 then
- amount[talkUser] = lowLevelPrice
- str = ""..amount[talkUser].." gold coin?"
- elseif playerLevel[talkUser] > 30 and playerLevel[talkUser] < 120 then
- amount[talkUser] = (((playerLevel[talkUser]-30)*pricePerLevel)+lowLevelPrice)
- str = ""..amount[talkUser].." gold coin?"
- elseif playerLevel[talkUser] >= 120 then
- amount[talkUser] = highLevelPrice
- str = ""..amount[talkUser].." gold coin?"
- end
- end
- str = text..str
- if (msgcontains(msg, "help") or msgcontains(msg, "job")) then
- talktopic[talkUser] = 0
- npcHandler:say(help, cid)
- elseif talktopic[talkUser] == 0 and (msgcontains(msg, "yes") or msgcontains(msg, "embra") or msgcontains(msg, "embrace of tibia")) then
- talktopic[talkUser] = 1
- npcHandler:say(str, cid)
- elseif talktopic[talkUser] == 1 and (msgcontains(msg, "yes") or msgcontains(msg, "ok")) then
- talktopic[talkUser] = 2
- if doPlayerRemoveMoney(cid, amount[talkUser]) then
- for i = 1,5 do
- doPlayerAddBlessing(cid,5)
- end
- npcHandler:say(thankyou..""..amount[talkUser].." gold coins.", cid)
- else
- npcHandler:say(nomoney, cid)
- return false
- end
- end
- return true
- end
- npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. I can bless you with a {embrace of tibia}.")
- npcHandler:setMessage(MESSAGE_WALKAWAY, "Please visit again. You never know when you may need my blessings!")
- npcHandler:setMessage(MESSAGE_FAREWELL, "Please visit again. |PLAYERNAME|.")
- npcHandler:setCallback(CALLBACK_GREET, greetCallback)
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement