having a problem with multibars

LoveTD's

New Member
Reaction score
34
hey all, I have a problem that has been bothering for quite a while now...

I recently found a system that adds bars on the multiboard and I wanted to use it on mine so I downloaded the system and imported it in my map...

now that I had the system I could go on to get it to work...

I did but now I have a little problem:

In the readme file it said:
JASS:
//function CreateMultibarHelper takes unit whichunit, multiboard whichboard, integer col, integer row, integer size, integer bartype, integer whichtype returns integer

//The integer returned is the unique MultibarHelper ID which is given to each multibar. You must keep track of these in variables if you wish to modify the bar later on.

//An exmaple of calling this functions is:

//local integer h = CreateMultibarHelper(someunit, someboard, 0, 0, 14, MULTIBAR_TYPE_HEALTH, MULTIBAR_HELPER_HEALTH)


now I did exactly the same thing as they asked me to do so:

This way it works:

JASS:
call CreateMultibarHelper(udg_Headquarter_Raiders, udg_Headquarters_multiboard, 2, 1, 4, 6, 1)


But this way it doesn't (for some reason):

JASS:
local integer bar1 = CreateMultibarHelper(udg_Headquarter_Raiders, udg_Headquarters_multiboard, 2, 1, 4, 6, 1)


And I want to store it in a variable because then I can destroy the bar and remake it whenever somekind of event occurs...

can someone help me out on this? :)

+rep if you can :thup:
 

Tyrulan

Ultra Cool Member
Reaction score
37
It says clearly here:

JASS:
local integer h = CreateMultibarHelper(someunit, someboard, 0, 0, 14, MULTIBAR_TYPE_HEALTH, MULTIBAR_HELPER_HEALTH)


Why are you using integers in their place? These variables must have been declared somewhere else in his system. (MULTIBAR_TYPE_HEALTH, MULTIBAR_HELPER_HEALTH)
 

LoveTD's

New Member
Reaction score
34
because its an index of the type of bars and if you look correctly it is an integer value they just used **

JASS:
//function CreateMultibarHelper takes unit whichunit, multiboard whichboard, integer col, integer row, integer size, *integer bartype, integer whichtype* returns integer


MULTIBAR_TYPE_HEALTH to indicate the icon of the multibar and

MULTIBAR_HELPER_HEALTH to indicate what type... these types are set in the script... this is the full script:

JASS:
//====================================================//
//                                                    //
//                      README                        //
//                                                    //
//====================================================//


//TESH.scrollpos=0
//TESH.alwaysfold=0
//Multibars (Jass) Readme

//Created by Ammorth

//Compiled January 10th, 2008

//This version does NOT Requires vJass
//If you want to use the vJass version, you can download it here:  <a href="http://www.wc3campaigns.net/showthread.php?t=98138" target="_blank" class="link link--external" rel="nofollow ugc noopener">www.wc3campaigns.net/showthread.php?t=98138</a>


//PLEASE GIVE CREDIT IF YOU USE MULTIBARS OR ANY OF MY BARTYPES IN YOUR MAP!

//==================================
//About
//==================================

//Multibars is an easy way to create dynamic and sexy looking progress bars for multiboards.
//You can also create dynamic health, mana and experience bars with 1 line of code.
//Included in this version are 11 different bartypes:

//Name        - Type                  (Description)

//Build       - udg_MULTIBAR_TYPE_BUILD        (based on the in-game construction bar)
//Health      - udg_MULTIBAR_TYPE_HEALTH       (A red health bar)
//Mana        - udg_MULTIBAR_TYPE_MANA         (A blue mana bar)
//Experience  - udg_MULTIBAR_TYPE_EXPERIENCE   (A purple experience bar)
//Chunk       - udg_MULTIBAR_TYPE_CHUNK        (A green bar that displays in chunks, rather than smoothly)
//Radio       - udg_MULTIBAR_TYPE_RADIO        (A radioactive [yellow and black] bar)
//Mac         - udg_MULTIBAR_TYPE_MAC          (resembles a Mac OS X loading bar)
//Orange      - udg_MULTIBAR_TYPE_ORANGE       (An orange bar that displays in chuncks, but chunks light up vs. appearing)
//Hearts      - udg_MULTIBAR_TYPE_HEARTS       (Hearts which display health based off of Zelda Ocarina of Time)
//Hearts Up   - udg_MULTIBAR_TYPE_HEARTS_UP    (Hearts with a white outline which display health, based off of Zelda Ocarina of Time)
//Magic       - udg_MULTIBAR_TYPE_MAGIC        (Green energy bar based off of Zelda Ocarina of Time) 


//==================================
//Installation
//==================================

//1) Copy the Multibars Library to your map script (copy the entire text, except for the bottem section mentioned, and paste it)
//2) Copy the MultiBars Variables trigger to your map.  Make sure you have &quot;Automatically create unknown variables while pasting trigger data&quot; before
//   pasting, as this will create all required variables.  Delete it after since it is of no use but to create the variables.
//3) For each type of bar you want to use, import the entire folder to your map
//4) If you want to use the dynamic health, mana and experience bars, copy the MutliBarsHelper library to the custom script section aswell
//    Note:  You must paste the MultibarsHelper library BELOW the Multibars library for it to compile correctly.
//    A) Paste the MultiBars Helper Variables trigger to your map.  Make sure you have &quot;Automatically create unknown variables while pasting trigger data&quot;
//        before pasting, as this will create all required variables.  Delete it after since it is of no use but to create the variables.
//    B) Change the udg_MULTIBAR_PERIOD constant, found in the MultibarsHelper Init function, if you want the bars updating smoother or more efficiently.


//==================================
//Usage
//==================================

//Before doing anything, you must call:

//function InitMultibars takes nothing returns nothing
//to setup the system.

//If you are using MultibarHelpers then you must also call:

//function InitMultibarsHelper takes nothing returns nothing
//to setup the helper system.



//To create a MultiBar, call:

//function CreateMultibar takes multiboard whichboard, integer colstart, integer row, integer size, real maxval, real currentval, integer bartype returns integer
//- whichboard - the multiboard which the bar will be added to
//- colstart - which column do you want the bar to start on
//- row - which row do you want the bar on
//- size - how many columns do you want to use for your bar (max of 16, min of 2)
//- maxval - the maximum value of the bar
//- currentval - the starting value the bar will display
//- bartype - the bartype of the bar (Defualts are shown in the table above)

//The integer returned is the unique Multibar ID which is given to each multibar.  You must keep track of these in variables if you wish to modify the bar later on.

//An example of calling this function would be:

//local integer mb = CreateMultibar(SomeMultiboard, 3, 0, 12, 50., 10., BAR_TYPE_BUILD)
//- This would create a Build Multibar on SomeMultiboard, at column 4, row 1, (remember, multiboards in jass start at 0,0) a size of 12,
//  max value is 50, and the current value is 10.

  
  
//To update the value of the bar, call:

//Ufunction UpdateMultibarValue takes integer this, real newvalue, boolean update returns nothing
//- this - the unique ID of the multibar you want to update
//- newvalue - the new current value
//- update - if you want the bar to visually update to the new value

//An exmaple of calling this function would be:

//call UpdateMultibarValue(MyBar, 45., true)
//- This would update our Multibar with the ID stored in MyBar to a value of 45.  It would also update the visual bar on the multiboard.


//function UpdateMultibarMaxValue takes integer this, real newvalue, boolean update returns nothing
//- this - the unique ID of the multibar you want to update
//- newvalue - the new maximum value
//- update - if you want the bar to visually update to the new value

//An exmaple of calling this function would be:

//call UpdateMultibarMaxValue(MyBar, 45., true)
//- This would update our Multibar with the ID stored in MyBar to a value of 45.  It would also update the visual bar on the multiboard.
//- Note: if the maximum value becomes less than the current value, the current value will automatically equal the new max value.


//To create dynamic Health, Mana or Experience bars, make sure you have the MultiBarsHelper library installed then call:

//function CreateMultibarHelper takes unit whichunit, multiboard whichboard, integer col, integer row, integer size, integer bartype, integer whichtype returns integer
//- whichunit - the unit you want to create the bar for
//- whichboard - the multiboard which the bar will be added to
//- col - which column do you want the bar to start on
//- row - which row do you want the bar on
//- size - how many columns do you want to use for your bar (max of 16, min of 2)
//- bartype - the bartype of the bar (Defualts are shown in the table above)
//- whichtype - the type of the helper bar.
//            - MULTIBAR_HELPER_HEALTH = health bar
//            - MULTIBAR_HELPER_MANA = mana bar
//            - MULTIBAR_HELPER_EXPERIENCE = experience bar

//The integer returned is the unique MultibarHelper ID which is given to each multibar.  You must keep track of these in variables if you wish to modify the bar later on.
//THIS ID SHOULD BE NOT CONFUSED WITH THE MULTIBAR ID.  Calling this function with a Multibar ID or vice-versa may cause serious problems.

//This function will create a helper bar that will automatically update itself, depending on the units status.

//An exmaple of calling this functions is:

//local integer h = CreateMultibarHelper(someunit, someboard, 0, 0, 14, MULTIBAR_TYPE_HEALTH, MULTIBAR_HELPER_HEALTH)
//- This function would create a health bar at col 0 row 0 on someboard, displaying the health of someunit.
//- The types used do not have to be the default types.  For example, you can use MULTIBAR_TYPE_CHUNK for a health bar.


//If you want to create a label for your health, mana, or experience bar, call:

//function AddMultibarHelperLabel takes integer this, integer col, integer row, real width, integer red, integer green, integer blue, integer alpha, string icon returns nothing
//- this - the unique ID of the MultibarHelper you want to update
//- col - which column you want the label to be on
//- row - which row you want the label to be on
//- width - the width you want the label cell to be
//- red/green/blue/alpha - the color your want the label to be
//- icon - the icon you want beside the label (use &quot;&quot; for no icon)

//Labels can only be created for MultiBarHelpers bars (health, mana, experience).  Attempting to create a label for a regular MultiBar bar will
//cause serious problems.  Do not try it!

//An exmaple of calling this function would be:

//call AddMultibarHelperLabel(Helper, 0, 2, 0.07, 0, 0, 255, 255, &quot;&quot;)
//- This will create a label for somebar at column 1, row 3, with a width of 7%, blue text and no icon.
//- Labels are automatically cleared from memory when the multibarhelper is destroyed.
//- You can only have 1 label per multibarhelper.


//When you are done with a MultiBar, dont forget to call:

//function DestroyMultibar takes integer this returns nothing
//- this - The unique ID of the multibar you want to destroy
//An example of calling this function would be:

//call DestroyMultibar(MyBar)
//- This will remove the Multibar from memory, but will not remove the visuals from the multiboard.  To do this, either clear the multiboard or replace it with something else.
//- Always remember to destroy multibars when you are done with them.


//To Destroy MultibarHelpers, call:

//function DestroyMultibarHelper takes integer this returns nothing
//- this - the unique ID of the multibarhelper you want to destroy
//An example of calling this function would be:

//call DestroyMultibarHelper(MyHelper)
//- This will remove the MultibarHelper from memory, but will not remove the visuals from the multiboard.  To do this, either clear the multiboard or replace it with something else.
//- Always remember to destroy multibarhelpers when you are done with them.


//NOTE:  DO NOT CONFUSED MULTIBARS AND MULTIBARHELPERS!  MIXING IDS UP WHILE CALLING THE WRONG FUNCTION WILL CREATE SERIOUS ERRORS.
//        IE:  DONT USE DestroyMultibarHelper TO DESTROY A MULTIBAR.  IT WILL NOT WORK.   DO NOT TRY IT!


//==================================
//Customization
//==================================

//MultiBars allows for custom bartypes that are created by others.  The formats that are supported are .tga and .blp (same as WC3).
//To create a new bartype, it is important to understand what makes up a bar.

//Each bar consists of 3 different types:

//A left piece ---- A middle piece ---- A right piece

//Using all 3 pieces, the MultiBar script can place them side-by-side and simulate a progress bar.


//Now, to make the bars smoother, there are sub levels to each piece.  These are called the divisions.  In this demo map, 5 out of the 6
//bartypes have a division of 8.  This means that there are 8 images of varying &quot;fill&quot; to simulate a smooth fill.  Counting up, from 1 to n
//where n is complete fill and 1 is only 1/n fill) are how the divisions are arranged.  Since an image is only 16x16, it is not smart to
//have more than 16 divisions (because they will not be noticed).  The trick is to use the &quot;cover fill&quot; layer to cover up parts of the fill,
//then save.  So if you have a bartype with a division of 16, you would cover up 1/16 of the fill at a time (1 pixel at 16x16) and then save.
//With a division of 4 you would cover up 1/4 of the fill at a time (4 pixels at 16x16) and then save.

//A visual representation would be:

//     1            2            3           4            5            6            7            8
//[|       ]   [||      ]   [|||     ]   [||||    ]   [|||||   ]   [||||||  ]   [||||||| ]   [||||||||]

//Of course, on top of the divisions, there is an empty image, or 0.

//     0
//[        ]

//This image is not counted in the divisions since it is required no matter how many divisions there are.

//DONT FORGET TO MAKE A 0 DIVISION!


//Each piece of each bartype requires the same number of divisions.  Using both the divisions and the pieces, the MultiBar script can draw
//the progress bars on the multiboard.

//Creating the images may take some time.  I have included the .ps (photoshop) document I used to create the bars in the demo.  It contains
//all the fills and borders, arranged in groups.  Hopefully this will help ease some pains.

//When saving the images, make sure to follow this name-scheme.

//[Bartype][piece][divisionN].[filetype]

//The bartype, is the name or type that you will use to distinguish your bartype from others
//The piece is the piece the image is(either &quot;L&quot; for left, &quot;M&quot; for middle or &quot;R&quot; for right)
//The divisionN is the division number (look at the visual representation above for more info)
//The filetype is either .tga or .blp (Most graphics programs save as .tga so I would recommend to use that.  The ammount of file-size you
//save by compressing to .blp is small, since each image is only 1kb to begin with).

//Exmaple:
//Bartype is called &quot;Crazy&quot;
//The piece is the left (&quot;L&quot;)
//This is the 4th Division(&quot;4&quot;)
//and it will be a .tga

