• 🏆 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!

[Solved] Show/Hide Multiboard works only once

Status
Not open for further replies.
Level 3
Joined
Nov 12, 2018
Messages
43
I want to show and hide multiboards multiple times. But once I hide one multiboard, I can't show it again. It looks like the function just stops working after first use.

  • Show Hide MB
    • Events
      • Player - Player 1 (Red) types a chat message containing ! as A substring
      • Player - Player 2 (Blue) types a chat message containing ! as A substring
      • Player - Player 3 (Teal) types a chat message containing ! as A substring
      • Player - Player 4 (Purple) types a chat message containing ! as A substring
      • Player - Player 5 (Yellow) types a chat message containing ! as A substring
      • Player - Player 6 (Orange) types a chat message containing ! as A substring
    • Conditions
    • Actions
      • For each (Integer loop_HumanPlayerA) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering player) Equal to (Player(loop_HumanPlayerA))
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring((Entered chat string), 7, 8)) Equal to mb
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring((Entered chat string), 2, 6)) Equal to show
                      • b_ViewsMBArmy[loop_HumanPlayerA] Equal to False
                    • Then - Actions
                      • Set b_ViewsMBArmy[loop_HumanPlayerA] = True
                      • Custom script: if GetTriggerPlayer() == GetLocalPlayer() then
                      • Game - Display to (All players) the text: test show
                      • Multiboard - Show mb_Army
                      • Multiboard - Maximize mb_Army
                      • Sound - Play ItemReceived <gen> at 100.00% volume, skipping the first 0.00 seconds
                      • Custom script: endif
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Substring((Entered chat string), 2, 6)) Equal to hide
                      • b_ViewsMBArmy[loop_HumanPlayerA] Equal to True
                    • Then - Actions
                      • Set b_ViewsMBArmy[loop_HumanPlayerA] = False
                      • Custom script: if GetTriggerPlayer() == GetLocalPlayer() then
                      • Game - Display to (All players) the text: test hide
                      • Multiboard - Hide all multiboards
                      • Sound - Play ItemReceived <gen> at 100.00% volume, skipping the first 0.00 seconds
                      • Custom script: endif
                    • Else - Actions
                • Else - Actions
            • Else - Actions
Text message and audio are working every time.
I also tried without "GetLocalPlayer()" but it still won't work as intended.

Is it even possible to show/hide one multiboard multiple times? And if yes; what em I doing wrong?

edit:
  • Multiboard - Hide mb_Army
It's working if I hide the Mulitboard by using this function. But I still would like to know, why "Hide all Multiboards" doesn't work.
 

Attachments

  • TEST Multiboard.w3x
    18.5 KB · Views: 41
Last edited:
Level 15
Joined
Oct 29, 2012
Messages
1,474
While I've been exploring your test map, I've noticed you put this :
  • For each (Integer loop_HumanPlayerA) from 1 to 6, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to (Player(loop_HumanPlayerA))
        • Then - Actions
        • Else - Actions

I can't see the point of this looping, I believe the map is played by 6 players, so why check if the triggering player is indeed one of the players ? It's not like someone who didn't trigger the event would have his multiboards hidden anyway, (Triggering Player) saves all the looping; but again, I might be missing your point from that.

Aside from that, the function "Hide All Multiboards" makes it "forbidden" for the game to show any individual multiboard on its own.
Which means, if you use "Hide All multiboards", you'll most likely get no result showing the multiboard. So I tweaked a bit with your trigger and here's the final meal :
  • Show Hide MB
    • Events
      • Player - Player 1 (Red) types a chat message containing ! as A substring
      • Player - Player 2 (Blue) types a chat message containing ! as A substring
      • Player - Player 3 (Teal) types a chat message containing ! as A substring
      • Player - Player 4 (Purple) types a chat message containing ! as A substring
      • Player - Player 5 (Yellow) types a chat message containing ! as A substring
      • Player - Player 6 (Orange) types a chat message containing ! as A substring
    • Conditions
      • (Substring((Entered chat string), 7, 8)) Equal to mb
    • Actions
      • Set PlayerIndex = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring((Entered chat string), 2, 5)) Equal to show
          • b_ViewsMBArmy[PlayerIndex] Equal to False
        • Then - Actions
          • Set b_ViewsMBArmy[PlayerIndex] = True
          • Custom script: if GetTriggerPlayer() == GetLocalPlayer() then
          • Game - Display to (All players) the text: test show
          • Multiboard - Show mb_Army
          • Multiboard - Maximize mb_Army
          • Custom script: endif
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring((Entered chat string), 2, 5)) Equal to hide
              • b_ViewsMBArmy[PlayerIndex] Equal to True
            • Then - Actions
              • Set b_ViewsMBArmy[PlayerIndex] = False
              • Custom script: if GetTriggerPlayer() == GetLocalPlayer() then
              • Game - Display to (All players) the text: test hide
              • Multiboard - Hide mb_Army
              • // As you can see here, I hid only mb_Army which is the only multiboard we have, I bet you have more multiboards.
              • // The point from replacing "Hide All Multiboards" with that one is for the sake of testing, and indeed, it was showing normally.
              • Custom script: endif
            • Else - Actions

As you can see, I've changed your trigger a bit and removed some unnecessary parts, also I moved some triggers here and there.
I used "PlayerIndex" which was a variable of mine instead of your integer, it doesn't matter.

So what's the solution ? What should you do if you can't use "Hide All Multiboards"; I didn't think much but the closest approach is that you create multiboards and store them in Array-variables. then loop through all the array-variables and hide the multiboard one by one. If you didn't get that, you will get it by looking at this trigger :
upload_2019-3-7_19-15-35.png

We create a multiboard variable with an array, so we store each multiboard in a different array. Now to our trigger :
First of all, let's create two multiboards for the sake of testing :
  • Nahkampf-Initialisierung
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Multiboard - Create a multiboard with 1 columns and 1 rows, titled test mb
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 1 to Show text and Hide icons
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 1 to Hello!
      • Multiboard - Set the width for (Last created multiboard) item in column 1, row 1 to 5.00% of the total screen width
      • Set mb_ArmywithArray[1] = (Last created multiboard)
      • Multiboard - Create a multiboard with 1 columns and 1 rows, titled test mb
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 1 to Show text and Hide icons
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 1 to Bye
      • Multiboard - Set the width for (Last created multiboard) item in column 1, row 1 to 5.00% of the total screen width
      • Set mb_ArmywithArray[2] = (Last created multiboard)
      • Set b_ViewsMBArmy[1] = True
As you can see, I stored the first multiboard in Array = 1, and second one in Array =2, but both into the same variable.

Now, we should use this trigger to hide our multiboards : When we are about to hide our multiboards, we use this trigger instead of "Hide All Multiboards"
  • For each (Integer A) from 1 to "The Amount of multiboards you have", do (Actions)
    • Loop - Actions
      • Multiboard - Hide mb_ArmywithArray[(Integer A)]

When you show multiboards, just loop again through all the multiboards. I assume the multiboards are the same for every player, in other words, all players see the same multiboard right ? They just choose whether to hide it for their own without hiding other players' multiboards.
If not, that's a problem, you'd need a hashtable if you have different multiboard values (and hence different multiboards to begin with) for every player, but I am pretty sure that's not the case.

I hope that was useful, as a summary, just don't use "Hide All Multiboards", because the game perceives them as "Shown" but they're just invisible. Here's the test trigger I used :
  • checker
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (mb_Army is showing) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text:the multiboard is showing lulz
        • Else - Actions

Although the multiboard was hidden, yet the game displayed "the multiboard is showing lulz", which would be very weird since the multiboard is already hidden.

Hope that helps.
 
Level 3
Joined
Nov 12, 2018
Messages
43
First of all: Thank very much for helping me! ;)

While I've been exploring your test map, I've noticed you put this :
  • For each (Integer loop_HumanPlayerA) from 1 to 6, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering player) Equal to (Player(loop_HumanPlayerA))
        • Then - Actions
        • Else - Actions
I can't see the point of this looping, I believe the map is played by 6 players, so why check if the triggering player is indeed one of the players ? It's not like someone who didn't trigger the event would have his multiboards hidden anyway, (Triggering Player) saves all the looping; but again, I might be missing your point from that.
Showing/Hiding multiboards is not the only purpose of that trigger. It handles every chat command of my map. Some of those commands are working with arrays where "loop_HumanPlayerA" is their index number.
I left the loop for my example trigger, in case that this causes problems somehow. So you would be able to spot that potencial mistake...

