• 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.

[JASS] Noobalicious question

Status
Not open for further replies.
Level 5
Joined
Sep 19, 2006
Messages
152
This trigger creates a leaderboard, but doesn't add the players to it as needed. What am I doing wrong here?

JASS:
function GameStart_Action01 takes nothing returns nothing
    local integer Pnum = 1
    local player Plyr
    local string Pnam
    local leaderboard Lb = CreateLeaderboard ()
    call DisableTrigger (gg_trg_GameStart)
    call LeaderboardSetLabel (Lb, "Score")
    set udg_Leaderboard = Lb
    loop
        exitwhen Pnum == 9
        set Plyr = Player (Pnum)
        if GetPlayerSlotState (Plyr) ==  PLAYER_SLOT_STATE_PLAYING and GetPlayerController (Plyr) == MAP_CONTROL_USER then
            set Pnam = GetPlayerName (Plyr)
            call LeaderboardAddItem (Lb, Pnam, 1, Plyr)
            call PlayerSetLeaderboard (Plyr, Lb) 
        endif
        set Pnum = Pnum + 1
    endloop
    call LeaderboardDisplay (Lb, true)
    call DestroyTrigger (gg_trg_GameStart)
endfunction

function InitTrig_GameStart takes nothing returns nothing
    set gg_trg_GameStart = CreateTrigger ()
    call TriggerAddAction (gg_trg_GameStart, function GameStart_Action01)
endfunction
 
Level 5
Joined
Sep 19, 2006
Messages
152
I was under the impression that the spaces don't register to JASS anyway. Besides, this trigger DOES create a leaderboard; it just doesn't add the players to it.
 
Level 5
Joined
Sep 19, 2006
Messages
152
Adding a few of text into the trigger now displays numbers 1 - 8 in sequence, and a message that the loop has finished. Still, however, the players are not added into the leaderboard.

What else is missing?
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Look into this function

JASS:
function LeaderboardResizeBJ takes leaderboard lb returns nothing
    local integer size = LeaderboardGetItemCount(lb)

    if (LeaderboardGetLabelText(lb) == "") then
        set size = size - 1
    endif
    call LeaderboardSetSizeByItemCount(lb, size)
endfunction

GUI seems to call it after LeaderboardSetItemBJ
 
Status
Not open for further replies.
Top