• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Multi-Multiboard Error

Status
Not open for further replies.
Level 5
Joined
Feb 6, 2008
Messages
134
Hi i have problem with multiboards when is more than one player connected multiboards are hidden for both here is script


JASS:
function HeroInfoMultiboard_Action takes nothing returns nothing
   local multiboard mb = null
   local integer i = 0
   local mapcontrol mct
   local playerslotstate pss
   
   loop
      set mct = GetPlayerController(Player(i))
      set pss = GetPlayerSlotState(Player(i))
      if(mct == MAP_CONTROL_USER and pss == PLAYER_SLOT_STATE_PLAYING)then
         set mb = CreateMultiboard()
         call SaveMultiboardHandle(HeroDatabaseHashtable(), i, 28, mb)
         // MB Settings
         call MultiboardSetRowCount(mb, 10)
         call MultiboardSetColumnCount(mb, 2)
         call MultiboardSetTitleText(mb, "Hero Stats - " + GetPlayerName(Player(i)))
         call MultiboardSetItemsStyle(mb, true, false)
         //....................
         //.......................
         call MultiboardDisplay(mb, false) // This will hide multiboard mb for all players...
         if(GetLocalPlayer() == Player(i))then
            call MultiboardDisplay(mb, true) // And This will show it only to player i...
         endif
         //
         set i = i + 1
      endif
   exitwhen i == 9
   endloop
   
   set mb = null
   set mct = null
   set pss = null
endfunction

function InitTrig_MultiboardHeroStats takes nothing returns nothing
   local trigger tt = CreateTrigger()

    call TriggerRegisterTimerEventSingle(tt, 0.01)
    call TriggerAddAction(tt, function HeroInfoMultiboard_Action)
    set tt = null
endfunction
^^^^^ Creates multiboards for each online player and show only for him...
 
Last edited:
Level 13
Joined
Sep 13, 2010
Messages
550
so I saw an exitwhen il == 9 what is il supposed to be? Is it i just miswritten? Also putting the set i = i + 1 inside an if is the worst thing I ever seen, because you use it for next time. Eg Player( 0 ) is online Player( 1 ) is not and Player( 2 ) is online then it will stop at Player( 1 ) because you use the same variable as before, but the value don't changes because the if, so it will loop for Player( 1 ) forever. Also if il is a different value and not i then I haven't seen any other lines that change the il's value so it is an endless loop again.

The upper thing a bit longer:
JASS:
function HeroInfoMultiboard_Action takes nothing returns nothing
   local multiboard mb = null
   local integer i = 0
   local mapcontrol mct
   local playerslotstate pss
   
   loop
      set mct = GetPlayerController(Player(0))
      set pss = GetPlayerSlotState(Player(0))
      // The following statement is true
      if(mct == MAP_CONTROL_USER and pss == PLAYER_SLOT_STATE_PLAYING)then
         set mb = CreateMultiboard()
         call SaveMultiboardHandle(HeroDatabaseHashtable(), 0, 28, mb)
         // MB Settings
         call MultiboardSetRowCount(mb, 10)
         call MultiboardSetColumnCount(mb, 2)
         call MultiboardSetTitleText(mb, "Hero Stats - " + GetPlayerName(Player(0)))
         call MultiboardSetItemsStyle(mb, true, false)
         //....................
         //.......................
         call MultiboardDisplay(mb, false) // This will hide multiboard mb for all players...
         if(GetLocalPlayer() == Player(0))then
            call MultiboardDisplay(mb, true) // And This will show it only to player i...
         endif
         // So it will be 1 now
         set 0 = 0 + 1
      endif
   // Now I change it to i
   // Also it is false continue loop
   exitwhen i(1) == 9
   endloop
   
   set mb = null
   set mct = null
   set pss = null
endfunction

It is still allright. Now comes with value 1

JASS:
function HeroInfoMultiboard_Action takes nothing returns nothing
   local multiboard mb = null
   local integer i = 0
   local mapcontrol mct
   local playerslotstate pss
   
   loop
      set mct = GetPlayerController(Player(1))
      set pss = GetPlayerSlotState(Player(1))
      // The following statement is false
      if(mct == MAP_CONTROL_USER and pss == PLAYER_SLOT_STATE_PLAYING)then
         //Blah your functions...
         // The if is not running so value not changes, it still be 1 now
         set 0 = 0 + 1
      endif
   // Also it is false continue loop
   exitwhen i(1) == 9
   endloop
   
   set mb = null
   set mct = null
   set pss = null
endfunction

So as you see it will run for "forever"

Suggestions:
The hide multiboard function is inneed. It will be hidden until you show it. If you create a MB via GUI it will show up of course because the MB BJ has a function to show it.
I think you overcomlicate it. You are too afraid of leaks but setting a value and nulling it doesn't makes difference because you are not destroying it. If I am mistaken correct me. I don't know really how WC engine works. I don't think that 9*2 instance of that will ruin a map, or crash a computer.
If you really want to make your script faster then do not call functions again and again. The Player( i ) function. Save it into a value.
Anyway starting the mb value with a null is inneed. It will be null and not create a new MB.

So the mayor thing: put that function outside the if.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Multiboards default to being displayed. Thus what you need to do is the process in 2 steps.

1. Create all multiboards for each player (making sure to hide them as you make them).
2. Display all multiboards for each player.

Both steps must be done separatly, this means 2 loops, first loop to make them and then after the loop ends you just need to loop through all multiboards and display them to the correct players.
 
Level 5
Joined
Feb 6, 2008
Messages
134
so I saw an exitwhen il == 9 what is il supposed to be? Is it i just miswritten? Also putting the set i = i + 1 inside an if is the worst thing I ever seen

Ohh sorry both are misswritten i think the solution with two loops will fix the problem.


EDIT:
I tested it and now it works... Thanks to both +Rep
Sorry Dr Super Good i can't give you +rep now because it is saying: You must spread some reputation...
 
Status
Not open for further replies.
Top