@name Coolface Secret ChatV3
@persist Say1:string Say2:string Number STime Toggle Name:string Vec:vector Message:array
#by Talix
runOnTick(1)
runOnChat(1)
if(first()|duped()){
    hint("Made by Talix of Wiremod.com Forums",5)
    hint("VIEW CHAT FOR COMMANDS",7)
    printColor(vec(255,100,200),"$$ANNOUNCE",vec(255,255,255),": ''~c STR'' to talk secretly.")
    printColor(vec(255,100,200),"$$ANNOUNCE",vec(255,255,255),": ''~t'' to toggle this.")
    printColor(vec(255,100,200),"$$ANNOUNCE",vec(255,255,255),": ''~n NUM'' to change encryption level")
    Number=1
    gSetGroup("coolface")
    gShare(1)
    STime=0
}
if(chatClk(owner())){
    if(owner():lastSaid():left(3)=="~n ") {
        gSetVec("color"+Number:toString(),vec(255,100,200))
        gSetStr("name"+Number:toString(),"ANNOUNCE")
        gSetStr("message"+Number:toString(),"''"+owner():name()+"'' changed encryption number.")
        gSetNum("time"+Number:toString(),curtime())
        Number=owner():lastSaid():sub(4,owner():lastSaid():length()):toNumber()
        hideChat(1)
        print("New encryption number is: "+Number)
        gSetVec("color"+Number:toString(),vec(255,100,200))
        gSetStr("name"+Number:toString(),"ANNOUNCE")
        gSetStr("message"+Number:toString(),"''"+owner():name()+"'' joined your encryption number.")
        gSetNum("time"+Number:toString(),curtime())
    }
    elseif(owner():lastSaid()=="~t"){
        hideChat(1)
        if(Toggle==0){
            Toggle=1
            print("Toggle Private On")
        }
        else{
            Toggle=0
            print("Toggle Private Off")
        }
    }
    elseif(owner():lastSaid():left(3)=="~c "|Toggle==1)  {
        if(Toggle==0){
            Say1=owner():lastSaid():sub(4, owner():lastSaid():length())
        }
        else{
            Say1=owner():lastSaid()
        }
        hideChat(1)
        #numbers
        Say1=Say1:replace("1", " ) ")  
        Say1=Say1:replace("2", " ( ")  
        Say1=Say1:replace("3", " * ")  
        Say1=Say1:replace("4", " & ")  
        Say1=Say1:replace("5", " ^ ")  
        Say1=Say1:replace("6", " ^^ ")  
        Say1=Say1:replace("7", " $ ")  
        Say1=Say1:replace("8", " # ")  
        Say1=Say1:replace("9", " @ ")  
        Say1=Say1:replace("0", " ! ")  
        #loweralphabet
        Say1=Say1:replace("a", " "+(57*Number)+" ")  
        Say1=Say1:replace("b", " "+(42*Number)+" ")  
        Say1=Say1:replace("c", " "+(64*Number)+" ")  
        Say1=Say1:replace("d", " "+(43*Number)+" ")  
        Say1=Say1:replace("e", " "+(89*Number)+" ")  
        Say1=Say1:replace("f", " "+(54*Number)+" ")  
        Say1=Say1:replace("g", " "+(12*Number)+" ")  
        Say1=Say1:replace("h", " "+(44*Number)+" ")  
        Say1=Say1:replace("i", " "+(14*Number)+" ")  
        Say1=Say1:replace("j", " "+(78*Number)+" ")  
        Say1=Say1:replace("k", " "+(76*Number)+" ")  
        Say1=Say1:replace("l", " 0"+(8*Number)+" ")  
        Say1=Say1:replace("m", " "+(65*Number)+" ")  
        Say1=Say1:replace("n", " "+(49*Number)+" ")  
        Say1=Say1:replace("o", " "+(16*Number)+" ")  
        Say1=Say1:replace("p", " 0"+(1*Number)+" ")  
        Say1=Say1:replace("q", " "+(33*Number)+" ")  
        Say1=Say1:replace("r", " "+(40*Number)+" ")  
        Say1=Say1:replace("s", " "+(29*Number)+" ")  
        Say1=Say1:replace("t", " "+(55*Number)+" ")  
        Say1=Say1:replace("u", " "+(22*Number)+" ")  
        Say1=Say1:replace("v", " "+(11*Number)+" ")  
        Say1=Say1:replace("w", " 0"+(7*Number)+" ")  
        Say1=Say1:replace("x", " "+(45*Number)+" ")  
        Say1=Say1:replace("y", " "+(66*Number)+" ")  
        Say1=Say1:replace("z", " "+(97*Number)+" ")  
        #Uppercase
        Say1=Say1:replace("A", " ."+(57*Number)+" ")  
        Say1=Say1:replace("B", " ."+(42*Number)+" ")  
        Say1=Say1:replace("C", " ."+(64*Number)+" ")  
        Say1=Say1:replace("D", " ."+(43*Number)+" ")  
        Say1=Say1:replace("E", " ."+(89*Number)+" ")  
        Say1=Say1:replace("F", " ."+(54*Number)+" ")  
        Say1=Say1:replace("G", " ."+(12*Number)+" ")  
        Say1=Say1:replace("H", " ."+(44*Number)+" ")  
        Say1=Say1:replace("I", " ."+(14*Number)+" ")  
        Say1=Say1:replace("J", " ."+(78*Number)+" ")  
        Say1=Say1:replace("K", " ."+(76*Number)+" ")  
        Say1=Say1:replace("L", " .0"+(8*Number)+" ")  
        Say1=Say1:replace("M", " ."+(65*Number)+" ")  
        Say1=Say1:replace("N", " ."+(49*Number)+" ")  
        Say1=Say1:replace("O", " ."+(16*Number)+" ")  
        Say1=Say1:replace("P", " .0"+(1*Number)+" ")  
        Say1=Say1:replace("Q", " ."+(33*Number)+" ")  
        Say1=Say1:replace("R", " ."+(40*Number)+" ")  
        Say1=Say1:replace("S", " ."+(29*Number)+" ")  
        Say1=Say1:replace("T", " ."+(55*Number)+" ")  
        Say1=Say1:replace("U", " ."+(22*Number)+" ")  
        Say1=Say1:replace("V", " ."+(11*Number)+" ")  
        Say1=Say1:replace("W", " .0"+(7*Number)+" ")  
        Say1=Say1:replace("X", " ."+(45*Number)+" ")  
        Say1=Say1:replace("Y", " ."+(66*Number)+" ")  
        Say1=Say1:replace("Z", " ."+(97*Number)+" ")  
        gSetVec("color"+Number:toString(),teamColor(owner():team()))
        gSetStr("name"+Number:toString(),owner():name())
        gSetStr("message"+Number:toString(),Say1)
        gSetNum("time"+Number:toString(),curtime())
    }
}
if(STime==0){
    STime=gGetNum("time"+Number:toString())
}else{
    if(gGetNum("time"+Number:toString())!=STime){
        STime=gGetNum("time"+Number:toString())
        Say2=gGetStr("message"+Number:toString())
        Name=gGetStr("name"+Number:toString())
        Vec=gGetVec("color"+Number:toString())
            Say2=Say2:replace(" ) ", "1")
            Say2=Say2:replace(" ( ", "2")
            Say2=Say2:replace(" * ", "3")
            Say2=Say2:replace(" & ", "4")
            Say2=Say2:replace(" ^ ", "5")
            Say2=Say2:replace(" ^^ ", "6")
            Say2=Say2:replace(" $ ", "7")
            Say2=Say2:replace(" # ", "8")
            Say2=Say2:replace(" @ ", "9")
            Say2=Say2:replace(" ! ", "0")
        #loweralphabet
            Say2=Say2:replace(" "+(57*Number)+" ", "a")
            Say2=Say2:replace(" "+(42*Number)+" ", "b")
            Say2=Say2:replace(" "+(64*Number)+" ", "c")
            Say2=Say2:replace(" "+(43*Number)+" ", "d")
            Say2=Say2:replace(" "+(89*Number)+" ", "e")
            Say2=Say2:replace(" "+(54*Number)+" ", "f")
            Say2=Say2:replace(" "+(12*Number)+" ", "g")
            Say2=Say2:replace(" "+(44*Number)+" ", "h")
            Say2=Say2:replace(" "+(14*Number)+" ", "i")
            Say2=Say2:replace(" "+(78*Number)+" ", "j")
            Say2=Say2:replace(" "+(76*Number)+" ", "k")
            Say2=Say2:replace(" 0"+(8*Number)+" ", "l")
            Say2=Say2:replace(" "+(65*Number)+" ", "m")
            Say2=Say2:replace(" "+(49*Number)+" ", "n")
            Say2=Say2:replace(" "+(16*Number)+" ", "o")
            Say2=Say2:replace(" 0"+(1*Number)+" ", "p")
            Say2=Say2:replace(" "+(33*Number)+" ", "q")
            Say2=Say2:replace(" "+(40*Number)+" ", "r")
            Say2=Say2:replace(" "+(29*Number)+" ", "s")
            Say2=Say2:replace(" "+(55*Number)+" ", "t")
            Say2=Say2:replace(" "+(22*Number)+" ", "u")
            Say2=Say2:replace(" "+(11*Number)+" ", "v")
            Say2=Say2:replace(" 0"+(7*Number)+" ", "w")
            Say2=Say2:replace(" "+(45*Number)+" ", "x")
            Say2=Say2:replace(" "+(66*Number)+" ", "y")
            Say2=Say2:replace(" "+(97*Number)+" ", "z")                
        #Uppercase
            Say2=Say2:replace(" ."+(57*Number)+" ", "A")
            Say2=Say2:replace(" ."+(42*Number)+" ", "B")
            Say2=Say2:replace(" ."+(64*Number)+" ", "C")
            Say2=Say2:replace(" ."+(43*Number)+" ", "D")
            Say2=Say2:replace(" ."+(89*Number)+" ", "E")
            Say2=Say2:replace(" ."+(54*Number)+" ", "F")
            Say2=Say2:replace(" ."+(12*Number)+" ", "G")
            Say2=Say2:replace(" ."+(44*Number)+" ", "H")
            Say2=Say2:replace(" ."+(14*Number)+" ", "I")
            Say2=Say2:replace(" ."+(78*Number)+" ", "J")
            Say2=Say2:replace(" ."+(76*Number)+" ", "K")
            Say2=Say2:replace(" .0"+(8*Number)+" ", "L")
            Say2=Say2:replace(" ."+(65*Number)+" ", "M")
            Say2=Say2:replace(" ."+(49*Number)+" ", "N")
            Say2=Say2:replace(" ."+(16*Number)+" ", "O")
            Say2=Say2:replace(" .0"+(1*Number)+" ", "P")
            Say2=Say2:replace(" ."+(33*Number)+" ", "Q")
            Say2=Say2:replace(" ."+(40*Number)+" ", "R")
            Say2=Say2:replace(" ."+(29*Number)+" ", "S")
            Say2=Say2:replace(" ."+(55*Number)+" ", "T")
            Say2=Say2:replace(" ."+(22*Number)+" ", "U")
            Say2=Say2:replace(" ."+(11*Number)+" ", "V")
            Say2=Say2:replace(" .0"+(7*Number)+" ", "W")
            Say2=Say2:replace(" ."+(45*Number)+" ", "X")
            Say2=Say2:replace(" ."+(66*Number)+" ", "Y")
            Say2=Say2:replace(" ."+(97*Number)+" ", "Z")                
        Message=array()
        Message:pushVector(Vec)
        Message:pushString("$"+Number:toString()+"$")
        Message:pushString(Name)
        Message:pushVector(vec(255,255,255))
        Message:pushString(": ")
        Message:pushString(Say2)
        printColor(Message)
    }
}
