function onUse(cid, item, fromPosition, itemEx, toPosition)
local g = getCreaturePosition(cid)
local amountOfPlayers = 10
local teleport = {x = 999, y = 999, z = 999}
if getThingFromPos({x = g.x, y = g.y+1, z = g.z, stackpos = 253}).itemid == (1945 or 1946) then
local centerPos = {x = g.x, y = g.y-4, z = g.z, stackpos = 253}
local rangeX = 2
local rangeY = 2
local p = getSpectators(centerPos, rangex, rangey)
for v, k in pairs(p)
if(g.x > centerPos.x+1 or g.y > centerPos.y+1) then
table.remove(p, v)
end
end
local players = #p
if players >= amountOfPlayers then
for i = 1, players do
doTeleportThing(p, teleport)
doSendMagicEffect(getCreaturePosition(p), CONST_ME_TELEPORT)
end
else
doPlayerSendTextMessage(cid, 25, "You need atleast 10 players to use lever.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
elseif getThingFromPos({x = g.x+1, y = g.y+1, z = g.z, stackpos = 253}).itemid == (1945 or 1946) then
local centerPos = {x = g.x-1, y = g.y-4, z = g.z, stackpos = 253}
local rangeX = 2
local rangeY = 2
local p = getSpectators(centerPos, rangex, rangey)
for v, k in pairs(p)
if(g.x > centerPos.x+1 or g.y > centerPos.y+1) then
table.remove(p, v)
end
end
local players = #p
if players >= amountOfPlayers then
for i = 1, players do
doTeleportThing(p, teleport)
doSendMagicEffect(getCreaturePosition(p), CONST_ME_TELEPORT)
end
else
doPlayerSendTextMessage(cid, 25, "You need atleast 10 players to use lever.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
elseif getThingFromPos({x = g.x-1, y = g.y+1, z = g.z, stackpos = 253}).itemid == (1945 or 1946) then
local centerPos = {x = g.x+1, y = g.y-4, z = g.z, stackpos = 253}
local rangeX = 2
local rangeY = 2
local p = getSpectators(centerPos, rangex, rangey)
for v, k in pairs(p)
if(g.x > centerPos.x+1 or g.y > centerPos.y+1) then
table.remove(p, v)
end
end
local players = #p
if players >= amountOfPlayers then
for i = 1, players do
doTeleportThing(p, teleport)
doSendMagicEffect(getCreaturePosition(p), CONST_ME_TELEPORT)
end
else
doPlayerSendTextMessage(cid, 25, "You need atleast 10 players to use lever.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
return true
end
return true
end