@name Holographic ESP
@inputs
@outputs [Obj HoloArray]:array C ObjC Data:string
@persist Data:string C D [Obj HoloArray]:array HoloCount State
@trigger
@model models/Items/AR2_Grenade.mdl
#By Captain Maim STEAM_0:1:8017844
#interactive anything finder, stand still and look around for + which mark objects.
Time=50/1000
interval(Time*1000)
E=entity()
O=owner()
Blue=vec(0,0,1)*255
if(first()){
    State=1
    runOnChat(1)
    #timer("delay",10000)
    HoloArray=array()
    
    function entity:holoTarget(N:number,Color:vector){ 
        Material="models/props_combine/combine_interface_disp"
        Dir=This:pos()-O:shootPos()
        Dist=25
        
        if(!holoEntity(N)){
            holoCreate(N)
            holoCreate(N+1)
            holoScale(N,vec(3,0.1,0.1)*0.05)
            holoScale(N+1,vec(0.1,3,0.1)*0.05)
            holoColor(N,Color)
            holoColor(N+1,Color)
            holoVisible(N,players(),0)
            holoVisible(N+1,players(),0)
            holoVisible(N,O,1)
            holoVisible(N+1,O,1)
            holoMaterial(N,Material)
            holoMaterial(N+1,Material)
            holoDisableShading(N+1,1) #makes it glow in the dark?
            holoDisableShading(N,1) #makes it glow in the dark?
            holoShadow(N+1,0)
            holoShadow(N,0)
            HoloCount++
            HoloArray[N,entity]=holoEntity(N)
            HoloArray[N+1,entity]=holoEntity(N+1)
            
        }   
        Alpha=clamp(255-This:pos():distance(O:pos())/100,64,255)
                
        holoAlpha(N,Alpha)
        holoAlpha(N+1,Alpha)
        holoPos(N,O:shootPos()+O:vel()*5*Time+Dir:normalized()*Dist)
        holoAng(N,Dir:toAngle()+ang(90,0,0))
        holoPos(N+1,O:shootPos()+O:vel()*5*Time+Dir:normalized()*Dist)
        holoAng(N+1,Dir:toAngle()+ang(90,0,0))
    }
}
Chat=O:lastSaid()
Cmd="ESP"
Find="find"
Hunt="hunt"
On1="on"
On0="off"
Brk="<"

CMD=Chat:find(Cmd)
FIND=Chat:find(Find)
HUNT=Chat:find(Hunt)
BRK=Chat:find(Brk)
ON1=Chat:find(On1)
ON0=Chat:find(On0)

if(chatClk(O)&CMD){
    hideChat(1)
    if(BRK&(FIND|HUNT)){
        findClearWhiteList()
        findClearBlackList()

        Data=Chat:explode(Brk)[2,string]
        holoDeleteAll()
        if(Data=="e2"){Data="wire_expression2"}
        if(HUNT){State=2 print("Hunting: "+Data)}
        if(FIND){State=1 print("Finding Class: "+Data)}
           
    }
}else{hideChat(0)}
if(first()){Data="wire_expression2"}

if(findCanQuery()&!first()){
    
    if(State==1){
        findInSphere(entity():pos(),20000)
        findClipToClass(Data)
        findExcludeEntities(HoloArray)
        Obj=findToArray()
    }
    if(State==2){
        Obj=array()
        Obj:pushEntity(findPlayerByName(Data)) 
    }
    #findExcludeClass("hologram")
    ObjC=Obj:count()
    #holoDeleteAll()
}

if(C>Obj:count()){C=1}

while(C<=Obj:count()&perf()){
    Obj[C,entity]:holoTarget(C*2,Blue)
    C++
}


if((HoloCount>Obj:count())){
    #timer("delay",10000)
    while(D<Obj:count()&perf()){
        holoDelete(D*2)
        holoDelete(D*2+1)
        HoloArray:remove(D*2)
        HoloArray:remove(D*2+1)
        D++
    }    
}
