@name DoorOwner
@inputs 
@outputs Open1
@persist [Players AllowedPlayers]:array Closest:entity
@trigger 
interval(1)

if(first()){
    Players=players()
 #   runOnChat(1)
}


for(I=1,Players:count()){
    if(entity():pos():distance(Closest:pos()) > entity():pos():distance(Players[I,entity]:pos())){
        Closest = Players[I,entity]
        }
}

if(owner():lastSaid():lower():find("!add ") &chatClk(owner())){
    hideChat(1)
AllowedPlayers[AllowedPlayers:count()+1,entity] = findPlayerByName((owner():lastSaid():explode("!add "))[2,string]) 
print(AllowedPlayers[AllowedPlayers:count(),entity]:name()+" added to door allow list")
}

if(entity():pos():distance(Closest:pos())>150){Closest=noentity()}

Open1 = 0
for(I=1,AllowedPlayers:count()){
if(Closest==AllowedPlayers[I,entity]){
Open1=1 
}
}
