Advertisement
Kaiquegabriel

Untitled

Jul 9th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. local talktopic, amount, playerLevel = {30}, {60}, {90}
  6. local str = ""
  7.  
  8. --Config
  9. local highLevelPrice = 20000 --(Real Tibia Price: 20000) price for players level 120+, per blessing
  10. local lowLevelPrice = 2000 --(Real Tibia Price: 2000) price for players level 30 and lower, per blessing
  11. local pricePerLevel = 200 --(Real Tibia Price: 200) this price only applies to players between level 30 & 120, formula=((pricePerLevel*playerLevel)+lowLevelPrice)
  12. --Text
  13. local text = "Do you want to buy embrace of tibia for " --leave this unfinished (it will add the price to the end)
  14. local thankyou = "You have bought my blessings for " --leave this unfinished (it will add the price to the end)
  15. 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."
  16. local already = "You already have my blessings."
  17. local nomoney = "You don\'t have enough money for my blessings."
  18.  
  19. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  20. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  21. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  22. function onThink() npcHandler:onThink() end
  23.  
  24. function greetCallback(cid)
  25. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  26. talktopic[talkUser], amount[talkUser], playerLevel[talkUser] = 0, 0, 0
  27. return true
  28. end
  29.  
  30. function creatureSayCallback(cid, type, msg)
  31.  
  32. talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  33.  
  34. if(not npcHandler:isFocused(cid)) then
  35. return false
  36. end
  37.  
  38. playerLevel[talkUser] = getPlayerLevel(cid)
  39. amount[talkUser] = 0
  40.  
  41. if (getPlayerBlessing(cid,5)
  42. ) then
  43. npcHandler:say(already, cid)
  44. return false
  45. else
  46. if playerLevel[talkUser] < 30 then
  47. amount[talkUser] = lowLevelPrice
  48. str = ""..amount[talkUser].." gold coin?"
  49. elseif playerLevel[talkUser] > 30 and playerLevel[talkUser] < 120 then
  50. amount[talkUser] = (((playerLevel[talkUser]-30)*pricePerLevel)+lowLevelPrice)
  51. str = ""..amount[talkUser].." gold coin?"
  52. elseif playerLevel[talkUser] >= 120 then
  53. amount[talkUser] = highLevelPrice
  54. str = ""..amount[talkUser].." gold coin?"
  55. end
  56. end
  57.  
  58. str = text..str
  59.  
  60. if (msgcontains(msg, "help") or msgcontains(msg, "job")) then
  61. talktopic[talkUser] = 0
  62. npcHandler:say(help, cid)
  63.  
  64. elseif talktopic[talkUser] == 0 and (msgcontains(msg, "yes") or msgcontains(msg, "embra") or msgcontains(msg, "embrace of tibia")) then
  65. talktopic[talkUser] = 1
  66. npcHandler:say(str, cid)
  67.  
  68. elseif talktopic[talkUser] == 1 and (msgcontains(msg, "yes") or msgcontains(msg, "ok")) then
  69. talktopic[talkUser] = 2
  70. if doPlayerRemoveMoney(cid, amount[talkUser]) then
  71. for i = 1,5 do
  72. doPlayerAddBlessing(cid,5)
  73. end
  74. npcHandler:say(thankyou..""..amount[talkUser].." gold coins.", cid)
  75. else
  76. npcHandler:say(nomoney, cid)
  77. return false
  78. end
  79. end
  80. return true
  81. end
  82.  
  83. npcHandler:setMessage(MESSAGE_GREET, "Hello |PLAYERNAME|. I can bless you with a {embrace of tibia}.")
  84. npcHandler:setMessage(MESSAGE_WALKAWAY, "Please visit again. You never know when you may need my blessings!")
  85. npcHandler:setMessage(MESSAGE_FAREWELL, "Please visit again. |PLAYERNAME|.")
  86.  
  87. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  88. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  89. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement