CONST_FLYVOID = 460
IGNORED = {6495,7096,7099,5167,5162,5163,405,7100,
5315,5521,5316,5193,5192,5191,945,5048,923,950,951,
952,953,3623,954,955,949,9101,3352,9106,9103,1524,
1111,437,433,443,434,442,436,445,941,444,435,943,
1027,925,930,926,928,922,921,1112,406,904,931,934,
932,933,5319} --- Config here
up = {}
down = {}
fly = {}
fly.win = function(cid)-- Script by mock
setPlayerStorageValue(cid, 102015,1)
doPlayerSendTextMessage(cid,27,'Vocę já pode começar a voar.')
end
fly.add = function(cid)-- Script by mock
if getPlayerStorageValue(cid, 102015) == -1 or getPlayerStorageValue(cid,13241) == 1 then
return false
end
if getPlayerStorageValue(cid, 102059) <= 0 then
setPlayerStorageValue(cid, 102059,1)
doChangeSpeed(cid, 390)
doPlayerSendTextMessage(cid,27,'Fale \'up\' e \'down\'.' )
return true
else
doPlayerSendTextMessage(cid,27, "Vocę ja esta voando.")
return false
end
end
function doSetItemActionId(uid,aid)
doItemSetAttribute(uid,'aid',aid)
end
function hasSqm(pos)-- by Mock
return getTileThingByPos({x=pos.x,y=pos.y,z=pos.z,stackpos=0}).itemid ~= 0
end
function isWalkable(pos, creature, proj, pz)-- by Nord
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
pos.stackpos = i
local tile = getTileThingByPos(pos)
if tile.itemid ~= 0 and not isCreature(tile.uid) then
if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
return false
end
end
end
return true
end
fly.using=function(cid)-- Script by mock
return getPlayerStorageValue(cid, 102059) > 0
end
fly.logout = function(cid)-- Script by mock
if fly.using(cid) then
local p = getCreaturePosition(cid)
setPlayerStorageValue(cid, 102010,1)
setPlayerStorageValue(cid, 102011,p.x)
setPlayerStorageValue(cid, 102012,p.y)
setPlayerStorageValue(cid, 102013,p.z)
deletarEmVolta(p)
fly.del(cid)
end
return true
end
fly.login = function(cid)-- Script by mock
if getPlayerStorageValue(cid, 102010) ~= -1 then
setPlayerStorageValue(cid, 102010,-1)
local p = {}
p.x = getPlayerStorageValue(cid, 102011)
p.y = getPlayerStorageValue(cid, 102012)
p.z = getPlayerStorageValue(cid, 102013)
if not checkAround(p) then
fly.add(cid)
down.gerarEmVolta(p)
doTeleportThing(cid,p)
end
end
return true
end
fly.die = function(cid)-- Script by mock
if fly.using(cid) then
local p = getCreaturePosition(cid)
setPlayerStorageValue(cid, 102011,-1)
setPlayerStorageValue(cid, 102012,-1)
setPlayerStorageValue(cid, 102013,-1)
deletarEmVolta(p)
fly.del(cid)
end
return true
end
fly.del = function(cid)-- Script by mock
if getPlayerStorageValue(cid, 102059) > 0 then
if getSqmId(getCreaturePosition(cid)).itemid == CONST_FLYVOID then
return false
end
setPlayerStorageValue(cid, 102059,-1)
return true
end
end
function hasSqm2(pos)-- Script by mock
local f = getTileThingByPos(pos)
if f.itemid ~= 0 and f.itemid ~= 1 and (not isWalkable(pos) and not isInArray(IGNORED,f.itemid)) then
return true
end
return false
end
function hasSqm3(pos)-- Script by mock
local f = getTileThingByPos(pos)
if f.itemid ~= 0 and f.itemid ~= 1 and f.itemid ~= CONST_FLYVOID and not isInArray(IGNORED,f.itemid) then
return true
end
return false
end
function deletar(pos)-- Script by mock
if hasSqm(pos) then
local sqm = getSqmId(pos)
if sqm.itemid == CONST_FLYVOID then
doRemoveItem(sqm.uid,1)
end
end
end
function deletarEmVolta(pos)
for x=-1,1 do
for y=-1,1 do
deletar({x=pos.x+x,y=pos.y+y,z=pos.z})
end
end
end
function checkAround(pos)-- Script by mock
for x=-1,1 do
for y=-1,1 do
if hasSqm2({x=pos.x+x,y=pos.y+y,z=pos.z}) then
return true
end
end
end
return false
end
function fly.checkAround(pos)-- Script by mock
local n = 0
for x=-1,1 do
for y=-1,1 do
local g = getTileThingByPos({x=pos.x+x,y=pos.y+y,z=pos.z})
if g.itemid == CONST_FLYVOID then
n = n+1
end
if isCreature(getTopCreature({x=pos.x+x,y=pos.y+y,z=pos.z}).uid) then
return false
end
end
end
if n == 9 then
return true
end
return false
end
function up.checkAround(pos)-- Script by mock
for x=-1,1 do
for y=-1,1 do
local g = getTileThingByPos({x=pos.x+x,y=pos.y+y,z=pos.z})
if hasSqm3({x=pos.x+x,y=pos.y+y,z=pos.z}) or g.itemid == CONST_FLYVOID then
return true
end
end
end
return false
end
function down.checkAround(pos,f)-- Script by mock
for x=-1,1 do
for y=-1,1 do
local g = getTileThingByPos({x=pos.x+x,y=pos.y+y,z=pos.z})
if (not f and hasSqm2({x=pos.x+x,y=pos.y+y,z=pos.z})) or g.itemid == CONST_FLYVOID then
return true
end
end
end
return false
end
function gerarEmVolta(pos)-- Script by mock
local n = 30000
for x=-1,1 do
for y=-1,1 do
n =n+1
doItem({x=pos.x+x,y=pos.y+y,z=pos.z},n)
end
end
end
function doItem(pos,a,d)-- Script by mock
if not hasSqm2(pos) then
doCreateTile(CONST_FLYVOID,pos)
pos.stackpos = 0
local c = getTileThingByPos(pos)
doSetItemActionId(c.uid, a)
end
end
function getSqmId(pos,t)-- Script by mock
if hasSqm(pos) or t then
pos.stackpos = 0
local i = getTileThingByPos(pos)
return i
end
return nil
end
function down.doItem(pos,a)-- Script by mock
if not hasSqm(pos) then
doCreateTile(CONST_FLYVOID,pos)
pos.stackpos = 0
local c = getTileThingByPos(pos)
doSetItemActionId(c.uid, a)
end
end
function down.gerarEmVolta(pos)-- Script by mock
local n = 30000
for x=-1,1 do
for y=-1,1 do
n =n+1
down.doItem({x=pos.x+x,y=pos.y+y,z=pos.z},n)
end
end
end
function doCreateTile(id,pos) -- Script by mock
doAreaCombatHealth(0,0,pos,0,0,0,255)
doCreateItem(id,1,pos)
end