@name AutoDoor
@inputs  
@outputs Door
@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)
interval(100)
#Distance
D = 75
#
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()))
Distance10 = round(((entity():pos() - P[10,entity]:pos()):length()))
Distance11 = round(((entity():pos() - P[11,entity]:pos()):length()))
Distance12 = round(((entity():pos() - P[12,entity]:pos()):length()))
Distance13 = round(((entity():pos() - P[13,entity]:pos()):length()))
Distance14 = round(((entity():pos() - P[14,entity]:pos()):length()))
Distance15 = round(((entity():pos() - P[15,entity]:pos()):length()))
Distance16 = round(((entity():pos() - P[16,entity]:pos()):length()))
Distance17 = round(((entity():pos() - P[17,entity]:pos()):length()))
Distance18 = round(((entity():pos() - P[18,entity]:pos()):length()))
Distance19 = round(((entity():pos() - P[19,entity]:pos()):length()))
Distance20 = round(((entity():pos() - P[20,entity]:pos()):length()))

Door = 48
if(Distance1<D){Door = 3
}elseif(Distance2<D){Door = 3
}elseif(Distance3<D){Door = 3
}elseif(Distance4<D){Door = 3
}elseif(Distance5<D){Door = 3
}elseif(Distance6<D){Door = 3
}elseif(Distance7<D){Door = 3
}elseif(Distance8<D){Door = 3
}elseif(Distance9<D){Door = 3
}elseif(Distance10<D){Door = 3
}elseif(Distance11<D){Door = 3
}elseif(Distance12<D){Door = 3
}elseif(Distance13<D){Door = 3
}elseif(Distance14<D){Door = 3
}elseif(Distance15<D){Door = 3
}elseif(Distance16<D){Door = 3
}elseif(Distance17<D){Door = 3
}elseif(Distance18<D){Door = 3
}elseif(Distance19<D){Door = 3
}elseif(Distance20<D){Door = 3
}
