1
[Function] getSpectatorsFromArea ( Otx 2 y TFs 0.4) Dom Mar 29, 2020 11:30 pm
[Admin] God Maya
![[Admin] God Maya](https://2img.net/u/2712/30/40/04/avatars/1-92.jpg)
Administrador

Bueno aqui les traigo una funcion getSpectatorsFromArea es un funcion que verifica una area determinada sin hay jugadores dentro del area correspondiente dictada en la funcion
- Código:
function getSpectatorsFromArea(fromPosition, toPosition, multifloor)
local lenght = ((math.max(fromPosition.x, toPosition.x) - math.min(fromPosition.x, toPosition.x)) * 0.5) + 1
local width = ((math.max(fromPosition.y, toPosition.y) - math.min(fromPosition.y, toPosition.y)) * 0.5) + 1
if multifloor == true then
local ret = {}
for f = math.min(fromPosition.z, toPosition.z), math.max(fromPosition.z, toPosition.z) do
local tmp = getSpectators({x = math.min(fromPosition.x, toPosition.x) + lenght, y = math.min(fromPosition.y, toPosition.y) + width, z = f}, lenght, width, false)
for k = 1, #tmp do
table.insert(ret, tmp[k])
end
end
return ret
end
return getSpectators({x = math.min(fromPosition.x, toPosition.x) + lenght, y = math.min(fromPosition.y, toPosition.y) + width, z = fromPosition.z}, lenght, width, false)
end
La funcion funciona de esta manera multifloor multi subsuelos
- Código:
getSpectators({x = 100, y = 100, z = 7}, {x = 200, y = 200, z = 11}, true)
verificara piso 7 hasta el piso 11 siempre y cuando contega true al final
o tambien puede haceerlo que verifique solamente un solo piso o floor
- Código:
getSpectators({x = 100, y = 100, z = 7}, {x = 200, y = 200, z = 7}, false)
solo verificara un cuadrante plano o floor 7 seguido de false
como podrian utilizarlo en un scripts simple
- Código:
if getSpectators({x = 100, y = 100, z = 7}, {x = 200, y = 200, z = 11}, true) <= 10 then
......hacer algo
else
...... hacer algo
end
y listo
credito: Oneshot

![[Function] getSpectatorsFromArea ( Otx 2 y TFs 0.4) YNU5B25](https://i.imgur.com/yNU5B25.png)