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

[Crash] Oskey Crash And UI Button Crash Question

Status
Not open for further replies.
Level 7
Joined
Nov 6, 2019
Messages
186
Ok so, it testing single player not one issue, however in multiplayer has many issues, anyone know fixes?

so First OsKeys

JASS:
globals

    boolean array WASD_IsKeyDown_L
    boolean array WASD_IsKeyDown_K
    boolean array WASD_IsKeyDown_O
    boolean array WASD_IsKeyDown_I
    boolean array WASD_IsKeyDown_1
    boolean array WASD_IsKeyDown_2
    boolean array WASD_IsKeyDown_3
    boolean array WASD_IsKeyDown_4
    boolean array WASD_IsKeyDown_5
    boolean array WASD_IsKeyDown_6
    boolean array WASD_IsKeyDown_0
    boolean array WASD_IsKeyDown_8
    boolean array WASD_IsKeyDown_9

    constant oskeytype WASD_KEY_L = ConvertOsKeyType($4C)
    constant oskeytype WASD_KEY_K = ConvertOsKeyType($4B)
    constant oskeytype WASD_KEY_O = ConvertOsKeyType($4F)
    constant oskeytype WASD_KEY_I = ConvertOsKeyType($49)
    constant oskeytype WASD_KEY_1 = ConvertOsKeyType($31)
    constant oskeytype WASD_KEY_2 = ConvertOsKeyType($32)
    constant oskeytype WASD_KEY_3 = ConvertOsKeyType($33)
    constant oskeytype WASD_KEY_4 = ConvertOsKeyType($34)
    constant oskeytype WASD_KEY_5 = ConvertOsKeyType($35)
    constant oskeytype WASD_KEY_6 = ConvertOsKeyType($36)
    constant oskeytype WASD_KEY_0 = ConvertOsKeyType($30)
    constant oskeytype WASD_KEY_8 = ConvertOsKeyType($38)
    constant oskeytype WASD_KEY_9 = ConvertOsKeyType($39)

endglobals

//========================================================================================
//========================================================================================

function PlayerKeyEvent_Actions takes nothing returns nothing
    local oskeytype osKeyPressed = BlzGetTriggerPlayerKey() // What key was pressed or released?
    local boolean isKeyDown = BlzGetTriggerPlayerIsKeyDown() // Was the event key pressed or released?
    local boolean isVisible = false

    //Not used here, but this way we can detect the meta-key.
    //local integer metaKeyPressed = BlzGetTriggerPlayerMetaKey()



// AdminUI

    if (osKeyPressed == WASD_KEY_9) then
        set WASD_IsKeyDown_9[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 

    set isVisible = BlzFrameIsVisible(AdminPanelUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(AdminPanelUIBD, false)
                    set udg_APUILimit = 0
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call ConditionalTriggerExecute( gg_trg_OpenAdminUI )



    
            endif

    endif
endif


// Selected Settings

    if (osKeyPressed == WASD_KEY_8) then
        set WASD_IsKeyDown_8[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 

    call ConditionalTriggerExecute( gg_trg_GSUICheckSettings )

    
            endif

    endif

// SkinUI
    if (osKeyPressed == WASD_KEY_0) then
        set WASD_IsKeyDown_0[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then
    set isVisible = BlzFrameIsVisible(SkinUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(SkinUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(SkinUIBD, true)
            endif

    endif
endif


    // Biology Missing
    if (osKeyPressed == WASD_KEY_1) then
        set WASD_IsKeyDown_1[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h012')) == 0 ) ) then
            call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: You Don't Own a |cffffff00Biology|r School." )

    
            endif

    endif
endif

    // Biology Got
    if (osKeyPressed == WASD_KEY_1) then
        set WASD_IsKeyDown_1[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h012')) >= 1 ) ) then
            call SelectGroupForPlayerBJ( GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h012'), GetTriggerPlayer() )

    
            endif

    endif
endif

    // Mechanic Missing
    if (osKeyPressed == WASD_KEY_2) then
        set WASD_IsKeyDown_2[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h00Z')) == 0 ) ) then
            call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: You Don't Own a |cffffff00Mechanic|r School." )
    
            endif

    endif
endif

    // Mechanic Got
    if (osKeyPressed == WASD_KEY_2) then
        set WASD_IsKeyDown_2[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h00Z')) >= 1 ) ) then
            call SelectGroupForPlayerBJ( GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h00Z'), GetTriggerPlayer() )
    
            endif

    endif
endif

    // Poacher Missing
    if (osKeyPressed == WASD_KEY_3) then
        set WASD_IsKeyDown_3[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h010')) == 0 ) ) then
            call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: You Don't Own a |cffffff00Poacher|r School." )
    
            endif

    endif
endif

    // Poacher Got
    if (osKeyPressed == WASD_KEY_3) then
        set WASD_IsKeyDown_3[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h010')) >= 1 ) ) then
            call SelectGroupForPlayerBJ( GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h010'), GetTriggerPlayer() )
    
            endif

    endif
endif    

    // Physics Missing
    if (osKeyPressed == WASD_KEY_4) then
        set WASD_IsKeyDown_4[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h011')) == 0 ) ) then
            call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: You Don't Own a |cffffff00Physics|r School." )
    
            endif

    endif
endif

    // Physics Got
    if (osKeyPressed == WASD_KEY_4) then
        set WASD_IsKeyDown_4[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h011')) >= 1 ) ) then
            call SelectGroupForPlayerBJ( GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h011'), GetTriggerPlayer() )
    
            endif

    endif
endif

    // Undead Missing
    if (osKeyPressed == WASD_KEY_5) then
        set WASD_IsKeyDown_5[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h69F')) == 0 ) ) then
            call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: You Don't Own a |cffffff00Undead|r Science School." )
    
            endif

    endif
endif

    // Undead Got
    if (osKeyPressed == WASD_KEY_5) then
        set WASD_IsKeyDown_5[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h69F')) >= 1 ) ) then
            call SelectGroupForPlayerBJ( GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h69F'), GetTriggerPlayer() )
    
            endif

    endif
endif

    // Adaptive Missing
    if (osKeyPressed == WASD_KEY_6) then
        set WASD_IsKeyDown_6[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h03A')) == 0 ) ) then
            call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: You Don't Own a |cffffff00Adaptive|r Technology School." )
    
            endif

    endif
endif

    // Adaptive Got
    if (osKeyPressed == WASD_KEY_6) then
        set WASD_IsKeyDown_6[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
        if ( ( CountUnitsInGroup(GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h03A')) >= 1 ) ) then
            call SelectGroupForPlayerBJ( GetUnitsOfPlayerAndTypeId(GetTriggerPlayer(), 'h03A'), GetTriggerPlayer() )
    
            endif

    endif
endif



// Craft Menu CD
    if (osKeyPressed == WASD_KEY_O) then
        set WASD_IsKeyDown_O[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
    if ( ( udg_CraftCD == 1 ) ) then 

        set isVisible = BlzFrameIsVisible(CSUIBD)
            if (isVisible != true) then

    call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: |cff008080Crafting Station|r on |cff800000CD|r, Check Again in |cff808000Few Seconds|r." )

    
            endif

    endif
endif
endif

// Craft Menu
    if (osKeyPressed == WASD_KEY_O) then
        set WASD_IsKeyDown_O[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 
    if ( ( udg_CraftCD == 0 ) ) then 

        set isVisible = BlzFrameIsVisible(CSUIBD)
            if (isVisible != true) then

    call ConditionalTriggerExecute( gg_trg_OpenCraftUI )

    
            endif

    endif
endif
endif

// Craft Close
    if (osKeyPressed == WASD_KEY_O) then
        set WASD_IsKeyDown_O[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then 

        set isVisible = BlzFrameIsVisible(CSUIBD)
            if (isVisible == true) then

            call BlzFrameSetVisible(CSUIBD, false)

            endif

    endif
endif




// Loyalty store
    if (osKeyPressed == WASD_KEY_L) then
        set WASD_IsKeyDown_L[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then
    set isVisible = BlzFrameIsVisible(LSUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(LSUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(LSUIBD, true)
    set udg_LSPOwned = ( "|cffff0000" + ( I2S(udg_LoyaltyPoints[1]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[00], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff0000ff" + ( I2S(udg_LoyaltyPoints[2]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[01], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff00ffff" + ( I2S(udg_LoyaltyPoints[3]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[02], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff6f2583" + ( I2S(udg_LoyaltyPoints[4]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[03], udg_LSPOwned)
    set udg_LSPOwned = ( "|cffffff00" + ( I2S(udg_LoyaltyPoints[5]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[04], udg_LSPOwned)
    set udg_LSPOwned = ( "|cffd45e19" + ( I2S(udg_LoyaltyPoints[6]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[05], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff00ff00" + ( I2S(udg_LoyaltyPoints[7]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[06], udg_LSPOwned)
            endif

    endif
endif
// Camera UI
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(0) ) ) then
    set isVisible = BlzFrameIsVisible(P1CamBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P1CamBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P1CamBD, true)
            endif

    endif


endif    
if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(1) ) ) then
    set isVisible = BlzFrameIsVisible(P2CamBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P2CamBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P2CamBD, true)
            endif

    endif


endif
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(2) ) ) then
    set isVisible = BlzFrameIsVisible(P3CamBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P3CamBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P3CamBD, true)
            endif

    endif


endif
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(3) ) ) then
    set isVisible = BlzFrameIsVisible(P4CamBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P4CamBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P4CamBD, true)
            endif

    endif


endif
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(4) ) ) then
    set isVisible = BlzFrameIsVisible(P5CamBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P5CamBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P5CamBD, true)
            endif

    endif


endif
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(5) ) ) then
    set isVisible = BlzFrameIsVisible(P6CamBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P6CamBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P6CamBD, true)
            endif

    endif


endif
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(6) ) ) then
    set isVisible = BlzFrameIsVisible(P7CamBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P7CamBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P7CamBD, true)
            endif

    endif


endif

// BaP Inv Research
    if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if (GetTriggerPlayer() == GetLocalPlayer()) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 0 ) ) then

call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), "[|cffff0000U|rD|cff0000ffA|r]: |cff00ff00BaP|r Research |cff800000Required|r!" )

            endif

    endif


endif 

// BaP Inv
    if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(0) ) ) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 1 ) ) then
    set isVisible = BlzFrameIsVisible(P1SUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P1SUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P1SUIBD, true)
endif
            endif

    endif


endif   
if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(1) ) ) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 1 ) ) then
    set isVisible = BlzFrameIsVisible(P2SUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P2SUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P2SUIBD, true)
endif
            endif

    endif


endif  
if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(2) ) ) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 1 ) ) then
    set isVisible = BlzFrameIsVisible(P3SUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P3SUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P3SUIBD, true)
endif
            endif

    endif


endif    
if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(3) ) ) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 1 ) ) then
    set isVisible = BlzFrameIsVisible(P4SUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P4SUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P4SUIBD, true)
endif
            endif

    endif


endif   
if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(4) ) ) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 1 ) ) then
    set isVisible = BlzFrameIsVisible(P5SUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P5SUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P5SUIBD, true)
endif
            endif

    endif


endif   
if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(5) ) ) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 1 ) ) then
    set isVisible = BlzFrameIsVisible(P6SUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P6SUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P6SUIBD, true)
endif
            endif

    endif


endif  
if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown

    if ( ( GetTriggerPlayer() == Player(6) ) ) then    
    if ( ( GetPlayerTechCountSimple('R03W', GetTriggerPlayer()) == 1 ) ) then
    set isVisible = BlzFrameIsVisible(P7SUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(P7SUIBD, false)
                  elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(P7SUIBD, true)
endif
            endif

    endif


endif  
endfunction

//===========================================================================
function InitTrig_UI_Hotkeys takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0

    //takes trigger whichTrigger, player whichPlayer, oskeytype key, integer metaKey, boolean keyDown returns event

    loop
    exitwhen(i > 24)

        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_L, 0, true )
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_K, 0, true )
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_O, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_I, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_1, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_2, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_3, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_4, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_5, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_6, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_0, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_8, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_9, 0, true )
    set i = i + 1
    endloop

    call TriggerAddAction( t, function PlayerKeyEvent_Actions )


endfunction

When pressing Any OsKey, that player Desynces
When Pressing K for camera option it pops up UI for every player not the one and then that player that clicke dit crashes

Buttons

So i disabled Oskeys, tested had no issues again, even tested online and didnt have issues to start with

However i got it set to select ur building of time if u own that building for researching faster, when u dont own one it says u dont won one, but if u do own one and click it you desynce

  • QoLClick
    • Events
      • Game - BiologyOpen becomes Not equal to 0.00
      • Game - MechanicOpen becomes Not equal to 0.00
      • Game - PoacherOpen becomes Not equal to 0.00
      • Game - PhysicsOpen becomes Not equal to 0.00
      • Game - ScienceOpen becomes Not equal to 0.00
      • Game - AdaptiveOpen becomes Not equal to 0.00
      • Game - LPOpen becomes Not equal to 0.00
    • Conditions
    • Actions
      • -------- Loyalty Shop --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LPOpen Not equal to 0.00
        • Then - Actions
          • Set VariableSet LPOpen = 0.00
          • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
          • Custom script: call BlzFrameSetVisible(LSUIBD, true)
          • Custom script: endif
        • Else - Actions
      • -------- Biology --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BiologyOpen Not equal to 0.00
          • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Equal to 0
        • Then - Actions
          • Set VariableSet BiologyOpen = 0.00
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BiologyOpen Not equal to 0.00
              • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Greater than or equal to 1
            • Then - Actions
              • Set VariableSet BiologyOpen = 0.00
              • Selection - Select (Units owned by (Triggering player) of type Biology Centre) for (Triggering player)
            • Else - Actions
      • -------- Mechanic --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MechanicOpen Not equal to 0.00
          • (Number of units in (Units owned by (Triggering player) of type Mechanic School)) Equal to 0
        • Then - Actions
          • Set VariableSet MechanicOpen = 0.00
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MechanicOpen Not equal to 0.00
              • (Number of units in (Units owned by (Triggering player) of type Mechanic School)) Greater than or equal to 1
            • Then - Actions
              • Set VariableSet MechanicOpen = 0.00
              • Selection - Select (Units owned by (Triggering player) of type Mechanic School) for (Triggering player)
            • Else - Actions
      • -------- Poacher --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PoacherOpen Not equal to 0.00
          • (Number of units in (Units owned by (Triggering player) of type Poacher Centre)) Equal to 0
        • Then - Actions
          • Set VariableSet PoacherOpen = 0.00
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PoacherOpen Not equal to 0.00
              • (Number of units in (Units owned by (Triggering player) of type Poacher Centre)) Greater than or equal to 1
            • Then - Actions
              • Set VariableSet PoacherOpen = 0.00
              • Selection - Select (Units owned by (Triggering player) of type Poacher Centre) for (Triggering player)
            • Else - Actions
      • -------- Physics --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PhysicsOpen Not equal to 0.00
          • (Number of units in (Units owned by (Triggering player) of type Physics Faculity)) Equal to 0
        • Then - Actions
          • Set VariableSet PhysicsOpen = 0.00
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PhysicsOpen Not equal to 0.00
              • (Number of units in (Units owned by (Triggering player) of type Physics Faculity)) Greater than or equal to 1
            • Then - Actions
              • Set VariableSet PhysicsOpen = 0.00
              • Selection - Select (Units owned by (Triggering player) of type Physics Faculity) for (Triggering player)
            • Else - Actions
      • -------- Undead --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ScienceOpen Not equal to 0.00
          • (Number of units in (Units owned by (Triggering player) of type |cff00ff00Undead|r Science School)) Equal to 0
        • Then - Actions
          • Set VariableSet ScienceOpen = 0.00
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ScienceOpen Not equal to 0.00
              • (Number of units in (Units owned by (Triggering player) of type |cff00ff00Undead|r Science School)) Greater than or equal to 1
            • Then - Actions
              • Set VariableSet ScienceOpen = 0.00
              • Selection - Select (Units owned by (Triggering player) of type |cff00ff00Undead|r Science School) for (Triggering player)
            • Else - Actions
      • -------- Adaptive --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AdaptiveOpen Not equal to 0.00
          • (Number of units in (Units owned by (Triggering player) of type |cff00ff00Undead|r Adaptive Technology)) Equal to 0
        • Then - Actions
          • Set VariableSet AdaptiveOpen = 0.00
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AdaptiveOpen Not equal to 0.00
              • (Number of units in (Units owned by (Triggering player) of type |cff00ff00Undead|r Adaptive Technology)) Greater than or equal to 1
            • Then - Actions
              • Set VariableSet AdaptiveOpen = 0.00
              • Selection - Select (Units owned by (Triggering player) of type |cff00ff00Undead|r Adaptive Technology) for (Triggering player)
            • Else - Actions
