• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Getting Player Color Not Working

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
I'm trying to detect the Player's chosen Color at the start of the game.
  • Player Colors Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet Colors[1] = |cffff0303
      • Set VariableSet Colors[2] = |cff0042ff
      • Set VariableSet Colors[3] = |cff1ce6b9
      • Set VariableSet Colors[4] = |cff540081
      • Set VariableSet Colors[5] = |cfffffc00
      • Set VariableSet Colors[6] = |cfffe8a0e
      • Set VariableSet Colors[7] = |cff20c000
      • Set VariableSet Colors[8] = |cffe55bb0
      • Set VariableSet Colors[9] = |cff959697
      • Set VariableSet Colors[10] = |cff7ebff1
      • Set VariableSet Colors[11] = |cff106246
      • Set VariableSet Colors[12] = |cff4a2a04
      • Set VariableSet Colors[13] = |cff9b0000
      • Set VariableSet Colors[14] = |cff0000c3
      • Set VariableSet Colors[15] = |cff00eaff
      • Set VariableSet Colors[16] = |cffbe00fe
      • Set VariableSet Colors[17] = |cffebcd87
      • Set VariableSet Colors[18] = |cfff8a48b
      • Set VariableSet Colors[19] = |cffbfff80
      • Set VariableSet Colors[20] = |cffdcb9eb
      • Set VariableSet Colors[21] = |cff282828
      • Set VariableSet Colors[22] = |cffebf0ff
      • Set VariableSet Colors[23] = |cff00781e
      • Set VariableSet Colors[24] = |cffa46f33
      • For each (Integer A) from 1 to 24, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Player_Color[1] Equal to <Empty String>
              • (Color of Player 1 (Red)) Equal to (Color of (Player((Integer A))))
            • Then - Actions
              • Set VariableSet Player_Color[1] = Colors[(Integer A)]
              • Game - Display to (All players) for 30.00 seconds the text: (Player Color #: + (String((Integer A))))
            • Else - Actions
So this trigger should detect the Player's chosen Color and then store that as a String. From that point on I can reference "Player_Color[Player number]" to get the player's chosen color code.

I tested this as Player 1 in the Game Lobby and changed my color to Purple but for whatever reason the game is still assigning me Red's color.

I modified the conditions and removed the empty string check:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Color of Player 1 (Red)) Equal to (Color of (Player((Integer A))))
    • Then - Actions
      • Set VariableSet Player_Color[1] = Colors[(Integer A)]
      • Game - Display to (All players) for 30.00 seconds the text: (Player Color #: + (String((Integer A))))
And in this case it displayed that my color was first Red (1) and then it actually worked and displayed that my color was Purple (4). So it's as if i'm both Red AND Purple at the same time... Anyone know what's going on?

Edit:
In the meantime I found a fix by calculating how many Colors the game detects for a given player. If it detects more than 1 color than I know that you've changed for example Player 1 from Red to something else.
  • Player Colors Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet Colors[1] = |cffff0303
      • Set VariableSet Colors[2] = |cff0042ff
      • Set VariableSet Colors[3] = |cff1ce6b9
      • Set VariableSet Colors[4] = |cff540081
      • Set VariableSet Colors[5] = |cfffffc00
      • Set VariableSet Colors[6] = |cfffe8a0e
      • Set VariableSet Colors[7] = |cff20c000
      • Set VariableSet Colors[8] = |cffe55bb0
      • Set VariableSet Colors[9] = |cff959697
      • Set VariableSet Colors[10] = |cff7ebff1
      • Set VariableSet Colors[11] = |cff106246
      • Set VariableSet Colors[12] = |cff4a2a04
      • Set VariableSet Colors[13] = |cff9b0000
      • Set VariableSet Colors[14] = |cff0000c3
      • Set VariableSet Colors[15] = |cff00eaff
      • Set VariableSet Colors[16] = |cffbe00fe
      • Set VariableSet Colors[17] = |cffebcd87
      • Set VariableSet Colors[18] = |cfff8a48b
      • Set VariableSet Colors[19] = |cffbfff80
      • Set VariableSet Colors[20] = |cffdcb9eb
      • Set VariableSet Colors[21] = |cff282828
      • Set VariableSet Colors[22] = |cffebf0ff
      • Set VariableSet Colors[23] = |cff00781e
      • Set VariableSet Colors[24] = |cffa46f33
      • -------- --------
      • -------- Player 1 --------
      • Set VariableSet Color_Fix = 0
      • For each (Integer A) from 1 to 24, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Color of Player 1 (Red)) Equal to (Color of (Player((Integer A))))
            • Then - Actions
              • Set VariableSet Color_Fix = (Color_Fix + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Color_Fix Equal to 1
        • Then - Actions
          • Set VariableSet Player_Color[1] = Colors[1]
        • Else - Actions
          • For each (Integer A) from 1 to 24, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Not equal to 1
                  • Player_Color[1] Equal to <Empty String>
                  • (Color of Player 1 (Red)) Equal to (Color of (Player((Integer A))))
                • Then - Actions
                  • Set VariableSet Player_Color[1] = Colors[(Integer A)]
                • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top