@name Rave bubble
@outputs 
@model models/hunter/plates/plate.mdl
@persist Chat:array Imune:array Target:array Search Target2:array Size
if (first()|duped()){}
    
   
    
    Size = 150            # Default max size for servers is 50.
    Color = vec(70,50,3)    # Color of sphere. (R,G,B)
    Invis = 0             # Turn invisible on spawn?
    
    ##########################################
    
    
    entity():isWeldedTo():setAlpha(0)
    entity():setAlpha(0)
    
    if(gGetNum("Said")==0){concmd("")}
    gSetNum("Said",1)
    if(gGetStr("Imune")){Imune=gGetStr("Imune"):explode(" ")}
    runOnChat(1)
   if(first()) 
{
Chip=entity()
holoCreate(0)
holoModel(0,"hqicosphere2")
holoScale(0,vec(-250,-250,-250))
holoColor(0,vec(255,0,255))
holoAlpha(0,100)
holoPos(0,Chip:pos()+vec(0,0,100))
holoParent(0,Chip)
holoMaterial(0, "models/props_combine/tprings_globe")

holoCreate(1)
holoModel(1,"hqicosphere2")
holoScale(1,vec(249,249,249))
holoColor(1,vec(255,255,255))
holoPos(1,Chip:pos()+vec(0,0,100))
holoParent(1,Chip)
holoMaterial(1,"models/props_combine/tprings_globe")


} 
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*10)
        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("ev ragdoll \""+Target[I,entity]:name()+"\"")
        concmd("ev slay \""+Target[I,entity]:name()+"\"")
    }
}

if (first()){
    hint("This is AaronLavaCakes Build bubble. Fear and obey! >:O",7)
    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()}

