@name Cloak And Mass Calculator
@inputs On Cloak MassScan
@outputs Mass
@persist Objects:array Setup Color:array Count Alpha:array
@persist Mass Stop C P K P1 K1
if (On) {
interval(20)
Origin = entity():pos()
findInSphere(Origin,1500)
findExcludePlayerProps("*")
findAllowPlayerProps(entity():owner())
findIncludePlayerProps(entity():owner())  
findSortByDistance(Origin)
Objects = findToArray()
if (!Setup) {
Setup = 1
C = 1
K = 1
P = 1
Mass = 0
Count = Objects:count()
Color = array()
Alpha = array()
}
if (C!=0) {
Colors = Objects:entity(C):getColor()
Alpha1 = Objects:entity(C):getAlpha()
Color:setVector(C,Colors)
Alpha:setNumber(C,Alpha1)
if (C==Count) {C = 0}
C += 1
}
if (Cloak) {
Distance = Objects:entity(K):pos():distance(entity():pos())
if (Distance < 1000) {Objects:entity(K):setAlpha(0)}
if (entity():getAlpha()!=0) {entity():setAlpha(0)}
#if (Distance > 1000) {Objects:entity(K):setAlpha(Alpha:number(K))}
if (Distance > 1000) {Objects:entity(K):setAlpha(255)}
if (K==Count) {K = 0}
K +=1
}
if (!Cloak) {
K = 0
#Objects:entity(K):setAlpha(Alpha:number(K))
Objects:entity(K1):setAlpha(255)
entity():setAlpha(255)
if (K1==Count) {K1 = 0}
K1 += 1
}
if (MassScan) {
if (Distance < 1000) {Objects:entity(P):setColor(vec(0,0,255))}
if (P!=0 & !Stop) {Mass += Objects:entity(P):mass()}
#if (Distance > 1000) {Objects:entity(P):setColor(Color:vector(P))}
if (Distance > 1000) {Objects:entity(P):setColor(255,255,255)}
if (P==Count) {P = 0 Stop = 1}
P +=1
}
if (!MassScan) {
Mass = 0
Stop = 0
P = 0
#Objects:entity(P):setColor(Color:vector(P))
Objects:entity(P1):setColor(255,255,255)
if (P1==Count) {P = 0}
P1 +=1
}
} else {Setup = 0}
