| 07-29-2009, 03:52 AM | #1 |
Yes I do realize TC has an awesome chat system. I would still like to know why mine doesn't work. JASS:scope AddChatMessage globals multiboard array MB [11] integer MB_COUNTER = 0 force ALL_PLAYERS = CreateForce() string TEMP_STRING boolean TEMP_BOOLEAN player TEMP_PLAYER string array MB_STRINGS [11][9] integer array MB_CHATSIZE [11] endglobals private function UpdateMultiboard takes nothing returns nothing local integer p = GetPlayerId(GetEnumPlayer()) local integer a = 0 if IsPlayerAlly(Player(p), TEMP_PLAYER) == true or TEMP_BOOLEAN == true then loop set MB_STRINGS[p][a] = MB_STRINGS[p][a + 1] call MultiboardSetItemValue(MultiboardGetItem(MB[p], a, 0), MB_STRINGS[p][a]) set a = a + 1 exitwhen a >= MB_CHATSIZE[p] - 1 endloop if Player(p) == TEMP_PLAYER and TEMP_BOOLEAN == true then set MB_STRINGS[p][a] = "[|cffff0000All|r]: " + TEMP_STRING elseif Player(p) == TEMP_PLAYER and TEMP_BOOLEAN == false then set MB_STRINGS[p][a] = "[|cff6464ffAllies|r]: " + TEMP_STRING else set MB_STRINGS[p][a] = "[|cffff0000" + GetPlayerName(TEMP_PLAYER) + "|r] " + TEMP_STRING endif call MultiboardSetItemValue(MultiboardGetItem(MB[p], a, 0), MB_STRINGS[p][a]) endif endfunction private function Actions takes nothing returns nothing local string s = GetEventPlayerChatString() local player p = GetTriggerPlayer() local integer a = 0 if SubString(s, 0, 1) == "+" then if SubString(s, 1, 2) == "/" then set TEMP_BOOLEAN = true set TEMP_STRING = SubString(s, 2, StringLength(s)) else set TEMP_BOOLEAN = false set TEMP_STRING = SubString(s, 1, StringLength(s)) endif set TEMP_PLAYER = p call ForForce(ALL_PLAYERS, function UpdateMultiboard) endif set s = null endfunction //=========================================================================== function InitTrig_AddChatMessage takes nothing returns nothing local integer a = 0 set gg_trg_AddChatMessage = CreateTrigger() call TriggerAddAction(gg_trg_AddChatMessage, function Actions) endfunction endscope When I type "+/" anything I type after that deletes it. Here's a picture to show the problem. I can't find a solution @_@ |
| 07-29-2009, 04:26 AM | #2 |
For the substring part in Actions, you're checking if "0 to 1" and "1 to 2" is ONE character, but doesn't it have to be two? eg. +/ is 2 characters, so if you're checking only + it should be Substring (s, 1, 1) |
| 07-29-2009, 04:30 AM | #3 | |
Quote:
That's rather incorrect. Substring's layout:
A n o p o b 0 1 2 3 4 5 6 |
| 07-29-2009, 04:43 AM | #4 |
I fail, nvm. Thanks. |
| 07-29-2009, 07:45 AM | #5 |
Took me quite a bit of trial/error to figure that out myself :p Anybody got an answer? |
| 07-31-2009, 12:06 AM | #6 |
Bump |
