Caduceus
Unknown Member
- Joined
- May 10, 2010
- Messages
- 321
- Solutions
- 2
- Reaction score
- 24
I am looking for a way to make the second player optional. So you have the option to do the quest solo or 2 players. How would I implement this?
Code:
local config = {
requiredLevel = 75,
daily = false,
centerStormblastChamber = Position(82, 71, 6),
playerPositions = {
Position(1098, 991, 9),
Position(1098, 993, 9) --how to make 2nd player optional?
},
newPositions = {
Position(1108, 994, 10),
Position(1108, 996, 10) --how to make 2nd player optional?
},
monsterSpawnPosition = Position(1112, 994, 10),
monsterName = {
[1] = "Stormblast2",
[2] = "Stormblast"
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 1945 then
local storePlayers, playerTile = {}
for i = 1, #config.playerPositions do
playerTile = Tile(config.playerPositions[i]):getTopCreature()
if not playerTile or not playerTile:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "You need to be on the tile.")
return true
end
if playerTile:getLevel() < config.requiredLevel then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Players need to be level ".. config.requiredLevel .." or higher.")
return true
end
storePlayers[#storePlayers + 1] = playerTile
end
--Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]])
local specs, spec = Game.getSpectators(config.centerStormblastChamber, true, false, 37, 37, 23, 26)
for i = 1, #specs do
spec = specs[i]
if spec:isPlayer() then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "A player is already inside the quest area. Please try again later.")
return true
end
spec:remove()
end
if isInArray({4,9}, player:getVocation():getBase():getId()) then
Game.createMonster(config.monsterName[2], config.monsterSpawnPosition)
elseif isInArray({1,2,3}, player:getVocation():getBase():getId()) then
Game.createMonster(config.monsterName[1], config.monsterSpawnPosition)
end
local players
for i = 1, #storePlayers do
players = storePlayers[i]
config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
players:teleportTo(config.newPositions[i])
config.newPositions[i]:sendMagicEffect(CONST_ME_POFF)
players:setDirection(DIRECTION_SOUTH)
players:sendTextMessage(MESSAGE_INFO_DESCR, "Hope to see you on the other side!")
end
elseif item.itemid == 1945 then
if config.daily then
player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE))
return true
end
end
item:transform(item.itemid == 1946 and 1945 or 1946)
return true
end