it prob soemthing simple, and it new tryign to add buttons / oskeys for me, so of cos ima have some issues.

anyone got idea why?
 
Level 7
Joined
Nov 6, 2019
Messages
186
ok so, not sure what i have to change, i assume it the oskey that needs changing, as the other trigger uses it for the frames
but it still crashes online does the second trigger by clicking a button

like what should i change get local to?
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,682
You still need to use GetLocalPlayer() in certain cases. You just need to avoid putting other unnecessary code in there when possible.

Good:
vJASS:
if GetLocalPlayer() == SomePlayer then
    call BlzFrameSetVisibility(SomeFrame, true)
endif
AdjustSomeOtherVariables
RunSomeOtherFunction()
Bad:
vJASS:
if GetLocalPlayer() == SomePlayer then
    call BlzFrameSetVisibility(SomeFrame, true)
    AdjustSomeOtherVariables
    RunSomeOtherFunction()
endif

So only put the things that need to be changed locally in there. For example, visibility needs to be changed locally since frames by default are visible to everyone and there's no function like BlzFrameSetVisibiityForPlayer().
 
Last edited:
Level 7
Joined
Nov 6, 2019
Messages
186
ok i fixed most of the trigger, changed how it reacts

JASS:
globals
    boolean array WASD_IsKeyDown_L
    boolean array WASD_IsKeyDown_K
    boolean array WASD_IsKeyDown_O
    boolean array WASD_IsKeyDown_I
    boolean array WASD_IsKeyDown_1
    boolean array WASD_IsKeyDown_2
    boolean array WASD_IsKeyDown_3
    boolean array WASD_IsKeyDown_4
    boolean array WASD_IsKeyDown_5
    boolean array WASD_IsKeyDown_6
    boolean array WASD_IsKeyDown_0
    boolean array WASD_IsKeyDown_8
    boolean array WASD_IsKeyDown_9
    constant oskeytype WASD_KEY_L = ConvertOsKeyType($4C)
    constant oskeytype WASD_KEY_K = ConvertOsKeyType($4B)
    constant oskeytype WASD_KEY_O = ConvertOsKeyType($4F)
    constant oskeytype WASD_KEY_I = ConvertOsKeyType($49)
    constant oskeytype WASD_KEY_1 = ConvertOsKeyType($31)
    constant oskeytype WASD_KEY_2 = ConvertOsKeyType($32)
    constant oskeytype WASD_KEY_3 = ConvertOsKeyType($33)
    constant oskeytype WASD_KEY_4 = ConvertOsKeyType($34)
    constant oskeytype WASD_KEY_5 = ConvertOsKeyType($35)
    constant oskeytype WASD_KEY_6 = ConvertOsKeyType($36)
    constant oskeytype WASD_KEY_0 = ConvertOsKeyType($30)
    constant oskeytype WASD_KEY_8 = ConvertOsKeyType($38)
    constant oskeytype WASD_KEY_9 = ConvertOsKeyType($39)
endglobals
//========================================================================================
//========================================================================================
function PlayerKeyEvent_Actions takes nothing returns nothing
    local oskeytype osKeyPressed = BlzGetTriggerPlayerKey() // What key was pressed or released?
    local boolean isKeyDown = BlzGetTriggerPlayerIsKeyDown() // Was the event key pressed or released?
    local boolean isVisible = false
    //Not used here, but this way we can detect the meta-key.
    //local integer metaKeyPressed = BlzGetTriggerPlayerMetaKey()


// AdminUI
    if (osKeyPressed == WASD_KEY_9) then
        set WASD_IsKeyDown_9[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    call ConditionalTriggerExecute( gg_trg_OpenAdminUI )
            endif
// Selected Settings
    if (osKeyPressed == WASD_KEY_8) then
        set WASD_IsKeyDown_8[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    call ConditionalTriggerExecute( gg_trg_GSUICheckSettings )
    endif
// SkinUI
    if (osKeyPressed == WASD_KEY_0) then
        set WASD_IsKeyDown_0[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    if (GetTriggerPlayer() == GetLocalPlayer()) then
    set isVisible = BlzFrameIsVisible(SkinUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(SkinUIBD, false)
                elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(SkinUIBD, true)
            endif
    endif
endif
// Biology Check
    if (osKeyPressed == WASD_KEY_1) then
        set WASD_IsKeyDown_1[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_BiologyCheck )
    endif
// Mechanic Check
    if (osKeyPressed == WASD_KEY_2) then
        set WASD_IsKeyDown_2[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_MechanicCheck )
    endif
// Poacher Check
    if (osKeyPressed == WASD_KEY_3) then
        set WASD_IsKeyDown_3[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_PoacherCheck )
    endif
// Physics Check
    if (osKeyPressed == WASD_KEY_4) then
        set WASD_IsKeyDown_4[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_PhysicsCheck )
    endif
// Undead Check
    if (osKeyPressed == WASD_KEY_5) then
        set WASD_IsKeyDown_5[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_UndeadCheck )
    endif
// Adaptive Check
    if (osKeyPressed == WASD_KEY_6) then
        set WASD_IsKeyDown_6[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_AdaptiveCheck )
    endif
// Craft Menu
    if (osKeyPressed == WASD_KEY_O) then
        set WASD_IsKeyDown_O[GetPlayerId(GetTriggerPlayer())] = isKeyDown
        call ConditionalTriggerExecute( gg_trg_OpenCraftUI )
endif
// Loyalty store
    if (osKeyPressed == WASD_KEY_L) then
        set WASD_IsKeyDown_L[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    if (GetTriggerPlayer() == GetLocalPlayer()) then
    set isVisible = BlzFrameIsVisible(LSUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(LSUIBD, false)
                elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(LSUIBD, true)
                endif
    set udg_LSPOwned = ( "|cffff0000" + ( I2S(udg_LoyaltyPoints[1]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[00], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff0000ff" + ( I2S(udg_LoyaltyPoints[2]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[01], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff00ffff" + ( I2S(udg_LoyaltyPoints[3]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[02], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff6f2583" + ( I2S(udg_LoyaltyPoints[4]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[03], udg_LSPOwned)
    set udg_LSPOwned = ( "|cffffff00" + ( I2S(udg_LoyaltyPoints[5]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[04], udg_LSPOwned)
    set udg_LSPOwned = ( "|cffd45e19" + ( I2S(udg_LoyaltyPoints[6]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[05], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff00ff00" + ( I2S(udg_LoyaltyPoints[7]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[06], udg_LSPOwned)
    endif
endif
// Camera UI
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown
        call ConditionalTriggerExecute( gg_trg_CamUIPress )
endif   
// BaP Inv
    if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown
        call ConditionalTriggerExecute( gg_trg_BaPUIInvPress )
endif
endfunction
//===========================================================================
function InitTrig_UI_Hotkeys takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0
    //takes trigger whichTrigger, player whichPlayer, oskeytype key, integer metaKey, boolean keyDown returns event
    loop
    exitwhen(i > 24)
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_L, 0, true )
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_K, 0, true )
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_O, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_I, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_1, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_2, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_3, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_4, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_5, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_6, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_0, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_8, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_9, 0, true )
    set i = i + 1
    endloop
    call TriggerAddAction( t, function PlayerKeyEvent_Actions )

endfunction


Now my issue, is the GUI part

  • BiologyCheck
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Equal to 0
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Greater than or equal to 1
            • Then - Actions
              • Selection - Select (Units owned by (Triggering player) of type Biology Centre) for (Triggering player)
            • Else - Actions

So issue here, i want it to select ur unit if you own one, of type when u press, 1 in this biology case

however if you dont own a biology unit, it says you dont own one perfectly

however if you do own one, it crashes and desynces


EDIT: i changed trigger to this

  • BiologyCheck
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Equal to 0
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Greater than or equal to 1
            • Then - Actions
              • Selection - Select BiologyUnitCheck[(Player number of (Triggering player))] for (Triggering player)
            • Else - Actions
And from testing on local area play multi boxing, it doesnt crash anymore, however it onyl selects 1 unit, and prefer it to select all of that type. but works for now
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,682
ok i fixed most of the trigger, changed how it reacts

JASS:
globals
    boolean array WASD_IsKeyDown_L
    boolean array WASD_IsKeyDown_K
    boolean array WASD_IsKeyDown_O
    boolean array WASD_IsKeyDown_I
    boolean array WASD_IsKeyDown_1
    boolean array WASD_IsKeyDown_2
    boolean array WASD_IsKeyDown_3
    boolean array WASD_IsKeyDown_4
    boolean array WASD_IsKeyDown_5
    boolean array WASD_IsKeyDown_6
    boolean array WASD_IsKeyDown_0
    boolean array WASD_IsKeyDown_8
    boolean array WASD_IsKeyDown_9
    constant oskeytype WASD_KEY_L = ConvertOsKeyType($4C)
    constant oskeytype WASD_KEY_K = ConvertOsKeyType($4B)
    constant oskeytype WASD_KEY_O = ConvertOsKeyType($4F)
    constant oskeytype WASD_KEY_I = ConvertOsKeyType($49)
    constant oskeytype WASD_KEY_1 = ConvertOsKeyType($31)
    constant oskeytype WASD_KEY_2 = ConvertOsKeyType($32)
    constant oskeytype WASD_KEY_3 = ConvertOsKeyType($33)
    constant oskeytype WASD_KEY_4 = ConvertOsKeyType($34)
    constant oskeytype WASD_KEY_5 = ConvertOsKeyType($35)
    constant oskeytype WASD_KEY_6 = ConvertOsKeyType($36)
    constant oskeytype WASD_KEY_0 = ConvertOsKeyType($30)
    constant oskeytype WASD_KEY_8 = ConvertOsKeyType($38)
    constant oskeytype WASD_KEY_9 = ConvertOsKeyType($39)
endglobals
//========================================================================================
//========================================================================================
function PlayerKeyEvent_Actions takes nothing returns nothing
    local oskeytype osKeyPressed = BlzGetTriggerPlayerKey() // What key was pressed or released?
    local boolean isKeyDown = BlzGetTriggerPlayerIsKeyDown() // Was the event key pressed or released?
    local boolean isVisible = false
    //Not used here, but this way we can detect the meta-key.
    //local integer metaKeyPressed = BlzGetTriggerPlayerMetaKey()


// AdminUI
    if (osKeyPressed == WASD_KEY_9) then
        set WASD_IsKeyDown_9[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    call ConditionalTriggerExecute( gg_trg_OpenAdminUI )
            endif
// Selected Settings
    if (osKeyPressed == WASD_KEY_8) then
        set WASD_IsKeyDown_8[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    call ConditionalTriggerExecute( gg_trg_GSUICheckSettings )
    endif
// SkinUI
    if (osKeyPressed == WASD_KEY_0) then
        set WASD_IsKeyDown_0[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    if (GetTriggerPlayer() == GetLocalPlayer()) then
    set isVisible = BlzFrameIsVisible(SkinUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(SkinUIBD, false)
                elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(SkinUIBD, true)
            endif
    endif
endif
// Biology Check
    if (osKeyPressed == WASD_KEY_1) then
        set WASD_IsKeyDown_1[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_BiologyCheck )
    endif
// Mechanic Check
    if (osKeyPressed == WASD_KEY_2) then
        set WASD_IsKeyDown_2[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_MechanicCheck )
    endif
// Poacher Check
    if (osKeyPressed == WASD_KEY_3) then
        set WASD_IsKeyDown_3[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_PoacherCheck )
    endif
// Physics Check
    if (osKeyPressed == WASD_KEY_4) then
        set WASD_IsKeyDown_4[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_PhysicsCheck )
    endif
// Undead Check
    if (osKeyPressed == WASD_KEY_5) then
        set WASD_IsKeyDown_5[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_UndeadCheck )
    endif
// Adaptive Check
    if (osKeyPressed == WASD_KEY_6) then
        set WASD_IsKeyDown_6[GetPlayerId(GetTriggerPlayer())] = isKeyDown
call ConditionalTriggerExecute( gg_trg_AdaptiveCheck )
    endif
// Craft Menu
    if (osKeyPressed == WASD_KEY_O) then
        set WASD_IsKeyDown_O[GetPlayerId(GetTriggerPlayer())] = isKeyDown
        call ConditionalTriggerExecute( gg_trg_OpenCraftUI )
endif
// Loyalty store
    if (osKeyPressed == WASD_KEY_L) then
        set WASD_IsKeyDown_L[GetPlayerId(GetTriggerPlayer())] = isKeyDown
    if (GetTriggerPlayer() == GetLocalPlayer()) then
    set isVisible = BlzFrameIsVisible(LSUIBD)
                if (isVisible == true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]- 1
                    call BlzFrameSetVisible(LSUIBD, false)
                elseif (isVisible != true) then
                    set udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())] = udg_UIESCKey[GetConvertedPlayerId(GetTriggerPlayer())]+ 1
                    call BlzFrameSetVisible(LSUIBD, true)
                endif
    set udg_LSPOwned = ( "|cffff0000" + ( I2S(udg_LoyaltyPoints[1]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[00], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff0000ff" + ( I2S(udg_LoyaltyPoints[2]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[01], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff00ffff" + ( I2S(udg_LoyaltyPoints[3]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[02], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff6f2583" + ( I2S(udg_LoyaltyPoints[4]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[03], udg_LSPOwned)
    set udg_LSPOwned = ( "|cffffff00" + ( I2S(udg_LoyaltyPoints[5]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[04], udg_LSPOwned)
    set udg_LSPOwned = ( "|cffd45e19" + ( I2S(udg_LoyaltyPoints[6]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[05], udg_LSPOwned)
    set udg_LSPOwned = ( "|cff00ff00" + ( I2S(udg_LoyaltyPoints[7]) + "|r" ) )
    call BlzFrameSetText(LPAmountT[06], udg_LSPOwned)
    endif
endif
// Camera UI
    if (osKeyPressed == WASD_KEY_K) then
        set WASD_IsKeyDown_K[GetPlayerId(GetTriggerPlayer())] = isKeyDown
        call ConditionalTriggerExecute( gg_trg_CamUIPress )
endif  
// BaP Inv
    if (osKeyPressed == WASD_KEY_I) then
        set WASD_IsKeyDown_I[GetPlayerId(GetTriggerPlayer())] = isKeyDown
        call ConditionalTriggerExecute( gg_trg_BaPUIInvPress )
endif
endfunction
//===========================================================================
function InitTrig_UI_Hotkeys takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    local integer i = 0
    //takes trigger whichTrigger, player whichPlayer, oskeytype key, integer metaKey, boolean keyDown returns event
    loop
    exitwhen(i > 24)
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_L, 0, true )
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_K, 0, true )
        call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_O, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_I, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_1, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_2, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_3, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_4, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_5, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_6, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_0, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_8, 0, true )
    call BlzTriggerRegisterPlayerKeyEvent( t, Player(i), WASD_KEY_9, 0, true )
    set i = i + 1
    endloop
    call TriggerAddAction( t, function PlayerKeyEvent_Actions )

endfunction


Now my issue, is the GUI part

  • BiologyCheck
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Equal to 0
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Greater than or equal to 1
            • Then - Actions
              • Selection - Select (Units owned by (Triggering player) of type Biology Centre) for (Triggering player)
            • Else - Actions

So issue here, i want it to select ur unit if you own one, of type when u press, 1 in this biology case

however if you dont own a biology unit, it says you dont own one perfectly

however if you do own one, it crashes and desynces


EDIT: i changed trigger to this

  • BiologyCheck
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Equal to 0
        • Then - Actions
          • Game - Display to (Player group((Triggering player))) the text: [|cffff0000U|rD|cff...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units owned by (Triggering player) of type Biology Centre)) Greater than or equal to 1
            • Then - Actions
              • Selection - Select BiologyUnitCheck[(Player number of (Triggering player))] for (Triggering player)
            • Else - Actions
And from testing on local area play multi boxing, it doesnt crash anymore, however it onyl selects 1 unit, and prefer it to select all of that type. but works for now
You're leaking unit groups here (look up memory leaks if you're confused).

You want to use a Unit Group variable to store the Biology Centers owned by the player:
  • Set Variable BiologyGroup = Units owned by (Triggering player) of type Biology Centre
Then you can use the Pick Every Unit action to loop over the group and handle the selection using the Add Unit to Selection action. You can also use the Integer comparison (Number of units in BiologyGroup) to count the units inside of the group. I also recommend using a Player variable to store the (Triggering player) at the start of the trigger and then you can reference that throughout to make things more efficient and safe.
 
Status
Not open for further replies.
Top