So what's the solution ? What should you do if you can't use "Hide All Multiboards"; I didn't think much but the closest approach is that you create multiboards and store them in Array-variables. then loop through all the array-variables and hide the multiboard one by one. If you didn't get that, you will get it by looking at this trigger :
View attachment 317955
We create a multiboard variable with an array, so we store each multiboard in a different array. Now to our trigger :
First of all, let's create two multiboards for the sake of testing :
  • Nahkampf-Initialisierung
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Multiboard - Create a multiboard with 1 columns and 1 rows, titled test mb
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 1 to Show text and Hide icons
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 1 to Hello!
      • Multiboard - Set the width for (Last created multiboard) item in column 1, row 1 to 5.00% of the total screen width
      • Set mb_ArmywithArray[1] = (Last created multiboard)
      • Multiboard - Create a multiboard with 1 columns and 1 rows, titled test mb
      • Multiboard - Set the display style for (Last created multiboard) item in column 1, row 1 to Show text and Hide icons
      • Multiboard - Set the text for (Last created multiboard) item in column 1, row 1 to Bye
      • Multiboard - Set the width for (Last created multiboard) item in column 1, row 1 to 5.00% of the total screen width
      • Set mb_ArmywithArray[2] = (Last created multiboard)
      • Set b_ViewsMBArmy[1] = True
As you can see, I stored the first multiboard in Array = 1, and second one in Array =2, but both into the same variable.

Now, we should use this trigger to hide our multiboards : When we are about to hide our multiboards, we use this trigger instead of "Hide All Multiboards"
  • For each (Integer A) from 1 to "The Amount of multiboards you have", do (Actions)
    • Loop - Actions
      • Multiboard - Hide mb_ArmywithArray[(Integer A)]
There will be only 3 (maybe 4) different multiboards. Currently, only one is finished. One of them will be available for all players. The rest is for debugging and monitoring purposes, when I test my map. I want to be able to see whatever multiboard I desire, regardless of my player slot.
I think it won't be necessary to loop through a couple of multiboards, but thanks for that advice anyway. It won't kil me to add those few functions manually for each multiboard.


When you show multiboards, just loop again through all the multiboards. I assume the multiboards are the same for every player, in other words, all players see the same multiboard right ? They just choose whether to hide it for their own without hiding other players' multiboards.
If not, that's a problem, you'd need a hashtable if you have different multiboard values (and hence different multiboards to begin with) for every player, but I am pretty sure that's not the case.
I would like to know, why I have to use hashtables for different multiboards? I already know, how to use hashtables. I just don't see any reason for that, since all GUI functions for multiboards, require a parameter for a multiboard variable. Wouldn't it be enough to use unique multiboards variables for those functions? I just want to know for sure, before I start working on the next multiboard.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Showing/Hiding multiboards is not the only purpose of that trigger. It handles every chat command of my map. Some of those commands are working with arrays where "loop_HumanPlayerA" is their index number.
I left the loop for my example trigger, in case that this causes problems somehow. So you would be able to spot that potencial mistake...

I recommend creating isolated triggers for each command. You wouldn't worry about the interference of any functions and you'd make it really easy, without losing anything efficiency-wise. It's just a recommendation. There is a chance you might end up dealing with buggy chat-commands especially if each command has its own function. There would be no worry if you'd do it the right way, but it's better if you avoid that in the first place. 'Separate triggers for separate commands' is always the way to go.

I think it won't be necessary to loop through a couple of multiboards, but thanks for that advice anyway. It won't kil me to add those few functions manually for each multiboard.

That's one way to do it. There are maps where multiboards are created and deleted frequently so you'd not know the exact number of multiboards throughout the game so, a loop with a variable-end would be the optimal solution. But if you have only just a few of them, yes, it would not be bothersome to create one trigger line for each.

I would like to know, why I have to use hashtables for different multiboards? I already know, how to use hashtables. I just don't see any reason for that, since all GUI functions for multiboards, require a parameter for a multiboard variable. Wouldn't it be enough to use unique multiboards variables for those functions? I just want to know for sure, before I start working on the next multiboard.

Hashtables are commonly used to handle MUI spells and functions. I mentioned that a hashtable would be necessary for storing multiboard's values just in case every player has his own multiboard and multiboard's values. In your case, it is not needed.

Hope you got it to work. Bonne Chance.
 
Status
Not open for further replies.
Top