Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5.  
  6. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  7. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  8. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  9. function onThink() npcHandler:onThink() end
  10.  
  11. function creatureSayCallback(cid, type, msg)
  12. if(not npcHandler:isFocused(cid)) then
  13. return false
  14. end
  15.  
  16. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  17.  
  18. if(msgcontains(msg, 'prestige')) then
  19. selfSay('Are you ready to prestige and start a new life?', cid)
  20. talkState[talkUser] = 1
  21. elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
  22. -------CONFIGS-------
  23. local level = 120000
  24. local cost = 1000
  25. ------/CONFIGS-------
  26. -----LOCALS-----
  27. local id = getPlayerGUID(cid)
  28. local name = getCreatureName(cid)
  29. local vocation = getPlayerVocation(cid)
  30. local storage = getCreatureStorage(cid, 85987)
  31. ----/LOCALS-----
  32. if(getPlayerLevel(cid) >= level) then
  33. if(doPlayerRemoveMoney(cid, cost) == TRUE) then
  34. if(isInArray({5, 6, 7, 8}, vocation)) then
  35. doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
  36. doRemoveCreature(cid)
  37. db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 0 WHERE `id` ='"..id.."';")
  38. db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
  39. else
  40. selfSay('Please talk with Forgotten King and promote first.', cid)
  41. talkState[talkUser] = 0
  42. end
  43. else
  44. selfSay('You don\'t have enough money. You need to pay 1000 mil to be rebirthed.', cid)
  45. talkState[talkUser] = 0
  46. end
  47. else
  48. selfSay('Only characters of level 5000 or higher can be rebirthed.', cid)
  49. talkState[talkUser] = 0
  50. end
  51. elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
  52. selfSay('Okey. Come back when you feel ready.', cid)
  53. talkState[talkUser] = 0
  54. end
  55.  
  56. return true
  57. end
  58.  
  59. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  60. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement