• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[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
 
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.
 
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?
 
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.
Back
Top