- Joined
- Aug 1, 2013
- Messages
- 4,658
Hi all.
I am making a GUI chat system for multiplayer maps.
I am a bit stuck on features to add etc.
Are there also any suggestions on what to do?
(The JASS stuff shouldn't be modified.)
Upcoming features:
- option to revert messages sent to all players and all messages from all players.
- in-built calculator
- easier colorizer
- /me command (but everyone should be able to make that)
- timestamps (which everyone should be able to make as well)
I am making a GUI chat system for multiplayer maps.
I am a bit stuck on features to add etc.
Are there also any suggestions on what to do?
(The JASS stuff shouldn't be modified.)
JASS:
function MCS_GetPreferredColor takes player p returns string
local integer id = GetPlayerId(p)
if udg_MCS_Color_Type[id] == udg_MCS_COLOR_TYPE_PLAYER then
return PlayerColorToString(GetPlayerColor(udg_MCS_Sender))
elseif udg_MCS_Color_Type[id] == udg_MCS_COLOR_TYPE_TEAM then
if p == udg_MCS_Sender then
return udg_MCS_Color_Team_Self[id]
elseif IsPlayerAlly(p, udg_MCS_Sender) then
return udg_MCS_Color_Team_Ally[id]
else
return udg_MCS_Color_Team_Enemy[id]
endif
endif
return ""
endfunction
function MCS_SendChatMessage takes player whichPlayer, string message returns nothing
local player localPlayer = GetLocalPlayer()
set udg_MCS_Sender = whichPlayer
set udg_MCS_Sender_Id = GetPlayerId(udg_MCS_Sender)
set udg_MCS_Message = message
set udg_MCS_AbortMessage = false
set udg_MCS_Tag1 = ""
set udg_MCS_Tag2 = ""
set udg_MCS_Tag3 = ""
set udg_MCS_Tag4 = ""
set udg_MCS_Tag5 = ""
set udg_MCS_Event_OnChat = 1
set udg_MCS_Event_OnChat = 0
if not udg_MCS_AbortMessage then
if IsPlayerInForce(localPlayer, udg_MCS_Recievers) then
if GetPlayerController(localPlayer) == MAP_CONTROL_USER then
call DisplayTextToPlayer(localPlayer, udg_MCS_Location_X, udg_MCS_Location_Y, udg_MCS_Tag1 + MCS_GetPreferredColor(localPlayer) + udg_MCS_Tag2 + GetPlayerName(udg_MCS_Sender) + udg_MCS_Tag3 + ":|r " + udg_MCS_Tag4 + udg_MCS_Message + udg_MCS_Tag5)
endif
endif
endif
call DestroyForce(udg_MCS_Recievers)
set localPlayer = null
endfunction
function MCS_SendChatMessageBJ takes nothing returns nothing
call MCS_SendChatMessage(udg_MCS_Sender, udg_MCS_Message)
endfunction
function MCS_Chat_Response takes nothing returns boolean
call MCS_SendChatMessage(GetTriggerPlayer(), GetEventPlayerChatString())
return false
endfunction
//===========================================================================
function InitTrig_MCS_System takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
local player p
call TriggerAddCondition(t, Filter(function MCS_Chat_Response))
set udg_MCS_Location_X = 0
set udg_MCS_Location_Y = 0
set udg_MCS_COLOR_TYPE_PLAYER = 0
set udg_MCS_COLOR_TYPE_TEAM = 1
set udg_MCS_RECIEVERS_ALLIES = 0
set udg_MCS_RECIEVERS_ALL = 1
loop
exitwhen i >= 12
set p = Player(i)
if GetPlayerController(p) == MAP_CONTROL_USER then
set udg_MCS_Color_Team_Self[i] = "|cff00ffff"
set udg_MCS_Color_Team_Ally[i] = "|cff00ff00"
set udg_MCS_Color_Team_Enemy[i] = "|cffff0000"
call TriggerRegisterPlayerChatEvent(t, p, "", false)
endif
set i = i + 1
endloop
set p = null
set udg_MCS_Trigger_Send_Message = CreateTrigger()
call TriggerAddAction(udg_MCS_Trigger_Send_Message, function MCS_SendChatMessageBJ)
endfunction
-
MCS Response
-
Events
-
Game - MCS_Event_OnChat becomes Equal to 0.00
-
-
Conditions
-
Actions
-
-------- ----------------------------- --------
-
-------- Do the commands --------
-
-------- ----------------------------- --------
-
-------- help --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 5)) Equal to /help
-
(Substring((String(MCS_Message) as Lower case), 1, 5)) Equal to /halp
-
-
-
-
Then - Actions
-
Set TempForce = (Player group(MCS_Sender))
-
Game - Display to TempForce the text: Press "/listcommand...
-
Custom script: call DestroyForce(udg_TempForce)
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 14)) Equal to /colorsettings
-
-
Then - Actions
-
Set TempForce = (Player group(MCS_Sender))
-
Game - Display to TempForce the text: /setcolor <group> <...
-
Custom script: call DestroyForce(udg_TempForce)
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
-------- autoally, autoallies, autoall --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 11)) Equal to /autoallies
-
(Substring((String(MCS_Message) as Lower case), 1, 9)) Equal to /autoally
-
-
-
-
Then - Actions
-
Set MCS_Recievers_Auto[MCS_Sender_Id] = MCS_RECIEVERS_ALLIES
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 8)) Equal to /autoall
-
-
Then - Actions
-
Set MCS_Recievers_Auto[MCS_Sender_Id] = MCS_RECIEVERS_ALL
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
-
-
-------- setcolortype --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 14)) Equal to /setcolortype
-
-
Then - Actions
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 4)) Equal to team
-
(Substring((String(MCS_Message) as Lower case), 1, 9)) Equal to teamcolor
-
-
-
-
Then - Actions
-
Set MCS_Color_Type[MCS_Sender_Id] = MCS_COLOR_TYPE_TEAM
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 6)) Equal to player
-
(Substring((String(MCS_Message) as Lower case), 1, 11)) Equal to playercolor
-
-
-
-
Then - Actions
-
Set MCS_Color_Type[MCS_Sender_Id] = MCS_COLOR_TYPE_PLAYER
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
-------- invalid command --------
-
Set TempForce = (Player group(MCS_Sender))
-
Game - Display to TempForce the text: Invalid "setcolorty...
-
Custom script: call DestroyForce(udg_TempForce)
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
-------- setcolor --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 10)) Equal to /setcolor
-
-
Then - Actions
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 5)) Equal to self
-
(Substring((String(MCS_Message) as Lower case), 1, 3)) Equal to me
-
-
-
-
Then - Actions
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Set MCS_Color_Team_Self[MCS_Sender_Id] = (|c + (Substring(MCS_Message, 1, 8)))
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 5)) Equal to team
-
(Substring((String(MCS_Message) as Lower case), 1, 5)) Equal to ally
-
(Substring((String(MCS_Message) as Lower case), 1, 7)) Equal to allies
-
-
-
-
Then - Actions
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Set MCS_Color_Team_Ally[MCS_Sender_Id] = (|c + (Substring(MCS_Message, 1, 8)))
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 6)) Equal to enemy
-
(Substring((String(MCS_Message) as Lower case), 1, 8)) Equal to enemies
-
(Substring((String(MCS_Message) as Lower case), 1, 4)) Equal to all
-
-
-
-
Then - Actions
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Set MCS_Color_Team_Enemy[MCS_Sender_Id] = (|c + (Substring(MCS_Message, 1, 8)))
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
-------- invalid command --------
-
Set TempForce = (Player group(MCS_Sender))
-
Game - Display to TempForce the text: Invalid "setcolor" ...
-
Custom script: call DestroyForce(udg_TempForce)
-
Set MCS_AbortMessage = True
-
Skip remaining actions
-
-
Else - Actions
-
-
-------- ---------------------------- --------
-
-------- Choose recievers --------
-
-------- ---------------------------- --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 8)) Equal to /allies
-
(Substring((String(MCS_Message) as Lower case), 1, 6)) Equal to /ally
-
-
-
-
Then - Actions
-
Set MCS_Recievers = (All allies of MCS_Sender)
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Set MCS_Tag2 = ([allies] + MCS_Tag2)
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Substring((String(MCS_Message) as Lower case), 1, 5)) Equal to /all
-
-
Then - Actions
-
Set MCS_Recievers = (All players controlled by a User player)
-
Custom script: set udg_TempInteger = FirstIndexOfBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Custom script: set udg_TempInteger = FirstIndexOfNotBJ(udg_MCS_Message, " ")
-
Set MCS_Message = (Substring(MCS_Message, TempInteger, (Length of MCS_Message)))
-
Set MCS_Tag2 = ([all] + MCS_Tag2)
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MCS_Recievers_Auto[MCS_Sender_Id] Equal to MCS_RECIEVERS_ALL
-
-
Then - Actions
-
Set MCS_Recievers = (All players controlled by a User player)
-
Set MCS_Tag2 = ([all] + MCS_Tag2)
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
MCS_Recievers_Auto[MCS_Sender_Id] Equal to MCS_RECIEVERS_ALLIES
-
-
Then - Actions
-
Set MCS_Recievers = (All allies of MCS_Sender)
-
Set MCS_Tag2 = ([allies] + MCS_Tag2)
-
-
Else - Actions
-
-
-
-
-
-
-
-
-------- ----------------------- --------
-
-------- Apply Colorizer --------
-
-------- ----------------------- --------
-
Custom script: set udg_MCS_Message = Colorizer(udg_MCS_Message)
-
-
- option to revert messages sent to all players and all messages from all players.
- in-built calculator
- easier colorizer
- /me command (but everyone should be able to make that)
- timestamps (which everyone should be able to make as well)
Attachments
Last edited: