local config = {
invisfloor = 1, --will teleport to this level of "z"
groupaccess = 0, --set if you want a minimun group access
denied = "You are not authorized to use this"
}
local pos = getPlayerPosition(cid)
function onEquip(cid, item, slot)
if getPlayerGroupId(cid) < config.groupaccess then
doPlayerSendCancel(cid, denied)
return false
end
if pos.z == config.invisfloor then
print('Player: '..getCreatureName(cid)..' has tried to equip a broom at the highest altitude... [X= '..pos.x..' Y= '..pos.y..' Z= '..pos.z.. ']')
doPlayerSendCancel(cid, 'Please contact a staff member!')
return false
end
doTeleportThing(cid, {x=pos.x, y=pos.y, z=config.invisfloor}, false)
doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
return true
end
function onDeEquip(cid, item, slot)
if getPlayerGroupId(cid) < config.groupaccess then
doPlayerSendCancel(cid, denied)
return false
end
if pos.z ~= config.invisfloor then
print('Player: '..getCreatureName(cid)..' has tried to deEquip a broom in a nonflying zone... [X= '..pos.x..' Y= '..pos.y..' Z= '..pos.z.. ']')
doPlayerSendCancel(cid, 'Please contact a staff member!')
return false
end
doTeleportThing(cid, {x=pos.x, y=pos.y, z=1}, false)
doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
return true
end