End-of-Round Leaderboard from a Map

In this lesson you'll learn to

  • βœ“Student can sort a [player]int map and present a ranked top-N leaderboard at round end.

Student can sort a [player]int map and present a ranked top-N leaderboard at round end.

πŸ“– Reference & full walkthrough: End-of-Round Leaderboard from a Map

πŸ” Builds on: north-jungle: arrays + sorting patterns; lesson 3's score map

🧩 Your capstone piece: Post-wave and game-over leaderboard screen


What you'll learn

  • How to drive a real hud_message_device from Verse with SetText, Show, SetDisplayTime, Hide, and ClearAllMessages.
  • How to author a localized message (with interpolated parameters) instead of passing a raw string.
  • How to subscribe to the device's ShowMessageEvent to react when a banner appears.
  • How to pin a personal standings banner to each player using the player-UI stack: GetPlayerUI[], AddWidget, a canvas and a text_block.

How it works

The hud_message_device is your beach-wide announcer. Its two most useful calls are:

  • SetText(Text:message) stores the message, then Show() (or Show(Agent)) displays it.
  • Show(Message:message, ?DisplayTime:float) does both at once. DisplayTime := 0.0 shows the banner forever until you Hide(); a positive value auto-hides.

Every text parameter is a message, not a string β€” so we declare a <localizes> function like LeaderMessage(Name:string, Coins:int):message. Interpolation ({Name}, {Coins}) fills in live data.

That covers the shared shout. For a personal banner that each hunter carries, we drop to the player-UI layer: GetPlayerUI[Player] (fallible β€” bind it in an if), then AddWidget(...) a canvas whose slot holds a text_block. This is the piece the requirement demands β€” it actually paints a widget onto one player's HUD, independent of the device's queue.

Let's build it

using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/UI }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# Localized message β€” interpolates live leaderboard data into a `message`.
LeaderMessage<localizes>(Name:string, Coins:int):message = "Captain {Name} takes the lead β€” {Coins} coins!"

cove_leaderboard := class<concrete>(creative_device):

    # The shared beach megaphone. Configure Display Time in User Options too.
    @editable
    Announcer:hud_message_device = hud_message_device{}

    # Stepping on this pad marks a new leader for the demo.
    @editable
    LeadPad:trigger_device = trigger_device{}

    OnBegin<override>()<suspends>: void =
        # React when the device actually shows a banner on someone's screen.
        Announcer.ShowMessageEvent.Subscribe(OnBannerShown)
        # New-leader pad drives both the shared shout and a personal widget.
        LeadPad.TriggeredEvent.Subscribe(OnNewLeader)

    # Called by the device once a message is on-screen.
    OnBannerShown(Agent:agent):void =
        Print("HUD banner shown on the cove.")

    OnNewLeader(MaybeAgent:?agent):void =
        if (Agent := MaybeAgent?):
            # Demo standings β€” in a real game read these from your score store.
            Name := "Bella"
            Coins := 300
            # Persistent shared shout (0.0 = stays until Hide/ClearAllMessages).
            Announcer.SetDisplayTime(0.0)
            Announcer.SetText(LeaderMessage(Name, Coins))
            Announcer.Show()
            # Pin a personal banner directly onto THIS player's HUD.
            PinPersonalBanner(Agent, Name, Coins)

    # Uses the real player-UI stack: GetPlayerUI[] + AddWidget + canvas/text_block.
    PinPersonalBanner(Agent:agent, Name:string, Coins:int):void =
        if:
            Player := player[Agent]
            PlayerUI := GetPlayerUI[Player]
        then:
            Banner := text_block{DefaultText := LeaderMessage(Name, Coins)}
            Root := canvas{Slots := array{
                canvas_slot{
                    Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.1}, Maximum := vector2{X := 0.5, Y := 0.1}},
                    Alignment := vector2{X := 0.5, Y := 0.0},
                    SizeToContent := true,
                    Widget := Banner
                }
            }}
            PlayerUI.AddWidget(Root)

Try it yourself

  • Change DisplayTime from 0.0 to 3.0 in SetDisplayTime and watch the shared banner auto-hide.
  • Call Announcer.ClearAllMessages() from a second trigger to wipe every queued banner at once.
  • Swap Announcer.Show() for Announcer.Show(Agent) so only the triggering hunter sees the shout.
  • Read real coin totals from your own map/score store instead of the hard-coded 300.

Recap

  • SetText + Show (or the combined Show(Message, ?DisplayTime)) drive the hud_message_device; 0.0 display time is persistent.
  • Text params are message values β€” build them with a <localizes> interpolated function, never a raw string.
  • Subscribe to ShowMessageEvent/ClearAllMessagesEvent to react to banner lifecycle.
  • For per-player HUD pixels, use GetPlayerUI[Player] (fallible) then AddWidget a canvas holding a text_block.
πŸ”’

Keep going β€” free

You've read the intro. The rest of this lesson is free for members. Sign in to continue and track your progress.

Sign in free to continue this lesson
Pass the quiz above to chart this quest in your Journal.

Sources

/guides/leaderboard-from-map
Source

Biloxi Studios original lesson

Guided course

Add this lesson to your free study plan.

🧭 The Keeper’s log

Quest complete? Chart your next heading from the πŸ‰ East Volcano expedition.

β›΅ Take me there