Trigger to change color of player voluntarily

Status
Not open for further replies.
Level 4
Joined
Apr 9, 2020
Messages
15
Hello! I need to make a trigger that will change the color of a players units when they type a message.
For example: Player 2 Blue, types a message containing "-red" and automatically the color of his units changes to red. If he types -green, then it goes green, and so on. For any player, not just player 2.

Thanks!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
  • Color Changer Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- Define your Color strings: --------
      • Set VariableSet ColorString[1] = -red
      • Set VariableSet ColorString[2] = -blue
      • Set VariableSet ColorString[3] = -teal
      • Set VariableSet ColorString[4] = -purple
      • Set VariableSet ColorString[5] = -yellow
      • Set VariableSet ColorString[6] = -orange
      • Set VariableSet ColorString[7] = -green
      • Set VariableSet ColorString[8] = -pink
      • Set VariableSet ColorString[9] = -gray
      • Set VariableSet ColorString[10] = -lightblue
      • Set VariableSet ColorString[11] = -darkgreen
      • Set VariableSet ColorString[12] = -brown
      • -------- --------
      • -------- Add the chat Events to the Color Changer Chat Msg trigger: --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to User
              • ((Picked player) slot status) Equal to Is playing
            • Then - Actions
              • For each (Integer A) from 1 to 12, do (Actions)
                • Loop - Actions
                  • Trigger - Add to Color Changer Chat Msg <gen> the event (Player - (Picked player) types a chat message containing ColorString[(Integer A)] as An exact match)
            • Else - Actions
  • Color Changer Chat Msg
    • Events
    • Conditions
    • Actions
      • -------- The Events for this trigger are added in Color Changer Setup! --------
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Entered chat string) Equal to ColorString[(Integer A)]
            • Then - Actions
              • Player - Change color of (Triggering player) to (Color of (Player((Integer A)))), Changing color of existing units
              • Custom script: exitwhen true
            • Else - Actions
I set this up to work for the first 12 players (Red -> Brown). If your map supports more than 12 users then you will need to add more ColorStrings and adjust your For Loops to run from 1 to X, where X is the highest Player Number. You'll see the For Loops are set to go from 1 to 12 since Brown's player number is 12.
 

Attachments

  • Color Changer 1.w3m
    17.7 KB · Views: 13
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
The only issue I can see is that this Color of Player function will get the Player's CURRENT color and not their original color:
  • Player - Change color of (Triggering player) to (Color of (Player((Integer A)))), Changing color of existing units
If that's the case then you should add a new Player Color variable (array) that tracks each color inside of the Setup trigger:
  • Actions
    • -------- Define your Colors: --------
    • Set VariableSet ColorType[1] = Red
    • Set VariableSet ColorType[2] = Blue
    • Set VariableSet ColorType[3] = Teal
    • etc...
    • -------- Define your Color strings: --------
Then you can reference this in the Chat Msg trigger:
  • Player - Change color of (Triggering player) to ColorType[(Integer A)], Changing color of existing units
 
Status
Not open for further replies.
Top