-- Annihilator by Shawak v2.1
-- CONFIG --
local room = { -- room with demons
fromX = 33217,
fromY = 31655,
fromZ = 13,
--------------
toX = 33224,
toY = 31663,
toZ = 13
}
local monster_pos = {
[1] = {pos = {33220, 31657, 13}, monster = "Demon"},
[2] = {pos = {33222, 31657, 13}, monster = "Demon"},
[3] = {pos = {33219, 31661, 13}, monster = "Demon"},
[4] = {pos = {33221, 31661, 13}, monster = "Demon"},
[5] = {pos = {33223, 31659, 13}, monster = "Demon"},
[6] = {pos = {33224, 31659, 13}, monster = "Demon"}
}
local players_pos = {
{x = 33225, y =31671, z = 13, stackpos = 253},
{x = 33224, y =31671, z = 13, stackpos = 253},
{x = 33223, y =31671, z = 13, stackpos = 253},
{x = 33222, y =31671, z = 13, stackpos = 253}
}
local new_player_pos = {
{x = 33222, y = 31659, z = 13},
{x = 33221, y = 31659, z = 13},
{x = 33220, y = 31659, z = 13},
{x = 33219, y = 31659, z = 13}
}
local playersOnly = "yes"
local questLevel = 100
------------------------------------------------------
--- CONFIG END ---------------------------------------
------------------------------------------------------
function onUse(cid, item, fromPosition, itemEx, toPosition)
local all_ready, monsters, player, level = 0, 0, {}, 0
if item.itemid == 1945 then
for i = 1, #players_pos do
table.insert(player, 0)
end
for i = 1, #players_pos do
player = getThingfromPos(players_pos)
if player.itemid > 0 then
if string.lower(playersOnly) == "yes" then
if isPlayer(player.uid) == TRUE then
all_ready = all_ready+1
else
monsters = monsters+1
end
else
all_ready = all_ready+1
end
end
end
if all_ready == #players_pos then
for i = 1, #players_pos do
player = getThingfromPos(players_pos)
if isPlayer(player.uid) == TRUE then
if getPlayerLevel(player.uid) >= questLevel then
level = level+1
end
else
level = level+1
end
end
if level == #players_pos then
if string.lower(playersOnly) == "yes" and monsters == 0 or string.lower(playersOnly) == "no" then
local door = getTileItemById({x=33225, y=31659, z=13}, 5109).uid
if door > 0 then
doTransformItem(door, 5108)
end
for _, area in pairs(monster_pos) do
doSummonCreature(area.monster,{x=area.pos[1],y=area.pos[2],z=area.pos[3]})
end
for i = 1, #players_pos do
doSendMagicEffect(players_pos, CONST_ME_POFF)
doTeleportThing(player.uid, new_player_pos, FALSE)
doSendMagicEffect(new_player_pos, CONST_ME_ENERGYAREA)
doTransformItem(item.uid,1946)
end
else
doPlayerSendTextMessage(cid,19,"Only players can do this quest.")
end
else
doPlayerSendTextMessage(cid,19,"All Players have to be level "..questLevel.." to do this quest.")
end
else
doPlayerSendTextMessage(cid,19,"You need "..table.getn(players_pos).." players to do this quest.")
end
elseif item.itemid == 1946 then
local player_room = 0
for x = room.fromX, room.toX do
for y = room.fromY, room.toY do
for z = room.fromZ, room.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
if isPlayer(thing.uid) == TRUE then
player_room = player_room+1
end
end
end
end
end
if player_room >= 1 then
doPlayerSendTextMessage(cid,19,"There is already a team in the quest room.")
elseif player_room == 0 then
for x = room.fromX, room.toX do
for y = room.fromY, room.toY do
for z = room.fromZ, room.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if thing.itemid > 0 then
doRemoveCreature(thing.uid)
end
end
end
end
doTransformItem(item.uid,1945)
end
end
return TRUE
end
function onCombat(cid, target)
if not isPlayer(target)
return true
end
if getCreatureStorage(cid, 21000) == getCreatureStorage(target, 21000) then
return false
end
return true
end
Btw, Congratz with 10.000 postsFor the annihilator script, you can just add more positions to the tables, atm there are 4, so add 4 more for 8 players instead of 4, same goes for the monster positions if you want more demons.
For the attack part, you can use function onCombat and compare the storagevalues of the attacker (cid) and the target, if it's the same, return false, this way the attacker is unable to attack the target if it has the same storagevalue.
Code:function onCombat(cid, target) if not isPlayer(target) return true end if getCreatureStorage(cid, 21000) == getCreatureStorage(target, 21000) then return false end return true end
Stop posting Offtopic posts.Btw, Congratz with 10.000 posts
TyBtw, Congratz with 10.000 posts
\/ I think that's exactly what I posted@Limos I think he means if 2 players have the same storage value. They can't invite/attack each other.
this way the attacker is unable to attack the target if it has the same storagevalue.
Code:function onCombat(cid, target) if not isPlayer(target) return true end if getCreatureStorage(cid, 21000) == getCreatureStorage(target, 21000) then return false end return true end
local config = {
daily = "no",
level = 100,
storage = 30015,
entry =
{
{x = 1105, y = 1241, z = 7},
{x = 1107, y = 1241, z = 7},
{x = 1109, y = 1241, z = 7},
{x = 1111, y = 1241, z = 7}
},
destination =
{
{x = 1101, y = 1238, z = 7},
{x = 1102, y = 1238, z = 7},
{x = 1103, y = 1238, z = 7},
{x = 1102, y = 1239, z = 7}
}
}
entry2 =
({
{x = 1105, y = 1230, z = 7},
{x = 1107, y = 1230, z = 7},
{x = 1109, y = 1230, z = 7},
{x = 1111, y = 1230, z = 7}
},
destination2 =
{
{x = 1101, y = 1232, z = 7},
{x = 1102, y = 1232, z = 7},
{x = 1103, y = 1232, z = 7},
{x = 1102, y = 1231, z = 7}
}
})
local conditionBlue = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, 1800 * 1000)
addOutfitCondition(conditionBlue, {lookType = 152, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87})
local conditionRed = createConditionObject(CONDITION_OUTFIT)
setConditionParam(conditionRed, CONDITION_PARAM_TICKS, 1800 * 1000)
addOutfitCondition(conditionRed, {lookType = 143, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94})
config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 1946) then
if(config.daily) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
else
doTransformItem(item.uid, item.itemid - 1)
end
return true
end
if(item.itemid ~= 1945) then
return true
end
local players = {}
for _, position in ipairs(config.entry) do
local pid2 = getTopCreature(position).uid
if(pid == 0 or not isPlayer(pid) or getPlayerLevel(pid) < config.level) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
return true
end
table.insert(players, pid)
local players2 = ({})
for _, position in ipairs(config.entry2) do
local pid = getTopCreature(position).uid
if(pid == 0 or not isPlayer(pid) or getPlayerLevel(pid) < config.level) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
return true
end
table.insert(players2, pid)
end
for i, pid in ipairs(players) do
doSendMagicEffect(config.entry, CONST_ME_POFF)
doTeleportThing(pid, config.destination, false)
doPlayerSetTown(pid, 2)
doAddCondition(pid, conditionBlue)
for i, pid2 in ipairs(players) do
doSendMagicEffect(config.entry2, CONST_ME_POFF)
doTeleportThing(pid2, config.destination2, false)
doPlayerSetTown(pid2, 2)
doAddCondition(pid2, conditionRed)
doSendMagicEffect(config.destination, 48)
doSendMagicEffect(config.destination2, 48)
doBroadcastMessage("-WAR TEAM EVENT-: The 2 teams already are being prepared for the war, they have one minute and a half (90 seg) to enlist.")
end
doTransformItem(item.uid, item.itemid + 1)
return true
end