Hello, I am using TFS 1.0 and printer's annihilator script but there's something wrong.
Checked the coordinations a thousand times they are ok. No error message
Checked the coordinations a thousand times they are ok. No error message
Code:
local function isPlayerInArea(fromPos, toPos)
for _x = fromPos.x, toPos.x do
for _y = fromPos.y, toPos.y do
for _z = fromPos.z, toPos.z do
creature = getTopCreature({x = _x, y = _y, z = _z})
if (isPlayer(creature.uid)) then
return true
end
end
end
end
return false
end
local function doRemoveMonsterFromArea(fromPos, toPos)
for _x = fromPos.x, toPos.x do
for _y = fromPos.y, toPos.y do
for _z = fromPos.z, toPos.z do
creature = getTopCreature({x = _x, y = _y, z = _z})
if (isMonster(creature.uid)) then
doRemoveCreature(creature.uid)
end
end
end
end
return false
end
local Area_fromPos = {x = 1057, y = 1040, z = 14} --top left of the room
local Area_toPos = {x = 1063, y = 1047, z = 14} --bottom right of the room
local players_pos = {
{x = 1094, y = 1034, z = 14, stackpos = STACKPOS_TOP_CREATURE},
{x = 1094, y = 1035, z = 14, stackpos = STACKPOS_TOP_CREATURE},
{x = 1094, y = 1036, z = 14, stackpos = STACKPOS_TOP_CREATURE},
{x = 1094, y = 1037, z = 14, stackpos = STACKPOS_TOP_CREATURE}
}
local new_player_pos = {
{x = 1061, y = 1043, z = 14},
{x = 1060, y = 1043, z = 14},
{x = 1059, y = 1043, z = 14},
{x = 1058, y = 1043, z = 14}
}
local demonPos = {
{x = 1058, y = 1041, z = 14},
{x = 1060, y = 1041, z = 14},
{x = 1062, y = 1043, z = 14},
{x = 1063, y = 1043, z = 14},
{x = 1061, y = 1045, z = 14},
{x = 1059, y = 1045, z = 14}
}
local config = {
min_level = 100, --min player level to make the quest
min_players = 1, --min players needed to make the quest
once_per_restart = true --global like real tibia, once per "day"/"restart"
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = {}
summon_demons = true
if (item.itemid == 1946) then
if (config.once_per_restart) then
if (getGlobalStorageValue(10000) == 1) then
return (doPlayerSendCancel(cid, "Someone has already made the quest today."))
end
end
for i = 1,4 do
player[i] = getTopCreature(players_pos).uid
if (isPlayer(player[i])) then
if (getThingfromPos(player[i]).itemid >= config.min_players) then
if(getPlayerLevel(player[i]) >= config.min_level) then
if (not isPlayerInArea(Area_fromPos, Area_toPos)) then
doTeleportThing(player[i], new_player_pos)
doSendMagicEffect(new_player_pos, CONST_ME_TELEPORT)
doSendMagicEffect(players_pos, CONST_ME_POFF)
doSetCreatureDirection(player[i], EAST)
if (config.once_per_restart) then
setGlobalStorageValue(10000, 1)
end
else
return (doPlayerSendCancel(cid, "A team is already inside the quest room."))
end
else
return (doPlayerSendCancel(cid, "All players must be above level "..config.min_level.."."))
end
else
return (doPlayerSendCancel(cid, "You need "..config.min_players.." players."))
end
end
end
if(summon_demons) then
doRemoveMonsterFromArea(Area_fromPos, Area_toPos)
for d = 1, 6 do
doSummonCreature("Demon", demonPos[d])
end
end
summon_demons = false
doTransformItem(item.uid, 1945)
elseif (item.itemid == 1945) then
doTransformItem(item.uid, 1946)
end
return true
end