• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[General] Leaderboard help

Status
Not open for further replies.
Level 8
Joined
Feb 3, 2013
Messages
277
if u use jass, these functions will make life complete when setting up multiboards/leaderboards

JASS:
    function SetItem takes multiboard mboard, integer row, integer col, string text returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col )
        call MultiboardSetItemValue( mbi, text)
        call MultiboardReleaseItem( mbi )
        set mbi = null
    endfunction

    function SetWidth takes multiboard mboard, integer row, integer col, real width returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemWidth( mbi, width )
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction
    
   function SetStyleValue takes multiboard mboard, integer row, integer col returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemStyle( mbi, true, false )
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction

   function SetStyleIcon takes multiboard mboard, integer row, integer col returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemStyle( mbi, false, true )
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction
    
    function SetStylePath takes multiboard mboard, integer row, integer col, string path returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemIcon( mbi, path)
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction

Let's say you have... 3 teams, 3 players on each team.

Set column 0, row 0 = Name of Force 1
row 1 player 1
row 2 player 2
row 3 player 3
Set column 0, row 4 = Name of Force 2
row 5 player 4
row 6 player 5
row 7 player 6
Set column 0, row 8 = Name of Force 3
row 9 player 7
row 10 player 8
row 11 player 9

column 1, row 0 = Gold
column 1, row 4 = Gold
column 1, row 8 = Gold

column 2, row 0 = Lumber
column 2, row 4 = Lumber
column 2, row 8 = Lumber

column 3, row 0 = kills
column 3, row 4 = kills
column 3, row 8 = kills

What you can do is set timers or events

example:

initialize integer array to represent a players kills
like event unit dies

loop
if GetPlayerId(GetOwningPlayer(GetKillingUnit())) == 0 then
set Kills[GetPlayerId(GetOwningPlayer(GetKillingUnit())) = Kills[GetPlayerId(GetOwningPlayer(GetKillingUnit())) + 1
call SetItem ( 1, 3, Kills[GetPlayerId(GetOwningPlayer(GetKillingUnit())))
elseif blah blah
blah blah
so on so forth
endif

I've posted a demo map, of how to use multiboards

It updates gold, lumber and kills. I hope it helps - you just gotta read the code and just rinse and repeat baby.

JASS:
library Multiboard initializer init 

    globals
        multiboard MULTIBOARD 
        integer array KILLS
        string array PLAYER_COLOR
        integer array PR
    endglobals
    
    function SetItem takes multiboard mboard, integer row, integer col, string text returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col )
        call MultiboardSetItemValue( mbi, text)
        call MultiboardReleaseItem( mbi )
        set mbi = null
    endfunction

    function SetWidth takes multiboard mboard, integer row, integer col, real width returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemWidth( mbi, width )
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction
    
   function SetStyleValue takes multiboard mboard, integer row, integer col returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemStyle( mbi, true, false )
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction

   function SetStyleIcon takes multiboard mboard, integer row, integer col returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemStyle( mbi, false, true )
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction
    
    function SetStylePath takes multiboard mboard, integer row, integer col, string path returns nothing
        local multiboarditem mbi = MultiboardGetItem(mboard, row, col)
        call MultiboardSetItemIcon( mbi, path)
        call MultiboardReleaseItem(mbi)
        set mbi = null
    endfunction
    
    private function mbCreate takes nothing returns nothing
        local integer r = 0
        local integer c = 0
        local integer ip = 0
        call DestroyTimer(GetExpiredTimer())
        set MULTIBOARD = CreateMultiboard()
        call MultiboardSetColumnCount(MULTIBOARD, 4)
        call MultiboardSetRowCount(MULTIBOARD, 12)
        call MultiboardSetTitleText(MULTIBOARD, "Scoreboard")
        
        loop
            exitwhen c == 4
                loop
                    exitwhen r == 12
                    call SetStyleValue(MULTIBOARD, r, c)
                    if c == 0 then
                        if r == 0 or r == 4 or r == 8 then
                            call SetItem(MULTIBOARD, r, c, "Team " + I2S(r/4 + 1))
                        else
                            call SetItem(MULTIBOARD, r, c, PLAYER_COLOR[ip] + GetPlayerName(Player(ip)) + "|r")
                            set ip = ip + 1
                        endif
                        call SetWidth(MULTIBOARD, r, c, .10)
                    elseif c == 1 then
                        if r == 0 or r == 4 or r == 8 then
                            call SetItem(MULTIBOARD, r, c, "Kills")
                        else
                            call SetItem(MULTIBOARD, r, c, "0")
                        endif
                        call SetWidth(MULTIBOARD, r, c, .05)
                    elseif c == 2 then
                        if r == 0 or r == 4 or r == 8 then
                            call SetItem(MULTIBOARD, r, c, "Gold")
                        else
                            call SetItem(MULTIBOARD, r, c, "0")
                        endif
                        call SetWidth(MULTIBOARD, r, c, .05)
                    elseif c == 3 then
                        if r == 0 or r == 4 or r == 8 then
                            call SetItem(MULTIBOARD, r, c, "Lumber")
                        else
                            call SetItem(MULTIBOARD, r, c, "0")
                        endif
                        call SetWidth(MULTIBOARD, r, c, .05)
                    endif
                    set r = r + 1
                endloop
            set c = c + 1
            set r = 0
        endloop
        
        call MultiboardDisplay(MULTIBOARD, true)
    endfunction
    
    private function mbUpdateResources takes nothing returns nothing
        local integer i = 0
        local integer c = 2
        loop
            exitwhen c == 4
            loop
                exitwhen i == 9
                if c == 2 then
                    call SetItem(MULTIBOARD, PR[i], c, I2S(GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD)))
                elseif c == 3 then
                    call SetItem(MULTIBOARD, PR[i], c, I2S(GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_LUMBER)))
                endif
                set i = i + 1
            endloop
            set i = 0
            set c = c + 1
        endloop
    endfunction
    
    private function mbKillsUpdate takes nothing returns boolean
        local unit lvUnit = GetKillingUnit()
        local player lvPlayer = GetOwningPlayer(lvUnit)
        local integer i = 0
        
        loop
            exitwhen i == 9
            if GetPlayerId(lvPlayer) == i then
                set KILLS[i] = KILLS[i] + 1
                call SetItem(MULTIBOARD, PR[i], 1, I2S(KILLS[i]))
            endif
            set i = i + 1
        endloop
        
        set lvUnit = null
        set lvPlayer = null
        return false
    endfunction
    
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        
        loop
            exitwhen i == 13
            set KILLS[i] = 0
            set i = i + 1
        endloop
        
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
        call TriggerAddCondition(t, function mbKillsUpdate)
        
        call TimerStart(CreateTimer(), .01, false, function mbCreate)
        call TimerStart(CreateTimer(), .25, true, function mbUpdateResources)
        
        set PLAYER_COLOR[0] = "|c00FF0303"
        set PR[0] = 1
        set PLAYER_COLOR[1] = "|c000042FF"
        set PR[1] = 2
        set PLAYER_COLOR[2] = "|c001CE6B9"
        set PR[2] = 3
        set PLAYER_COLOR[3] = "|c00540081"
        set PR[3] = 5
        set PLAYER_COLOR[4] = "|c00FFFC01"
        set PR[4] = 6
        set PLAYER_COLOR[5] = "|c00fEBA0E"
        set PR[5] = 7
        set PLAYER_COLOR[6] = "|c0020C000"
        set PR[6] = 9
        set PLAYER_COLOR[7] = "|c00E55BB0"
        set PR[7] = 10
        set PLAYER_COLOR[8] = "|c00959697"
        set PR[8] = 11
        set PLAYER_COLOR[9] = "|c007EBFF1"
        set PLAYER_COLOR[10] = "|c00106246"
        set PLAYER_COLOR[11] = "|c004E2A04"
        
        set t = null
    endfunction
    
endlibrary
JASS:
scope GiveStat initializer init  

    private function gsGold takes nothing returns nothing
        local integer i 
        local integer a = 0
        
        loop
            exitwhen a == 5
            set i = GetRandomInt(0, 8)
            call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) + GetRandomInt(3, 10))
            set a = a + 1
        endloop
    endfunction
    
    private function gsLumber takes nothing returns nothing
        local integer i 
        local integer a = 0
        
        loop
            exitwhen a == 5
            set i = GetRandomInt(0, 8)
            call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_LUMBER) + GetRandomInt(3, 10))
            set a = a + 1
        endloop
    endfunction
        
    private function init takes nothing returns nothing
        call TimerStart(CreateTimer(), .25, true, function gsGold)
        call TimerStart(CreateTimer(), .25, true, function gsLumber)
    endfunction
    
endscope
 

Attachments

  • Multiboard.w3m
    24.1 KB · Views: 67
Last edited:
Level 8
Joined
Feb 3, 2013
Messages
277
hm? what do you mean an error?

btw I used scopes in the map so if you dont have JNGP 1.5e + it will crash regardless

I don't like JASS but I'm becoming painfully aware I need to learn it to a degree.
Trust me, JASS is so much simpler to deal with once you get the hang - No clicking, just typing. It's fun too because you to feel like a programmer lol :)
 
Level 3
Joined
Sep 9, 2009
Messages
658
hm? what do you mean an error?

btw I used scopes in the map so if you dont have JNGP 1.5e + it will crash regardless


Trust me, JASS is so much simpler to deal with once you get the hang - No clicking, just typing. It's fun too because you to feel like a programmer lol :)

Does it need to be 1.5e+? My version is only 1.5d annyway, the error is when I try to test the map doesn't load. It just takes me to the starting screen of Frozen Throne.
 
Status
Not open for further replies.
Top