Advertisement
Guest User

Untitled

a guest
May 25th, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. function Player:sendBossRaidWindow(raids)
  2. local function buttonCallback(button, choice)
  3. -- Modal window functionallity
  4. if button.text == "Confirm" then
  5. -- Start Checks
  6. -- Check if the system is on cooldown.
  7. if Game.getStorageValue(raids.raidStorage) > os.time() then
  8. self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait ".. showTimeLeft(Game.getStorageValue(raids.raidStorage) - os.time(), true) ..", before you can start another boss raid.")
  9. return false
  10. end
  11.  
  12. -- Check if the player has enough enough
  13. if self:getMoney() < cost then
  14. self:sendTextMessage(MESSAGE_EVENT_ADVANCE, raids.moneyMsg)
  15. return false
  16. end
  17. -- End Checks
  18.  
  19. self:removeMoney(raids.cost)
  20. self:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
  21. Game.startRaid(raids[choice.id].raid)
  22. Game.setStorageValue(raids.raidStorage, os.time() + raids.cooldown)
  23. return true
  24. end
  25. end
  26.  
  27. -- Modal window design
  28. local window = ModalWindow {
  29. title = raids.mainTitle, -- Title of the modal window
  30. message = raids.mainMsg, -- The message to be displayed on the modal window
  31. }
  32.  
  33. -- Add buttons to the window (Note: if you change the names of these you must change the functions in the modal window functionallity!)
  34. window:addButton("Confirm", buttonCallback)
  35. window:addButton("Cancel")
  36.  
  37. -- Set what button is pressed when the player presses enter or escape
  38. window:setDefaultEnterButton("Confirm")
  39. window:setDefaultEscapeButton("Cancel")
  40.  
  41. -- Add choices from the action script
  42. for i = 1, #raids do
  43. local o = raids[i].raid
  44. window:addChoice(o)
  45. end
  46.  
  47. -- Send the window to player
  48. window:sendToPlayer(self)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement