Caduceus
Unknown Member
- Joined
- May 10, 2010
- Messages
- 321
- Solutions
- 2
- Reaction score
- 24
If monster is still in area, script is supposed to teleport both players to the start.pos, however, it is only teleporting one player. Script works as intended besides this aspect.
Code:
local config = {
requiredLevel = 80,
requiredMaxLevel = 150,
centerIslandPosition = Position(1259, 1274, 6),
playerPositions = {
Position(1249, 1242, 5),
Position(1251, 1242, 5)
},
startPositions = {
Position(1267, 1294, 5),
Position(1279, 1294, 5)
},
newPositions = {
Position(1241, 1248, 5),
Position(1254, 1249, 5)
},
pirate_skeletonPositions = {
Position(1266, 1293, 6),
Position(1278, 1293, 6)
},
pirate_ghostPositions = {
Position(1266, 1293, 6),
Position(1278, 1293, 6)
},
red_beardPositions = {
Position(1256, 1244, 4)
}
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if item.itemid == 9827 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 2 players.")
return true
end
--[[if playerTile:getItemCount(18422) < 10 then
player:say('Each team member must sacrifice 10 daily tokens to enter!', TALKTYPE_MONSTER_SAY)
return true
end]]
--or playerTile:getLevel() > config.requiredMaxLevel then
if playerTile:getLevel() < config.requiredLevel then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Both players need to be between level ".. config.requiredLevel .." and ".. config.requiredMaxLevel ..".")
return true
end
storePlayers[#storePlayers + 1] = playerTile
end
local specs, spec = Game.getSpectators(config.centerIslandPosition, true, false, 20, 20, 20, 20)
for i = 1, #specs do
spec = specs[i]
if spec:isMonster() then
local players
for i = 1, #storePlayers do
players = storePlayers[i]
config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
players:teleportTo(config.startPositions[i])
config.startPositions[i]:sendMagicEffect(CONST_ME_TELEPORT)
players:sendTextMessage(MESSAGE_INFO_DESCR, "You did not kill all of the monsters!")
return true
end
end
end
end
for i = 1, #config.pirate_skeletonPositions do
Game.createMonster("pirate skeleton", config.pirate_skeletonPositions[i])
end
for i = 1, #config.red_beardPositions do
Game.createMonster("red beard", config.red_beardPositions[i])
end
local players
for i = 1, #storePlayers do
players = storePlayers[i]
--players:removeItem(18422, 10)
config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)
players:teleportTo(config.newPositions[i])
config.newPositions[i]:sendMagicEffect(CONST_ME_TELEPORT)
players:setDirection(DIRECTION_SOUTH)
return true
end
item:transform(item.itemid == 9827 and 9828 or 9827)
return true
end
Last edited: