Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3.  
  4. NpcSystem.parseParameters(npcHandler)
  5.  
  6. local talkState = {}
  7.  
  8. function onCreatureAppear(cid)
  9. npcHandler:onCreatureAppear(cid)
  10. end
  11. function onCreatureDisappear(cid)
  12. npcHandler:onCreatureDisappear(cid)
  13. end
  14. function onCreatureSay(cid, type, msg)
  15. npcHandler:onCreatureSay(cid, type, msg)
  16. end
  17. function onThink()
  18. npcHandler:onThink()
  19. end
  20.  
  21. local fyi {
  22. [50] = "Sample text."
  23. [75] = "Sample text 2."
  24. }
  25.  
  26. function creatureSayCallback(cid, type, msg)
  27. if (not npcHandler:isFocused(cid)) then
  28. return false
  29. end
  30.  
  31. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  32. local reb = getPlayerRebirth(cid)
  33. local c, current = getRebirthCost(reb + 1), getPlayerStorageValue(cid, REBIRTH_STORAGE_STAGE)
  34. local name, i, amount = "", 0, 0
  35.  
  36. if (current > 0 or (current == -1 and REBIRTH_MISSIONS[reb] ~= nil and REBIRTH_MISSIONS[reb]["kill"] ~= nil)) then
  37. for k, v in pairs(REBIRTH_MISSIONS[reb]["kill"]) do
  38. i = i + 1
  39.  
  40. if (current == i or current == -1) then
  41. name = k
  42. amount = v
  43. break
  44. end
  45. end
  46. end
  47.  
  48. local str, nr = "", 0
  49. if (REBIRTH_MISSIONS[reb] ~= nil and REBIRTH_MISSIONS[reb]["collect"] ~= nil) then
  50. for _, v in pairs(REBIRTH_MISSIONS[reb]["collect"]) do
  51. nr = nr + 1
  52. str = str .. v[2] .. " " .. getItemNameById(v[1]) .. "s, "
  53. end
  54. end
  55.  
  56. if (msgcontains(msg, 'mission')) then
  57. if (current == 0) then
  58. if (nr > 0) then
  59. selfSay('Your (final) mission for this rebirth is to bring me ' .. str .. ' and say {rebirth}.', cid)
  60. else
  61. selfSay('You have finished all your missions. Please ask me to {rebirth} you.', cid)
  62. end
  63. else
  64. if (amount == 0) then
  65. selfSay('I do not have any missions for your rebirth.', cid)
  66. else
  67. if (current == -1) then
  68. setPlayerStorageValue(cid, REBIRTH_STORAGE_STAGE, 1)
  69. setPlayerStorageValue(cid, REBIRTH_STORAGE_AMOUNT, 0)
  70. end
  71. selfSay('Your current mission is to kill ' .. amount .. ' ' .. name:lower() .. 's.', cid)
  72. end
  73. end
  74.  
  75. elseif (msgcontains(msg, 'rebirth')) then
  76. if getPlayerLevel(cid) >= 717217 then
  77. if (reb <= 200) then
  78. selfSay('Are you ready for me to rebirth you!? You would have ' .. (getPlayerRebirth(cid) + 1) .. ' rebirths. But you have to give me ' .. (c > 1 and c or 'a') .. ' gold ingot' .. (c > 1 and 's' or '') .. ' OR finish my {missions} in return.', cid)
  79. else
  80. selfSay('Are you ready for me to rebirth you!? You would have ' .. (getPlayerRebirth(cid) + 1) .. ' rebirths. But you have to finish my {missions} in return.', cid)
  81. end
  82. talkState[talkUser] = 1
  83. else
  84. selfSay('Only characters of level 717 217 level or higher may rebirth.', cid)
  85. talkState[talkUser] = 0
  86. end
  87.  
  88.  
  89. elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  90. if (getPlayerLevel(cid) >= 717217) then
  91. local hasIngots = (getPlayerItemCount(cid, 9971) >= c)
  92. local didMissions = (current == 0)
  93.  
  94. if (didMissions) then
  95. if (nr > 0) then
  96. for _, v in pairs(REBIRTH_MISSIONS[reb]["collect"]) do
  97. if (getPlayerItemCount(cid, v[1]) < v[2]) then
  98. didMissions = false
  99. break
  100. end
  101. end
  102. end
  103. end
  104.  
  105. if didMissions or hasIngots then
  106. if (didMissions) then
  107. if (nr > 0) then
  108. for _, v in pairs(REBIRTH_MISSIONS[reb]["collect"]) do
  109. doPlayerRemoveItem(cid, v[1], v[2])
  110. end
  111. end
  112. else
  113. doPlayerRemoveItem(cid, 9971, c)
  114. end
  115. setPlayerRebirth(cid, getPlayerRebirth(cid) + 1)
  116. doPlayerAddSkill(cid, SKILL__LEVEL, -717208, true)
  117. local fyiData = fyi[getPlayerRebirth(cid)]
  118. if fyiData then
  119. doPlayerPopupFYI(cid, fyiData)
  120. end
  121.  
  122. while (getPlayerLevel(cid) > 8) do
  123. doPlayerAddSkill(cid, SKILL__LEVEL, -100000, true)
  124. end
  125.  
  126. doCreatureSetStorage(cid, REBIRTH_STORAGE_STAGE)
  127. doCreatureSetStorage(cid, REBIRTH_STORAGE_AMOUNT)
  128. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREATTACK)
  129. updateStats(cid)
  130. else
  131. selfSay('You do not have enough gold ingots nor have you finished all your mission!', cid)
  132. doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
  133. end
  134.  
  135.  
  136. else
  137. selfSay('Only characters of level 717 217 level or higher may rebirth.', cid)
  138. talkState[talkUser] = 0
  139. end
  140. elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
  141. talkState[talkUser] = 0
  142. selfSay('Okey come back when you have some money you poor scum.', cid)
  143. end
  144. return true
  145. end
  146.  
  147. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  148. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement