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

Troubles with code

Status
Not open for further replies.
Level 31
Joined
Aug 6, 2015
Messages
636
So i am trying to create frames that are showing some player information.
But i am encountering a problem.
(The Text on the Banner is not showing properly , it is showing only Red level i belive or maybe it is changing the Frame visibility wrong for players , i am confused of what is happening , i am still a newbie in codding and frames , i wonder if someone can tell me what is wrong and how i can fix it)
Screenshot_12.jpg

Variables that are causing problems are Z_LevelText and udg_CR_Game_level[tn]

JASS:
globals
    boolean array Z_statsOpen
    framehandle array Z_openButton
    framehandle array Z_levelText
    framehandle array Z_levelIcon
    framehandle array Z_expIcon
    framehandle array Z_GlueIcon
    framehandle array Z_expText
    framehandle array Z_killsText
    framehandle array Z_healsText
    framehandle array Z_spearsText
endglobals
// you can call this function to update a player's stats text:
function ZUI_UpdateText takes integer tn returns nothing
call BlzFrameSetText(Z_levelText[tn],"|cff99ffcf" + I2S(udg_CR_Game_level[tn]))
call BlzFrameSetText(Z_expText[tn],I2S(udg_TotalExpGainedThisGame[tn]))
call BlzFrameSetText(Z_killsText[tn],I2S(udg_CR_Game_Kills[tn]))
call BlzFrameSetText(Z_healsText[tn],I2S(udg_CR_Game_Heals[tn]))
call BlzFrameSetText(Z_spearsText[tn],I2S(udg_CR_Game_Spears[tn]))
endfunction

// this runs when a player clicks their stats buttons
function ZUI_OpenCallback takes nothing returns nothing
    local integer tn = GetConvertedPlayerId(GetTriggerPlayer())
    local boolean toggle2
    // this fixes an issue with the frame getting stuck in focus and taking the users control away
    call BlzFrameSetEnable(BlzGetTriggerFrame(), false)
    call BlzFrameSetEnable(BlzGetTriggerFrame(), true)
    // toggle2 open/close boolean to keep track of the state of the frames (open or closed)
    if (Z_statsOpen[tn]) then
        set Z_statsOpen[tn] = false
        set toggle2 = false
        // advanced stats need to be hidden
    else
        set Z_statsOpen[tn] = true
        set toggle2 = true
    endif
    // show/hide frames for the player
    if (GetLocalPlayer() == Player(tn-1)) then
        call BlzFrameSetVisible(Z_killsText[tn], toggle2)
        call BlzFrameSetVisible(Z_healsText[tn], toggle2)
        call BlzFrameSetVisible(Z_spearsText[tn], toggle2)
        call BlzFrameSetVisible(Z_expIcon[tn], toggle2)
        call BlzFrameSetVisible(Z_expText[tn], toggle2)
    endif
    // adjust test
    call ZUI_UpdateText(tn)
endfunction

// this needs to run first before anything else
function ZUI_SetupFrames takes nothing returns nothing
    // this loads the needed UI files from the Asset Manager
    call BlzLoadTOCFile("war3mapImported\\Templates.toc")
    call BlzLoadTOCFile("war3mapImported\\SpartanUI.toc")
endfunction
// this creates UI frames for the given player
function ZUI_CreateFrames takes integer tn returns nothing
    local framehandle z_fh
    local trigger openTrigger
   
    // position of the UI
    local real x = 0.24
    local real y = 0.22
    // icons paths - these art paths need two backslashes \\
    local string Z_levelTexture = "BannerT.tga" // art path for level icon
    local string Z_BackdropTexture = "TLogo2.dds" // art path for exp icon
    local string Z_GlueButtonTexture = "GlueButton.tga" // art path for exp icon
    // stats button (Glue Button)
    set z_fh = BlzCreateFrame("ScriptDialogButton", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI,0), 0, 0)
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.258500, 0.138670) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.288290, 0.117600) 
    call BlzFrameSetVisible(z_fh, true)
    set Z_openButton[tn] = z_fh
   
//Create a "GLUEBUTTON" named "Facebutton", the clickable Button, for game UI
    set z_fh  = BlzCreateFrameByType("BACKDROP", "FaceButtonIcon", z_fh, "", 0)
//buttonIconFrame will mimic buttonFrame in size and position
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.258500, 0.138670) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.288290, 0.117600) 
//Set a Texture
    call BlzFrameSetTexture(z_fh, Z_GlueButtonTexture, 0, true)
    call BlzFrameSetVisible(z_fh, true)
    set Z_GlueIcon[tn] = z_fh
    
   /////////// 
  // icons // 
 ///////////  
    //  icons - Stat Backdrop
    set z_fh = BlzCreateFrameByType("BACKDROP", "Icon", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    //call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.291200, 0.139410) 
    //call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.576000, 0.119800) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.274500, 0.160440) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.594200, 0.140100) 
  //  call BlzFrameSetSize(z_fh, 0.03, 0.03)
// call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_CENTER, x - 0.0425, y - 0.0275)
    call BlzFrameSetTexture(z_fh, Z_BackdropTexture, 0, true)
    call BlzFrameSetEnable(z_fh, false)
    call BlzFrameSetVisible(z_fh, false)
    set Z_expIcon[tn] = z_fh
   //  icons - Banner Backdrop
    set z_fh = BlzCreateFrameByType("BACKDROP", "Icon", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    //call BlzFrameSetSize(z_fh, 0.03, 0.03)
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.196700, 0.146590) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.240300, 0.0848500) 
    call BlzFrameSetTexture(z_fh, Z_levelTexture, 0, true) 
    call BlzFrameSetEnable(z_fh, false)
    call BlzFrameSetVisible(z_fh, false)
    set Z_levelIcon[tn] = z_fh
    
    // Players Stats Texts
    // SpartanLevel Button Text
    set z_fh = BlzCreateFrameByType("TEXT", "Text", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    //call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.208300, 0.129260) 
    //call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.237360, 0.111100) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.211500, 0.129260) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.239560, 0.111100) 
    call BlzFrameSetText(z_fh,"0")
    call BlzFrameSetEnable(z_fh, false)
    call BlzFrameSetVisible(z_fh, false)
    call BlzFrameSetScale(z_fh, 1.53) 
    // call BlzFrameSetTextColor (z_fh, "|cff99ffcf")
    set Z_levelText[tn] = z_fh

    set z_fh = BlzCreateFrameByType("TEXT", "Text", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
   // call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.544800, 0.133590) 
   // call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.566600, 0.111800) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.542600, 0.154350) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.584020, 0.142000) 
    call BlzFrameSetText(z_fh, "4444")
    call BlzFrameSetEnable(z_fh, false)
    call BlzFrameSetVisible(z_fh, false)
    set Z_expText[tn] = z_fh
    set z_fh = BlzCreateFrameByType("TEXT", "Text", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.300000, 0.154350) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.341420, 0.142000) 
    call BlzFrameSetText(z_fh, "1111")
    call BlzFrameSetEnable(z_fh, false)
    call BlzFrameSetVisible(z_fh, false)
    set Z_killsText[tn] = z_fh
    set z_fh = BlzCreateFrameByType("TEXT", "Text", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.461200, 0.154350) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.502620, 0.142000) 
    call BlzFrameSetText(z_fh, "33333")
    call BlzFrameSetEnable(z_fh, false)
    call BlzFrameSetVisible(z_fh, false)
    set Z_healsText[tn] = z_fh
    set z_fh = BlzCreateFrameByType("TEXT", "Text", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_TOPLEFT, 0.382700, 0.154350) 
    call BlzFrameSetAbsPoint(z_fh, FRAMEPOINT_BOTTOMRIGHT, 0.424120, 0.142000) 
    call BlzFrameSetText(z_fh, "2222")
    call BlzFrameSetEnable(z_fh, false)
    call BlzFrameSetVisible(z_fh, false)
    set Z_spearsText[tn] = z_fh


    // triggers for Open/Close Button
    set openTrigger = CreateTrigger()
    call BlzTriggerRegisterFrameEvent(openTrigger, Z_openButton[tn], FRAMEEVENT_CONTROL_CLICK)
    call TriggerAddAction(openTrigger, function ZUI_OpenCallback)
    if (IsPlayerInForce(Player(tn-1), udg_SupporterGroupG))  then
      call BlzFrameSetVisible(Z_levelIcon[tn], true)
      call BlzFrameSetVisible(Z_levelText[tn], true)
        endif
    if (GetLocalPlayer() == Player(tn-1)) then
        call BlzFrameSetVisible(Z_openButton[tn], true)
    endif
endfunction
 
Last edited:
Status
Not open for further replies.
Top