strutZ
Australian OT Member {AKA Beastn}
- Joined
- Nov 16, 2014
- Messages
- 1,391
- Solutions
- 7
- Reaction score
- 550
Hello,
Today I would like to release my modal window raid selector.
Features
- Configurable price to start a raid
- Configurable CD between raid starting
data/actions/actions.xml
data/actions/scripts/raidstarter.lua
data/creaturescripts/scripts/raidstarter.lua
data/creaturescripts/creaturescripts.xml
Then dont forget to register it in your login.lua
Enjoy.
Today I would like to release my modal window raid selector.
Features
- Configurable price to start a raid
- Configurable CD between raid starting
![ccca3482f82369e624e9e858e7ca1c3c.jpg](/proxy.php?image=https%3A%2F%2Fi.gyazo.com%2Fccca3482f82369e624e9e858e7ca1c3c.jpg&hash=318ba9ffa1bf8a0fc1a0f2fab127435e)
data/actions/actions.xml
Code:
<action actionid="5000" script="custom/modalRAID_Bosses.lua"/>
data/actions/scripts/raidstarter.lua
Code:
local raids = {
[1] = {raid = 'Arachir the Ancient One'},
[2] = {raid = 'Diblis The Fair'},
[3] = {raid = 'Ferumbras'},
[4] = {raid = 'Ghazbaran'},
[5] = {raid = 'Horned Fox'},
[6] = {raid = 'Morgaroth'},
[7] = {raid = 'Necropharus'},
[8] = {raid = 'Orshabaal'},
[9] = {raid = 'Sir Valorcrest'},
[10] = {raid = 'The Old Widow'},
[11] = {raid = 'Zevelon Duskbringer'},
[12] = {raid = 'Zulazza the Corruptor'},
[13] = {raid = 'Apocalypse'},
}
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
player:registerEvent("modalRAID_Bosses")
local title = "Pick a Raid!"
local message = "Pick the raid you wish to start. Each raid will cost you 50cc"
local window = ModalWindow(1003, title, message)
window:addButton(100, "Confirm")
window:addButton(101, "Cancel")
for i = 1, #raids do
local o = raids[i].raid
window:addChoice(i, o)
end
window:setDefaultEnterButton(100)
window:setDefaultEscapeButton(101)
window:sendToPlayer(player)
return true
end
data/creaturescripts/scripts/raidstarter.lua
Code:
local cost = 50 --Amount of Crystal Coins per raid
local wait = 30 * 60 -- Wait time between raids (Works in minitues right now its set to 30 mins. Change the 30 to w/e you want)
local raids = {
[1] = {name = 'Arachir the Ancient One'},
[2] = {name = 'Diblis The Fair'},
[3] = {name = 'Ferumbras'},
[4] = {name = 'Ghazbaran'},
[5] = {name = 'Horned Fox'},
[6] = {name = 'Morgaroth'},
[7] = {name = 'Necropharus'},
[8] = {name = 'Orshabaal'},
[9] = {name = 'Sir Valorcrest'},
[10] = {name = 'The Old Widow'},
[11] = {name = 'Zevelon Duskbringer'},
[12] = {name = 'Zulazza the Corruptor'},
[13] = {name = 'Apocalypse'},
}
function onModalWindow(player, modalWindowId, buttonId, choiceId)
player:unregisterEvent("modalRAID_Bosses")
if modalWindowId ~= 1003 or buttonId ~= 100 then
return false
end
local raid = raids[choiceId]
if not raid then
return false
end
local raidStorage = Game.getStorageValue(12345)
raidStorage = not raidStorage and 0 or raidStorage
if raidStorage > os.time() then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait ".. showTimeLeft(raidStorage - os.time(), true) ..", before you can start another boss raid.")
return false
end
if player:getItemCount(2160) < 20 then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You dont have enough money.")
return false
end
player:removeItem(2160, cost)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
Game.startRaid(raid.name)
Game.setStorageValue(12345, os.time() + wait)
return true
end
data/creaturescripts/creaturescripts.xml
Code:
<event type="modalwindow" name="raidstarter" script="raidstarter.lua"/>
Then dont forget to register it in your login.lua
Code:
raidstarter
Enjoy.
Last edited: