1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Get Local Player for UI Modification

Discussion in 'Triggers & Scripts' started by xorkatoss, Aug 13, 2019.

  1. xorkatoss

    xorkatoss

    Joined:
    Jul 12, 2010
    Messages:
    1,515
    Resources:
    7
    Models:
    5
    Maps:
    1
    Spells:
    1
    Resources:
    7
    Alright guys after reading that I'm super confused about using LocalPlayer for UI Modifications.

    Basically my goal is to make a UI Inventory and that involves showing/hiding/moving a lot of "framehandles"

    If I'm correct frames should never be created with local player right?
    Code (vJASS):
    local framehandle invall = BlzCreateFrameByType("BACKDROP" , "InventoryUI" , BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)


    Instead all frames should be created for all players and then you can locally show/hide/move them
    Code (vJASS):
    if GetLocalPlayer() == GetTriggerPlayer() then
    call BlzFrameSetVisible(BlzGetFrameByName("InventoryUI",0) , true)
    endif


    Code in the Test Map I Provided:
    Code (vJASS):
    function Inventory_Actions takes nothing returns nothing
        local framehandle invall = BlzCreateFrameByType("BACKDROP" , "InventoryUI" , BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
        call BlzFrameSetSize(invall, 0.3, 0.3)
        call BlzFrameSetAbsPoint(invall, FRAMEPOINT_CENTER, 0.63, 0.35)
        call BlzFrameSetTexture(invall, "Inventory.tga",0, true)
    endfunction
    //===========================================================================
    function InitTrig_Inventory_UI takes nothing returns nothing
        set gg_trg_Inventory_UI = CreateTrigger(  )
        call TriggerRegisterTimerEventSingle( gg_trg_Inventory_UI, 0.40 )
        call TriggerAddAction( gg_trg_Inventory_UI, function Inventory_Actions )
    endfunction

    • Hide Show Inventory
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Backpack
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Inventory_Hide[(Player number of (Owner of (Triggering unit)))] Equal to False
          • Then - Actions
            • Set Inventory_Hide[(Player number of (Owner of (Triggering unit)))] = True
            • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
            • Custom script: call BlzFrameSetVisible(BlzGetFrameByName("InventoryUI",0) , true)
            • Custom script: endif
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Inventory_Hide[(Player number of (Owner of (Triggering unit)))] Equal to True
              • Then - Actions
                • Set Inventory_Hide[(Player number of (Owner of (Triggering unit)))] = False
                • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
                • Custom script: call BlzFrameSetVisible(BlzGetFrameByName("InventoryUI",0) , false)
                • Custom script: endif
              • Else - Actions


    I tested this in single player with different players and it works for each player, I'm just not sure if it will cause desync when used in multiplayer, so I'm seeking the help of an expert.
     

    Attached Files:

  2. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,662
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    Correct.

    Yes.

    You can run multiple instances of the game and test for desyncs in LAN.
     
  3. xorkatoss

    xorkatoss

    Joined:
    Jul 12, 2010
    Messages:
    1,515
    Resources:
    7
    Models:
    5
    Maps:
    1
    Spells:
    1
    Resources:
    7
    @TriggerHappy alright thanks! I'm gonna try multiple instances and see what happens.