• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

[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