System Chat System

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Everything is in the READ ME.

Code:
Well this a system to all of you that hate WarCraft's chat interface, where you have to keep 
pressing on F12 to change chat settings, this system is very simple, you write "Send destination:
Message" for example "Send all: Hi, this is an example". The list is:

All ("Send All: message" -- Will show to all players your message)
Allies  ("Send Allies: message" -- Will show to all allies your message)
Enemies  ("Send Enemies: message" -- Will show to all enemies your message)
Player's Number ("Send X: message" -- Will show to player X your message)
Player's Color  ("Send Color: message" -- Will show to player <color> your message)
Player's Name  ("Send Name: message" -- Will show to <name> player your message)

This was originally made to increase my skill with substrings, but I thought posting it wouldn't
hurt. ;) Thanks Tom Jones for spotting a bug in my code! In order to use this system simply copy
the trigger ChatSys and you are done.

If you are using this system I suggest you hide players' messages. Here is a tutorial on how to 
do that by shadow1500: http://www.wc3campaigns.net/showthread.php?t=80691

Side Notes: Works with RoC as well.

Enjoy

JASS:

function ChatSys_Actions takes nothing returns nothing
    local player sender = GetTriggerPlayer()

    local string sent = GetEventPlayerChatString()
    local string letter = &quot;&quot;
    local string message = &quot;&quot;
    local string safety = SubString(sent,0,5)

    local integer readers = 0
    local integer counter = 0
    local integer length = StringLength(sent)
    local integer limit = 0
    local integer Id = GetPlayerId(sender)

    local string array colors
    local string array colored
    
    if safety == &quot;Send &quot; then
        set colors[0] = &quot;Red&quot;
        set colors[1] = &quot;Blue&quot;
        set colors[2] = &quot;Teal&quot;
        set colors[3] = &quot;Purple&quot;
        set colors[4] = &quot;Yellow&quot;
        set colors[5] = &quot;Orange&quot;
        set colors[6] = &quot;Green&quot;
        set colors[7] = &quot;Pink&quot;
        set colors[8] = &quot;Grey&quot;
        set colors[9] = &quot;Light Blue&quot;
        set colors[10] = &quot;Dark Green&quot;
        set colors[11] = &quot;Brown&quot;
        
        set colored[0] = &quot;|CFFFF0303&quot;
        set colored[1] = &quot;|CFF0042FF&quot;
        set colored[2] = &quot;|CFF1CB619&quot;
        set colored[3] = &quot;|CFF540081&quot;
        set colored[4] = &quot;|CFFFFFF01&quot;
        set colored[5] = &quot;|CFFFE8A0E&quot;
        set colored[6] = &quot;|CFF20C000&quot;
        set colored[7] = &quot;|CFFE55BB0&quot;
        set colored[8] = &quot;|CFF959697&quot;
        set colored[9] = &quot;|CFF7EBFF1&quot;
        set colored[10] = &quot;|CFF106246&quot;
        set colored[11] = &quot;|CFF4E2A04&quot;
        
        loop
           set letter = SubString(sent,counter,counter+1)
           if letter == &quot;:&quot; then
              set limit = counter 
              exitwhen true
          elseif counter + 1 == length then
              call DisplayTextToPlayer(sender,0.,0.,&quot;Error sending Message&quot;)
              exitwhen true
          endif
           set counter = counter + 1
        endloop
        set counter = 0
        set message = &quot;From &quot; + colored[Id] + GetPlayerName(sender) + &quot;|r: &quot; + SubString(sent,limit + 1,length)
        loop
            exitwhen counter &gt; length
            if SubString(sent,5,limit) == colors[counter] then
                call DisplayTextToPlayer(Player(counter),0.,0.,message)
                exitwhen true
            elseif SubString(sent,5,limit) == I2S(counter + 1) then
                call DisplayTextToPlayer(Player(counter),0.,0.,message)
                exitwhen true
            elseif SubString(sent,5,limit) == GetPlayerName(Player(counter)) then
                call DisplayTextToPlayer(Player(counter),0.,0.,message)
                exitwhen true
            elseif SubString(sent,5,limit) == &quot;all&quot; then
                loop
                    exitwhen readers &gt; 11
                    call DisplayTextToPlayer(Player(readers),0.,0.,message)
                    set readers = readers + 1
                endloop
                exitwhen true
            elseif SubString(sent,5,limit) == &quot;allies&quot; then
                loop
                    exitwhen readers &gt; 11
                    if IsPlayerAlly(sender,Player(readers)) then
                        call DisplayTextToPlayer(Player(readers),0.,0.,message)
                    endif 
                    set readers = readers + 1
                endloop
                exitwhen true
            elseif SubString(sent,5,limit) == &quot;enemies&quot; then
                loop
                    exitwhen readers &gt; 11
                    if not(IsPlayerAlly(sender,Player(readers))) then
                        call DisplayTextToPlayer(Player(readers),0.,0.,message)
                    endif 
                    set readers = readers + 1
                endloop
                exitwhen true
            endif
            set counter = counter + 1
        endloop
    endif

    set sender = null
endfunction

//===========================================================================
function InitTrig_ChatSys takes nothing returns nothing
    local integer counter = 0 
    set gg_trg_ChatSys = CreateTrigger()
    loop
        exitwhen counter == 11
        call TriggerRegisterPlayerChatEvent(gg_trg_ChatSys, Player(counter),&quot;&quot;,false)
        set counter = counter + 1
    endloop
    call TriggerAddAction(gg_trg_ChatSys,function ChatSys_Actions)
endfunction
 

Attachments

  • Chat System.w3m
    14.1 KB · Views: 236

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Bump, I would love to hear comments regarding this system.
 

ArmedCitizen

Kisses Cats
Reaction score
198
I can't comment on the actual make up of the system (the coding) but I can comment on the usefulness.

The first two are pretty easy to do without any special system. Hold Shift + Enter for All. Hold Ctrl + Enter for Allies. The Enemies chat seems like it would be useful along with the talk to Player # and Player Color. The Player Name is also easy with Blizzard's chat system, /w Player Name. I'd use this but only if I was really looking to customize a map.


Much better system then I could ever make. :D
 

Sim

Forum Administrator
Staff member
Reaction score
534
Whoa.

I typed in "Send All: lol". nothing happened.

I typed in "Send Allies: lol" and the game closed suddenly, without any error message :p
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Are you sure? This is a tested, working system, maybe you changed somthing by accident?
 

Sim

Forum Administrator
Staff member
Reaction score
534
I just opened it really. Tested alone though, without any other player in the game.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
I checked few more times it.

All players alone worked (name, number, color).
All players worked as well.
Allies and Enemies worked only once out of few tests, I guess I got lucky when I tested them before posting the system, I'll see if there is anyway to fix the problem. I tryed local player instead of Player(readers), but no luck there as well.
 

emjlr3

Change can be a good thing
Reaction score
395
graveyarded until updated working
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top