• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Local multiboard

Status
Not open for further replies.
Level 12
Joined
Dec 2, 2016
Messages
733
I posted about this before but I lost the post.

I have 2 multiboards. One shown to team 1, other shown to team 2.

I understand I have to assign this via jass coding locally.

How would I go about doing this?

I need to have the code check if player[X] belongs to PlayerGroup X then show multiboard for that player.
 
Level 12
Joined
Dec 2, 2016
Messages
733
I came up with this, but I can't seem to be able to assign my multiboards to a variable, I guess I'm not doing it properly?

Code:
function Trig_multijass_Copy_2_Func001Func001Func001C takes nothing returns boolean
    if ( not ( IsPlayerInForce(ConvertedPlayer(GetForLoopIndexA()), udg_Vampires) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_multijass_Copy_2_Func001Func001C takes nothing returns boolean
    if ( not ( IsPlayerInForce(ConvertedPlayer(GetForLoopIndexA()), udg_Humans) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_multijass_Copy_2_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 12
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_multijass_Copy_2_Func001Func001C() ) then
       
       
       

     set udg_Multi = Multiboard1

     
   if GetLocalPlayer() == Player(0) then

 call MultiboardDisplayBJ(true,udg_Multi)
endif

       
       
       
        else
            if ( Trig_multijass_Copy_2_Func001Func001Func001C() ) then
           
                 set udg_Multi2 = Multiboard2

     
   if GetLocalPlayer() == Player(0) then

 call MultiboardDisplayBJ(true,udg_Multi2)
endif

           
           
            else
            endif
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_multijass_Copy_2 takes nothing returns nothing
    set gg_trg_multijass_Copy_2 = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_multijass_Copy_2, 2.00 )
    call TriggerAddAction( gg_trg_multijass_Copy_2, function Trig_multijass_Copy_2_Actions )
endfunction
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
I cannot see where Multiboard1 and Multiboard2 are declared.

You do not need JASS to do this directly. All you need is a line of custom script that assigns GetLocalPlayer to a global variable. For example with a global player variable named "LocalPlayer"...

  • custom script: set udg_LocalPlayer = GetLocalPlayer()
After doing that show the appropriate multiboard to the appropriate player. The easiest way to do this is create both multiboards and hide both multiboards for all players. Then assign players to player groups for each team. Then use a GUI if then else if block to test if LocalPlayer is inside the player group and if true then show the multiboard assigned to that player group. Repeat for the other player group.

Be warned that GetLocalPlayer returns a value which is not synchronized between clients allowing code to be run locally for a specific client. Using it to run code that alters game state rather than local visuals will cause that player to drop out of sync in multiplayer. It is safe to show/hide multiboards and leaderboards with it. It is not safe to create units, show/hide units, add abilities to units, move units etc.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
Or did I understand that wrong.
Yes that is not quite what I said.

You assign a global variable the value of GetLocalPlayer(). You then create 2 Player Group variables representing the players on each team. Add the appropriate players to the player group variables. Then test if the variable you assigned GetLocalPlayer() to is inside the team 1 player group and if so show team 1 multiboard. Then test if the variable you assigned GetLocalPlayer() to is inside the team 2 player group and if so show team 2 multiboard.

The advantage of this approach is that it can be done in GUI with only 1 line of custom script, as shown above. It avoids the programming knowledge requirement required to write JASS.
 
Level 12
Joined
Dec 2, 2016
Messages
733
So I came up with this, it outputs "yes" but no multiboard is shown.

  • Multiboard assign
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Multiboard - Hide all multiboards
      • Custom script: set udg_LocalPlayer = GetLocalPlayer()
      • 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
              • (Player((Integer A))) Equal to LocalPlayer
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Player((Integer A))) is in Humans) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: Yes
                  • Multiboard - Show HumanMultiboardVariable
                • Else - Actions
                  • Game - Display to (All players) the text: no
                  • Multiboard - Show VampireMultiboardVariable
            • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,206
Why is there a for loop? I never mentioned that...

Make sure the player group is initialized before the trigger fires. Also make sure both multiboards are initialized before the trigger fires. Avoid displaying messages locally as unique strings can cause out of sync problems.
 
Level 12
Joined
Dec 2, 2016
Messages
733
My human is assigned to human players, I mean it's running as I get the message and btw the msg is just for testing to make sure it's actually running.

  • Multiboard assign
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Multiboard - Hide all multiboards
      • Wait 2.00 seconds
      • Custom script: set udg_LocalPlayer = GetLocalPlayer()
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LocalPlayer is in Humans) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: Yes
          • Multiboard - Show HumanMultiboardVariable
        • Else - Actions
          • Multiboard - Show VampireMultiboardVariable
The multiboard is visible until the hide command runs, then the message reads yes and it does not show.

Edit: Changed hide all multiboards to hide Human board, and another to hide vamp board. And now it's working.
 
Status
Not open for further replies.
Top