@name Interactive Targeting
@inputs 
@outputs T1 T2 T3 T:array Play:array
@persist Players:array Chat1:string Last Dist:array Passoff:entity Targets:array
@persist Play:array T:array
Time = 125
interval(Time)
gSetGroup("Finder")
entity():setColor(0,140,255)
Command = "EMP"
Menu = "menu"
Attack = "get" 
List = "list"
P1 = "1"
P2 = "2"
P3 = "3"
P4 = "4"
P5 = "5"
P6 = "6"
P7 = "7"
P8 = "8"
P9 = "9"
P10 = "0"
PKC = "PK"
NKC = "NK"
S = " "
B = " "


Chat = entity():owner():lastSaid()
K = (curtime() - entity():owner():lastSaidWhen()) < Time/1000 
C = Chat:find(Command)
M = Chat:find(Menu)
A = Chat:find(Attack)
L = Chat:find(List)
C1 = Chat:find(P1)
C2 = Chat:find(P2)
C3 = Chat:find(P3)
C4 = Chat:find(P4)
C5 = Chat:find(P5)
C6 = Chat:find(P6)
C7 = Chat:find(P7)
C8 = Chat:find(P8)
C9 = Chat:find(P9)
C10 = Chat:find(P10)
PK = Chat:find(PKC)
NK = Chat:find(NKC)



Origin = entity():owner():pos()
findInSphere(Origin,1000000)
findSortByDistance(Origin)
findIncludeClass("player")
Play = findToArray()



if (C&M&K) { 
Players = Play:clone()


Concat = array()
if (Players:count()>0) {
Concat:setString(1,"Targets: ")
Concat:setString(2,P1+S)
Concat:setString(3,Players:entity(1):name())
}
if (Players:count()>1) {
Concat:setString(4,B+P2+S)
Concat:setString(5,Players:entity(2):name())
}
if (Players:count()>2) {
Concat:setString(6,B+P3+S)
Concat:setString(7,Players:entity(3):name())
}
if (Players:count()>3) {
Concat:setString(8,B+P4+S)
Concat:setString(9,Players:entity(4):name())
}
if (Players:count()>4) {
Concat:setString(10,B+P5+S)
Concat:setString(11,Players:entity(5):name())
}
if (Players:count()>5) {
Concat:setString(12,B+P6+S)
Concat:setString(13,Players:entity(6):name())
}
if (Players:count()>6) {
Concat:setString(14,B+P7+S)
Concat:setString(15,Players:entity(7):name())
}
if (Players:count()>7) {
Concat:setString(16,B+P8+S)
Concat:setString(17,Players:entity(8):name())
}
if (Players:count()>8) {
Concat:setString(18,B+P9+S)
Concat:setString(19,Players:entity(9):name())
}
if (Players:count()>9) {
Concat:setString(20,B+P10+S)
Concat:setString(21,Players:entity(10):name())
}
}

if (C & M & K) {print(Concat:concat())}

if (C & A & K) {
Targets = array()
E = 1
if (C1) {Targets:setEntity(E,Players:entity(1)) E+=1}
if (C2) {Targets:setEntity(E,Players:entity(2)) E+=1}
if (C3) {Targets:setEntity(E,Players:entity(3)) E+=1}
if (C4) {Targets:setEntity(E,Players:entity(4)) E+=1}
if (C5) {Targets:setEntity(E,Players:entity(5)) E+=1}
if (C6) {Targets:setEntity(E,Players:entity(6)) E+=1}
if (C7) {Targets:setEntity(E,Players:entity(7)) E+=1}
if (C8) {Targets:setEntity(E,Players:entity(8)) E+=1}
if (C9) {Targets:setEntity(E,Players:entity(9)) E+=1}
if (C10) {Targets:setEntity(E,Players:entity(10)) E+=1}
}
if (Targets:count()==0) {Error1 = "No Targets Spesified"} else {Error1 = ""}
if (C & L & K) {print(Targets:concat()+Error1)}

Count = Targets:count()
D1=D2=D3=D4=D5=D6=D7=D8=D9=D10=1000000
Dist = array()
if (Count>0) {D1 = Targets:entity(1):pos():distance(Origin)} 
if (Count>1) {D2 = Targets:entity(2):pos():distance(Origin)} 
if (Count>2) {D3 = Targets:entity(3):pos():distance(Origin)} 
if (Count>3) {D4 = Targets:entity(4):pos():distance(Origin)} 
if (Count>4) {D5 = Targets:entity(5):pos():distance(Origin)} 
if (Count>5) {D6 = Targets:entity(6):pos():distance(Origin)} 
if (Count>6) {D7 = Targets:entity(7):pos():distance(Origin)} 
if (Count>7) {D8 = Targets:entity(8):pos():distance(Origin)} 
if (Count>8) {D9 = Targets:entity(9):pos():distance(Origin)} 
if (Count>9) {D10 = Targets:entity(10):pos():distance(Origin)} 
Dist:setNumber(1,D1)
Dist:setNumber(2,D2)
Dist:setNumber(3,D3)
Dist:setNumber(4,D4)
Dist:setNumber(5,D5)
Dist:setNumber(6,D6)
Dist:setNumber(7,D7)
Dist:setNumber(8,D8)
Dist:setNumber(9,D9)
Dist:setNumber(10,D10)
K1 = Dist:minIndex()
Dist:remove(K1)
K2 = Dist:minIndex()
Dist:remove(K2)
K3 = Dist:minIndex()

T1 = Targets:entity(K1):id()
T2 = Targets:entity(K2):id()
T3 = Targets:entity(K3):id()

T = array()
T:setEntity(1,entity(K1))
T:setEntity(2,entity(K2))
T:setEntity(3,entity(K3))

if (C & K & PK) {gSetNum("Kill",1)}
if (C & K & NK) {gSetNum("Kill",0)}








