@name Nearest Player to Entity Finder
#@inputs Tar:entity 
@inputs On Flags:array
#@outputs Player:entity
@outputs P Self T
@persist Player:entity P
@persist Self A B C D
gSetGroup("CTF")
interval(500)
if (!On) {
Self = 0 A = 0 B = 0 C = 0 D = 0
gDeleteNum("A")
gDeleteNum("B")
gDeleteNum("C")
gDeleteNum("D")
}
A = gGetNum("A")
B = gGetNum("B")
C = gGetNum("C")
D = gGetNum("D")
if (On & Self==0 & A==0) {Self = 1 A = 1}
if (On & Self==0 & B==0) {Self = 2 B = 2}
if (On & Self==0 & C==0) {Self = 3 C = 3}
if (On & Self==0 & D==0) {Self = 4 D = 4}
gSetNum("A",A)
gSetNum("B",B)
gSetNum("C",C)
gSetNum("D",D)
Off=0
if(Off){
if (Self==1) {T = gGetNum("N1")}
if (Self==2) {T = gGetNum("N2")}
if (Self==3) {T = gGetNum("N3")}
if (Self==4) {T = gGetNum("N4")}
Tar = entity(T)
}
if (Self==1) {Tar=Flags:entity(1)}
if (Self==2) {Tar=Flags:entity(2)}
if (Self==3) {Tar=Flags:entity(3)}
if (Self==4) {Tar=Flags:entity(4)}
T=Tar:id()
interval(findUpdateRate()*3)
findInSphere(Tar:pos(),120)
findClipToClass("player")
Player = find()
P = Player:id()
Color = Tar:getColor()
entity():setColor(Color)
if (Self==1) {gSetNum("T1a",P)}
if (Self==2) {gSetNum("T2a",P)}
if (Self==3) {gSetNum("T3a",P)}
if (Self==4) {gSetNum("T4a",P)}
