Home Showcase
Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!

Private chat channels

KatelynKatelyn Registered, Administrator Posts: 171
edited April 2011 in Showcase #1
This chip allows you a host of features to chatting. You can create private chat channels and password protect them. People with this chip can communicate with each other if they are in the same channel. It also features its own private message system. Put ! before you talk to talk in the channel. !help for a list of commands.
@name Chat controller
@persist Config:table G:gtable
@persist Debug:array Chat:array Results:array
@persist Start Out On Position Who:string

#By Katelyn
#Version 1.1.0.2
#E-mail: Katelyn135@gmail.com
#Aim: Consta135

if (first() | dupefinished())
{
    #fileRemove("Chatcfg.txt")
    runOnFile(1)
    Start = 0
    runOnChat(1)
    runOnLast(1)
    
    fileLoad("Chatcfg.txt")
    
}

if (fileClk())
{


    if (fileStatus() == _FILE_OK)
    {
        Debug[1, string] = "Configuration file loaded..."
        Config = glonDecodeTable(fileRead())
        Config["channel.current", string] = Config["channel.home", string]
        
    }
    else
    {
        Config["color.name.self", vector] = vec(128,128,52)
        Config["color.text.self", vector] = vec(255,255,255)
        
        Config["color.name.other", vector] = vec(255,255,128)
        Config["color.text.other", vector] = vec(255,255,255)
        
        Config["color.notice.channel", vector] = vec(52,52,128)
        Config["color.notice.error", vector] = vec(255,0,0)
        Config["color.notice.pm", vector] = vec(128,255,128)
        Config["color.notice.message", vector] = vec(255,128,128)
        
        Config["color.override", number] = 0
        
        Config["channel.current", string] = "default"
        
        Config["command.marker", string] = "!"
        Config["chat.marker", string] = ""
        
        Config["hide", number] = 1

        fileWrite("Chatcfg.txt", glonEncode(Config))
        Debug[1, string] = "Configuration file not found, creating one with default settings."
        Error = 1
    }

   



    
#[    if (Config["hide", number])
    {
        print(_HUD_PRINTCONSOLE, "Hiding chip...")
        entity():setSolid(0)
        entity():setAlpha(0)
        entity():isWeldedTo():unWeld(entity())
        entity():setPosition(randvec(-16500, 16500))
    }]#

    Debug:clear()
    
    
    signalSetGroup(Config["channel.current", string])
    G = gTable(Config["channel.current", string], 1)
    
    #G["BACC-Count" + owner():steamID(), number] = 0
    if (G["BACC-Count" + owner():steamID(), number] > 0)
    {
        printColor(vec(255,0,0), "Chat chip is already spawned...")
        selfDestruct()
    }
    else
    {
        G["BACC-Count" + owner():steamID(), number] = G["BACC-Count" + owner():steamID(), number] + 1

    
        printColor(Config["color.notice.channel", vector], "Joining channel " + Config["channel.home", string])
        
        runOnSignal(Config["channel.current", string], 2, 1)
        runOnSignal(Config["channel.current", string] + "join", 2, 1)
        
        runOnSignal(Config["channel.current", string], 2, 1)
        runOnSignal(Config["channel.current", string] + "join", 2, 1)
          
        runOnSignal("pm" + owner():steamID(), 2, 1)
        
        On = 1
        
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "help ")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: Opens the help document.\n")
            
        
        signalSend(Config["channel.current", string] + "join", 2)
        G[Config["channel.current", string] + "join", string] = owner():name() + " has joined the channel."    
        
        Temp = glonDecode(G[Config["channel.current", string] + "list", string])
        Temp:pushEntity(owner())
        Position = Temp:count()
                
        G[Config["channel.current", string] + "list", string] = glonEncode(Temp)
                
        Who = Config["channel.current", string] + "list"
        timer("list", 10)


    }
}


if (chatClk(owner()) & 
    lastSaid()[1] == Config["command.marker", string])
{
    Command = lastSaid():lower():trim()
    Cmd = Command:explode(" ")

#Command Color#
    if (Cmd[1, string]:sub(2) == "color")
    {
        Red = Cmd[3, string]:sub(1, 2)
        Green = Cmd[3, string]:sub(3, 4)
        Blue = Cmd[3, string]:sub(5, 6)
        
        R = Red:toNumber(16)
        Gr = Green:toNumber(16)
        B = Blue:toNumber(16)
        
        if (Cmd[2, string] == "my")
        {
            Red = Cmd[4, string]:sub(1, 2)
            Green = Cmd[4, string]:sub(3, 4)
            Blue = Cmd[4, string]:sub(5, 6)
            
            R = Red:toNumber(16)
            Gr = Green:toNumber(16)
            B = Blue:toNumber(16)
            
            
            if (Cmd[3, string] == "name")
            {
                Config["color.name.self", vector] = vec(R, Gr, B)
                printColor(Config["color.notice.message", vector], "Name color updated")

            }
            elseif (Cmd[3, string] == "text")
            {
                Config["color.text.self", vector] = vec(R, Gr, B)
                printColor(Config["color.notice.message", vector], "Text color updated")

            }
            else
            {
                printColor(Config["color.notice.error", vector], "Sytax error: Must be " + Config["command.marker", string] + "color <text/color/my text/my color> <red> <green> <blue>")
            }
        }
        elseif (Cmd[2, string] == "name")
        {
            Config["color.name.other", vector] = vec(R, Gr, B)
            printColor(Config["color.notice.message", vector], "Name color updated")

        }
        elseif (Cmd[2, string] == "text")
        {
            Config["color.text.other", vector] = vec(R, Gr, B)
            printColor(Config["color.notice.message", vector], "Text color updated")

        }
        elseif (Cmd[2, string] == "channel")
        {
            Config["color.notice.channel", vector] = vec(R,Gr,B)
            printColor(Config["color.notice.message", vector], "Notice color updated")

        }
        elseif (Cmd[2, string] == "error")
        {
            Config["color.notice.error", vector] = vec(R,Gr,B)
            printColor(Config["color.notice.message", vector], "Notice color updated")

        }
        elseif (Cmd[2, string] == "pm")
        {
            Config["color.notice.pm", vector] = vec(R,Gr,B)
            printColor(Config["color.notice.message", vector], "Notice color updated")

        }
        elseif (Cmd[2, string] == "message")
        {
            Config["color.notice.message", vector] = vec(R,Gr,B)
            printColor(Config["color.notice.message", vector], "Notice color updated")
        }
        elseif (Cmd[2, string] == "override")
        {
            Config["color.override", number] = abs(Config["color.override", number] - 1)
            printColor(Config["color.notice.message", vector], "Color override now " + (Config["color.override", number] ? "enabled." : "disabled."))
        }
        elseif (Cmd[2, string] == "default")
        {
            Config["color.name.self", vector] = vec(128,128,52)
            Config["color.text.self", vector] = vec(255,255,255)
            
            Config["color.name.other", vector] = vec(255,255,128)
            Config["color.text.other", vector] = vec(255,255,255)
            
            Config["color.notice.channel", vector] = vec(52,52,128)
            Config["color.notice.error", vector] = vec(255,0,0)
            Config["color.notice.pm", vector] = vec(128,255,128)
            Config["color.notice.message", vector] = vec(255,128,128)
        }
        else
        {
            printColor(Config["color.notice.error", vector], "Sytax error: Must be " + Config["command.marker", string] + "color (my) name/text, color message, color error, color channel, color pm - RRGGBB. Check help if you're lost.")
        }
    }
#Command PM#
    elseif (Cmd[1, string]:sub(2) == "pm")
    {
        findByClass("Player")
        findClipToName(Cmd[2, string])
        
        Results = findToArray()
        if (Results:count() == 1)
        {
            Chat[11, string] = owner():name()
            Chat[21, string] = ": " + lastSaid():sub(6 + Cmd[2, string]:length())
            
            signalSend("pm" + find():steamID(), 2)
            G["pm" + find():steamID(), string] = glonEncode(Chat)
            
            printColor(Config["color.notice.pm", vector], Chat[11, string] + Chat[21, string])
        }
        elseif (Results:count() > 1)
        {
            Return = ""
            for (K = 1, Results:count())
            {
                Return = Return + Results[K, entity]:name() + "\n"
            }
            printColor(Config["color.notice.error", vector], "Multiple results returned\n", Config["color.notice.message", vector], Return)
        }
        else
        {
            printColor(Config["color.notice.error", vector], "No results found for phrase: ", vec(255,0,0), Cmd[2, string])
        }
    }


            
#Command Who#
    elseif (Cmd[1, string]:sub(2) == "who")
    {
        if (Cmd[2, string] == "")
        {
            printColor(Config["color.notice.channel", vector], "Checking room " + Config["channel.current", string] + ":")
    
            Who = Config["channel.current", string] + "list"
        }
        else
        {
            printColor(Config["color.notice.channel", vector], "Checking room " + Cmd[2, string] + ":")
    
            Who = Cmd[2, string] + "list"
        }
        timer("list", 10)
    }
#Command Join#
    elseif (Cmd[1, string]:sub(2) == "join")
    {
        if (Cmd[3, string] == G[Cmd[2, string] + "pass", string] | G[Cmd[2, string] + "pass", string] == "" | Cmd[2, string] == "default")
        {
            Temp = glonDecode(G[Cmd[2, string] + "list", string])
            if (Temp:count() == 0 & G[Cmd[2, string] + "pass", string] == "" & Cmd[3, string] != "")
            {
                G[Cmd[2, string] + "pass", string] = Cmd[3, string]
                printColor(Config["color.notice.channel", vector], "Password set to " + Cmd[3, string])
    
            }
            elseif (Cmd[3, string] != "")
            {
                printColor(Config["color.notice.channel", vector], "Can not set a password!")
            }
        
                
            signalSend(Config["channel.current", string] + "join", 2)
            G[Config["channel.current", string] + "join", string] = owner():name() + " has left the channel. (" + Cmd[2, string] + ")"
            
            runOnSignal(Config["channel.current", string], 2, 0)
            runOnSignal(Config["channel.current", string] + "join", 2, 0)
            
            Temp = glonDecode(G[Config["channel.current", string] + "list", string])
            Temp:removeEntity(Position)
            
            G[Config["channel.current", string] + "list", string] = glonEncode(Temp)
            
            
            Temp = glonDecode(G[Cmd[2, string] + "list", string])
            Temp:pushEntity(owner())
            Position = Temp:count()
            
            G[Cmd[2, string] + "list", string] = glonEncode(Temp)
            
            
            
            Config["channel.current", string] = Cmd[2, string]
            
            signalSend(Config["channel.current", string] + "join", 2)
            G[Config["channel.current", string] + "join", string] = owner():name() + " has joined the channel."
            
            
            runOnSignal(Config["channel.current", string], 2, 1)
            runOnSignal(Config["channel.current", string] + "join", 2, 1)
          
            printColor(Config["color.notice.channel", vector], "Joining channel " + Config["channel.current", string])
            
            Who = Config["channel.current", string] + "list"
            timer("list", 10)
        }
        else
        {
            printColor(Config["color.notice.channel", vector], "Channel is password protected!")
        }
    } 
#Command Hide#
    elseif (Cmd[1, string]:sub(2) == "hide")
    {
        if (Cmd[2, string] == "1" | Cmd[2, string] == "on")
        {
            entity():unWeld(entity():isWeldedTo())
            entity():setSolid(0)
            entity():setAlpha(0)
            
            Config["hide", number] = 1
            
            entity():setPosition(randvec(-16500, 16500))
            printColor(Config["color.notice.message", vector], "Hiding the chip")
        }
        elseif (Cmd[2, string] == "0" | Cmd[2, string] == "off")
        {
            entity():setSolid(1)
            entity():setAlpha(255)
            entity():unWeld(entity():isWeldedTo())
            Config["hide", number] = 0
            
            entity():setPosition(owner():aimPos())
            printColor(Config["color.notice.message", vector], "Unhiding the chip")
        }
        elseif (Cmd[2, string] == "")
        {
            if (Config["hide", number] == 0)
            {
                entity():setSolid(0)
                entity():setAlpha(0)
                
                Config["hide", number] = 1
                
                entity():setPosition(randvec(-16500, 16500))
                printColor(Config["color.notice.message", vector], "Hiding the chip")
            }
            else  {
          
                entity():setSolid(1)
                entity():setAlpha(255)
                
                Config["hide", number] = 0
                
                entity():setPosition(owner():aimPos())
                printColor(Config["color.notice.message", vector], "Unhiding the chip")

            }
        }            
    }
#Command Default#
    elseif (Cmd[1, string]:sub(2) == "default")
    {
        #fileRemove("Chatcfg.txt")
        printColor(Config["color.notice.message", vector], "All defaults have been set. Reloading chip.")
        Config["color.name.self", vector] = vec(128,128,52)
        Config["color.text.self", vector] = vec(255,255,255)
        
        Config["color.name.other", vector] = vec(255,255,128)
        Config["color.text.other", vector] = vec(255,255,255)
        
        Config["color.notice.channel", vector] = vec(52,52,128)
        Config["color.notice.error", vector] = vec(255,0,0)
        Config["color.notice.pm", vector] = vec(128,255,128)
        Config["color.notice.message", vector] = vec(255,128,128)
        
        Config["color.override", number] = 0
        
        Config["channel.current", string] = "default"
        
        Config["command.marker", string] = "!"
        Config["chat.marker", string] = ""
        
        Config["hide", number] = 1

        fileWrite("Chatcfg.txt", glonEncode(Config))
        reset()

    }
#Command Help#
    elseif (Cmd[1, string]:sub(2) == "help")
    {
        printColor(vec(255, 255, 0), "Help file accessed.\n")
        
        printColor(Config["color.notice.message", vector], "Command format: " + Config["command.marker", string] + "Command <Argument1> [Optional argument]")
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "color [my] <argument> <RRGGBB In hexcode format (FF0000 is red)> ")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: Supports a large list of sub arguments. My is only used with Name and Text to change YOUR colors.")
        printColor(Config["color.notice.message", vector], "Name - Changes the override default name color of everyone else.")
        printColor(Config["color.notice.message", vector], "Text - Changes the override default text color of everyone else.")
        printColor(Config["color.notice.message", vector], "My Name - Changes your name color.")
        printColor(Config["color.notice.message", vector], "My Text - Changes your text color.")
        printColor(Config["color.notice.message", vector], "Channel - Changes the default channel notice color.")
        printColor(Config["color.notice.message", vector], "Error - Changes the default error notice color.")
        printColor(Config["color.notice.message", vector], "PM - Changes the default PM color.")
        printColor(Config["color.notice.message", vector], "Message - Changes the default general message color.")
        printColor(Config["color.notice.message", vector], "Override - Toggles color overriding for other players (Client side for you only). This helps if you can't read someone's text.")
        printColor(Config["color.notice.message", vector], "Default - Restores the default preset colors for you. \n")
        
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "pm <name> <message>")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: Sends a message to the person with the name or partial name you give.\n")
       
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "who <channel name>")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: Looks in a channel and tells you who is in it.\n")
        
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "join <channel name> [password]")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: You leave your current channel and join the specified one. If no one is in the channel and no password is set, you will join the channel and set the password to what you specify. Otherwise the password field is used to join password protected channels.\n")
       
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "hide <(On/1) - (Off/0) - (Nothing toggles)>")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: Hides or shows the chip (For giving to other admins).\n")
        
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "default")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: Resets ALL YOUR SETTINGS TO DEFAULT!!!.\n")
        
        printColor(Config["color.notice.message", vector], Config["command.marker", string] + "help ")
        printColor(Config["color.notice.message", vector], "Alias: None")
        printColor(Config["color.notice.message", vector], "Description: Opens the help document.\n")
        
        
        
        
    }
    else
    {
        Chat[11, string] = owner():name()
        Chat[21, string] = ": " + lastSaid():sub(2)
        Chat[12, vector] = Config["color.name.self", vector]
        Chat[22, vector] = Config["color.text.self", vector]
        
        signalSend(Config["channel.current", string], 2)
        G[Config["channel.current", string], string] = glonEncode(Chat)
        
        printColor(Chat[12, vector], Chat[11, string], Chat[22, vector], Chat[21, string])

        Chat:clear()
    }
    fileWrite("Chatcfg.txt", glonEncode(Config))
    hideChat(1)
}



if (last())
{
    signalSend(Config["channel.current", string] + "join", 2)
    G[Config["channel.current", string] + "join", string] = owner():name() + " has left the channel. [Chip was removed]"

    Temp = glonDecode(G[Config["channel.current", string] + "list", string])
    Temp:removeEntity(Position)
            
    G[Config["channel.current", string] + "list", string] = glonEncode(Temp)
            
    G["BACC-Count" + owner():steamID(), number] = G["BACC-Count" + owner():steamID(), number] - 1
}



if (signalClk(Config["channel.current", string]))
{
    Chat = glonDecode(G[Config["channel.current", string], string])
    if (!Config["color.override", number])
    {
        printColor(Chat[12, vector], Chat[11, string], Chat[22, vector], Chat[21, string])
    }
    else
    {
        printColor(Config["color.name.other", vector], Chat[11, string], Config["color.text.other", vector], Chat[21, string])
    }
    Chat:clear()
}
if (signalClk(Config["channel.current", string] + "join"))
{
    printColor(Config["color.notice.channel", vector], G[Config["channel.current", string] + "join", string])
 
    Chat:clear()
}
if (signalClk("pm" + owner():steamID()))
{
    Chat = glonDecode(G["pm" + owner():steamID(), string])
    printColor(Config["color.notice.pm", vector], Chat[11, string] + Chat[21, string])
}
if (clk("list"))
{
    List = glonDecode(G[Who, string])
    if (List:count() > 0)
    {
        for (K = 1, List:count())
        {
            if (List[K, entity] == noentity())
            {
                continue
            }
            else
            {
                printColor(Config["color.notice.message", vector], K + ": " + List[K, entity]:name())
            }
        }
    }
    else
    {
        printColor(Config["color.notice.message", vector], "Channel is empty...")
    }
    Who = ""
}

Comments

  • AmaroqAmaroq Registered, Administrator Posts: 450
    This chip seems like it would conflict with ULX in some way. Otherwise, cool.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file