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