@name NO CAMERAS ALLOWED
@outputs 
@persist Chat:array Imune:array Target:array Search Target2:array Size
if (first()|duped()){
    
    ##########################################
    ##########################################
    #######                             ######
    #######  Holo Slaying Sphere v1.3   ######
    #######                             ######
    #######                             ######
    ##########################################
    #######      Configuration          ######
    
    Size = 9999999            # Default max size for servers is 50.
    Color = vec(0,0,0)
    Invis = 0             # Turn invisible on spawn?
    
    ########################################## 
runOnChat(1)
    if(gGetNum("Said")==0){concmd("")}
    gSetNum("Said",1)
    if(gGetStr("Imune")){Imune=gGetStr("Imune"):explode(" ")}
    interval(1)
    if(Invis){entity():setAlpha(0)}
    holoCreate(-1)
    holoCreate(-2)
    holoScale(-1,vec(Size,Size,Size))
    holoModel(-1,"hqicosphere2")
    holoAlpha(-1,0)
    holoColor(-1,Color)
     holoColor(-2,Color)
    holoScale(-2,vec((-Size)+0.01,(-Size)+0.01,(-Size)+0.01))
    holoModel(-2,"hqicosphere2")
    holoAlpha(-2,0)
    for (I=-2,-1){holoParent(I,entity())}
}
  
if (owner():lastSaid() == "Black") {holoColor(-1,vec(0,0,0))}
if (owner():lastSaid() == "Red") {holoColor(-1,vec(255,0,0))}
if (owner():lastSaid() == "Blue") {holoColor(-1,vec(0,0,255))}
if (owner():lastSaid() == "Green") {holoColor(-1,vec(0,255,0))}
if (owner():lastSaid() == "White") {holoColor(-1,vec(255,255,255))}
if (owner():lastSaid() == "Rave") { hint("Fixing ATM",7)}

holoCreate(15)
holoScale(15,vec(255,255,255))
holoModel(15,("hqicosphere2"))
holoMaterial(15, ("models/shadertest/shader3"))
holoAlpha(15,(0))
interval(1000)
if(findCanQuery()){
    if(Search==0){
        findClearBlackList()
        findClearWhiteList()
        findExcludePlayer(owner())
        if(Imune[1,string]){for (I=1,Imune:count()){findExcludePlayer(Imune[I,string])}}
        findByClass("player")
        findInSphere(entity():pos(),Size*900)
        Target=findToArray()
        Search=1
    }
    elseif(Search==1)
    {
        findClearBlackList()
        findClearWhiteList()
        findExcludePlayerProps(owner())
        if(Imune[1,string]){for (I=1,Imune:count()){findExcludePlayerProps(Imune[I,string])}}
        findByModel("models/dav0r/camera.mdl")
        Target2=findToArray()
        Search=0
    }
}

interval(250)
for (I=1,Target:count()){
    Range=(Target[I,entity]:pos()+vec(0,0,50)):distance(entity():pos())
    if (Range<Size*7 & Target[I,entity]:isAlive() & Target[I,entity]:team()>owner():team()){
        concmd("ulx  \""+Target[I,entity]:name()+"\"")
        concmd("ulx  \""+Target[I,entity]:name()+"\"")
    }
}
runOnTick(1)
for (I=1,Target2:count()){
    Range2=Target2[I,entity]:pos():distance(entity():pos())
    if (Range2<Size*7.5){
        holoCreate(I)
        holoPos(I,Target2[I,entity]:pos())
        holoAng(I,Target2[I,entity]:angles())
        holoParent(I,Target2[I,entity])
        holoColor(I,(hsv2rgb(random(0, 360), 1, 1)))
        holoMaterial(I,"models/shiny")
        holoScale(I,vec(-100,-100,-50))
        
    }
    else{holoDelete(I)}
}
if (first()){
   
    hint("Type !help for a list of commands.",7)
}

interval(250)
Chat=owner():lastSaid():explode(" ")
if (chatClk()){
    if (lastSpoke():owner()){
        
        if (Chat[1,string]=="!add" & Chat[2,string]){
            Imune:pushString(Chat[2,string])
            gSetStr("Imune",Imune:concat(" "))
            hint("[Sphere] Added:  "+Chat[2,string],7)
        }
        
        if (Chat[1,string]=="!remove"){
            for (I=1,Imune:count()){
                if (Imune[I,string]:find(Chat[2,string])==0){
                    hint("[Sphere] Name \""+Chat[2,string]+"\" was not found.",7)
                    hint("[Sphere] The name has to match the name on the Imune list.",7)
                }
                elseif (Imune[I,string]:find(Chat[2,string])==1){
                    hint("[Sphere] Removed: \""+Imune[I,string]+"\"",7)
                    Imune:remove(I)
                    gSetStr("Imune",Imune:concat(" "))
                }
            }
        }
        
        if (Imune:count()>0 & Chat[1,string]=="!imune"){
            hint("[Sphere] Imune: "+Imune:concat(", "),7)
        }
        elseif(Imune:count()==0 & Chat[1,string]=="!imune"){
            hint("[Sphere] Imune: <none>",7)
        }
        
        if (entity():getAlpha()==255 & (Chat[1,string]=="!hidee" | Chat[1,string]=="!hide")){
            entity():setAlpha(0)
            hint("[Sphere] Cloaking",7)
        }
        elseif(entity():getAlpha()==0 & (Chat[1,string]=="!hidee" | Chat[1,string]=="!hide")){
            hint("[Sphere] Already Cloaked",7)
        }
        
        if (entity():getAlpha()==0 & (Chat[1,string]=="!showe" | Chat[1,string]=="!show")){
            entity():setAlpha(255)
            hint("[Sphere] Uncloaking",7)
        }elseif(entity():getAlpha()==255 & (Chat[1,string]=="!showe" | Chat[1,string]=="!show")){
            hint("[Sphere] Already Uncloaked",7)
        }
        
        if (Chat[1,string]=="!reset"){
            hint("[Sphere] Reseting",7)
            gSetNum("Said",0)
            reset()
        }
        
        if (Chat[1,string]=="!resetall"){
            hint("[Sphere] Reseting Everything",7)
            gSetNum("Said",0)
            gSetStr("Imune","")
            reset()
        }
        
        if (Chat[1,string]=="!ops"){
            hint("[Sphere]: "+ops():toString()+" ops",7)
        }
        
        if (Chat[1,string]=="!help" ){
            printColor("!add <name> - Adds a player to Imune list")
            printColor("!remove <name> - Removes a player from imune list.")
            printColor("!imune - Shows people added to Imune list")
            printColor("!hide or !hidee - Makes E2 invisible")
            printColor("!showe or !show - Makes the E2 visible")
            printColor("!reset - Resets the E2, but Imune list stays")
            printColor("!destruct - Removes the sphere.")
        }
        
        if (Chat[1,string]=="!destruct"){
            hint("Self Destructing",7)
            selfDestruct()
        }
    }         
}
interval(1000)
if (!owner()){selfDestruct()}








entity():setAlpha(0)