//&quot;CrazyL4.tga&quot;


//Once you have made all your images, just stick them all in a folder and upload the entire folder to your map.  There, you can leave them in
//the default directory or change the directory of the images.

//MAKE SURE, IF YOU CHANGE THE DIRECTORY, TO CHANGE ALL
//THE IMAGES OF THE SAME BARTYPE TO THE NEW DIRECTORY!

//To create a bartype for your custom bar, use the function:

//function CreateMultibarBartype takes string name, string filetype, string directory, integer divisions returns integer
//- name - the name of the bartype
//- filetype - the filetype of the images
//- directory - where the images can be found
//- divisions - the number of divisions the bar uses

//An exmaple of calling this function would be:
//set MyBar_NewBar = CreateMultibarBartype(&quot;NewBar&quot;, &quot;.tga&quot;, &quot;MyBars\\&quot;, 8)
//- MyBar_NewBar is a global integer you use to store the bartype in.
//- Thie function created a bartype called NewBar found in MyBars\ with a filetype of .tga and 8 divisions.


//Summary:
//Each image is 16x16 .tga or .blp
//There are 3 piece types: left (&quot;L&quot;), middle (&quot;M&quot;) and right (&quot;R&quot;).
//Each piece has n divisions, which progress from 1 being 1/n fill to n being 100% fill.
//Each piece also has an empty image, called the 0 division.
//Images are saved as [Bartype][piece][divisionN].[filetype]
//Use CreateBartype() to create your custom bartypes


//==================================
//Public Functions and Variables
//==================================

//MultiBars
//=========


//    udg_MULTIBAR_TYPE_HEALTH = 1
    
//    udg_MULTIBAR_TYPE_MANA = 2
    
//    udg_MULTIBAR_TYPE_EXPERIENCE = 3
    
//    udg_MULTIBAR_TYPE_BUILD = 4
    
//    udg_MULTIBAR_TYPE_CHUNK = 5
    
//    udg_MULTIBAR_TYPE_RADIO = 6
    
//    udg_MULTIBAR_TYPE_MAC = 7
   
//    udg_MULTIBAR_TYPE_ORANGE = 8
    
//    udg_MULTIBAR_TYPE_HEARTS = 9
    
//    udg_MULTIBAR_TYPE_HEARTS_UP = 10
    
//    udg_MULTIBAR_TYPE_MAGIC = 11
    
//    function CreateMultibar takes multiboard whichboard, integer colstart, integer row, integer size, real maxval, real currentval, integer bartype returns integer
    
//    function DestroyMultibar takes integer this returns nothing
    
//    function UpdateMultibarValue takes integer this, real newvalue, boolean update returns nothing
    
//    function UpdateMultibarMaxValue takes integer this, real newvalue, boolean update returns nothing
    
//    function CreateMultibarBartype takes string name, string filetype, string directory, integer divisions returns integer
    
//    function InitMultibars takes nothing returns nothing
    
    
    
//MultiBars Helper
//================


//    udg_MULTIBAR_HELPER_HEALTH = 1
    
//    udg_MULTIBAR_HELPER_MANA = 2
    
//    udg_MULTIBAR_HELPER_EXPERIENCE = 3
    
//    udg_multibarhelper_MULTIBAR_PERIOD = 0.035
    
//    function CreateMultibarHelper takes unit whichunit, multiboard whichboard, integer col, integer row, integer size, integer bartype, integer whichtype returns integer
    
//    function AddMultibarHelperLabel takes integer this, integer col, integer row, real width, integer red, integer green, integer blue, integer alpha, string icon returns nothing
    
//    function DestroyMultibarHelper takes integer this returns nothing
    
//    function InitMultibarsHelper takes nothing returns nothing


//==================================
//Change-Log
//==================================

//Version 1.20

//    - Created a non-vJass Version (this version)
//    - Changed the MultibarHelper group to use an array rather than a list (improves performance)
//    - Modfied some of the variable names to comply with GUI variable name lengths
//    - Should have fixed the problem with both winning and losing
//    - Fixed a minor leak when creating a label
//    - Added 3 new bar types (Hearts, HeartsUp and Magic)

//Version 1.11

//    - Split MultiBars into two libraries (core and helper)
//    - Decreased difficulty of survival game

//Version 1.10

//    - Added dynamic health, mana and experience bars
//    - Changed the name of the library from &quot;MultiBarsEngine&quot; to &quot;MultiBars&quot;
//    - Bartypes are now stored as integers and must be created
//    - Added labels for dynamic health, mana and experience bars
//    - Default bartypes now have constant pointers
//    - Added CreateBartype()
//    - Added &quot;Mac&quot; and &quot;Orange&quot; bartypes
//    - Added a list of public functions and variables to the readme

//Version 1.00

//    - First Public Release
//    - Includes the &quot;Health&quot;, &quot;Mana&quot;, &quot;Experience&quot;, &quot;Build&quot;, &quot;Chunk&quot; and &quot;Radio&quot; bartypes.
    

//====================================================//
//                                                    //
//                   END OF README                    //
//                                                    //
//====================================================//


//====================================================//
//                                                    //
//                     MULTIBARS                      //
//                                                    //
//====================================================//



function private_AllocateMultibarSlot takes nothing returns integer
    local integer this
    if udg_multibar_sdata_size &gt; 0 then
        set udg_multibar_sdata_size = udg_multibar_sdata_size - 1
        set this = udg_multibar_sdata_free[udg_multibar_sdata_size]
    else
        set udg_multibar_sdata_used = udg_multibar_sdata_used + 1
        set this = udg_multibar_sdata_used
    endif
    if this &gt; 511 then
        call BJDebugMsg(&quot;Exceeded number of Multibars Allowed at once!  Make sure you are destroying un-used multibars!&quot;)
        return -1
    else
        set udg_multibar_sdata_isUsed[this] = true
        return this
    endif
endfunction

function private_SetMultiboardBar takes integer this returns nothing
    local integer col = udg_multibar_s_colstart[this]
    local integer end = col + udg_multibar_s_numcols[this]
    local multiboarditem mbi
    loop
        exitwhen col &gt;= end
        set mbi = MultiboardGetItem(udg_multibar_s_whichboard[this], udg_multibar_s_row[this], col)
        call MultiboardSetItemWidth(mbi, 0.01)
        call MultiboardSetItemStyle(mbi, false, true)
        call MultiboardReleaseItem(mbi)
        set col = col + 1
    endloop
    set mbi = null
endfunction

function private_UpdateMultibar takes integer this returns nothing
    local real step = udg_multibar_s_max[this]/udg_multibar_s_numcols[this]
    local real step2 = step/udg_multibar_s_numdivs[this]
    local real val = udg_multibar_s_current[this]
    local multiboarditem mbi
    local integer col = udg_multibar_s_colstart[this]
    local integer num
    loop
        exitwhen val &lt;= 0.
        if val &gt;= step then
            if udg_multibar_s_curfill[this+col*511] != udg_multibar_s_numdivs[this] then // check if it requires an update
                set mbi = MultiboardGetItem(udg_multibar_s_whichboard[this], udg_multibar_s_row[this], col)
                if col == udg_multibar_s_colstart[this] then
                    call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;L&quot;+I2S(udg_multibar_s_numdivs[this])+udg_multibar_s_filetype[this]) // Left
                elseif col == udg_multibar_s_colstart[this]+udg_multibar_s_numcols[this]-1 then
                    call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;R&quot;+I2S(udg_multibar_s_numdivs[this])+udg_multibar_s_filetype[this]) // Right
                else
                    call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;M&quot;+I2S(udg_multibar_s_numdivs[this])+udg_multibar_s_filetype[this]) // Middle
                endif
                call MultiboardReleaseItem(mbi)
                set udg_multibar_s_curfill[this+col*511] = udg_multibar_s_numdivs[this]
            endif
            set val = val - step
        else
            set num = R2I((val/step2)+0.5)
            if udg_multibar_s_curfill[this+col*511] != num then // check if it requires an update
                set mbi = MultiboardGetItem(udg_multibar_s_whichboard[this], udg_multibar_s_row[this], col)
                if col == udg_multibar_s_colstart[this] then
                    call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;L&quot;+I2S(num)+udg_multibar_s_filetype[this]) // Left
                elseif col == udg_multibar_s_colstart[this]+udg_multibar_s_numcols[this]-1 then
                    call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;R&quot;+I2S(num)+udg_multibar_s_filetype[this]) // Right
                else
                    call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;M&quot;+I2S(num)+udg_multibar_s_filetype[this]) // Middle
                endif
                call MultiboardReleaseItem(mbi)
                set udg_multibar_s_curfill[this+col*511] = num
            endif
            set val = 0.
        endif
        set col = col + 1
    endloop
    loop
        exitwhen col &gt;= udg_multibar_s_colstart[this] + udg_multibar_s_numcols[this]
        if udg_multibar_s_curfill[this+col*511] != 0 then // check if it requires an update
            set mbi = MultiboardGetItem(udg_multibar_s_whichboard[this], udg_multibar_s_row[this], col)
            if col == udg_multibar_s_colstart[this] then
                call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;L0&quot;+udg_multibar_s_filetype[this]) // Left
            elseif col == udg_multibar_s_colstart[this]+udg_multibar_s_numcols[this]-1 then
                call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;R0&quot;+udg_multibar_s_filetype[this]) // Right
            else
                call MultiboardSetItemIcon(mbi, udg_multibar_s_dir[this]+udg_multibar_s_bartype[this]+&quot;M0&quot;+udg_multibar_s_filetype[this]) // Middle
            endif
            call MultiboardReleaseItem(mbi)
            set udg_multibar_s_curfill[this+col*511] = 0
        endif
        set col = col + 1
    endloop
    set mbi = null
endfunction

function CreateMultibar takes multiboard whichboard, integer colstart, integer row, integer size, real maxval, real currentval, integer bartype returns integer
    local integer this = private_AllocateMultibarSlot()
    local integer i = 0
    if this == -1 then
        return -1
    endif
    call BJDebugMsg(I2S(this))
    set udg_multibar_s_whichboard[this] = whichboard
    set udg_multibar_s_row[this] = row
    set udg_multibar_s_colstart[this] = colstart
    set udg_multibar_s_numcols[this] = size
    set udg_multibar_s_max[this] = maxval
    set udg_multibar_s_current[this] = currentval
    set udg_multibar_s_numdivs[this] = udg_multibar_Gdivs[bartype]
    set udg_multibar_s_bartype[this] = udg_multibar_Gbartype[bartype]
    set udg_multibar_s_filetype[this] = udg_multibar_Gfiletype[bartype]
    set udg_multibar_s_dir[this] = udg_multibar_Gdir[bartype]
    loop
        exitwhen i &gt; 15
        set udg_multibar_s_curfill[this+i*511] = -1
        set i = i + 1
    endloop
    call private_SetMultiboardBar(this)
    call private_UpdateMultibar(this)
    return this
endfunction

function DestroyMultibar takes integer this returns nothing
    if udg_multibar_sdata_isUsed[this] then
        set udg_multibar_sdata_free[udg_multibar_sdata_size] = this
        set udg_multibar_sdata_size = udg_multibar_sdata_size + 1
        set udg_multibar_sdata_isUsed[this] = false
        // set values (onDestroy)
        set udg_multibar_s_whichboard[this] = null
    else
        call BJDebugMsg(&quot;Attempting to destroy a null multibar!&quot;)
    endif
endfunction

function UpdateMultibarValue takes integer this, real newvalue, boolean update returns nothing
    if newvalue &gt; udg_multibar_s_max[this] then
        set udg_multibar_s_current[this] = udg_multibar_s_max[this]
    elseif newvalue &lt; 0. then
        set udg_multibar_s_current[this] = 0.
    else
        set udg_multibar_s_current[this] = newvalue
    endif
    if update then
        call private_UpdateMultibar(this)
    endif
endfunction

function UpdateMultibarMaxValue takes integer this, real newvalue, boolean update returns nothing
    if newvalue &lt; 1 then
        set udg_multibar_s_max[this] = 1
    else
        set udg_multibar_s_max[this] = newvalue
    endif
    if udg_multibar_s_current[this] &gt; udg_multibar_s_max[this] then
            set udg_multibar_s_current[this] = udg_multibar_s_max[this]
        endif
    if update then
        call private_UpdateMultibar(this)
    endif
endfunction

function CreateMultibarBartype takes string name, string filetype, string directory, integer divisions returns integer
    set udg_multibar_Gcurrent = udg_multibar_Gcurrent + 1
    set udg_multibar_Gbartype[udg_multibar_Gcurrent] = name
    set udg_multibar_Gfiletype[udg_multibar_Gcurrent] = filetype
    set udg_multibar_Gdir[udg_multibar_Gcurrent] = directory
    set udg_multibar_Gdivs[udg_multibar_Gcurrent] = divisions
    return udg_multibar_Gcurrent
endfunction

function private_CreateNativeMultibarBartype takes integer bartype, string name, string filetype, string directory, integer divisions returns nothing
    if bartype &gt; udg_multibar_Gcurrent then
        set udg_multibar_Gcurrent = bartype
    endif
    set udg_multibar_Gbartype[bartype] = name
    set udg_multibar_Gfiletype[bartype] = filetype
    set udg_multibar_Gdir[bartype] = directory
    set udg_multibar_Gdivs[bartype] = divisions
endfunction

function InitMultibars takes nothing returns nothing    
    // Set-up Native Bartypes
    set udg_MULTIBAR_TYPE_HEALTH = 1
    set udg_MULTIBAR_TYPE_MANA = 2
    set udg_MULTIBAR_TYPE_EXPERIENCE = 3
    set udg_MULTIBAR_TYPE_BUILD = 4
    set udg_MULTIBAR_TYPE_CHUNK = 5
    set udg_MULTIBAR_TYPE_RADIO = 6
    set udg_MULTIBAR_TYPE_MAC = 7
    set udg_MULTIBAR_TYPE_ORANGE = 8
    set udg_MULTIBAR_TYPE_HEARTS = 9
    set udg_MULTIBAR_TYPE_HEARTS_UP = 10
    set udg_MULTIBAR_TYPE_MAGIC = 11
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_HEALTH, &quot;Health&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 8)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_MANA, &quot;Mana&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 8)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_EXPERIENCE, &quot;Experience&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 8)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_BUILD, &quot;Build&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 8)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_CHUNK, &quot;Chunk&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 2)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_RADIO, &quot;Radio&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 8)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_MAC, &quot;Mac&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 8)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_ORANGE, &quot;Orange&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 2)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_HEARTS, &quot;ZeldaHearts&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 4)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_HEARTS_UP, &quot;ZeldaHeartsUp&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 4)
    call private_CreateNativeMultibarBartype(udg_MULTIBAR_TYPE_MAGIC, &quot;ZeldaMagic&quot;, &quot;.tga&quot;, &quot;war3mapImported\\&quot;, 8)
endfunction



//====================================================//
//                                                    //
//                 END OF MULTIBARS                   //
//                                                    //
//====================================================//



//====================================================//
//                                                    //
//                 MULTIBARHELPERS                    //
//                                                    //
//====================================================//


function private_MultibarHelperGetMaxXP takes integer level returns integer
    local unit u
    set level = level + 1
    if level == 1 then
        return 0
    endif
    if udg_multibarhelper_GXPForLevel[level] == 0 then
        set u = CreateUnit(Player(12), udg_multibarhelper_DummyHeroUnit, 0., 0., 0.)
        call SetHeroLevel(u, level, false)
        set udg_multibarhelper_GXPForLevel[level] = GetHeroXP(u)
        call RemoveUnit(u)
        set u = null
    endif
    return udg_multibarhelper_GXPForLevel[level]
endfunction

function private_AllocateMultibarHelperSlot takes nothing returns integer
    local integer this
    if udg_multibarhelper_sdata_size &gt; 0 then
        set udg_multibarhelper_sdata_size = udg_multibarhelper_sdata_size - 1
        set this = udg_multibarhelper_sdata_free[udg_multibarhelper_sdata_size]
    else
        set udg_multibarhelper_sdata_used = udg_multibarhelper_sdata_used + 1
        set this = udg_multibarhelper_sdata_used
    endif
    if this &gt; 8191 then
        call BJDebugMsg(&quot;Exceeded number of Multibar Helpers Allowed at once!  Make sure you are destroying un-used multibar helpers!&quot;)
        return -1
    else
        set udg_multibarhelper_sdata_isUsed[this] = true
        return this
    endif
endfunction

function private_MultibarHelperUpdateParent takes integer this, boolean always returns nothing
    local real value
    local real maxvalue
    local integer level
    local string text
    local multiboarditem mbi
    if udg_multibarhelper_s_mtype[this] == udg_MULTIBAR_HELPER_HEALTH then
        set value = GetUnitState(udg_multibarhelper_s_whichunit[this], UNIT_STATE_LIFE)
        set maxvalue = GetUnitState(udg_multibarhelper_s_whichunit[this], UNIT_STATE_MAX_LIFE)
    elseif udg_multibarhelper_s_mtype[this] == udg_MULTIBAR_HELPER_MANA then
        set value = GetUnitState(udg_multibarhelper_s_whichunit[this], UNIT_STATE_MANA)
        set maxvalue = GetUnitState(udg_multibarhelper_s_whichunit[this], UNIT_STATE_MAX_MANA)
    elseif udg_multibarhelper_s_mtype[this] == udg_MULTIBAR_HELPER_EXPERIENCE then
        set level = GetHeroLevel(udg_multibarhelper_s_whichunit[this])
        if private_MultibarHelperGetMaxXP(level-1) == private_MultibarHelperGetMaxXP(level) then // Max level
            set value = GetHeroXP(udg_multibarhelper_s_whichunit[this])
            set maxvalue = value
        else
            set value = GetHeroXP(udg_multibarhelper_s_whichunit[this]) - private_MultibarHelperGetMaxXP(level-1)
            set maxvalue = private_MultibarHelperGetMaxXP(level)-private_MultibarHelperGetMaxXP(level-1)
        endif
    endif
    if udg_multibar_s_current[udg_multibarhelper_s_bar[this]] != value or udg_multibar_s_max[udg_multibarhelper_s_bar[this]] != maxvalue or always then             
        call UpdateMultibarMaxValue(udg_multibarhelper_s_bar[this], maxvalue, false)
        call UpdateMultibarValue(udg_multibarhelper_s_bar[this], value, true)
        if udg_multibarhelper_s_label[this] then
            set mbi = MultiboardGetItem(udg_multibar_s_whichboard[udg_multibarhelper_s_bar[this]], udg_multibarhelper_s_row[this], udg_multibarhelper_s_col[this])
            if udg_multibarhelper_s_mtype[this] == udg_MULTIBAR_HELPER_EXPERIENCE then
                set text = (I2S(GetHeroXP(udg_multibarhelper_s_whichunit[this]))+&quot;/&quot;+I2S(private_MultibarHelperGetMaxXP(level)))
            else 
                set text = (I2S(R2I(value+0.5))+&quot;/&quot;+I2S(R2I(maxvalue+0.5))) // 0.5 to round, like the health is shown in-game
            endif
            call MultiboardSetItemValue(mbi, text)
            call MultiboardReleaseItem(mbi)
        endif
    endif
    set mbi = null
endfunction

function CreateMultibarHelper takes unit whichunit, multiboard whichboard, integer col, integer row, integer size, integer bartype, integer whichtype returns integer
    local integer this = private_AllocateMultibarHelperSlot()
    if this == -1 then
        return -1
    endif
    set udg_multibarhelper_s_bar[this] = CreateMultibar(whichboard, col, row, size, 1, 1, bartype)
    set udg_multibarhelper_s_whichunit[this] = whichunit
    set udg_multibarhelper_s_mtype[this] = whichtype
    set udg_multibarhelper_s_label[this] = false
    set udg_multibarhelper_HelperTotal = udg_multibarhelper_HelperTotal + 1
    set udg_multibarhelper_HelperArray[udg_multibarhelper_HelperTotal] = this
    set udg_multibarhelper_s_slot[this] = udg_multibarhelper_HelperTotal
    call private_MultibarHelperUpdateParent(this, true)
    return this
endfunction

function AddMultibarHelperLabel takes integer this, integer col, integer row, real width, integer red, integer green, integer blue, integer alpha, string icon returns nothing
    local multiboarditem mbi = MultiboardGetItem(udg_multibar_s_whichboard[udg_multibarhelper_s_bar[this]], row, col)
    local string text
    set udg_multibarhelper_s_row[this] = row
    set udg_multibarhelper_s_col[this] = col
    set udg_multibarhelper_s_label[this] = true
    if icon != &quot;&quot; then
        call MultiboardSetItemStyle(mbi, true, true)
        call MultiboardSetItemIcon(mbi, icon)
    else
        call MultiboardSetItemStyle(mbi, true, false)
    endif
    call MultiboardSetItemWidth(mbi, width)
    call MultiboardSetItemValueColor(mbi, red, green, blue, alpha)
    call MultiboardReleaseItem(mbi)
    set mbi = null
    call private_MultibarHelperUpdateParent(this, true)
endfunction

function DestroyMultibarHelper takes integer this returns nothing
    set udg_multibarhelper_s_whichunit[this] = null
    call DestroyMultibar(udg_multibarhelper_s_bar[this])
    set udg_multibarhelper_HelperArray[udg_multibarhelper_s_slot[this]] = udg_multibarhelper_HelperArray[udg_multibarhelper_HelperTotal]
    set udg_multibarhelper_HelperTotal = udg_multibarhelper_HelperTotal - 1
endfunction

function private_MultibarHelperController takes nothing returns nothing
    local integer i = 1
    loop
        exitwhen i &gt; udg_multibarhelper_HelperTotal
        call private_MultibarHelperUpdateParent(udg_multibarhelper_HelperArray<i>, true)
        set i = i + 1
    endloop
endfunction

function InitMultibarsHelper takes nothing returns nothing    
    local unit u
    set udg_MULTIBAR_HELPER_HEALTH = 1
    set udg_MULTIBAR_HELPER_MANA = 2
    set udg_MULTIBAR_HELPER_EXPERIENCE = 3
    set udg_multibarhelper_MULTIBAR_PERIOD = 0.015 // You can change this value to improve performance or improve update rate.  (Default : 0.035 )
    set udg_multibarhelper_DummyHeroUnit = &#039;Hpal&#039;
    
    set u = CreateUnit(Player(12), udg_multibarhelper_DummyHeroUnit, 0., 0., 0.)
    call SetHeroLevel(u, 2, false)
    set udg_multibarhelper_GXPForLevel[2] = GetHeroXP(u)
    call SetHeroLevel(u, 3, false)
    set udg_multibarhelper_GXPForLevel[3] = GetHeroXP(u)
    call SetHeroLevel(u, 4, false)
    set udg_multibarhelper_GXPForLevel[4] = GetHeroXP(u)
    call RemoveUnit(u)
    set u = null    
    call TimerStart(CreateTimer(), udg_multibarhelper_MULTIBAR_PERIOD, true, function private_MultibarHelperController)    
endfunction

//====================================================//
//                                                    //
//               END OF MULTIBARHELPERS               //
//                                                    //
//====================================================//</i>


on a side note: I can't find the place where it shows how many multibars you have. Because when I am testing it in-game it will show me how much multibars I have for example:
(this stays in chat forever)

1
2

and I like to remove them because it looks kinda ugly....
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top