Scoreboard integration

For badges

An example code is available to use in your scoreboard if you want badges integration.

// Check if ashop is on the server
if ashop then 
    // Retrieve badges of this player, will always return a table
    local badges = ashop.GetPlayerBadges(THE_PLAYER)

    /*
    v:
        desc: String, description of the badge
        mat: Function. Call it every paint to get the material. 
            THIS CAN RETURN A NIL VALUE !
        name: String, name of the badge, used for the item name.
    */
    
    for k, v in pairs(badges) do
        local badge = vgui.Create("DPanel", subPnl)
        badge:Dock(LEFT)
        badge:SetMouseInputEnabled(true)
        badge:SetTooltipPanelOverride("Flux_Tooltip")
        badge:SetTooltip(v.desc)

        function badge:Paint(w, h)
            local m = v.mat()
                        
            if m then
                surface.SetMaterial(m)
                surface.SetDrawColor(color_white)
                surface.DrawTexturedRect(0, 0, w, h)
            end
        end
    end
end

You can use this template to add compatibility with your scoreboard.

You may need to resize the badge, etc...

Last updated