@name AutoDoor New
@outputs Door Door2
@persist P:array Distance:array A:array Target:entity D Z
@trigger
if(first()){F = vec(255,255,0) B = vec(0,0,255)}
runOnChat(1)
runOnTick(1)
#Distance
D = 60
#
S = owner():lastSaid():explode(" ")
if(S[1,string]=="/add" & chatClk(owner())){
    TP = findPlayerByName(S[2,string])
    hideChat(1)
    if(TP:isPlayer()){
        Target = TP
        P:pushEntity(TP) 
           }
    
}
if(S[1,string]=="/remove"& chatClk(owner())){
    TP = findPlayerByName(S[2,string])
    hideChat(1)
    if(TP:isPlayer()){
        while(Z < 20){
        if(TP == P[Z,entity])
        {
        P:remove(Z)
        }
        Z++
}
}
Z = 0
}
Distance1 = round(((entity():pos() - P[1,entity]:pos()):length()))
Distance2 = round(((entity():pos() - P[2,entity]:pos()):length()))
Distance3 = round(((entity():pos() - P[3,entity]:pos()):length()))
Distance4 = round(((entity():pos() - P[4,entity]:pos()):length()))
Distance5 = round(((entity():pos() - P[5,entity]:pos()):length()))
Distance6 = round(((entity():pos() - P[6,entity]:pos()):length()))
Distance7 = round(((entity():pos() - P[7,entity]:pos()):length()))
Distance8 = round(((entity():pos() - P[8,entity]:pos()):length()))
Distance9 = round(((entity():pos() - P[9,entity]:pos()):length()))



if(Distance1<D){Door = 1
}elseif(Distance2<D){Door = 1
}elseif(Distance3<D){Door = 1
}elseif(Distance4<D){Door = 1
}elseif(Distance5<D){Door = 1
}elseif(Distance6<D){Door = 1
}elseif(Distance7<D){Door = 1
}elseif(Distance8<D){Door = 1
}elseif(Distance9<D){Door = 1
}
else{Door = 0}
if(Door==1){
Door2=0}
if(Door==0){
Door2=1
}
