Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Player:sendBossRaidWindow(raids)
- local function buttonCallback(button, choice)
- -- Modal window functionallity
- if button.text == "Confirm" then
- -- Start Checks
- -- Check if the system is on cooldown.
- if Game.getStorageValue(raids.raidStorage) > os.time() then
- self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait ".. showTimeLeft(Game.getStorageValue(raids.raidStorage) - os.time(), true) ..", before you can start another boss raid.")
- return false
- end
- -- Check if the player has enough enough
- if self:getMoney() < cost then
- self:sendTextMessage(MESSAGE_EVENT_ADVANCE, raids.moneyMsg)
- return false
- end
- -- End Checks
- self:removeMoney(raids.cost)
- self:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
- Game.startRaid(raids[choice.id].raid)
- Game.setStorageValue(raids.raidStorage, os.time() + raids.cooldown)
- return true
- end
- end
- -- Modal window design
- local window = ModalWindow {
- title = raids.mainTitle, -- Title of the modal window
- message = raids.mainMsg, -- The message to be displayed on the modal window
- }
- -- Add buttons to the window (Note: if you change the names of these you must change the functions in the modal window functionallity!)
- window:addButton("Confirm", buttonCallback)
- window:addButton("Cancel")
- -- Set what button is pressed when the player presses enter or escape
- window:setDefaultEnterButton("Confirm")
- window:setDefaultEscapeButton("Cancel")
- -- Add choices from the action script
- for i = 1, #raids do
- local o = raids[i].raid
- window:addChoice(o)
- end
- -- Send the window to player
- window:sendToPlayer(self)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement