• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[TEASER] Ultimate Chat System

Status
Not open for further replies.

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
This is my new system, named Ultimate Chat System, it's still in progress.

UCS is entirely a new level of chat system. Supports many advanced and fascinating features like colorized chat, degraded chat, word replacing. And many more that certainly makes your map become more elegant.

How is it looks like? Not far from this.
133337d1394385685-teaser-ultimate-chat-system-teaser.jpg

The progress of it will be discussed here.

Description

Name: Ultimate/Superior Chat System
Coded in: vJass
Completition: ~20%
Just wait for the release. :thumbs_up:
 

Attachments

  • teaser.jpg
    teaser.jpg
    171.9 KB · Views: 348
Last edited:

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
JASS:
    globals
        // Interfaces
        private                 string          TITLE               = "SuperiorChatSystem v1.0"
        private     constant    string          PM_PREFIX           = "[|cff0000ffPrivate|r]"
        private     constant    string          SM_PREFIX           = "[|cff0000ffSystem|r]"
        private     constant    string          TM_PREFIX           = "[|cff0000ffTeam|r]"
        private     constant    string          AM_PREFIX           = "[|cff0000ffAll|r]"
        private     constant    string          TIME_COLOR          = "|CFFFFFF00"
        private     constant    string          TIME_DEVIDER        = ":"
        private     constant    string          TIME_EQUATION1      = "<"
        private     constant    string          TIME_EQUATION2      = ">"
        private     constant    string          CHAT_SYMBOL         = ":"
        private     constant    string          DEBUG_MSG1          = "INVALID COMMAND"
        // Commands
        private     constant    string          CMD_PREFIX          = "-"
        private     constant    string          CMD_CLOSE           = "close"
        private     constant    string          CMD_OPEN            = "open"
        private     constant    string          CMD_CLEAR           = "clear"
        private     constant    string          CMD_BAN             = "reject"
        private     constant    string          CMD_UNBAN           = "unreject"
        private     constant    string          CMD_SHOWALL         = "all"
        private     constant    string          CMD_SHOWPRIVATE     = "private"
        private     constant    string          CMD_SHOWTEAM        = "team"
        private     constant    string          CMD_SHOWSYSTEM      = "system"
        private     constant    string          CMD_SHOWGENERAL     = "general"
        // Messaging
        private     constant    string          MSG_PREFIX          = "*"
        private     constant    string          MSG_ALL             = "all"
        private     constant    string          MSG_TEAM            = "team"
        private     constant    string          MSG_PRIVATE         = "pm"
        private     constant    string          MSG_ANNOUNCEMENT    = "announce"
        // Options
        private                 integer         MAX_MSG             = 15
        private     constant    integer         MAX_SAVED           = 50
        private     constant    integer         MAX_LENGTH          = 93
        private     constant    boolean         FORMAT              = true
        private     constant    boolean         SHOW_TIME_TAG       = true
        private     constant    boolean         SHOW_TITLE          = true
        private     constant    boolean         ENABLE_REPLACER     = true
        
        private                 string array    PLAYER_COLOR
        private                 string array    PLAYER_NAME
    endglobals
you can configure anything ;)
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
current code (~20% done)
JASS:
library UltimateChat initializer ini requires GradientText, Table
    globals
        private                 string array    PLAYER_COLOR
        private                 string array    PLAYER_NAME
        // Interfaces
        private                 string          TITLE               = "SuperiorChatSystem v1.0"
        private     constant    string          PM_PREFIX           = "[|cff0000ffPrivate|r]"
        private     constant    string          SM_PREFIX           = "[|cff0000ffSystem|r]"
        private     constant    string          TM_PREFIX           = "[|cff0000ffTeam|r]"
        private     constant    string          AM_PREFIX           = "[|cff0000ffAll|r]"
        private     constant    string          TIME_DEVIDER        = ":"
        private     constant    string          TIME_QUOTATION1     = "["
        private     constant    string          TIME_QUOTATION2     = "]"
        private     constant    string          EQUAL_SYMBOL        = ":"
        private     constant    string          WARNING_NOFLOOD     = "|CFFFF0000DON'T FLOOD!|r"
        private     constant    string          WARNING_NOSWEAR     = "|CFFFF0000NO SWEAR!|r"
        private     constant    string          DEBUG_MSG1          = "|CFFFF0000INVALID COMMAND|r"
        private     constant    string          DEBUG_MSG2          = "|CFFFF0000INPUT OVERSIZED|r"
        // Commands
        private     constant    string          CMD_PREFIX          = "-"
        private     constant    string          CMD_CLOSE           = "close"
        private     constant    string          CMD_OPEN            = "open"
        private     constant    string          CMD_CLEAR           = "clear"
        private     constant    string          CMD_BAN             = "reject"
        private     constant    string          CMD_UNBAN           = "unreject"
        private     constant    string          CMD_SHOWALL         = "all"
        private     constant    string          CMD_SHOWPRIVATE     = "private"
        private     constant    string          CMD_SHOWTEAM        = "team"
        private     constant    string          CMD_SHOWSYSTEM      = "system"
        private     constant    string          CMD_SHOWGENERAL     = "general"
        // Messaging
        private     constant    string          MSG_PREFIX          = "*"
        private     constant    string          MSG_ALL             = "all"
        private     constant    string          MSG_TEAM            = "team"
        private     constant    string          MSG_PRIVATE         = "pm"
        private     constant    string          MSG_ANNOUNCEMENT    = "announce"
        // Options
        private                 integer         MAX_MSG             = 15
        private     constant    integer         MAX_SAVED           = 50
        private     constant    integer         MAX_LENGTH          = 100
        private     constant    boolean         SHOW_TIME_TAG       = true
        private     constant    boolean         SHOW_TITLE          = true
        private     constant    boolean         ENABLE_REPLACER     = true
        private     constant    boolean         ENABLE_SCROLLING    = true
        
    endglobals
    
    private function setname takes nothing returns nothing
        set PLAYER_COLOR[0] = "|CFFFF0303"
        set PLAYER_COLOR[1] = "|CFF0042FF"
        set PLAYER_COLOR[2] = "|CFF00FFFF"
        set PLAYER_COLOR[3] = "|CFF540081"
        set PLAYER_COLOR[4] = "|CFFFFFF01"
        set PLAYER_COLOR[5] = "|CFFFE8A0E"
        set PLAYER_COLOR[6] = "|CFF20C000"
        set PLAYER_COLOR[7] = "|CFFE55BB0"
        set PLAYER_COLOR[8] = "|CFF959697"
        set PLAYER_COLOR[9] = "|CFF7EBFF1"
        set PLAYER_COLOR[10] = "|CFF106246"
        set PLAYER_COLOR[11] = "|CFF4E2A04"
    endfunction
    
    globals
        private                 player          HOST
        private                 integer array   TOTAL_ALL
        private                 integer array   TOTAL_PRIVATE
        private                 integer array   TOTAL_TEAM
        private                 integer array   TOTAL_SYSTEM
        private                 integer array   TOTAL_GENERAL
        private                 integer array   SCROLLINT
        private                 integer array   WINDOW
        private                 force array     REJECT_LIST
        private                 integer         GAME_TIME           = 0
        private                 string          GAME_TIMES          = "00" + TIME_DEVIDER + "00"
        private                 boolean         SWEAR               = false
        private                 Table array     MAILBOX_ALL[11]
        private                 Table array     MAILBOX_PRIVATE[11]
        private                 Table array     MAILBOX_TEAM[11]
        private                 Table array     MAILBOX_SYSTEM[11]
        private                 Table array     MAILBOX_GENERAL[11]
                                trigger         CHAT                = CreateTrigger()
    endglobals
    
    function AddRestrictedWord takes string s returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerChatEvent(CHAT, Player(i), s, false)
            set i = i + 1
        endloop
    endfunction
    
    function ChangeTitle takes string s returns nothing
        set TITLE = s
    endfunction
    
    function SetHost takes player p returns nothing
        set HOST = p
    endfunction
    
    function SetNickName takes integer i, string s returns nothing
        set PLAYER_NAME[i] = s
    endfunction
    
    function GetElapsedGameTime takes nothing returns string
        if SHOW_TIME_TAG then
            return GAME_TIMES
        else
        endif
        return ""
    endfunction
    
    private function unswear takes nothing returns nothing
        set SWEAR = false
        call DestroyTimer(GetExpiredTimer())
    endfunction
    
    private function update takes integer i returns nothing
        local integer i2
        
        if WINDOW[i] == 1 then
            if GetLocalPlayer() == Player(i) then
                call ClearTextMessages()
            endif
            if SHOW_TITLE then
                call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, TITLE)
            endif
            if TOTAL_ALL[i] < MAX_MSG + SCROLLINT[i] then
                set i2 = 0
                loop
                    exitwhen i2 >= MAX_MSG - TOTAL_ALL[i] + SCROLLINT[i]
                    call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, " ")
                    set i2 = i2 + 1
                endloop
            endif
            set i2 = TOTAL_ALL[i] - MAX_MSG + 1 - SCROLLINT[i]
            loop
                exitwhen i2 > TOTAL_ALL[i] - SCROLLINT[i]
                if MAILBOX_ALL[i].string[i2] != null then
                    call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, MAILBOX_ALL[i].string[i2])
                endif
                set i2 = i2 + 1
            endloop
        endif
    endfunction
    
    private function add_general takes integer i, integer pn, string msg returns nothing
        local integer i2
        
        if TOTAL_GENERAL[i] >= MAX_SAVED then
            set i2 = 0
            loop
                set i2 = i2 + 1
                set MAILBOX_GENERAL[i].string[i2] = MAILBOX_GENERAL[i].string[i2 + 1]
                set MAILBOX_GENERAL[i].integer[i2] = MAILBOX_GENERAL[i].integer[i2 + 1]
                exitwhen i2 >= MAX_SAVED - 1
            endloop
            set TOTAL_GENERAL[i] = TOTAL_GENERAL[i] - 1
        endif
        set TOTAL_GENERAL[i] = TOTAL_GENERAL[i] + 1
        set MAILBOX_GENERAL[i].string[TOTAL_GENERAL[i]] = msg
        set MAILBOX_GENERAL[i].integer[TOTAL_GENERAL[i]] = pn
    endfunction
    
    private function chat takes nothing returns boolean
        local string msg
        local string cmd
        local string s
        local string res
        local player p
        local integer pn
        local integer len
        local integer i = 0
        local integer i2
        
        if GetEventPlayerChatStringMatched() != "" then
            set SWEAR = true
        endif
        if not SWEAR then
            set msg = GetEventPlayerChatString()
            set cmd = SubString(msg, 0, 1)
            set p = GetTriggerPlayer()
            set pn = GetPlayerId(p)
            set res = ""
            set i = 0
            if cmd == CMD_PREFIX then
                set len = StringLength(CMD_PREFIX)
                if SubString(msg, len, StringLength(CMD_SHOWALL)) == CMD_SHOWALL then
                elseif SubString(msg, len, StringLength(CMD_SHOWPRIVATE)) == CMD_SHOWPRIVATE then
                elseif SubString(msg, len, StringLength(CMD_SHOWTEAM)) == CMD_SHOWTEAM then
                elseif SubString(msg, len, StringLength(CMD_SHOWSYSTEM)) == CMD_SHOWSYSTEM then
                elseif SubString(msg, len, StringLength(CMD_SHOWGENERAL)) == CMD_SHOWGENERAL then
                endif
            elseif cmd == MSG_PREFIX then
                set len = StringLength(MSG_PREFIX)
                if StringLength(msg) - len <= MAX_LENGTH then
                    if SubString(msg, len, len + StringLength(MSG_ALL)) == MSG_ALL then
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_ALL) + 1, StringLength(msg)))
                        if SHOW_TIME_TAG then
                            set msg = AM_PREFIX + " " + TIME_QUOTATION1 + GAME_TIMES + TIME_QUOTATION2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        else
                            set msg = AM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        endif
                        loop
                            exitwhen i > 11
                            if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                                if TOTAL_ALL[i] >= MAX_SAVED then
                                    set i2 = 0
                                    loop
                                        set i2 = i2 + 1
                                        set MAILBOX_ALL[i].string[i2] = MAILBOX_ALL[i].string[i2 + 1]
                                        set MAILBOX_ALL[i].integer[i2] = MAILBOX_ALL[i].integer[i2 + 1]
                                        exitwhen i2 >= MAX_SAVED - 1
                                    endloop
                                    set TOTAL_ALL[i] = TOTAL_ALL[i] - 1
                                endif
                                set TOTAL_ALL[i] = TOTAL_ALL[i] + 1
                                set MAILBOX_ALL[i].string[TOTAL_ALL[i]] = msg
                                set MAILBOX_ALL[i].integer[TOTAL_ALL[i]] = pn
                                call add_general(i, pn, msg)
                                call update(i)
                            endif
                            set i = i + 1
                        endloop
                    endif
                endif
            else
            endif
        endif
        call TimerStart(CreateTimer(), 0.1, false, function unswear)
        return false
    endfunction
    
    private function time takes nothing returns nothing
        local string s1
        local string s2
        local integer i = 0
        
        set GAME_TIME = GAME_TIME + 1
        set s1 = I2S(GAME_TIME/60)
        set s2 = I2S(GAME_TIME-GAME_TIME/60*60)
        if StringLength(s1) == 1 then
            set s1 = "0" + s1
        endif
        if StringLength(s2) == 1 then
            set s2 = "0" + s2
        endif
        loop
            exitwhen i > 2
            if SubString(s1, i, i + 1) == "1" then
                set s1 = " " + s1
                set i = i + 1
            endif
            if SubString(s2, i, i + 1) == "1" then
                set s2 = s2 + " "
            endif
            set i = i + 1
        endloop
        set GAME_TIMES = s1 + TIME_DEVIDER + s2
    endfunction
    
    private function get_total takes integer i, integer pn returns integer
        if i == 1 then
            return TOTAL_ALL[pn]
        elseif i == 2 then
            return TOTAL_PRIVATE[pn]
        elseif i == 3 then
            return TOTAL_TEAM[pn]
        elseif i == 4 then
            return TOTAL_SYSTEM[pn]
        elseif i == 5 then
            return TOTAL_GENERAL[pn]
        endif
        return 0
    endfunction
    
    private function scroll_up takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] < get_total(WINDOW[i], i) - 1 then
            set SCROLLINT[i] = SCROLLINT[i] + 1
        endif
        call update(i)
    endfunction
    
    private function scroll_down takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] > 0 then
            set SCROLLINT[i] = SCROLLINT[i] - 1
        endif
        call update(i)
    endfunction
    
    private function ini takes nothing returns nothing
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
        local integer i = 0
        
        call setname()
        loop
            exitwhen i > 11
            if GetPlayerController(Player(i)) == MAP_CONTROL_USER  then
                call TriggerRegisterPlayerEvent(t1, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
                call TriggerRegisterPlayerEvent(t2, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
                static if not LIBRARY_ResWord then
                    call TriggerRegisterPlayerChatEvent(CHAT, Player(i), "", false)
                endif
                set REJECT_LIST[i] = CreateForce()
                set TOTAL_ALL[i] = 0
                set TOTAL_PRIVATE[i] = 0
                set TOTAL_TEAM[i] = 0
                set TOTAL_SYSTEM[i] = 0
                set TOTAL_GENERAL[i] = 0
                set SCROLLINT[i] = 0
                set WINDOW[i] = 1
                set MAILBOX_ALL[i] = Table.create()
                set MAILBOX_PRIVATE[i] = Table.create()
                set MAILBOX_TEAM[i] = Table.create()
                set MAILBOX_SYSTEM[i] = Table.create()
                set MAILBOX_GENERAL[i] = Table.create()
            endif
            set PLAYER_NAME[i] = PLAYER_COLOR[i] + GetPlayerName(Player(i)) + "|r"
            set i = i + 1
        endloop
        call TriggerAddAction(t1, function scroll_up)
        call TriggerAddAction(t2, function scroll_down)
        call TriggerAddCondition(CHAT, Condition(function chat))
        if SHOW_TIME_TAG then
            call TimerStart(CreateTimer(), 1, true, function time)
        endif
        if MAX_MSG > 15 then
            set MAX_MSG = 15
        endif
    endfunction
endlibrary

456th post!

EDIT:
newest code (60% completed)
JASS:
library UltimateChat initializer ini requires GradientText, Table
    globals
        private                 string array    PLAYER_COLOR
        private                 string array    PLAYER_NAME
        // Interfaces
        private                 string          TITLE               = "SuperiorChatSystem v1.0"
        private     constant    string          PM_PREFIX           = "[|cff0000ffPrivate|r]"
        private     constant    string          SM_PREFIX           = "[|cff0000ffSystem|r]"
        private     constant    string          TM_PREFIX           = "[|cff0000ffTeam|r]"
        private     constant    string          AM_PREFIX           = "[|cff0000ffAll|r]"
        private     constant    string          ANNOUNCEMENT        = "|cffffff00Announcement|r"
        private     constant    string          TIME_DEVIDER        = ":"
        private     constant    string          TIME_QUOTATION1     = "["
        private     constant    string          TIME_QUOTATION2     = "]"
        private     constant    string          TIME_SPACEFILLER    = " "
        private     constant    string          EQUAL_SYMBOL        = ":"
        private     constant    string          DEBUG_MSG1          = "|CFFFF0000INVALID COMMAND|r"
        private     constant    string          DEBUG_MSG2          = "|CFFFF0000MESSAGE OVERSIZED|r"
        private     constant    string          DEBUG_MSG3          = "|CFFFF0000INVALID RECIPIENT|r"
        private     constant    string          DEBUG_MSG4          = "|CFFFF0000RECIPIENT IS UNAVAILABLE|r"
        private     constant    string          DEBUG_MSG5          = "|CFFFF0000YOU DON'T HAVE THE AUTHORITY|r"
        private     constant    string          DEBUG_MSG6          = "|CFFFF0000DON'T FLOOD!|r"
        private     constant    string          DEBUG_MSG7          = "|CFFFF0000TIME TAG DISABLED|r"
        // Commands
        private     constant    string          CMD_PREFIX          = "-"
        private     constant    string          CMD_CLOSE           = "close"
        private     constant    string          CMD_OPEN            = "open"
        private     constant    string          CMD_CLEAR           = "clear"
        private     constant    string          CMD_BAN             = "reject"
        private     constant    string          CMD_UNBAN           = "unreject"
        private     constant    string          CMD_SHOWALL         = "all"
        private     constant    string          CMD_SHOWPRIVATE     = "private"
        private     constant    string          CMD_SHOWTEAM        = "team"
        private     constant    string          CMD_SHOWSYSTEM      = "system"
        private     constant    string          CMD_SHOWGENERAL     = "general"
        // Messaging
        private     constant    string          MSG_PREFIX          = "*"
        private     constant    string          MSG_ALL             = "all"
        private     constant    string          MSG_TEAM            = "team"
        private     constant    string          MSG_PRIVATE         = "pm"
        private     constant    string          MSG_ANNOUNCEMENT    = "announce"
        // Options
        private                 integer         MAX_MSG             = 15
        private     constant    integer         MAX_SAVED           = 50
        private     constant    integer         MAX_LENGTH          = 100
        private     constant    boolean         SHOW_TIME_TAG       = true
        private     constant    boolean         SHOW_TITLE          = true
        private     constant    boolean         ENABLE_REPLACER     = true
        private     constant    boolean         ENABLE_SCROLLING    = true
        
    endglobals
    
    private function setname takes nothing returns nothing
        set PLAYER_COLOR[0] = "|CFFFF0303"
        set PLAYER_COLOR[1] = "|CFF0042FF"
        set PLAYER_COLOR[2] = "|CFF00FFFF"
        set PLAYER_COLOR[3] = "|CFF540081"
        set PLAYER_COLOR[4] = "|CFFFFFF01"
        set PLAYER_COLOR[5] = "|CFFFE8A0E"
        set PLAYER_COLOR[6] = "|CFF20C000"
        set PLAYER_COLOR[7] = "|CFFE55BB0"
        set PLAYER_COLOR[8] = "|CFF959697"
        set PLAYER_COLOR[9] = "|CFF7EBFF1"
        set PLAYER_COLOR[10] = "|CFF106246"
        set PLAYER_COLOR[11] = "|CFF4E2A04"
    endfunction
    
    private function ScrollUpEvent takes trigger t returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
            set i = i + 1
        endloop
    endfunction
    
    private function ScrollDownEvent takes trigger t returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
            set i = i + 1
        endloop
    endfunction
    
    globals
        private                 player          HOST                = Player(15)
        private                 integer array   SCROLLINT
        private                 integer array   WINDOW
        private                 force array     REJECT_LIST
        private                 integer         GAME_TIME           = 0
        private                 string          GAME_TIMES          = "00" + TIME_DEVIDER + "00"
        private                 boolean         SWEAR               = false
        private                 Table array     TOTAL[11]
        private                 Table array     MAILBOX[11]
        private                 Table array     MAILSENDER[11]
        private                 Table array     MAILCTGRY[11]
                                trigger         CHAT                = CreateTrigger()
    endglobals
    
    function AddRestrictedWord takes string s returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerChatEvent(CHAT, Player(i), s, false)
            set i = i + 1
        endloop
    endfunction
    
    function ChangeTitle takes string s returns nothing
        set TITLE = s
    endfunction
    
    function SetHost takes player p returns nothing
        set HOST = p
    endfunction
    
    function SetNickName takes integer i, string s returns nothing
        set PLAYER_NAME[i] = s
    endfunction
    
    function GetElapsedGameTime takes nothing returns string
        if SHOW_TIME_TAG then
            return GAME_TIMES
        endif
        debug return DEBUG_MSG7
        return ""
    endfunction
    
    private function unswear takes nothing returns nothing
        set SWEAR = false
        call DestroyTimer(GetExpiredTimer())
    endfunction
    
    private function recycle takes integer i returns nothing
        local integer i2 = 0
        
        loop
            set i2 = i2 + 1
            set MAILBOX[i].string[i2] = MAILBOX[i].string[i2 + 1]
            set MAILSENDER[i].integer[i2] = MAILSENDER[i].integer[i2 + 1]
            set MAILCTGRY[i].integer[i2] = MAILCTGRY[i].integer[i2 + 1]
            exitwhen i2 >= MAX_SAVED - 1
        endloop
        set TOTAL[i].integer[MAILCTGRY[i].integer[1]] = TOTAL[i].integer[MAILCTGRY[i].integer[1]] - 1
        set TOTAL[i].integer[5] = TOTAL[i].integer[5] - 1
    endfunction
    
    private function update takes integer i returns nothing
        local integer i2
        local integer t = 0
        
        if GetLocalPlayer() == Player(i) then
            call ClearTextMessages()
        endif
        if SHOW_TITLE then
            call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, TITLE)
        endif
        if TOTAL[i].integer[WINDOW[i]] < MAX_MSG + SCROLLINT[i] then
            set i2 = 0
            loop
                exitwhen i2 >= MAX_MSG - TOTAL[i].integer[WINDOW[i]] + SCROLLINT[i]
                call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, " ")
                set i2 = i2 + 1
            endloop
        endif
        set i2 = TOTAL[i].integer[WINDOW[i]] - MAX_MSG + 1 - SCROLLINT[i]
        loop
            exitwhen i2 > TOTAL[i].integer[5] - SCROLLINT[i] or t >= MAX_MSG
            if MAILBOX[i].string[i2] != null then
                if MAILCTGRY[i].integer[i2] == WINDOW[i] or WINDOW[i] == 5 then
                    call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, MAILBOX[i].string[i2])
                    set t = t + 1
                endif
            endif
            set i2 = i2 + 1
        endloop
    endfunction
    
    private function showdebug takes integer pn, string msg returns nothing
        if TOTAL[pn].integer[5] >= MAX_SAVED then
            call recycle(pn)
        endif
        set TOTAL[pn].integer[4] = TOTAL[pn].integer[4] + 1
        set TOTAL[pn].integer[5] = TOTAL[pn].integer[5] + 1
        if SHOW_TIME_TAG then
            set MAILBOX[pn].string[TOTAL[pn].integer[5]] = SM_PREFIX + " " + TIME_QUOTATION1 + GAME_TIMES + TIME_QUOTATION2 + " " + msg
        else
            set MAILBOX[pn].string[TOTAL[pn].integer[5]] = SM_PREFIX + " " + DEBUG_MSG1
        endif
        set MAILSENDER[pn].integer[TOTAL[pn].integer[5]] = pn
        set MAILCTGRY[pn].integer[TOTAL[pn].integer[5]] = 4
        call update(pn)
    endfunction
    
    private function chat takes nothing returns boolean
        local string msg
        local string cmd
        local string s
        local string res
        local player p
        local integer pn
        local integer len
        local integer i = 0
        local integer i2
        local integer t
        
        if GetEventPlayerChatStringMatched() != "" then
            set SWEAR = true
            call TimerStart(CreateTimer(), 0.01, false, function unswear)
        endif
        if not SWEAR then
            set msg = GetEventPlayerChatString()
            set cmd = SubString(msg, 0, 1)
            set p = GetTriggerPlayer()
            set pn = GetPlayerId(p)
            set res = ""
            set i = 0
            if cmd == CMD_PREFIX then
                set len = StringLength(CMD_PREFIX)
                if SubString(msg, len, len + StringLength(CMD_SHOWALL)) == CMD_SHOWALL then
                    set WINDOW[pn] = 1
                    call update(pn)
                elseif SubString(msg, len, len + StringLength(CMD_SHOWPRIVATE)) == CMD_SHOWPRIVATE then
                    set WINDOW[pn] = 2
                    call update(pn)
                elseif SubString(msg, len, len + StringLength(CMD_SHOWTEAM)) == CMD_SHOWTEAM then
                    set WINDOW[pn] = 3
                    call update(pn)
                elseif SubString(msg, len, len + StringLength(CMD_SHOWSYSTEM)) == CMD_SHOWSYSTEM then
                    set WINDOW[pn] = 4
                    call update(pn)
                elseif SubString(msg, len, len + StringLength(CMD_SHOWGENERAL)) == CMD_SHOWGENERAL then
                    set WINDOW[pn] = 5
                    call update(pn)
                debug else
                    debug call showdebug(pn, DEBUG_MSG1)
                endif
            elseif cmd == MSG_PREFIX then
                set len = StringLength(MSG_PREFIX)
                if StringLength(msg) - len <= MAX_LENGTH then
                    if SubString(msg, len, len + StringLength(MSG_ALL)) == MSG_ALL then
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_ALL) + 1, StringLength(msg)))
                        if SHOW_TIME_TAG then
                            set msg = AM_PREFIX + " " + TIME_QUOTATION1 + GAME_TIMES + TIME_QUOTATION2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        else
                            set msg = AM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        endif
                        loop
                            exitwhen i > 11
                            if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                                if TOTAL[i].integer[5] >= MAX_SAVED then
                                    call recycle(i)
                                endif
                                set TOTAL[i].integer[1] = TOTAL[i].integer[1] + 1
                                set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                                set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                                set MAILSENDER[i].integer[TOTAL[i].integer[5]] = pn
                                set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 1
                                call update(i)
                            endif
                            set i = i + 1
                        endloop
                    elseif SubString(msg, len, len + StringLength(MSG_PRIVATE)) == MSG_PRIVATE then
                        set t = S2I(SubString(msg, len + StringLength(MSG_PRIVATE) + 1, StringLength(MSG_PRIVATE) + 3))
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_PRIVATE) + StringLength(I2S(t)), StringLength(msg)))
                        if SHOW_TIME_TAG then
                            set msg = PM_PREFIX + " " + TIME_QUOTATION1 + GAME_TIMES + TIME_QUOTATION2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        else
                            set msg = PM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        endif
                        if t != pn then
                            if GetPlayerSlotState(Player(t)) == PLAYER_SLOT_STATE_PLAYING then
                                if not IsPlayerInForce(Player(pn), REJECT_LIST[t]) then
                                    if TOTAL[t].integer[5] >= MAX_SAVED then
                                        call recycle(i)
                                    endif
                                    set TOTAL[t].integer[2] = TOTAL[t].integer[2] + 1
                                    set TOTAL[t].integer[5] = TOTAL[t].integer[5] + 1
                                    set MAILBOX[t].string[TOTAL[t].integer[5]] = msg
                                    set MAILSENDER[t].integer[TOTAL[t].integer[5]] = pn
                                    set MAILCTGRY[t].integer[TOTAL[t].integer[5]] = 2
                                    call update(t)
                                endif
                            debug else
                                debug call showdebug(pn, DEBUG_MSG4)
                            endif
                        debug else
                            debug call showdebug(pn, DEBUG_MSG3)
                        endif
                    elseif SubString(msg, len, len + StringLength(MSG_TEAM)) == MSG_TEAM then
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_TEAM) + 1, StringLength(msg)))
                        if SHOW_TIME_TAG then
                            set msg = TM_PREFIX + " " + TIME_QUOTATION1 + GAME_TIMES + TIME_QUOTATION2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        else
                            set msg = TM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
                        endif
                        loop
                            exitwhen i > 11
                            if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                                if TOTAL[i].integer[5] >= MAX_SAVED then
                                    call recycle(i)
                                endif
                                set TOTAL[i].integer[3] = TOTAL[i].integer[3] + 1
                                set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                                set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                                set MAILSENDER[i].integer[TOTAL[i].integer[5]] = pn
                                set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 3
                                call update(i)
                            endif
                            set i = i + 1
                        endloop
                    elseif SubString(msg, len, len + StringLength(MSG_ANNOUNCEMENT)) == MSG_ANNOUNCEMENT then
                        if p == HOST then
                            set msg = Gradient(SubString(msg, len + StringLength(MSG_ANNOUNCEMENT) + 1, StringLength(msg)))
                            if SHOW_TIME_TAG then
                                set msg = SM_PREFIX + " " + TIME_QUOTATION1 + GAME_TIMES + TIME_QUOTATION2 + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                            else
                                set msg = SM_PREFIX + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                            endif
                            loop
                                exitwhen i > 11
                                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                                    if TOTAL[i].integer[5] >= MAX_SAVED then
                                        call recycle(i)
                                    endif
                                    set TOTAL[i].integer[4] = TOTAL[i].integer[4] + 1
                                    set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                                    set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                                    set MAILSENDER[i].integer[TOTAL[i].integer[5]] = pn
                                    set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 4
                                    call update(i)
                                endif
                                set i = i + 1
                            endloop
                        debug else
                            debug call showdebug(pn, DEBUG_MSG5)
                        endif
                    debug else
                        debug call showdebug(pn, DEBUG_MSG1)
                    endif
                endif
            debug else
                debug call showdebug(pn, DEBUG_MSG1)
            endif
        endif
        return false
    endfunction
    
    private function time takes nothing returns nothing
        local string s1
        local string s2
        local integer i = 0
        
        set GAME_TIME = GAME_TIME + 1
        set s1 = I2S(GAME_TIME / 60)
        set s2 = I2S(GAME_TIME - GAME_TIME / 60 * 60)
        if StringLength(s1) == 1 then
            set s1 = "0" + s1
        endif
        if StringLength(s2) == 1 then
            set s2 = "0" + s2
        endif
        loop
            exitwhen i > 2
            if SubString(s1, i, i + 1) == "1" then
                set s1 = TIME_SPACEFILLER + s1
                set i = i + 1
            endif
            if SubString(s2, i, i + 1) == "1" then
                set s2 = s2 + TIME_SPACEFILLER
            endif
            set i = i + 1
        endloop
        set GAME_TIMES = s1 + TIME_DEVIDER + s2
    endfunction
    
    private function scroll_up takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] < TOTAL[i].integer[WINDOW[i]] - 1 then
            set SCROLLINT[i] = SCROLLINT[i] + 1
        endif
        call update(i)
    endfunction
    
    private function scroll_down takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] > 0 then
            set SCROLLINT[i] = SCROLLINT[i] - 1
        endif
        call update(i)
    endfunction
    
    private function ini takes nothing returns nothing
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
        local integer i = 0
        
        call setname()
        loop
            exitwhen i > 11
            if GetPlayerController(Player(i)) == MAP_CONTROL_USER  then
                static if not LIBRARY_ResWord then
                    call TriggerRegisterPlayerChatEvent(CHAT, Player(i), "", false)
                endif
                set REJECT_LIST[i] = CreateForce()
                set TOTAL[i] = 0
                set SCROLLINT[i] = 0
                set WINDOW[i] = 5
                set TOTAL[i] = Table.create()
                set MAILBOX[i] = Table.create()
                set MAILSENDER[i] = Table.create()
                set MAILCTGRY[i] = Table.create()
                set TOTAL[i].integer[1] = 0
                set TOTAL[i].integer[2] = 0
                set TOTAL[i].integer[3] = 0
                set TOTAL[i].integer[4] = 0
                set TOTAL[i].integer[5] = 0
            endif
            set PLAYER_NAME[i] = PLAYER_COLOR[i] + GetPlayerName(Player(i)) + "|r"
            set i = i + 1
        endloop
        if ENABLE_SCROLLING then
            call ScrollUpEvent(t1)
            call ScrollDownEvent(t2)
            call TriggerAddAction(t1, function scroll_up)
            call TriggerAddAction(t2, function scroll_down)
        endif
        call TriggerAddCondition(CHAT, Condition(function chat))
        if SHOW_TIME_TAG then
            call TimerStart(CreateTimer(), 1, true, function time)
        endif
        if MAX_MSG > 15 then
            set MAX_MSG = 15
        endif
    endfunction
endlibrary
 

Attachments

  • a.jpg
    a.jpg
    162 KB · Views: 311
Last edited:

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
it's an addition for any game.. not a chat room

EDIT:
Newest code (80% completed)
JASS:
library UltimateChat initializer ini requires GradientText, Table
    globals
        private                 string array    PLAYER_COLOR
        private                 string array    PLAYER_NAME
        // Interfaces
        private                 string          TITLE               = "UltimateChatSystem v1.0"
        private     constant    string          PM_PREFIX           = "[|cff0000ffPrivate|r]"
        private     constant    string          SM_PREFIX           = "[|cff0000ffSystem|r]"
        private     constant    string          TM_PREFIX           = "[|cff0000ffTeam|r]"
        private     constant    string          AM_PREFIX           = "[|cff0000ffAll|r]"
        private     constant    string          ANNOUNCEMENT        = "|cffffff00Announcement|r"
        private     constant    string          TIME_BRACKET1       = "["
        private     constant    string          TIME_DEVIDER        = ":"
        private     constant    string          TIME_BRACKET2       = "]"
        private     constant    string          TIME_SPACEFILLER    = ""
        private     constant    string          EQUAL_SYMBOL        = ":"
        // Commands
        private     constant    string          CMD_PREFIX          = "-"
        private     constant    string          CMD_CLOSE           = "close"
        private     constant    string          CMD_OPEN            = "open"
        private     constant    string          CMD_CLEAR           = "clear"
        private     constant    string          CMD_BAN             = "reject"
        private     constant    string          CMD_UNBAN           = "unreject"
        private     constant    string          CMD_SHOWALL         = "all"
        private     constant    string          CMD_SHOWPRIVATE     = "private"
        private     constant    string          CMD_SHOWTEAM        = "team"
        private     constant    string          CMD_SHOWSYSTEM      = "system"
        private     constant    string          CMD_SHOWGENERAL     = "general"
        // Messaging
        private     constant    string          MSG_PREFIX          = "*"
        private     constant    string          MSG_ALL             = "all"
        private     constant    string          MSG_TEAM            = "team"
        private     constant    string          MSG_PRIVATE         = "pm"
        private     constant    string          MSG_ANNOUNCEMENT    = "announce"
        // Options
        private                 integer         MAX_MSG             = 15
        private     constant    integer         MAX_SAVED           = 50
        private     constant    integer         MAX_LENGTH          = 73
        private     constant    integer         MAX_NICK_LENGTH     = 10
        private     constant    boolean         INITIALY_OPEN       = false
        private     constant    boolean         SHOW_TIME_TAG       = true
        private     constant    boolean         SHOW_TITLE          = true
        private     constant    boolean         ENABLE_REPLACER     = true
        private     constant    boolean         ENABLE_SCROLLING    = true
        private     constant    integer         ANNOUNCE_DELAY      = 30
        private     constant    integer         FLOOD_CHECK_TIMER   = 5
        private     constant    integer         FLOOD_CHAT_MAX      = 5
        // Debug Messages
        private     constant    string          DEBUG_MSG1          = "|CFFFF0000INVALID COMMAND|r"
        private     constant    string          DEBUG_MSG2          = "|CFFFF0000MESSAGE OVERSIZED|r"
        private     constant    string          DEBUG_MSG3          = "|CFFFF0000INVALID RECIPIENT|r"
        private     constant    string          DEBUG_MSG4          = "|CFFFF0000RECIPIENT IS UNAVAILABLE|r"
        private     constant    string          DEBUG_MSG5          = "|CFFFF0000YOU DON'T HAVE THE AUTHORITY|r"
        private     constant    string          DEBUG_MSG6          = "|CFFFF0000DON'T FLOOD!|r"
        private     constant    string          DEBUG_MSG7          = "|CFFFF0000TIME TAG DISABLED|r"
        private     constant    string          DEBUG_MSG8          = "|CFF00FF00PRIVATE MESSAGE HAS BEEN SENT|r"
        private     constant    string          DEBUG_MSG9          = "|CFFFF0000MESSAGE CONTAINS RESTRICTED WORD(S)|r"
        private     constant    string          DEBUG_MSG10         = "|CFFFF0000UNABLE TO REJECT/UNREJECT TARGET|r"
        private     constant    string          DEBUG_MSG11         = "|CFF00FF00TARGET HAS BEEN ADDED/REMOVED TO/FROM REJECT LIST|r"
        
    endglobals
    
    private function setname takes nothing returns nothing
        set PLAYER_COLOR[0] = "|CFFFF0303"
        set PLAYER_COLOR[1] = "|CFF0042FF"
        set PLAYER_COLOR[2] = "|CFF00FFFF"
        set PLAYER_COLOR[3] = "|CFF540081"
        set PLAYER_COLOR[4] = "|CFFFFFF01"
        set PLAYER_COLOR[5] = "|CFFFE8A0E"
        set PLAYER_COLOR[6] = "|CFF20C000"
        set PLAYER_COLOR[7] = "|CFFE55BB0"
        set PLAYER_COLOR[8] = "|CFF959697"
        set PLAYER_COLOR[9] = "|CFF7EBFF1"
        set PLAYER_COLOR[10] = "|CFF106246"
        set PLAYER_COLOR[11] = "|CFF4E2A04"
    endfunction
    
    private function ScrollUpEvent takes trigger t returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
            set i = i + 1
        endloop
    endfunction
    
    private function ScrollDownEvent takes trigger t returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
            set i = i + 1
        endloop
    endfunction
    
    globals
        private                 player          HOST                = Player(15)
        private                 integer array   SCROLLINT
        private                 integer array   WINDOW
        private                 integer array   LAST_CHAT
        private                 integer array   LAST_PM_TARGET
        private                 force array     REJECT_LIST
        private                 integer         GAME_TIME           = 0
        private                 string          GAME_TIMES          = "00" + TIME_DEVIDER + "00"
        private                 boolean         SWEAR               = false
        private                 boolean array   OPEN
        private                 Table array     TOTAL[11]
        private                 Table array     MAILBOX[11]
        private                 Table array     MAILCTGRY[11]
                                trigger         CHAT                = CreateTrigger()
    endglobals
    
    private function unswear takes nothing returns nothing
        set SWEAR = false
        call DestroyTimer(GetExpiredTimer())
    endfunction
    
    private function recycle takes integer i returns nothing
        local integer i2 = 0
        
        loop
            set i2 = i2 + 1
            set MAILBOX[i].string[i2] = MAILBOX[i].string[i2 + 1]
            set MAILCTGRY[i].integer[i2] = MAILCTGRY[i].integer[i2 + 1]
            exitwhen i2 >= MAX_SAVED - 1
        endloop
        set TOTAL[i].integer[MAILCTGRY[i].integer[1]] = TOTAL[i].integer[MAILCTGRY[i].integer[1]] - 1
        set TOTAL[i].integer[5] = TOTAL[i].integer[5] - 1
    endfunction
    
    private function update takes integer i returns nothing
        local integer i2
        local integer t = 0
        
        if GetLocalPlayer() == Player(i) then
            call ClearTextMessages()
        endif
        if SHOW_TITLE then
            call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, TITLE)
        endif
        if TOTAL[i].integer[WINDOW[i]] < MAX_MSG + SCROLLINT[i] then
            set i2 = 0
            loop
                exitwhen i2 >= MAX_MSG - TOTAL[i].integer[WINDOW[i]] + SCROLLINT[i]
                call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, " ")
                set i2 = i2 + 1
            endloop
        endif
        set i2 = TOTAL[i].integer[WINDOW[i]] - MAX_MSG + 1 - SCROLLINT[i]
        loop
            exitwhen i2 > TOTAL[i].integer[5] - SCROLLINT[i] or t >= MAX_MSG
            if MAILBOX[i].string[i2] != null then
                if MAILCTGRY[i].integer[i2] == WINDOW[i] or WINDOW[i] == 5 then
                    call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, MAILBOX[i].string[i2])
                    set t = t + 1
                endif
            endif
            set i2 = i2 + 1
        endloop
    endfunction
    
    private function showdebug takes integer pn, string msg returns nothing
        if TOTAL[pn].integer[5] >= MAX_SAVED then
            call recycle(pn)
        endif
        set TOTAL[pn].integer[4] = TOTAL[pn].integer[4] + 1
        set TOTAL[pn].integer[5] = TOTAL[pn].integer[5] + 1
        if SHOW_TIME_TAG then
            set MAILBOX[pn].string[TOTAL[pn].integer[5]] = SM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + msg
        else
            set MAILBOX[pn].string[TOTAL[pn].integer[5]] = SM_PREFIX + " " + DEBUG_MSG1
        endif
        set MAILCTGRY[pn].integer[TOTAL[pn].integer[5]] = 4
        if OPEN[pn] then
            call update(pn)
        endif
    endfunction
    
    private function save takes integer cat, integer pn, string msg returns nothing
        local integer i = 0
        
        if cat == 1 then
            if SHOW_TIME_TAG then
                set msg = AM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = AM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            loop
                exitwhen i > 11
                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                    if TOTAL[i].integer[5] >= MAX_SAVED then
                        call recycle(i)
                    endif
                    set TOTAL[i].integer[1] = TOTAL[i].integer[1] + 1
                    set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                    set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                    set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 1
                    if OPEN[i] then
                        call update(i)
                    endif
                endif
                set i = i + 1
            endloop
        elseif cat == 2 then
            if SHOW_TIME_TAG then
                set msg = PM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = PM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            if LAST_PM_TARGET[pn] != pn then
                if GetPlayerSlotState(Player(LAST_PM_TARGET[pn])) == PLAYER_SLOT_STATE_PLAYING then
                    if not IsPlayerInForce(Player(pn), REJECT_LIST[LAST_PM_TARGET[pn]]) then
                        if TOTAL[LAST_PM_TARGET[pn]].integer[5] >= MAX_SAVED then
                            call recycle(i)
                        endif
                        set TOTAL[LAST_PM_TARGET[pn]].integer[2] = TOTAL[LAST_PM_TARGET[pn]].integer[2] + 1
                        set TOTAL[LAST_PM_TARGET[pn]].integer[5] = TOTAL[LAST_PM_TARGET[pn]].integer[5] + 1
                        set MAILBOX[LAST_PM_TARGET[pn]].string[TOTAL[LAST_PM_TARGET[pn]].integer[5]] = msg
                        set MAILCTGRY[LAST_PM_TARGET[pn]].integer[TOTAL[LAST_PM_TARGET[pn]].integer[5]] = 2
                        if OPEN[LAST_PM_TARGET[pn]] then
                            call update(LAST_PM_TARGET[pn])
                        endif
                        call showdebug(pn, DEBUG_MSG8)
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG4)
                endif
            debug else
                debug call showdebug(pn, DEBUG_MSG3)
            endif
        elseif cat == 3 then
            if SHOW_TIME_TAG then
                set msg = TM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = TM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            loop
                exitwhen i > 11
                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                    if IsPlayerAlly(Player(pn), Player(i)) then
                        if TOTAL[i].integer[5] >= MAX_SAVED then
                            call recycle(i)
                        endif
                        set TOTAL[i].integer[3] = TOTAL[i].integer[3] + 1
                        set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                        set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                        set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 3
                        if OPEN[i] then
                            call update(i)
                        endif
                    endif
                endif
                set i = i + 1
            endloop
        endif
    endfunction
    
    private function chat takes nothing returns boolean
        local string msg
        local string cmd
        local string s
        local string res
        local player p = GetTriggerPlayer()
        local integer pn = GetPlayerId(p)
        local integer len
        local integer i = 0
        local integer i2
        local integer t
        
        if GetEventPlayerChatStringMatched() != "" and not SWEAR then
            set SWEAR = true
            debug call showdebug(pn, DEBUG_MSG9)
            call TimerStart(CreateTimer(), 0.01, false, function unswear)
        endif
        if not SWEAR then
            set msg = GetEventPlayerChatString()
            set cmd = SubString(msg, 0, 1)
            set res = ""
            if cmd == CMD_PREFIX then
                set len = StringLength(CMD_PREFIX)
                if SubString(msg, len, len + StringLength(CMD_SHOWALL)) == CMD_SHOWALL then
                    set WINDOW[pn] = 1
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWPRIVATE)) == CMD_SHOWPRIVATE then
                    set WINDOW[pn] = 2
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWTEAM)) == CMD_SHOWTEAM then
                    set WINDOW[pn] = 3
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWSYSTEM)) == CMD_SHOWSYSTEM then
                    set WINDOW[pn] = 4
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWGENERAL)) == CMD_SHOWGENERAL then
                    set WINDOW[pn] = 5
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_OPEN)) == CMD_OPEN then
                    set OPEN[pn] = true
                    call update(pn)
                elseif SubString(msg, len, len + StringLength(CMD_CLOSE)) == CMD_CLOSE then
                    set OPEN[pn] = false
                    if GetLocalPlayer() == p then
                        call ClearTextMessages()
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_CLEAR)) == CMD_CLEAR then
                    set TOTAL[pn].integer[1] = 0
                    set TOTAL[pn].integer[2] = 0
                    set TOTAL[pn].integer[3] = 0
                    set TOTAL[pn].integer[4] = 0
                    set TOTAL[pn].integer[5] = 0
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_BAN)) == CMD_BAN then
                    set t = S2I(SubString(msg, len + StringLength(CMD_BAN), len + StringLength(CMD_BAN) + 2)) - 1
                    if t != pn and t >= 0 then
                        debug call showdebug(pn, DEBUG_MSG11)
                        call ForceAddPlayer(REJECT_LIST[pn], Player(t))
                    debug else
                        debug call showdebug(pn, DEBUG_MSG10)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_UNBAN)) == CMD_UNBAN then
                    set t = S2I(SubString(msg, len + StringLength(CMD_UNBAN), len + StringLength(CMD_UNBAN) + 2)) - 1
                    if t != pn and t >= 0 then
                        debug call showdebug(pn, DEBUG_MSG11)
                        call ForceRemovePlayer(REJECT_LIST[pn], Player(t))
                    debug else
                        debug call showdebug(pn, DEBUG_MSG10)
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG1)
                endif
            elseif cmd == MSG_PREFIX then
                set len = StringLength(MSG_PREFIX)
                if StringLength(msg) - len <= MAX_LENGTH then
                    if SubString(msg, len, len + StringLength(MSG_ALL)) == MSG_ALL then
                        set LAST_CHAT[pn] = 1
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_ALL) + 1, StringLength(msg)))
                        call save(1, pn, msg)
                    elseif SubString(msg, len, len + StringLength(MSG_PRIVATE)) == MSG_PRIVATE then
                        set LAST_CHAT[pn] = 2
                        set LAST_PM_TARGET[pn] = S2I(SubString(msg, len + StringLength(MSG_PRIVATE), len + StringLength(MSG_PRIVATE) + 2)) - 1
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_PRIVATE) + StringLength(I2S(LAST_PM_TARGET[pn])), StringLength(msg)))
                        call save(2, pn, msg)
                    elseif SubString(msg, len, len + StringLength(MSG_TEAM)) == MSG_TEAM then
                        set LAST_CHAT[pn] = 3
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_TEAM) + 1, StringLength(msg)))
                        call save(3, pn, msg)
                    elseif SubString(msg, len, len + StringLength(MSG_ANNOUNCEMENT)) == MSG_ANNOUNCEMENT then
                        set LAST_CHAT[pn] = 4
                        if p == HOST then
                            set msg = Gradient(SubString(msg, len + StringLength(MSG_ANNOUNCEMENT) + 1, StringLength(msg)))
                            if SHOW_TIME_TAG then
                                set msg = SM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                            else
                                set msg = SM_PREFIX + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                            endif
                            loop
                                exitwhen i > 11
                                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                                    if TOTAL[i].integer[5] >= MAX_SAVED then
                                        call recycle(i)
                                    endif
                                    set TOTAL[i].integer[4] = TOTAL[i].integer[4] + 1
                                    set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                                    set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                                    set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 4
                                    if OPEN[i] then
                                        call update(i)
                                    endif
                                endif
                                set i = i + 1
                            endloop
                        debug else
                            debug call showdebug(pn, DEBUG_MSG5)
                        endif
                    debug else
                        debug call showdebug(pn, DEBUG_MSG1)
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG2)
                endif
            else
                if StringLength(msg) <= MAX_LENGTH then
                    call save(LAST_CHAT[pn], pn, Gradient(msg))
                debug else
                    debug call showdebug(pn, DEBUG_MSG2)
                endif
            endif
        endif
        return false
    endfunction
    
    private function time takes nothing returns nothing
        local string s1
        local string s2
        local integer i = 0
        
        set GAME_TIME = GAME_TIME + 1
        set s1 = I2S(GAME_TIME / 60)
        set s2 = I2S(GAME_TIME - GAME_TIME / 60 * 60)
        if StringLength(s1) == 1 then
            set s1 = "0" + s1
        endif
        if StringLength(s2) == 1 then
            set s2 = "0" + s2
        endif
        loop
            exitwhen i > 2
            if SubString(s1, i, i + 1) == "1" then
                set s1 = TIME_SPACEFILLER + s1
                set i = i + 1
            endif
            if SubString(s2, i, i + 1) == "1" then
                set s2 = s2 + TIME_SPACEFILLER
            endif
            set i = i + 1
        endloop
        set GAME_TIMES = s1 + TIME_DEVIDER + s2
    endfunction
    
    private function scroll_up takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] < TOTAL[i].integer[WINDOW[i]] - 1 then
            set SCROLLINT[i] = SCROLLINT[i] + 1
        endif
        if OPEN[i] then
            call update(i)
        endif
    endfunction
    
    private function scroll_down takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] > 0 then
            set SCROLLINT[i] = SCROLLINT[i] - 1
        endif
        if OPEN[i] then
            call update(i)
        endif
    endfunction
    
    private function ini takes nothing returns nothing
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
        local integer i = 0
        
        call setname()
        loop
            exitwhen i > 11
            if GetPlayerController(Player(i)) == MAP_CONTROL_USER  then
                static if not LIBRARY_ResWord then
                    call TriggerRegisterPlayerChatEvent(CHAT, Player(i), "", false)
                endif
                set REJECT_LIST[i] = CreateForce()
                set TOTAL[i] = 0
                set SCROLLINT[i] = 0
                set WINDOW[i] = 5
                set TOTAL[i] = Table.create()
                set MAILBOX[i] = Table.create()
                set MAILCTGRY[i] = Table.create()
                set TOTAL[i].integer[1] = 0
                set TOTAL[i].integer[2] = 0
                set TOTAL[i].integer[3] = 0
                set TOTAL[i].integer[4] = 0
                set TOTAL[i].integer[5] = 0
                set LAST_CHAT[i] = 1
                if INITIALY_OPEN then
                    call update(i)
                    set OPEN[i] = true
                else
                    set OPEN[i] = false
                endif
            endif
            set PLAYER_NAME[i] = PLAYER_COLOR[i] + SubString(GetPlayerName(Player(i)), 0, MAX_NICK_LENGTH) + "|r"
            set i = i + 1
        endloop
        if ENABLE_SCROLLING then
            call ScrollUpEvent(t1)
            call ScrollDownEvent(t2)
            call TriggerAddAction(t1, function scroll_up)
            call TriggerAddAction(t2, function scroll_down)
        endif
        call TriggerAddCondition(CHAT, Condition(function chat))
        if SHOW_TIME_TAG then
            call TimerStart(CreateTimer(), 1, true, function time)
        endif
        if MAX_MSG > 15 then
            set MAX_MSG = 15
        endif
    endfunction
    
    function AddRestrictedWord takes string s returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerChatEvent(CHAT, Player(i), s, false)
            set i = i + 1
        endloop
    endfunction
    
    function ChangeTitle takes string s returns nothing
        set TITLE = s
    endfunction
    
    function SetHost takes player p returns nothing
        set HOST = p
    endfunction
    
    function OpenChatWindow takes integer i returns nothing
        set OPEN[i] = true
        call update(i)
    endfunction
    
    function CloseChatWindow takes integer i returns nothing
        set OPEN[i] = false
        if GetLocalPlayer() == Player(i) then
            call ClearTextMessages()
        endif
    endfunction
    
    function GetElapsedGameTime takes nothing returns string
        if SHOW_TIME_TAG then
            return GAME_TIMES
        endif
        debug return DEBUG_MSG7
        return ""
    endfunction
endlibrary

EDIT:
newest code (95% done)
JASS:
library UltimateChat initializer ini requires GradientText, Table
    /****************************************************************************************************/
    /*                                                                                                  */
    /*                              'Ultimate Chat System' v1.0                                         */
    /*                                                  *****                                           */
    /*                                               by Dalvengyr                                       */
    /*                                                                                                  */
    /* A smooth, full-featured, light-weight chat system that would improve your game elegancy nicely.  */
    /* Beside using features of this system, you are also able to use advantages of other libraries     */
    /* like GradientText and Table. This is a so much improvements of my last chat system on thw. There */
    /* is no more uneeded process and everything is very optimized. You are also able to configure      */
    /* almost every aspect of this chat system, like interfaces, commands, debug messages, etc. This    */
    /* system also supports some APIs that would be very helpful in-game.                               */
    /*                                                                                                  */
    /* Requirements:                                                                                    */
    /*      1. JNGP                                                                                     */
    /*      2. GradientText   by me                                                                     */
    /*      3. Table          by Bribe                                                                  */
    /*                                                                                                  */
    /* API:                                                                                             */
    /*                                                                                                  */
    /* function AddRestrictedWord takes string s returns nothing                                        */
    /*                                                                                                  */
    /* function SetUCSTitle takes string s returns nothing                                              */
    /*                                                                                                  */
    /* function SetUCSHost takes player p returns nothing                                               */
    /*                                                                                                  */
    /* function GetUCSHost takes player p returns nothing                                               */
    /*                                                                                                  */
    /* function OpenUCSChatWindow takes integer pn returns nothing                                      */
    /*                                                                                                  */
    /* function CloseUCSChatWindow takes integer pn returns nothing                                     */
    /*                                                                                                  */
    /* function GetUCSElapsedGameTime takes nothing returns string                                      */
    /*                                                                                                  */
    /* function GetUCSNickname takes integer pn returns string                                          */
    /*                                                                                                  */
    /* function SendUCSChatAll takes integer sender, string msg returns nothing                         */
    /*                                                                                                  */
    /* function SendUCSChatTeam takes integer sender, string msg returns nothing                        */
    /*                                                                                                  */
    /* function SendUCSChatSystem takes integer reciever, string msg returns nothing                    */
    /*                                                                                                  */
    /* function SendUCSChatPrivate takes integer sender, integer reciever, string msg returns nothing   */
    /*                                                                                                  */
    /* function TriggerRegisterUCSChatEvent takes trigger t, code cond, code act returns nothing        */
    /*                                                                                                  */
    /* function GetUCSSender takes nothing returns player                                               */
    /*                                                                                                  */
    /* function GetUCSReciever takes nothing returns player                                             */
    /*                                                                                                  */
    /* function GetUCSMessage takes nothing returns string                                              */
    /*                                                                                                  */
    
    globals
        private                 string array    PLAYER_COLOR
        private                 string array    PLAYER_NAME
        // Interfaces
        private                 string          TITLE               = "UltimateChatSystem v1.0"
        private     constant    string          PM_PREFIX           = "[|cff0000ffPrivate|r]"
        private     constant    string          SM_PREFIX           = "[|cff0000ffSystem|r]"
        private     constant    string          TM_PREFIX           = "[|cff0000ffTeam|r]"
        private     constant    string          AM_PREFIX           = "[|cff0000ffAll|r]"
        private     constant    string          ANNOUNCEMENT        = "|cffffff00Announcement|r"
        private     constant    string          TIME_BRACKET1       = "["
        private     constant    string          TIME_DEVIDER        = ":"
        private     constant    string          TIME_BRACKET2       = "]"
        private     constant    string          TIME_SPACEFILLER    = ""
        private     constant    string          EQUAL_SYMBOL        = ":"
        // Commands
        private     constant    string          CMD_PREFIX          = "-"
        private     constant    string          CMD_OPEN            = "open"
        private     constant    string          CMD_CLOSE           = "close"
        private     constant    string          CMD_CLEAR           = "clear"
        private     constant    string          CMD_BAN             = "reject"
        private     constant    string          CMD_UNBAN           = "unreject"
        private     constant    string          CMD_SHOWALL         = "all"
        private     constant    string          CMD_SHOWPRIVATE     = "private"
        private     constant    string          CMD_SHOWTEAM        = "team"
        private     constant    string          CMD_SHOWSYSTEM      = "system"
        private     constant    string          CMD_SHOWGENERAL     = "general"
        // Messaging
        private     constant    string          MSG_PREFIX          = "*"
        private     constant    string          MSG_ALL             = "all"
        private     constant    string          MSG_TEAM            = "team"
        private     constant    string          MSG_PRIVATE         = "pm"
        private     constant    string          MSG_ANNOUNCEMENT    = "announce"
        // Options
        private                 integer         MAX_MSG             = 15
        private     constant    integer         MAX_SAVED           = 50
        private     constant    integer         MAX_LENGTH          = 73
        private     constant    integer         MAX_NICK_LENGTH     = 10
        private     constant    boolean         INITIALY_OPEN       = false
        private     constant    boolean         SHOW_TIME_TAG       = true
        private     constant    boolean         SHOW_TITLE          = true
        private     constant    boolean         ENABLE_RESTRICTION  = true
        private     constant    boolean         ENABLE_SCROLLING    = true
        private     constant    integer         ANNOUNCE_DELAY      = 30
        private     constant    integer         FLOOD_CHECK_TIMER   = 5
        private     constant    integer         FLOOD_CHAT_MAX      = 5
        // Debug Messages
        private     constant    string          DEBUG_MSG1          = "|CFFFF0000INVALID COMMAND|r"
        private     constant    string          DEBUG_MSG2          = "|CFFFF0000MESSAGE OVERSIZED|r"
        private     constant    string          DEBUG_MSG3          = "|CFFFF0000INVALID RECIPIENT|r"
        private     constant    string          DEBUG_MSG4          = "|CFFFF0000RECIPIENT IS UNAVAILABLE|r"
        private     constant    string          DEBUG_MSG5          = "|CFFFF0000YOU DON'T HAVE THE AUTHORITY|r"
        private     constant    string          DEBUG_MSG6          = "|CFFFF0000DON'T FLOOD!|r"
        private     constant    string          DEBUG_MSG7          = "|CFFFF0000TIME TAG DISABLED|r"
        private     constant    string          DEBUG_MSG8          = "|CFF00FF00PRIVATE MESSAGE HAS BEEN SENT|r"
        private     constant    string          DEBUG_MSG9          = "|CFFFF0000MESSAGE CONTAINS RESTRICTED WORD(S)|r"
        private     constant    string          DEBUG_MSG10         = "|CFFFF0000UNABLE TO REJECT/UNREJECT TARGET|r"
        private     constant    string          DEBUG_MSG11         = "|CFF00FF00TARGET HAS BEEN ADDED/REMOVED TO/FROM REJECT LIST|r"
        private     constant    string          DEBUG_MSG12         = "|CFFFF0000YOU CAN'T SEND ANNOUNCEMENT TOO OFTEN|r"
        
    endglobals
    
    private function setname takes nothing returns nothing
        set PLAYER_COLOR[0] = "|CFFFF0303"
        set PLAYER_COLOR[1] = "|CFF0042FF"
        set PLAYER_COLOR[2] = "|CFF00FFFF"
        set PLAYER_COLOR[3] = "|CFF540081"
        set PLAYER_COLOR[4] = "|CFFFFFF01"
        set PLAYER_COLOR[5] = "|CFFFE8A0E"
        set PLAYER_COLOR[6] = "|CFF20C000"
        set PLAYER_COLOR[7] = "|CFFE55BB0"
        set PLAYER_COLOR[8] = "|CFF959697"
        set PLAYER_COLOR[9] = "|CFF7EBFF1"
        set PLAYER_COLOR[10] = "|CFF106246"
        set PLAYER_COLOR[11] = "|CFF4E2A04"
    endfunction
    
    private function ScrollUpEvent takes trigger t returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
            set i = i + 1
        endloop
    endfunction
    
    private function ScrollDownEvent takes trigger t returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
            set i = i + 1
        endloop
    endfunction
    
    globals
        private                 player          HOST                = Player(15)
        private                 integer array   SCROLLINT
        private                 integer array   WINDOW
        private                 integer array   LAST_CHAT
        private                 integer array   LAST_PM_TARGET
        private                 integer array   FLOOD_CHAT_TOTAL
        private                 force array     REJECT_LIST
        private                 integer         ANNOUNCE_TIMER      = 0
        private                 integer         GAME_TIME           = 0
        private                 string          GAME_TIMES          = "00" + TIME_DEVIDER + "00"
        private                 boolean         SWEAR               = false
        private                 boolean array   OPEN
        private                 Table array     TOTAL[11]
        private                 Table array     MAILBOX[11]
        private                 Table array     MAILCTGRY[11]
        public                  real            EVT                 = 0.0
        public                  player          EVT_Reciever
        public                  player          EVT_Sender
        public                  string          EVT_Message
                                trigger         CHAT                = CreateTrigger()
    endglobals
    
    private function unswear takes nothing returns nothing
        set SWEAR = false
        call DestroyTimer(GetExpiredTimer())
    endfunction
    
    private function recycle takes integer i returns nothing
        local integer i2 = 0
        
        loop
            set i2 = i2 + 1
            set MAILBOX[i].string[i2] = MAILBOX[i].string[i2 + 1]
            set MAILCTGRY[i].integer[i2] = MAILCTGRY[i].integer[i2 + 1]
            exitwhen i2 >= MAX_SAVED - 1
        endloop
        set TOTAL[i].integer[MAILCTGRY[i].integer[1]] = TOTAL[i].integer[MAILCTGRY[i].integer[1]] - 1
        set TOTAL[i].integer[5] = TOTAL[i].integer[5] - 1
    endfunction
    
    private function update takes integer i returns nothing
        local integer i2
        local integer t = 0
        
        if GetLocalPlayer() == Player(i) then
            call ClearTextMessages()
        endif
        if SHOW_TITLE then
            call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, TITLE)
        endif
        if TOTAL[i].integer[WINDOW[i]] < MAX_MSG + SCROLLINT[i] then
            set i2 = 0
            loop
                exitwhen i2 >= MAX_MSG - TOTAL[i].integer[WINDOW[i]] + SCROLLINT[i]
                call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, " ")
                set i2 = i2 + 1
            endloop
        endif
        set i2 = TOTAL[i].integer[WINDOW[i]] - MAX_MSG + 1 - SCROLLINT[i]
        loop
            exitwhen i2 > TOTAL[i].integer[5] - SCROLLINT[i] or t >= MAX_MSG
            if MAILBOX[i].string[i2] != null then
                if MAILCTGRY[i].integer[i2] == WINDOW[i] or WINDOW[i] == 5 then
                    call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, MAILBOX[i].string[i2])
                    set t = t + 1
                endif
            endif
            set i2 = i2 + 1
        endloop
    endfunction
    
    private function showdebug takes integer pn, string msg returns nothing
        if TOTAL[pn].integer[5] >= MAX_SAVED then
            call recycle(pn)
        endif
        set TOTAL[pn].integer[4] = TOTAL[pn].integer[4] + 1
        set TOTAL[pn].integer[5] = TOTAL[pn].integer[5] + 1
        if SHOW_TIME_TAG then
            set MAILBOX[pn].string[TOTAL[pn].integer[5]] = SM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + msg
        else
            set MAILBOX[pn].string[TOTAL[pn].integer[5]] = SM_PREFIX + " " + DEBUG_MSG1
        endif
        set MAILCTGRY[pn].integer[TOTAL[pn].integer[5]] = 4
        if OPEN[pn] then
            call update(pn)
        endif
    endfunction
    
    private function save takes integer cat, integer pn, string msg returns nothing
        local integer i = 0
        
        set UltimateChat_EVT_Sender = Player(pn)
        set UltimateChat_EVT_Message = msg
        if cat == 1 then
            if SHOW_TIME_TAG then
                set msg = AM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = AM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            loop
                exitwhen i > 11
                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                    set UltimateChat_EVT_Reciever = Player(i)
                    if TOTAL[i].integer[5] >= MAX_SAVED then
                        call recycle(i)
                    endif
                    set TOTAL[i].integer[1] = TOTAL[i].integer[1] + 1
                    set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                    set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                    set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 1
                    if OPEN[i] then
                        call update(i)
                    endif
                    set UltimateChat_EVT = 1.00
                    set UltimateChat_EVT = 0.00
                    set UltimateChat_EVT_Reciever = null
                endif
                set i = i + 1
            endloop
        elseif cat == 2 then
            if SHOW_TIME_TAG then
                set msg = PM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = PM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            if LAST_PM_TARGET[pn] != pn and LAST_PM_TARGET[pn] >= 0 then
                if GetPlayerSlotState(Player(LAST_PM_TARGET[pn])) == PLAYER_SLOT_STATE_PLAYING then
                    if not IsPlayerInForce(Player(pn), REJECT_LIST[LAST_PM_TARGET[pn]]) then
                        set UltimateChat_EVT_Reciever = Player(LAST_PM_TARGET[pn])
                        if TOTAL[LAST_PM_TARGET[pn]].integer[5] >= MAX_SAVED then
                            call recycle(i)
                        endif
                        set TOTAL[LAST_PM_TARGET[pn]].integer[2] = TOTAL[LAST_PM_TARGET[pn]].integer[2] + 1
                        set TOTAL[LAST_PM_TARGET[pn]].integer[5] = TOTAL[LAST_PM_TARGET[pn]].integer[5] + 1
                        set MAILBOX[LAST_PM_TARGET[pn]].string[TOTAL[LAST_PM_TARGET[pn]].integer[5]] = msg
                        set MAILCTGRY[LAST_PM_TARGET[pn]].integer[TOTAL[LAST_PM_TARGET[pn]].integer[5]] = 2
                        if OPEN[LAST_PM_TARGET[pn]] then
                            call update(LAST_PM_TARGET[pn])
                        endif
                        call showdebug(pn, DEBUG_MSG8)
                        set UltimateChat_EVT = 1.00
                        set UltimateChat_EVT = 0.00
                        set UltimateChat_EVT_Reciever = null
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG4)
                endif
            debug else
                debug call showdebug(pn, DEBUG_MSG3)
            endif
        elseif cat == 3 then
            if SHOW_TIME_TAG then
                set msg = TM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = TM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            loop
                exitwhen i > 11
                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                    if IsPlayerAlly(Player(pn), Player(i)) then
                        set UltimateChat_EVT_Reciever = Player(i)
                        if TOTAL[i].integer[5] >= MAX_SAVED then
                            call recycle(i)
                        endif
                        set TOTAL[i].integer[3] = TOTAL[i].integer[3] + 1
                        set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                        set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                        set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 3
                        if OPEN[i] then
                            call update(i)
                        endif
                        set UltimateChat_EVT = 1.00
                        set UltimateChat_EVT = 0.00
                        set UltimateChat_EVT_Reciever = null
                    endif
                endif
                set i = i + 1
            endloop
        endif
        set UltimateChat_EVT_Sender = null
        set UltimateChat_EVT_Message = null
    endfunction
    
    private function chat takes nothing returns boolean
        local string msg
        local string cmd
        local string s
        local string res
        local player p = GetTriggerPlayer()
        local integer pn = GetPlayerId(p)
        local integer len
        local integer i = 0
        local integer i2
        local integer t
        
        if ENABLE_RESTRICTION then
            if GetEventPlayerChatStringMatched() != "" and not SWEAR then
                set SWEAR = true
                debug call showdebug(pn, DEBUG_MSG9)
                call TimerStart(CreateTimer(), 0.01, false, function unswear)
            endif
        endif
        if not SWEAR then
            set msg = GetEventPlayerChatString()
            set cmd = SubString(msg, 0, 1)
            set res = ""
            if cmd == CMD_PREFIX then
                set len = StringLength(CMD_PREFIX)
                if SubString(msg, len, len + StringLength(CMD_SHOWALL)) == CMD_SHOWALL then
                    set WINDOW[pn] = 1
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWPRIVATE)) == CMD_SHOWPRIVATE then
                    set WINDOW[pn] = 2
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWTEAM)) == CMD_SHOWTEAM then
                    set WINDOW[pn] = 3
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWSYSTEM)) == CMD_SHOWSYSTEM then
                    set WINDOW[pn] = 4
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_SHOWGENERAL)) == CMD_SHOWGENERAL then
                    set WINDOW[pn] = 5
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_OPEN)) == CMD_OPEN then
                    set OPEN[pn] = true
                    call update(pn)
                elseif SubString(msg, len, len + StringLength(CMD_CLOSE)) == CMD_CLOSE then
                    set OPEN[pn] = false
                    if GetLocalPlayer() == p then
                        call ClearTextMessages()
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_CLEAR)) == CMD_CLEAR then
                    set TOTAL[pn].integer[1] = 0
                    set TOTAL[pn].integer[2] = 0
                    set TOTAL[pn].integer[3] = 0
                    set TOTAL[pn].integer[4] = 0
                    set TOTAL[pn].integer[5] = 0
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_BAN)) == CMD_BAN then
                    set t = S2I(SubString(msg, len + StringLength(CMD_BAN), len + StringLength(CMD_BAN) + 2)) - 1
                    if t != pn and t >= 0 then
                        debug call showdebug(pn, DEBUG_MSG11)
                        call ForceAddPlayer(REJECT_LIST[pn], Player(t))
                    debug else
                        debug call showdebug(pn, DEBUG_MSG10)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_UNBAN)) == CMD_UNBAN then
                    set t = S2I(SubString(msg, len + StringLength(CMD_UNBAN), len + StringLength(CMD_UNBAN) + 2)) - 1
                    if t != pn and t >= 0 then
                        debug call showdebug(pn, DEBUG_MSG11)
                        call ForceRemovePlayer(REJECT_LIST[pn], Player(t))
                    debug else
                        debug call showdebug(pn, DEBUG_MSG10)
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG1)
                endif
            elseif cmd == MSG_PREFIX then
                set len = StringLength(MSG_PREFIX)
                if StringLength(msg) - len <= MAX_LENGTH then
                    if SubString(msg, len, len + StringLength(MSG_ALL)) == MSG_ALL then
                        set LAST_CHAT[pn] = 1
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_ALL) + 1, StringLength(msg)))
                        call save(1, pn, msg)
                    elseif SubString(msg, len, len + StringLength(MSG_PRIVATE)) == MSG_PRIVATE then
                        set LAST_CHAT[pn] = 2
                        set LAST_PM_TARGET[pn] = S2I(SubString(msg, len + StringLength(MSG_PRIVATE), len + StringLength(MSG_PRIVATE) + 2)) - 1
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_PRIVATE) + StringLength(I2S(LAST_PM_TARGET[pn])), StringLength(msg)))
                        call save(2, pn, msg)
                    elseif SubString(msg, len, len + StringLength(MSG_TEAM)) == MSG_TEAM then
                        set LAST_CHAT[pn] = 3
                        set msg = Gradient(SubString(msg, len + StringLength(MSG_TEAM) + 1, StringLength(msg)))
                        call save(3, pn, msg)
                    elseif SubString(msg, len, len + StringLength(MSG_ANNOUNCEMENT)) == MSG_ANNOUNCEMENT then
                        if p == HOST then
                            if ANNOUNCE_TIMER == 0 then
                                set ANNOUNCE_TIMER = ANNOUNCE_DELAY
                                set msg = Gradient(SubString(msg, len + StringLength(MSG_ANNOUNCEMENT) + 1, StringLength(msg)))
                                if SHOW_TIME_TAG then
                                    set msg = SM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                                else
                                    set msg = SM_PREFIX + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                                endif
                                loop
                                    exitwhen i > 11
                                    if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                                        if TOTAL[i].integer[5] >= MAX_SAVED then
                                            call recycle(i)
                                        endif
                                        set TOTAL[i].integer[4] = TOTAL[i].integer[4] + 1
                                        set TOTAL[i].integer[5] = TOTAL[i].integer[5] + 1
                                        set MAILBOX[i].string[TOTAL[i].integer[5]] = msg
                                        set MAILCTGRY[i].integer[TOTAL[i].integer[5]] = 4
                                        if OPEN[i] then
                                            call update(i)
                                        endif
                                    endif
                                    set i = i + 1
                                endloop
                            debug else
                                debug call showdebug(pn, DEBUG_MSG12)
                            endif
                        debug else
                            debug call showdebug(pn, DEBUG_MSG5)
                        endif
                    debug else
                        debug call showdebug(pn, DEBUG_MSG1)
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG2)
                endif
            else
                if StringLength(msg) <= MAX_LENGTH then
                    call save(LAST_CHAT[pn], pn, Gradient(msg))
                debug else
                    debug call showdebug(pn, DEBUG_MSG2)
                endif
            endif
        endif
        return false
    endfunction
    
    private function time takes nothing returns nothing
        local string s1
        local string s2
        local integer i = 0
        
        if ANNOUNCE_TIMER > 0 then
            set ANNOUNCE_TIMER = ANNOUNCE_TIMER - 1
        endif
        if SHOW_TIME_TAG then
            set GAME_TIME = GAME_TIME + 1
            set s1 = I2S(GAME_TIME / 60)
            set s2 = I2S(GAME_TIME - GAME_TIME / 60 * 60)
            if StringLength(s1) == 1 then
                set s1 = "0" + s1
            endif
            if StringLength(s2) == 1 then
                set s2 = "0" + s2
            endif
            loop
                exitwhen i > 2
                if SubString(s1, i, i + 1) == "1" then
                    set s1 = TIME_SPACEFILLER + s1
                    set i = i + 1
                endif
                if SubString(s2, i, i + 1) == "1" then
                    set s2 = s2 + TIME_SPACEFILLER
                endif
                set i = i + 1
            endloop
            set GAME_TIMES = s1 + TIME_DEVIDER + s2
        endif
    endfunction
    
    private function scroll_up takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] < TOTAL[i].integer[WINDOW[i]] - 1 then
            set SCROLLINT[i] = SCROLLINT[i] + 1
        endif
        if OPEN[i] then
            call update(i)
        endif
    endfunction
    
    private function scroll_down takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] > 0 then
            set SCROLLINT[i] = SCROLLINT[i] - 1
        endif
        if OPEN[i] then
            call update(i)
        endif
    endfunction
    
    private function ini takes nothing returns nothing
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
        local integer i = 0
        
        call setname()
        loop
            exitwhen i > 11
            if GetPlayerController(Player(i)) == MAP_CONTROL_USER  then
                static if not LIBRARY_ResWord then
                    call TriggerRegisterPlayerChatEvent(CHAT, Player(i), "", false)
                endif
                set REJECT_LIST[i] = CreateForce()
                set TOTAL[i] = 0
                set SCROLLINT[i] = 0
                set WINDOW[i] = 5
                set TOTAL[i] = Table.create()
                set MAILBOX[i] = Table.create()
                set MAILCTGRY[i] = Table.create()
                set TOTAL[i].integer[1] = 0
                set TOTAL[i].integer[2] = 0
                set TOTAL[i].integer[3] = 0
                set TOTAL[i].integer[4] = 0
                set TOTAL[i].integer[5] = 0
                set FLOOD_CHAT_TOTAL[i] = 0
                set LAST_CHAT[i] = 1
                if INITIALY_OPEN then
                    call update(i)
                    set OPEN[i] = true
                else
                    set OPEN[i] = false
                endif
            endif
            set PLAYER_NAME[i] = PLAYER_COLOR[i] + SubString(GetPlayerName(Player(i)), 0, MAX_NICK_LENGTH) + "|r"
            set i = i + 1
        endloop
        if ENABLE_SCROLLING then
            call ScrollUpEvent(t1)
            call ScrollDownEvent(t2)
            call TriggerAddAction(t1, function scroll_up)
            call TriggerAddAction(t2, function scroll_down)
        endif
        call TriggerAddCondition(CHAT, Condition(function chat))
        call TimerStart(CreateTimer(), 1, true, function time)
        if MAX_MSG > 15 then
            set MAX_MSG = 15
        endif
    endfunction
    
    function AddRestrictedWord takes string s returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerChatEvent(CHAT, Player(i), s, false)
            set i = i + 1
        endloop
    endfunction
    
    function SetUCSTitle takes string s returns nothing
        set TITLE = s
    endfunction
    
    function SetUCSHost takes player p returns nothing
        set HOST = p
    endfunction
    
    function GetUCSHost takes nothing returns player
        return HOST
    endfunction
    
    function OpenUCSChatWindow takes integer pn returns nothing
        set OPEN[pn] = true
        call update(pn)
    endfunction
    
    function CloseUCSChatWindow takes integer pn returns nothing
        set OPEN[pn] = false
        if GetLocalPlayer() == Player(pn) then
            call ClearTextMessages()
        endif
    endfunction
    
    function GetUCSElapsedGameTime takes nothing returns string
        if SHOW_TIME_TAG then
            return GAME_TIMES
        endif
        debug return DEBUG_MSG7
        return ""
    endfunction
    
    function GetUCSNickname takes integer pn returns string
        return PLAYER_NAME[pn]
    endfunction
    
    function SendUCSChatAll takes integer sender, string msg returns nothing
        call save(1, sender, Gradient(msg))
    endfunction
    
    function SendUCSChatPrivate takes integer sender, integer reciever, string msg returns nothing
        set LAST_PM_TARGET[sender] = reciever
        call save(2, sender, Gradient(msg))
    endfunction
    
    function SendUCSChatTeam takes integer sender, string msg returns nothing
        call save(3, sender, Gradient(msg))
    endfunction
    
    function SendUCSChatSystem takes integer reciever, string msg returns nothing
        call showdebug(reciever, Gradient(msg))
    endfunction
    
    function TriggerRegisterUCSChatEvent takes trigger t, code cond, code act returns nothing
        call TriggerRegisterVariableEvent(t, "UltimateChat_EVT", EQUAL, 1.00)
        if cond != null then
            call TriggerAddCondition(t, Filter(cond))
        endif
        if act != null then
            call TriggerAddAction(t, act)
        endif
    endfunction
    
    function GetUCSSender takes nothing returns player
        return UltimateChat_EVT_Sender
    endfunction
    
    function GetUCSReciever takes nothing returns player
        return UltimateChat_EVT_Reciever
    endfunction
    
    function GetUCSMessage takes nothing returns string
        return UltimateChat_EVT_Message
    endfunction
endlibrary

attachment.php
 

Attachments

  • ucs.jpg
    ucs.jpg
    128.7 KB · Views: 294
Last edited:

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
it's now 100% done and ready to be tested
JASS:
library UltimateChat initializer ini requires GradientText, Table
    globals
        private                 string array    PLAYER_COLOR
        private                 string array    PLAYER_NAME
        
    /****************************************************************************************************/
    /*                                                                                                  */
    /*                              'Ultimate Chat System v1.0'                                         */
    /*                                                  *****                                           */
    /*                                               by Dalvengyr                                       */
    /*                                                                                                  */
    /* A smooth, full-featured, light-weight chat system that would improves your game elegantly.       */
    /* Beside using features of this system, you are also able to use advantages of other libraries     */
    /* like GradientText and Table. This is a so much improvements of my last chat system on thw. There */
    /* is no more uneeded process and everything is very optimized. You are also able to configure      */
    /* almost every aspect of this chat system, like interfaces, commands, debug messages, etc. This    */
    /* system also supports some APIs that would be very helpful in-game.                               */
    /*                                                                                                  */
    /* Requirements:                                                                                    */
    /*      - JNGP                                                                                      */
    /*      - GradientText   by me                                                                      */
    /*      - Table          by Bribe                                                                   */
    /*                                                                                                  */
    /* Disadvantages:                                                                                   */
    /*      - You should configure anything using notepad once you use war3mapMisc.txt                  */
    /*      - You should configure interfaces using notepad once you use war3mapSkin.txt                */
    /*      - You need to maintain each configuration of this system by yourself to evade bugs          */
    /*                                                                                                  */
    /* Features:                                                                                        */
    /*      - Time tag                                                                                  */
    /*      - History saving                                                                            */
    /*      - Colorized & gradient text                                                                 */
    /*      - Restrict words & anti-flood                                                               */
    /*      - etc.                                                                                      */
    /*                                                                                                  */
    /* How to import:                                                                                   */
    /*      - Copy UCS folder into your map                                                             */
    /*      - Export war3mapMisc.txt into your map                                                      */
    /*      - (Optional) Export war3mapSkin.txt & consola.ttf into your map                             */
    /*      - Make sure the imported files has the same paths with file paths in this map               */
    /*                                                                                                  */
    /* API:                                                                                             */
    /*                                                                                                  */
    /* function AddRestrictedWord takes string s returns nothing                                        */
    /*                                                                                                  */
    /* function SetUCSTitle takes string s returns nothing                                              */
    /*                                                                                                  */
    /* function SetUCSHost takes player p returns nothing                                               */
    /*                                                                                                  */
    /* function GetUCSHost takes player p returns nothing                                               */
    /*                                                                                                  */
    /* function OpenUCSChatWindow takes integer pn returns nothing                                      */
    /*                                                                                                  */
    /* function CloseUCSChatWindow takes integer pn returns nothing                                     */
    /*                                                                                                  */
    /* function GetUCSElapsedGameTime takes nothing returns string                                      */
    /*                                                                                                  */
    /* function GetUCSNickname takes integer pn returns string                                          */
    /*                                                                                                  */
    /* function SendUCSChatAll takes integer sender, string msg returns nothing                         */
    /*                                                                                                  */
    /* function SendUCSChatTeam takes integer sender, string msg returns nothing                        */
    /*                                                                                                  */
    /* function SendUCSChatSystem takes integer reciever, string msg returns nothing                    */
    /*                                                                                                  */
    /* function SendUCSChatPrivate takes integer sender, integer reciever, string msg returns nothing   */
    /*                                                                                                  */
    /* function TriggerRegisterUCSChatEvent takes trigger t, code cond, code act returns nothing        */
    /*                                                                                                  */
    /* function GetUCSSender takes nothing returns player                                               */
    /*                                                                                                  */
    /* function GetUCSReciever takes nothing returns player                                             */
    /*                                                                                                  */
    /* function GetUCSMessage takes nothing returns string                                              */
    /*                                                                                                  */
    /****************************************************************************************************/
    /*                                                                                                  */
    /*          CONFIGURATIONS                                                                          */
    /*                                                                                                  */
    /****************************************************************************************************/
    
    /****************************************************************************************************/
    /* Interfaces                                                                                       */
    /****************************************************************************************************/
        // Title will be shown at the top of chat window. You can change the title in-game using this API
        // function SetUCSTitle takes string s returns nothing
        // Although you can disable it in option part
        private                 string          TITLE               = "UltimateChatSystem v1.0"
        // Prefix for private messages
        private     constant    string          PM_PREFIX           = "[|cff0000ffPrivate|r]"
        // Prefix for system messages
        private     constant    string          SM_PREFIX           = "[|cff0000ffSystem|r]"
        // Prefix for team messages
        private     constant    string          TM_PREFIX           = "[|cff0000ffTeam|r]"
        // Prefix for all messages
        private     constant    string          AM_PREFIX           = "[|cff0000ffAll|r]"
        // Will be added when host announce something
        private     constant    string          ANNOUNCEMENT        = "|cffffff00Announcement|r"
        // Time tag format is TIME_BRACKET1 + MINUTE + TIME_DEVIDER + SECOND + TIME_BRACKET2
        private     constant    string          TIME_BRACKET1       = "["
        private     constant    string          TIME_DEVIDER        = ":"
        private     constant    string          TIME_BRACKET2       = "]"
        // Spacefiller is useful to equalize the length of time tags
        // Set to "" disable space filler
        private     constant    string          TIME_SPACEFILLER    = ""
        // Symbol after chat sender name
        private     constant    string          EQUAL_SYMBOL        = ":"
        
    /****************************************************************************************************/
    /* Commands                                                                                         */
    /****************************************************************************************************/
        // Prefix to identity a command. Ex: -open
        private     constant    string          CMD_PREFIX          = "-"
        // Command to open chat window
        private     constant    string          CMD_OPEN            = "open"
        // Command to close chat window
        private     constant    string          CMD_CLOSE           = "close"
        // Command to clear saved history
        private     constant    string          CMD_CLEAR           = "clear"
        // Command to add a player to reject list. The command must be followed by target player's number
        // Ex: -reject2 to add player 2 to your reject list
        // You won't recieve any message from that player
        private     constant    string          CMD_BAN             = "reject"
        // Command to remove a player from reject list
        private     constant    string          CMD_UNBAN           = "unreject"
        // Another command for your personal needs. Ex: ^ms
        private     constant    string          OTHER_CMD           = "^"
        
    /****************************************************************************************************/
    /* Messagings                                                                                       */
    /****************************************************************************************************/
        // Prefix to identity a message target. Ex: *all
        private     constant    string          MSG_PREFIX          = "*"
        // To send a message to all players
        private     constant    string          MSG_ALL             = "all"
        // To send a message to all allies
        private     constant    string          MSG_TEAM            = "team"
        // To send a message to specific player. Must be followed by target player's number
        // Ex: *pm3 to send message to player 3
        private     constant    string          MSG_PRIVATE         = "pm"
        // To announce something. Only host has this authority
        private     constant    string          MSG_ANNOUNCEMENT    = "announce"
        
    /****************************************************************************************************/
    /* Options                                                                                          */
    /****************************************************************************************************/
        // Max messages shown at screen. You may not set this more than 15
        private                 integer         MAX_MSG             = 15
        // Max messages that will be saved
        private     constant    integer         MAX_SAVED           = 50
        // Maximum length of entered message
        private     constant    integer         MAX_LENGTH          = 73
        // Maximum length of each player name
        // Substract MAX_LENGTH by 1 if you increase MAX_NICK_LENGTH by 1
        private     constant    integer         MAX_NICK_LENGTH     = 10
        // True to initialy open chat window for all players
        private     constant    boolean         INITIALY_OPEN       = false
        // True to attach time tag on each message
        private     constant    boolean         SHOW_TIME_TAG       = true
        // True to show title at the top of chat window
        private     constant    boolean         SHOW_TITLE          = true
        // True to restric several words which you could define
        private     constant    boolean         ENABLE_RESTRICTION  = true
        // True to allow player to scroll up/down
        private     constant    boolean         ENABLE_SCROLLING    = true
        // Delay for host to announce something
        private     constant    integer         ANNOUNCE_DELAY      = 30
        // Timer to check flooding
        private     constant    integer         FLOOD_CHECK_TIMER   = 5
        // Max message every FLOOD_CHECK_TIMER seconds or will be considered as flooding
        private     constant    integer         FLOOD_CHAT_MAX      = 5
        
    /****************************************************************************************************/
    endglobals
    static if DEBUG_MODE then
    globals
    
    /****************************************************************************************************/
    /* Debug Messages                                                                                   */
    /****************************************************************************************************/
        // Will be shown when player enters invalid command
        private     constant    string          DEBUG_MSG1          = "|CFFFF0000INVALID COMMAND|r"
        // Will be shown when player enters too long message
        private     constant    string          DEBUG_MSG2          = "|CFFFF0000MESSAGE OVERSIZED|r"
        // Will be shown when pm target is unidentified
        private     constant    string          DEBUG_MSG3          = "|CFFFF0000INVALID RECIPIENT|r"
        // Will be shown when pm target is unavailable
        private     constant    string          DEBUG_MSG4          = "|CFFFF0000RECIPIENT IS UNAVAILABLE|r"
        // Will be shown when not host player tries to announce something
        private     constant    string          DEBUG_MSG5          = "|CFFFF0000YOU DON'T HAVE THE AUTHORITY|r"
        // Will be shown when player floods
        private     constant    string          DEBUG_MSG6          = "|CFFFF0000DON'T FLOOD!|r"
        // Will be returned when you are trying to get elapsed game time but the time tag feature is disabled
        private     constant    string          DEBUG_MSG7          = "|CFFFF0000TIME TAG DISABLED|r"
        // Will be shown when player sends pm successfuly
        private     constant    string          DEBUG_MSG8          = "|CFF00FF00PRIVATE MESSAGE HAS BEEN SENT|r"
        // Will be shown if message contains one of restricted words
        private     constant    string          DEBUG_MSG9          = "|CFFFF0000MESSAGE CONTAINS RESTRICTED WORD(S)|r"
        // Will be shown if reject/unreject target is invalid
        private     constant    string          DEBUG_MSG10         = "|CFFFF0000UNABLE TO REJECT/UNREJECT TARGET|r"
        // Will be shown when target successfuly added/removed to reject list
        private     constant    string          DEBUG_MSG11         = "|CFF00FF00TARGET HAS BEEN ADDED/REMOVED TO/FROM REJECT LIST|r"
        // Will be shown when host trying to announce something too often/before delay timer expired
        private     constant    string          DEBUG_MSG12         = "|CFFFF0000YOU CAN'T SEND ANNOUNCEMENT TOO OFTEN|r"
        
    /****************************************************************************************************/
    endglobals
    endif
    
    /****************************************************************************************************/
    /* Player Colors                                                                                    */
    /****************************************************************************************************/
    private function setname takes nothing returns nothing
        set PLAYER_COLOR[0] = "|CFFFF0303"  // Player 1
        set PLAYER_COLOR[1] = "|CFF0042FF"
        set PLAYER_COLOR[2] = "|CFF00FFFF"
        set PLAYER_COLOR[3] = "|CFF540081"
        set PLAYER_COLOR[4] = "|CFFFFFF01"
        set PLAYER_COLOR[5] = "|CFFFE8A0E"
        set PLAYER_COLOR[6] = "|CFF20C000"
        set PLAYER_COLOR[7] = "|CFFE55BB0"
        set PLAYER_COLOR[8] = "|CFF959697"
        set PLAYER_COLOR[9] = "|CFF7EBFF1"
        set PLAYER_COLOR[10] = "|CFF106246"
        set PLAYER_COLOR[11] = "|CFF4E2A04" // Player 12
    endfunction
    /****************************************************************************************************/
    
    /****************************************************************************************************/
    /* Events                                                                                           */
    /****************************************************************************************************/
        // Event for scroll up trigger
        private function ScrollUpEvent takes trigger t returns nothing
            local integer i = 0
            
            loop
                exitwhen i > 11
                call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_UP_DOWN)
                set i = i + 1
            endloop
        endfunction
        
        // Event for scroll down trigger
        private function ScrollDownEvent takes trigger t returns nothing
            local integer i = 0
            
            loop
                exitwhen i > 11
                call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_ARROW_DOWN_DOWN)
                set i = i + 1
            endloop
        endfunction
    /****************************************************************************************************/
    
    /****************************************************************************************************/
    /*                                                                                                  */
    /*          END OF CONFIGURATIONS                                                                   */
    /*                                                                                                  */
    /****************************************************************************************************/
    
    globals
        private                 player          HOST                = Player(15)
        private                 integer array   SCROLLINT
        private                 integer array   LAST_CHAT
        private                 integer array   LAST_PM_TARGET
        private                 integer array   FLOOD_CHAT_TOTAL
        private                 integer array   FLOOD_CHAT_TIMER
        private                 force array     REJECT_LIST
        private                 integer         ANNOUNCE_TIMER      = 0
        private                 integer         GAME_TIME           = 0
        private                 string          GAME_TIMES          = "00" + TIME_DEVIDER + "00"
        private                 boolean         SWEAR               = false
        private                 boolean array   OPEN
        private                 integer array   MAILTOTAL
        private                 Table array     MAILBOX[11]
        public                  real            EVT                 = 0.0
        public                  player          EVT_Reciever
        public                  player          EVT_Sender
        public                  string          EVT_Message
                                trigger         CHAT                = CreateTrigger()
    endglobals
    
    private function unswear takes nothing returns nothing
        set SWEAR = false
        call DestroyTimer(GetExpiredTimer())
    endfunction
    
    private function recycle takes integer i returns nothing
        local integer i2 = 0
        
        loop
            set i2 = i2 + 1
            set MAILBOX[i].string[i2] = MAILBOX[i].string[i2 + 1]
            exitwhen i2 >= MAX_SAVED - 1
        endloop
        set MAILTOTAL[i] = MAILTOTAL[i] - 1
    endfunction
    
    private function update takes integer i returns nothing
        local integer i2
        local integer t = 0
        
        if GetLocalPlayer() == Player(i) then
            call ClearTextMessages()
        endif
        if SHOW_TITLE then
            call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, TITLE)
        endif
        if MAILTOTAL[i] < MAX_MSG + SCROLLINT[i] then
            set i2 = 0
            loop
                exitwhen i2 >= MAX_MSG - MAILTOTAL[i] + SCROLLINT[i]
                call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, " ")
                set i2 = i2 + 1
            endloop
        endif
        set i2 = MAILTOTAL[i] - MAX_MSG + 1 - SCROLLINT[i]
        loop
            exitwhen i2 > MAILTOTAL[i] - SCROLLINT[i] or t >= MAX_MSG
            if MAILBOX[i].string[i2] != null then
                call DisplayTimedTextToPlayer(Player(i), 0.0, 0.0, 0.0, MAILBOX[i].string[i2])
                set t = t + 1
            endif
            set i2 = i2 + 1
        endloop
    endfunction
    
    private function showdebug takes integer pn, string msg returns nothing
        if MAILTOTAL[pn] >= MAX_SAVED then
            call recycle(pn)
        endif
        set MAILTOTAL[pn] = MAILTOTAL[pn] + 1
        if SHOW_TIME_TAG then
            set MAILBOX[pn].string[MAILTOTAL[pn]] = SM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + msg
        else
            set MAILBOX[pn].string[MAILTOTAL[pn]] = SM_PREFIX + " " + DEBUG_MSG1
        endif
        if OPEN[pn] then
            call update(pn)
        endif
    endfunction
    
    private function save takes integer cat, integer pn, string msg returns nothing
        local integer i = 0
        local integer i2
        local integer t
        
        set UltimateChat_EVT_Sender = Player(pn)
        set UltimateChat_EVT_Message = msg
        if cat == 1 then
            if SHOW_TIME_TAG then
                set msg = AM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = AM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            loop
                exitwhen i > 11
                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                    set UltimateChat_EVT_Reciever = Player(i)
                    if MAILTOTAL[i] >= MAX_SAVED then
                        call recycle(i)
                    endif
                    set MAILTOTAL[i] = MAILTOTAL[i] + 1
                    set MAILBOX[i].string[MAILTOTAL[i]] = msg
                    if OPEN[i] then
                        call update(i)
                    endif
                    set UltimateChat_EVT = 1.00
                    set UltimateChat_EVT = 0.00
                    set UltimateChat_EVT_Reciever = null
                endif
                set i = i + 1
            endloop
        elseif cat == 2 then
            if SHOW_TIME_TAG then
                set msg = PM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = PM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            if LAST_PM_TARGET[pn] != pn and LAST_PM_TARGET[pn] >= 0 then
                if GetPlayerSlotState(Player(LAST_PM_TARGET[pn])) == PLAYER_SLOT_STATE_PLAYING then
                    if not IsPlayerInForce(Player(pn), REJECT_LIST[LAST_PM_TARGET[pn]]) then
                        set UltimateChat_EVT_Reciever = Player(LAST_PM_TARGET[pn])
                        if MAILTOTAL[LAST_PM_TARGET[pn]] >= MAX_SAVED then
                            call recycle(i)
                        endif
                        set MAILTOTAL[LAST_PM_TARGET[pn]] = MAILTOTAL[LAST_PM_TARGET[pn]] + 1
                        set MAILBOX[LAST_PM_TARGET[pn]].string[MAILTOTAL[LAST_PM_TARGET[pn]]] = msg
                        if OPEN[LAST_PM_TARGET[pn]] then
                            call update(LAST_PM_TARGET[pn])
                            call showdebug(pn, DEBUG_MSG8)
                        endif
                        set UltimateChat_EVT = 1.00
                        set UltimateChat_EVT = 0.00
                        set UltimateChat_EVT_Reciever = null
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG4)
                endif
            debug else
                debug call showdebug(pn, DEBUG_MSG3)
            endif
        elseif cat == 3 then
            if SHOW_TIME_TAG then
                set msg = TM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            else
                set msg = TM_PREFIX + " " + PLAYER_NAME[pn] + EQUAL_SYMBOL + " " + msg
            endif
            loop
                exitwhen i > 11
                if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                    if IsPlayerAlly(Player(pn), Player(i)) then
                        set UltimateChat_EVT_Reciever = Player(i)
                        if MAILTOTAL[i] >= MAX_SAVED then
                            call recycle(i)
                        endif
                        set MAILTOTAL[i] = MAILTOTAL[i] + 1
                        set MAILBOX[i].string[MAILTOTAL[i]] = msg
                        if OPEN[i] then
                            call update(i)
                        endif
                        set UltimateChat_EVT = 1.00
                        set UltimateChat_EVT = 0.00
                        set UltimateChat_EVT_Reciever = null
                    endif
                endif
                set i = i + 1
            endloop
        endif
        set UltimateChat_EVT_Sender = null
        set UltimateChat_EVT_Message = null
    endfunction
    
    private function chat takes nothing returns boolean
        local string msg
        local string cmd
        local string s
        local string res
        local player p = GetTriggerPlayer()
        local integer pn = GetPlayerId(p)
        local integer len
        local integer i = 0
        local integer i2
        local integer t
        
        if ENABLE_RESTRICTION then
            if GetEventPlayerChatStringMatched() != "" and not SWEAR then
                set SWEAR = true
                debug call showdebug(pn, DEBUG_MSG9)
                call TimerStart(CreateTimer(), 0.01, false, function unswear)
            endif
        endif
        if not SWEAR then
            set msg = GetEventPlayerChatString()
            set cmd = SubString(msg, 0, 1)
            set res = ""
            if cmd == CMD_PREFIX then
                set len = StringLength(CMD_PREFIX)
                if SubString(msg, len, len + StringLength(CMD_OPEN)) == CMD_OPEN then
                    set OPEN[pn] = true
                    call update(pn)
                elseif SubString(msg, len, len + StringLength(CMD_CLOSE)) == CMD_CLOSE then
                    set OPEN[pn] = false
                    if GetLocalPlayer() == p then
                        call ClearTextMessages()
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_CLEAR)) == CMD_CLEAR then
                    set MAILTOTAL[pn] = 0
                    set SCROLLINT[pn] = 0
                    if OPEN[pn] then
                        call update(pn)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_BAN)) == CMD_BAN then
                    set t = S2I(SubString(msg, len + StringLength(CMD_BAN), len + StringLength(CMD_BAN) + 2)) - 1
                    if t != pn and t >= 0 then
                        debug call showdebug(pn, DEBUG_MSG11)
                        call ForceAddPlayer(REJECT_LIST[pn], Player(t))
                    debug else
                        debug call showdebug(pn, DEBUG_MSG10)
                    endif
                elseif SubString(msg, len, len + StringLength(CMD_UNBAN)) == CMD_UNBAN then
                    set t = S2I(SubString(msg, len + StringLength(CMD_UNBAN), len + StringLength(CMD_UNBAN) + 2)) - 1
                    if t != pn and t >= 0 then
                        debug call showdebug(pn, DEBUG_MSG11)
                        call ForceRemovePlayer(REJECT_LIST[pn], Player(t))
                    debug else
                        debug call showdebug(pn, DEBUG_MSG10)
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG1)
                endif
            elseif cmd == MSG_PREFIX then
                set len = StringLength(MSG_PREFIX)
                if StringLength(msg) - len <= MAX_LENGTH then
                    if SubString(msg, len, len + StringLength(MSG_ALL)) == MSG_ALL then
                        if LAST_CHAT[pn] != 1 then
                            set FLOOD_CHAT_TOTAL[pn] = 0
                        else
                            set FLOOD_CHAT_TIMER[pn] = FLOOD_CHECK_TIMER
                            set FLOOD_CHAT_TOTAL[pn] = FLOOD_CHAT_TOTAL[pn] + 1
                        endif
                        set LAST_CHAT[pn] = 1
                        if FLOOD_CHAT_TOTAL[pn] <= FLOOD_CHAT_MAX then
                            set msg = Gradient(SubString(msg, len + StringLength(MSG_ALL) + 1, StringLength(msg)))
                            call save(1, pn, msg)
                        debug else
                            debug call showdebug(pn, DEBUG_MSG6)
                        endif
                    elseif SubString(msg, len, len + StringLength(MSG_PRIVATE)) == MSG_PRIVATE then
                        if LAST_CHAT[pn] != 2 then
                            set FLOOD_CHAT_TOTAL[pn] = 0
                        else
                            set FLOOD_CHAT_TIMER[pn] = FLOOD_CHECK_TIMER
                            set FLOOD_CHAT_TOTAL[pn] = FLOOD_CHAT_TOTAL[pn] + 1
                        endif
                        set LAST_CHAT[pn] = 2
                        if FLOOD_CHAT_TOTAL[pn] <= FLOOD_CHAT_MAX then
                            set LAST_PM_TARGET[pn] = S2I(SubString(msg, len + StringLength(MSG_PRIVATE), len + StringLength(MSG_PRIVATE) + 2)) - 1
                            set msg = Gradient(SubString(msg, len + StringLength(MSG_PRIVATE) + StringLength(I2S(LAST_PM_TARGET[pn])), StringLength(msg)))
                            call save(2, pn, msg)
                        debug else
                            debug call showdebug(pn, DEBUG_MSG6)
                        endif
                    elseif SubString(msg, len, len + StringLength(MSG_TEAM)) == MSG_TEAM then
                        if LAST_CHAT[pn] != 3 then
                            set FLOOD_CHAT_TOTAL[pn] = 0
                        else
                            set FLOOD_CHAT_TIMER[pn] = FLOOD_CHECK_TIMER
                            set FLOOD_CHAT_TOTAL[pn] = FLOOD_CHAT_TOTAL[pn] + 1
                        endif
                        set LAST_CHAT[pn] = 3
                        if FLOOD_CHAT_TOTAL[pn] <= FLOOD_CHAT_MAX then
                            set msg = Gradient(SubString(msg, len + StringLength(MSG_TEAM) + 1, StringLength(msg)))
                            call save(3, pn, msg)
                        debug else
                            debug call showdebug(pn, DEBUG_MSG6)
                        endif
                    elseif SubString(msg, len, len + StringLength(MSG_ANNOUNCEMENT)) == MSG_ANNOUNCEMENT then
                        if p == HOST then
                            if ANNOUNCE_TIMER == 0 then
                                set ANNOUNCE_TIMER = ANNOUNCE_DELAY
                                set msg = Gradient(SubString(msg, len + StringLength(MSG_ANNOUNCEMENT) + 1, StringLength(msg)))
                                if SHOW_TIME_TAG then
                                    set msg = SM_PREFIX + " " + TIME_BRACKET1 + GAME_TIMES + TIME_BRACKET2 + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                                else
                                    set msg = SM_PREFIX + " " + ANNOUNCEMENT + EQUAL_SYMBOL + " " + msg
                                endif
                                loop
                                    exitwhen i > 11
                                    if not IsPlayerInForce(Player(pn), REJECT_LIST[i]) then
                                        if MAILTOTAL[i] >= MAX_SAVED then
                                            call recycle(i)
                                        endif
                                        set MAILTOTAL[i] = MAILTOTAL[i] + 1
                                        set MAILBOX[i].string[MAILTOTAL[i]] = msg
                                        if OPEN[i] then
                                            call update(i)
                                        endif
                                    endif
                                    set i = i + 1
                                endloop
                            debug else
                                debug call showdebug(pn, DEBUG_MSG12)
                            endif
                        debug else
                            debug call showdebug(pn, DEBUG_MSG5)
                        endif
                    debug else
                        debug call showdebug(pn, DEBUG_MSG1)
                    endif
                debug else
                    debug call showdebug(pn, DEBUG_MSG2)
                endif
            else
                if SubString(msg, 0, StringLength(OTHER_CMD)) != OTHER_CMD then
                    if StringLength(msg) <= MAX_LENGTH then
                        set FLOOD_CHAT_TOTAL[pn] = FLOOD_CHAT_TOTAL[pn] + 1
                        set FLOOD_CHAT_TIMER[pn] = FLOOD_CHECK_TIMER
                        if FLOOD_CHAT_TOTAL[pn] <= FLOOD_CHAT_MAX then
                            call save(LAST_CHAT[pn], pn, Gradient(msg))
                        debug else
                            debug call showdebug(pn, DEBUG_MSG6)
                        endif
                    debug else
                        debug call showdebug(pn, DEBUG_MSG2)
                    endif
                endif
            endif
        endif
        return false
    endfunction
    
    private function time takes nothing returns nothing
        local string s1
        local string s2
        local integer i
        
        if ANNOUNCE_TIMER > 0 then
            set ANNOUNCE_TIMER = ANNOUNCE_TIMER - 1
        endif
        set i = 0
        loop
            exitwhen i > 11
            if FLOOD_CHAT_TIMER[i] > 0 then
                set FLOOD_CHAT_TIMER[i] = FLOOD_CHAT_TIMER[i] - 1
                if FLOOD_CHAT_TIMER[i] <= 0 then
                    set FLOOD_CHAT_TOTAL[i] = 0
                endif
            endif
            set i = i + 1
        endloop
        if SHOW_TIME_TAG then
            set GAME_TIME = GAME_TIME + 1
            set s1 = I2S(GAME_TIME / 60)
            set s2 = I2S(GAME_TIME - GAME_TIME / 60 * 60)
            if StringLength(s1) == 1 then
                set s1 = "0" + s1
            endif
            if StringLength(s2) == 1 then
                set s2 = "0" + s2
            endif
            set i = 0
            loop
                exitwhen i > 2
                if SubString(s1, i, i + 1) == "1" then
                    set s1 = TIME_SPACEFILLER + s1
                    set i = i + 1
                endif
                if SubString(s2, i, i + 1) == "1" then
                    set s2 = s2 + TIME_SPACEFILLER
                endif
                set i = i + 1
            endloop
            set GAME_TIMES = s1 + TIME_DEVIDER + s2
        endif
    endfunction
    
    private function scroll_up takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] < MAILTOTAL[i] - 1 then
            set SCROLLINT[i] = SCROLLINT[i] + 1
        endif
        if OPEN[i] then
            call update(i)
        endif
    endfunction
    
    private function scroll_down takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        
        if SCROLLINT[i] > 0 then
            set SCROLLINT[i] = SCROLLINT[i] - 1
        endif
        if OPEN[i] then
            call update(i)
        endif
    endfunction
    
    private function ini takes nothing returns nothing
        local trigger t1 = CreateTrigger()
        local trigger t2 = CreateTrigger()
        local integer i = 0
        
        call setname()
        loop
            exitwhen i > 11
            if GetPlayerController(Player(i)) == MAP_CONTROL_USER  then
                static if not LIBRARY_ResWord then
                    call TriggerRegisterPlayerChatEvent(CHAT, Player(i), "", false)
                endif
                set REJECT_LIST[i] = CreateForce()
                set SCROLLINT[i] = 0
                set MAILBOX[i] = Table.create()
                set MAILTOTAL[i] = 0
                set FLOOD_CHAT_TOTAL[i] = 0
                set FLOOD_CHAT_TIMER[i] = 0
                set LAST_CHAT[i] = 1
                if INITIALY_OPEN then
                    call update(i)
                    set OPEN[i] = true
                else
                    set OPEN[i] = false
                endif
            endif
            set PLAYER_NAME[i] = PLAYER_COLOR[i] + SubString(GetPlayerName(Player(i)), 0, MAX_NICK_LENGTH) + "|r"
            set i = i + 1
        endloop
        if ENABLE_SCROLLING then
            call ScrollUpEvent(t1)
            call ScrollDownEvent(t2)
            call TriggerAddAction(t1, function scroll_up)
            call TriggerAddAction(t2, function scroll_down)
        endif
        call TriggerAddCondition(CHAT, Condition(function chat))
        call TimerStart(CreateTimer(), 1, true, function time)
        if MAX_MSG > 15 then
            set MAX_MSG = 15
        endif
    endfunction
    
    function AddRestrictedWord takes string s returns nothing
        local integer i = 0
        
        loop
            exitwhen i > 11
            call TriggerRegisterPlayerChatEvent(CHAT, Player(i), s, false)
            set i = i + 1
        endloop
    endfunction
    
    function SetUCSTitle takes string s returns nothing
        set TITLE = s
    endfunction
    
    function SetUCSHost takes player p returns nothing
        set HOST = p
    endfunction
    
    function GetUCSHost takes nothing returns player
        return HOST
    endfunction
    
    function OpenUCSChatWindow takes integer pn returns nothing
        set OPEN[pn] = true
        call update(pn)
    endfunction
    
    function CloseUCSChatWindow takes integer pn returns nothing
        set OPEN[pn] = false
        if GetLocalPlayer() == Player(pn) then
            call ClearTextMessages()
        endif
    endfunction
    
    function GetUCSElapsedGameTime takes nothing returns string
        if SHOW_TIME_TAG then
            return GAME_TIMES
        endif
        debug return DEBUG_MSG7
        return ""
    endfunction
    
    function GetUCSNickname takes integer pn returns string
        return PLAYER_NAME[pn]
    endfunction
    
    function SendUCSChatAll takes integer sender, string msg returns nothing
        call save(1, sender, Gradient(msg))
    endfunction
    
    function SendUCSChatPrivate takes integer sender, integer reciever, string msg returns nothing
        set LAST_PM_TARGET[sender] = reciever
        call save(2, sender, Gradient(msg))
    endfunction
    
    function SendUCSChatTeam takes integer sender, string msg returns nothing
        call save(3, sender, Gradient(msg))
    endfunction
    
    function SendUCSChatSystem takes integer reciever, string msg returns nothing
        call showdebug(reciever, Gradient(msg))
    endfunction
    
    function TriggerRegisterUCSChatEvent takes trigger t, code cond, code act returns nothing
        call TriggerRegisterVariableEvent(t, "UltimateChat_EVT", EQUAL, 1.00)
        if cond != null then
            call TriggerAddCondition(t, Filter(cond))
        endif
        if act != null then
            call TriggerAddAction(t, act)
        endif
    endfunction
    
    function GetUCSSender takes nothing returns player
        return UltimateChat_EVT_Sender
    endfunction
    
    function GetUCSReciever takes nothing returns player
        return UltimateChat_EVT_Reciever
    endfunction
    
    function GetUCSMessage takes nothing returns string
        return UltimateChat_EVT_Message
    endfunction
endlibrary
hopefuly you could give me any suggestion or report :) thnks and enjoy..
 

Attachments

  • UCS v1.0.w3x
    270.9 KB · Views: 68
Dalvengyr said:
are you sure? I thought it's cool feature for a chat system

Yes I'm sure. It's cool but there's no reason it should be required.

How is the whole point of the chat system gradient text? I thought the point would be the chat system itself.

Dalvengyr said:
beside, they can also take some advantages of dat library.

Yes, they can. So why is it required?
 
Status
Not open for further replies.
Top